Project

General

Profile

« Previous | Next » 

Revision 79bf5d8b

Added by Leszek Koltunski about 4 years ago

Progress creating the Tutorial Dialog.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogTutorialView.java
35 35

  
36 36
import org.distorted.main.R;
37 37
import org.distorted.main.RubikActivity;
38
import org.distorted.objects.ObjectList;
38 39
import org.distorted.tutorial.TutorialList;
39 40

  
40 41
///////////////////////////////////////////////////////////////////////////////////////////////////
......
71 72
    String packageName = act.getPackageName();
72 73

  
73 74
    mList = TutorialList.getObject(position);
75
    ObjectList objList = mList.getObjectList();
76
    int size           = mList.getSize();
74 77

  
75 78
    View tab = inflate( act, R.layout.dialog_tutorial_tab, null);
76 79
    LinearLayout layout = tab.findViewById(R.id.tabLayout);
......
85 88

  
86 89
      int countryID = res.getIdentifier( coun, "drawable", packageName);
87 90

  
88
      View row = createRow(ract,countryID,desc,url,height);
91
      View row = createRow(ract,countryID,desc,url,height,objList,size);
89 92
      layout.addView(row);
90 93
      }
91 94

  
......
94 97

  
95 98
///////////////////////////////////////////////////////////////////////////////////////////////////
96 99

  
97
  private View createRow(final RubikActivity act, int countryID, final String desc, final String url, int height)
100
  private View createRow(final RubikActivity act, int countryID, final String desc, final String url, int height, final ObjectList obj, final int size)
98 101
    {
99 102
    int id = countryID!=0 ? countryID : R.drawable.un;
100 103

  
......
112 115
      @Override
113 116
      public void onClick(View v)
114 117
        {
115
        act.switchTutorial(url);
118
        act.switchTutorial(url,obj,size);
116 119
        }
117 120
      });
118 121

  
src/main/java/org/distorted/main/RubikActivity.java
555 555

  
556 556
///////////////////////////////////////////////////////////////////////////////////////////////////
557 557

  
558
    public void switchTutorial(String url)
558
    public void switchTutorial(String url, ObjectList object, int size)
559 559
      {
560 560
      Intent myIntent = new Intent(this, TutorialActivity.class);
561 561
      myIntent.putExtra("url", url);
562
      myIntent.putExtra("obj", object.ordinal());
563
      myIntent.putExtra("siz", size);
562 564
      startActivity(myIntent);
563 565
      }
564 566
}
src/main/java/org/distorted/tutorial/TutorialActivity.java
66 66
    private int mCurrentApiVersion;
67 67
    private TutorialState mState;
68 68
    private String mURL;
69
    private int mObjectOrdinal, mObjectSize;
69 70

  
70 71
///////////////////////////////////////////////////////////////////////////////////////////////////
71 72

  
......
79 80

  
80 81
      Bundle b = getIntent().getExtras();
81 82

  
82
      if(b != null) mURL = b.getString("url");
83
      if(b != null)
84
        {
85
        mURL           = b.getString("url");
86
        mObjectOrdinal = b.getInt("obj");
87
        mObjectSize    = b.getInt("siz");
88
        }
83 89

  
84 90
      mIsLocked = false;
85 91
      mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
......
197 203
      view.onResume();
198 204
      view.initialize();
199 205

  
200
      boolean success = false;
201
      RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass();
202
      int object = play.getObject();
203
      int size   = play.getSize();
204

  
205
      if( object>=0 && object< ObjectList.NUM_OBJECTS )
206
      if( mObjectOrdinal>=0 && mObjectOrdinal< ObjectList.NUM_OBJECTS )
206 207
        {
207
        ObjectList obj = ObjectList.getObject(object);
208
        ObjectList obj = ObjectList.getObject(mObjectOrdinal);
208 209
        int[] sizes = obj.getSizes();
209
        int sizeIndex = ObjectList.getSizeIndex(object,size);
210
        int sizeIndex = ObjectList.getSizeIndex(mObjectOrdinal,mObjectSize);
210 211

  
211 212
        if( sizeIndex>=0 && sizeIndex<sizes.length )
212 213
          {
213
          success = true;
214
          view.getPreRender().changeObject(obj,size);
214
          view.getPreRender().changeObject(obj,mObjectSize);
215 215
          }
216 216
        }
217
/*
218
      if( !success )
219
        {
220
        ObjectList obj = ObjectList.getObject(RubikStatePlay.DEF_OBJECT);
221
        int s = RubikStatePlay.DEF_SIZE;
222

  
223
        play.setObjectAndSize(this,obj,s);
224
        view.getPreRender().changeObject(obj,s);
225
        }
226
 */
227 217
      }
228 218
    
229 219
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/tutorial/TutorialList.java
165 165
    return -1;
166 166
    }
167 167

  
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

  
170
  public ObjectList getObjectList()
171
    {
172
    return mObject;
173
    }
174

  
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

  
177
  public int getSize()
178
    {
179
    return mSize;
180
    }
181

  
168 182
///////////////////////////////////////////////////////////////////////////////////////////////////
169 183

  
170 184
  public int getNumTutorials()
src/main/res/layout/dialog_tutorial_row.xml
2 2
<Button xmlns:android="http://schemas.android.com/apk/res/android"
3 3
    android:id="@+id/tutorialRowButton"
4 4
    android:layout_width="match_parent"
5
    android:layout_height="match_parent"
5
    android:layout_height="100dp"
6 6
    android:paddingStart="5dp"
7 7
    android:paddingEnd="5dp"
8
    android:textSize="20sp"
9 8
    android:maxLines="1"
10 9
    android:gravity="center"/>
11 10

  

Also available in: Unified diff