Project

General

Profile

Download (3.99 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / magic / RubikScores.java @ f3e12931

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// 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
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// 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
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.magic;
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;
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;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class RubikScores extends AppCompatDialogFragment
39
  {
40
  interface ScoresReceiver
41
    {
42
    void receive(String scores);
43
    }
44

    
45
  RubikScoresViewPager mViewPager;
46

    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48

    
49
  @NonNull
50
  @Override
51
  public Dialog onCreateDialog(Bundle savedInstanceState)
52
    {
53
    FragmentActivity act = getActivity();
54
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
55

    
56
    LayoutInflater layoutInflater = act.getLayoutInflater();
57
    TextView tv = (TextView) layoutInflater.inflate(R.layout.scores_title, null);
58
    tv.setText(R.string.scores_title);
59
    builder.setCustomTitle(tv);
60

    
61
    builder.setCancelable(true);
62
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
63
      {
64
      @Override
65
      public void onClick(DialogInterface dialog, int which)
66
        {
67

    
68
        }
69
      });
70

    
71
    LayoutInflater inflater = act.getLayoutInflater();
72
    final View view = inflater.inflate(R.layout.scores, null);
73
    builder.setView(view);
74

    
75
    ViewPager viewPager = view.findViewById(R.id.viewpager);
76
    TabLayout tabLayout = view.findViewById(R.id.sliding_tabs);
77
    mViewPager = new RubikScoresViewPager(act,viewPager);
78
    tabLayout.setupWithViewPager(viewPager);
79

    
80
    for (int i = 0; i< RubikSize.LENGTH; i++)
81
      {
82
      ImageView imageView = new ImageView(act);
83
      imageView.setImageResource(RubikSize.getSize(i).getIconID());
84
      TabLayout.Tab tab = tabLayout.getTabAt(i);
85
      if(tab!=null) tab.setCustomView(imageView);
86
      }
87

    
88
    RubikScoresDownloader.download(mViewPager);
89

    
90
    return builder.create();
91
    }
92
  }
(5-5/10)