Project

General

Profile

« Previous | Next » 

Revision 4895fff6

Added by Leszek Koltunski about 4 years ago

Beginnings of submitting one's high scores.

View differences:

src/main/java/org/distorted/dialog/RubikDialogScoresPagerAdapter.java
27 27
import android.view.ViewGroup;
28 28
import android.widget.LinearLayout;
29 29

  
30
import org.distorted.magic.R;
31
import org.distorted.scores.RubikScores;
32 30
import org.distorted.scores.RubikScoresDownloader;
33 31
import org.distorted.object.RubikObjectList;
34 32

  
......
42 40
  private RubikDialogScoresView[] mViews;
43 41
  private ViewPager mViewPager;
44 42
  private int mNumTabs;
43
  private boolean mIsSubmitting;
45 44

  
46 45
///////////////////////////////////////////////////////////////////////////////////////////////////
47 46

  
......
116 115

  
117 116
///////////////////////////////////////////////////////////////////////////////////////////////////
118 117

  
119
  public void exception(final String exce)
118
  public void message(final String mess)
120 119
    {
121 120
    mAct.runOnUiThread(new Runnable()
122 121
      {
......
125 124
        {
126 125
        for(int i=0; i<mNumTabs; i++)
127 126
          {
128
          mViews[i].exception(exce);
127
          mViews[i].message(mess);
129 128
          }
130 129
        }
131 130
      });
......
133 132

  
134 133
///////////////////////////////////////////////////////////////////////////////////////////////////
135 134

  
136
  RubikDialogScoresPagerAdapter(FragmentActivity act, ViewPager viewPager)
135
  RubikDialogScoresPagerAdapter(FragmentActivity act, ViewPager viewPager, boolean isSubmitting)
137 136
    {
138 137
    mAct = act;
139 138
    mNumTabs = RubikObjectList.getTotal();
140 139
    mViews = new RubikDialogScoresView[mNumTabs];
141 140
    mViewPager = viewPager;
141
    mIsSubmitting = isSubmitting;
142 142

  
143 143
    viewPager.setAdapter(this);
144 144
    viewPager.setOffscreenPageLimit(mNumTabs-1);
......
150 150
  @NonNull
151 151
  public Object instantiateItem(@NonNull ViewGroup collection, int position)
152 152
    {
153
    mViews[position] = new RubikDialogScoresView(mAct);
153
    mViews[position] = new RubikDialogScoresView(mAct, mIsSubmitting);
154 154
    collection.addView(mViews[position]);
155 155

  
156 156
    boolean allCreated = true;
......
166 166

  
167 167
    if( allCreated )
168 168
      {
169
      RubikScores scores = RubikScores.getInstance();
170 169
      RubikScoresDownloader downloader = RubikScoresDownloader.getInstance();
171
      downloader.download( this, scores.getName(), mAct.getString(R.string.app_version), scores.getNumRuns() );
170

  
171
      if( mIsSubmitting )  downloader.submit  ( this, mAct );
172
      else                 downloader.download( this, mAct );
172 173
      }
173 174

  
174 175
    return mViews[position];

Also available in: Unified diff