Revision fdec60a3
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikScores.java | ||
---|---|---|
1 | 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
2 | 2 |
// Copyright 2019 Leszek Koltunski // |
3 | 3 |
// // |
4 |
// This file is part of Distorted. //
|
|
4 |
// This file is part of Magic Cube. //
|
|
5 | 5 |
// // |
6 |
// Distorted is free software: you can redistribute it and/or modify //
|
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify //
|
|
7 | 7 |
// it under the terms of the GNU General Public License as published by // |
8 | 8 |
// the Free Software Foundation, either version 2 of the License, or // |
9 | 9 |
// (at your option) any later version. // |
10 | 10 |
// // |
11 |
// Distorted is distributed in the hope that it will be useful, //
|
|
11 |
// Magic Cube is distributed in the hope that it will be useful, //
|
|
12 | 12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
13 | 13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
14 | 14 |
// GNU General Public License for more details. // |
15 | 15 |
// // |
16 | 16 |
// You should have received a copy of the GNU General Public License // |
17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. //
|
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
|
18 | 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
19 | 19 |
|
20 | 20 |
package org.distorted.magic; |
21 | 21 |
|
22 |
import android.app.Dialog; |
|
23 |
import android.content.DialogInterface; |
|
24 |
import android.os.Bundle; |
|
25 |
import android.support.annotation.NonNull; |
|
26 |
import android.support.v4.app.FragmentActivity; |
|
27 |
import android.support.v4.view.ViewPager; |
|
28 |
import android.support.v7.app.AlertDialog; |
|
22 | 29 |
import android.support.v7.app.AppCompatDialogFragment; |
30 |
import android.support.design.widget.TabLayout; |
|
31 |
import android.view.LayoutInflater; |
|
32 |
import android.view.View; |
|
33 |
import android.widget.ImageView; |
|
34 |
import android.widget.TextView; |
|
23 | 35 |
|
24 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
25 | 37 |
|
26 | 38 |
public class RubikScores extends AppCompatDialogFragment |
27 | 39 |
{ |
40 |
RubikScoresViewPager mViewPager; |
|
28 | 41 |
|
42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
43 |
|
|
44 |
@NonNull |
|
45 |
@Override |
|
46 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
47 |
{ |
|
48 |
FragmentActivity act = getActivity(); |
|
49 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
50 |
|
|
51 |
LayoutInflater layoutInflater = act.getLayoutInflater(); |
|
52 |
TextView tv = (TextView) layoutInflater.inflate(R.layout.scores_title, null); |
|
53 |
tv.setText(R.string.scores_title); |
|
54 |
builder.setCustomTitle(tv); |
|
55 |
|
|
56 |
builder.setCancelable(true); |
|
57 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
58 |
{ |
|
59 |
@Override |
|
60 |
public void onClick(DialogInterface dialog, int which) |
|
61 |
{ |
|
62 |
|
|
63 |
} |
|
64 |
}); |
|
65 |
|
|
66 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
67 |
final View view = inflater.inflate(R.layout.scores, null); |
|
68 |
builder.setView(view); |
|
69 |
|
|
70 |
ViewPager viewPager = view.findViewById(R.id.viewpager); |
|
71 |
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs); |
|
72 |
mViewPager = new RubikScoresViewPager(act,viewPager); |
|
73 |
tabLayout.setupWithViewPager(viewPager); |
|
74 |
|
|
75 |
for (int i=0; i<RubikScoresTab.LENGTH; i++) |
|
76 |
{ |
|
77 |
ImageView imageView = new ImageView(act); |
|
78 |
imageView.setImageResource(RubikScoresTab.getTab(i).getIcon()); |
|
79 |
TabLayout.Tab tab = tabLayout.getTabAt(i); |
|
80 |
if(tab!=null) tab.setCustomView(imageView); |
|
81 |
} |
|
82 |
|
|
83 |
return builder.create(); |
|
84 |
} |
|
29 | 85 |
} |
Also available in: Unified diff
Skeleton of a new dialog: High Scores