1
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2
|
// Copyright 2019 Leszek Koltunski //
|
3
|
// //
|
4
|
// This file is part of Magic Cube. //
|
5
|
// //
|
6
|
// Magic Cube is proprietary software licensed under an EULA which you should have received //
|
7
|
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html //
|
8
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
9
|
|
10
|
package org.distorted.dialogs;
|
11
|
|
12
|
import android.app.Dialog;
|
13
|
import androidx.fragment.app.FragmentActivity;
|
14
|
import androidx.viewpager.widget.ViewPager;
|
15
|
import com.google.android.material.tabs.TabLayout;
|
16
|
|
17
|
import android.view.View;
|
18
|
import android.view.ViewGroup;
|
19
|
import android.view.Window;
|
20
|
import android.view.WindowManager;
|
21
|
import android.widget.ImageView;
|
22
|
|
23
|
import org.distorted.main.R;
|
24
|
import org.distorted.main.RubikActivity;
|
25
|
import org.distorted.objects.RubikObject;
|
26
|
import org.distorted.objects.RubikObjectList;
|
27
|
|
28
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
29
|
|
30
|
public class RubikDialogScores extends RubikDialogAbstract
|
31
|
{
|
32
|
private RubikDialogScoresPagerAdapter mPagerAdapter;
|
33
|
|
34
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
35
|
|
36
|
@Override
|
37
|
public void onResume()
|
38
|
{
|
39
|
super.onResume();
|
40
|
|
41
|
Window window = getDialog().getWindow();
|
42
|
|
43
|
if( window!=null )
|
44
|
{
|
45
|
WindowManager.LayoutParams params = window.getAttributes();
|
46
|
params.width = (int)Math.min( mHeight*0.65f,mWidth*0.98f );
|
47
|
params.height = (int)( mHeight*0.77f);
|
48
|
window.setAttributes(params);
|
49
|
}
|
50
|
}
|
51
|
|
52
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
53
|
|
54
|
public int getResource() { return R.layout.dialog_tabbed; }
|
55
|
public int getTitleResource() { return R.string.scores; }
|
56
|
public boolean hasArgument() { return true; }
|
57
|
public int getPositive() { return R.string.ok; }
|
58
|
public int getNegative() { return -1; }
|
59
|
|
60
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
61
|
|
62
|
public void positiveAction()
|
63
|
{
|
64
|
|
65
|
}
|
66
|
|
67
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
68
|
|
69
|
public void negativeAction()
|
70
|
{
|
71
|
|
72
|
}
|
73
|
|
74
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
75
|
|
76
|
public void prepareBody(Dialog dialog, View view, FragmentActivity act, float size)
|
77
|
{
|
78
|
final int tabHeight= (int)(mHeight*RubikActivity.TAB_HEIGHT);
|
79
|
final int tabWidth = (int)(mHeight*RubikActivity.TAB_WIDTH);
|
80
|
|
81
|
ViewPager viewPager = view.findViewById(R.id.viewpager);
|
82
|
TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
|
83
|
mPagerAdapter = new RubikDialogScoresPagerAdapter(act,viewPager,mArgument.equals("true"), this);
|
84
|
tabLayout.setupWithViewPager(viewPager);
|
85
|
|
86
|
viewPager.setCurrentItem(RubikObjectList.getCurrObject());
|
87
|
int numObjects = RubikObjectList.getNumObjects();
|
88
|
ViewGroup.LayoutParams paramsView = new ViewGroup.LayoutParams( tabWidth,tabHeight );
|
89
|
|
90
|
for (int object=0; object<numObjects; object++)
|
91
|
{
|
92
|
RubikObject robject = RubikObjectList.getObject(object);
|
93
|
ImageView imageView = new ImageView(act);
|
94
|
if( robject!=null ) robject.setIconTo(act,imageView);
|
95
|
imageView.setLayoutParams(paramsView);
|
96
|
TabLayout.Tab tab = tabLayout.getTabAt(object);
|
97
|
if(tab!=null) tab.setCustomView(imageView);
|
98
|
}
|
99
|
}
|
100
|
}
|