1 |
a7a7cc9c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
// Copyright 2019 Leszek Koltunski //
|
3 |
|
|
// //
|
4 |
fdec60a3
|
Leszek Koltunski
|
// This file is part of Magic Cube. //
|
5 |
a7a7cc9c
|
Leszek Koltunski
|
// //
|
6 |
fdec60a3
|
Leszek Koltunski
|
// Magic Cube is free software: you can redistribute it and/or modify //
|
7 |
a7a7cc9c
|
Leszek Koltunski
|
// it under the terms of the GNU General Public License as published by //
|
8 |
|
|
// the Free Software Foundation, either version 2 of the License, or //
|
9 |
|
|
// (at your option) any later version. //
|
10 |
|
|
// //
|
11 |
fdec60a3
|
Leszek Koltunski
|
// Magic Cube is distributed in the hope that it will be useful, //
|
12 |
a7a7cc9c
|
Leszek Koltunski
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
13 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
14 |
|
|
// GNU General Public License for more details. //
|
15 |
|
|
// //
|
16 |
|
|
// You should have received a copy of the GNU General Public License //
|
17 |
fdec60a3
|
Leszek Koltunski
|
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. //
|
18 |
a7a7cc9c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
19 |
|
|
|
20 |
|
|
package org.distorted.magic;
|
21 |
|
|
|
22 |
fdec60a3
|
Leszek Koltunski
|
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 |
946d9762
|
Leszek Koltunski
|
import android.support.v4.view.ViewPager;
|
28 |
fdec60a3
|
Leszek Koltunski
|
import android.support.v7.app.AlertDialog;
|
29 |
a7a7cc9c
|
Leszek Koltunski
|
import android.support.v7.app.AppCompatDialogFragment;
|
30 |
fdec60a3
|
Leszek Koltunski
|
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;
|
35 |
a7a7cc9c
|
Leszek Koltunski
|
|
36 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
|
38 |
|
|
public class RubikScores extends AppCompatDialogFragment
|
39 |
|
|
{
|
40 |
cc5ec229
|
Leszek Koltunski
|
RubikScoresPagerAdapter mPagerAdapter;
|
41 |
a7a7cc9c
|
Leszek Koltunski
|
|
42 |
fdec60a3
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
4918f19c
|
Leszek Koltunski
|
Bundle args = getArguments();
|
67 |
|
|
int curTab;
|
68 |
|
|
|
69 |
|
|
try
|
70 |
|
|
{
|
71 |
|
|
curTab = args.getInt("tab");
|
72 |
|
|
}
|
73 |
|
|
catch(Exception e)
|
74 |
|
|
{
|
75 |
|
|
curTab = 0;
|
76 |
|
|
}
|
77 |
|
|
|
78 |
fdec60a3
|
Leszek Koltunski
|
LayoutInflater inflater = act.getLayoutInflater();
|
79 |
|
|
final View view = inflater.inflate(R.layout.scores, null);
|
80 |
|
|
builder.setView(view);
|
81 |
|
|
|
82 |
946d9762
|
Leszek Koltunski
|
ViewPager viewPager = view.findViewById(R.id.viewpager);
|
83 |
fdec60a3
|
Leszek Koltunski
|
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
|
84 |
946d9762
|
Leszek Koltunski
|
mPagerAdapter = new RubikScoresPagerAdapter(act,viewPager);
|
85 |
|
|
tabLayout.setupWithViewPager(viewPager);
|
86 |
cc5ec229
|
Leszek Koltunski
|
|
87 |
4918f19c
|
Leszek Koltunski
|
viewPager.setCurrentItem(curTab);
|
88 |
fdec60a3
|
Leszek Koltunski
|
|
89 |
dd73fdab
|
Leszek Koltunski
|
for (int i = 0; i< RubikSize.LENGTH; i++)
|
90 |
fdec60a3
|
Leszek Koltunski
|
{
|
91 |
|
|
ImageView imageView = new ImageView(act);
|
92 |
f3e12931
|
Leszek Koltunski
|
imageView.setImageResource(RubikSize.getSize(i).getIconID());
|
93 |
fdec60a3
|
Leszek Koltunski
|
TabLayout.Tab tab = tabLayout.getTabAt(i);
|
94 |
|
|
if(tab!=null) tab.setCustomView(imageView);
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
return builder.create();
|
98 |
|
|
}
|
99 |
a7a7cc9c
|
Leszek Koltunski
|
}
|