Revision dca3888a
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/dialogs/RubikDialogNewRecord.java | ||
---|---|---|
183 | 183 |
|
184 | 184 |
return dialog; |
185 | 185 |
} |
186 |
|
|
187 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
188 |
|
|
189 |
public static String getDialogTag() |
|
190 |
{ |
|
191 |
return "DialogNewRecord"; |
|
192 |
} |
|
186 | 193 |
} |
src/main/java/org/distorted/dialogs/RubikDialogSolved.java | ||
---|---|---|
117 | 117 |
|
118 | 118 |
return dialog; |
119 | 119 |
} |
120 |
|
|
121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
122 |
|
|
123 |
public static String getDialogTag() |
|
124 |
{ |
|
125 |
return "DialogSolved"; |
|
126 |
} |
|
120 | 127 |
} |
src/main/java/org/distorted/main/RubikPreRender.java | ||
---|---|---|
24 | 24 |
import android.content.res.Resources; |
25 | 25 |
import android.os.Bundle; |
26 | 26 |
|
27 |
import com.google.firebase.analytics.FirebaseAnalytics; |
|
28 |
|
|
27 | 29 |
import org.distorted.dialogs.RubikDialogNewRecord; |
28 | 30 |
import org.distorted.dialogs.RubikDialogSolved; |
29 | 31 |
import org.distorted.effects.BaseEffect; |
... | ... | |
31 | 33 |
import org.distorted.objects.TwistyObject; |
32 | 34 |
import org.distorted.objects.ObjectList; |
33 | 35 |
import org.distorted.scores.RubikScores; |
36 |
import org.distorted.states.RubikStatePlay; |
|
34 | 37 |
import org.distorted.states.StateList; |
35 | 38 |
import org.distorted.states.RubikStateSolving; |
36 | 39 |
|
... | ... | |
323 | 326 |
mView.setQuat(); |
324 | 327 |
} |
325 | 328 |
|
329 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
330 |
|
|
331 |
private void reportRecord() |
|
332 |
{ |
|
333 |
RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass(); |
|
334 |
RubikScores scores = RubikScores.getInstance(); |
|
335 |
|
|
336 |
int object = play.getObject(); |
|
337 |
int size = play.getSize(); |
|
338 |
int level = play.getLevel(); |
|
339 |
ObjectList list = ObjectList.getObject(object); |
|
340 |
String name = scores.getName(); |
|
341 |
|
|
342 |
String record = list.name()+"_"+size+" level "+level+" time "+mNewRecord+" isNew: "+mIsNewRecord+" name: "+name; |
|
343 |
|
|
344 |
final RubikActivity act = (RubikActivity)mView.getContext(); |
|
345 |
FirebaseAnalytics analytics = act.getAnalytics(); |
|
346 |
|
|
347 |
if( analytics!=null ) |
|
348 |
{ |
|
349 |
Bundle bundle = new Bundle(); |
|
350 |
bundle.putString(FirebaseAnalytics.Param.LEVEL, record); |
|
351 |
analytics.logEvent(FirebaseAnalytics.Event.LEVEL_END, bundle); |
|
352 |
} |
|
353 |
} |
|
354 |
|
|
326 | 355 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
327 | 356 |
// |
328 | 357 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
557 | 586 |
Bundle bundle = new Bundle(); |
558 | 587 |
bundle.putLong("time", mNewRecord ); |
559 | 588 |
|
589 |
reportRecord(); |
|
590 |
|
|
560 | 591 |
if( mIsNewRecord ) |
561 | 592 |
{ |
562 | 593 |
RubikDialogNewRecord dialog = new RubikDialogNewRecord(); |
563 | 594 |
dialog.setArguments(bundle); |
564 |
dialog.show( act.getSupportFragmentManager(), null);
|
|
595 |
dialog.show( act.getSupportFragmentManager(), RubikDialogNewRecord.getDialogTag() );
|
|
565 | 596 |
} |
566 | 597 |
else |
567 | 598 |
{ |
568 | 599 |
RubikDialogSolved dialog = new RubikDialogSolved(); |
569 | 600 |
dialog.setArguments(bundle); |
570 |
dialog.show( act.getSupportFragmentManager(), null);
|
|
601 |
dialog.show( act.getSupportFragmentManager(), RubikDialogSolved.getDialogTag() );
|
|
571 | 602 |
} |
572 | 603 |
|
573 | 604 |
act.runOnUiThread(new Runnable() |
src/main/java/org/distorted/states/RubikStateDone.java | ||
---|---|---|
27 | 27 |
import android.widget.LinearLayout; |
28 | 28 |
import android.widget.TextView; |
29 | 29 |
|
30 |
import androidx.fragment.app.FragmentManager; |
|
31 |
|
|
32 |
import org.distorted.dialogs.RubikDialogNewRecord; |
|
33 |
import org.distorted.dialogs.RubikDialogSolved; |
|
30 | 34 |
import org.distorted.main.R; |
31 | 35 |
import org.distorted.main.RubikActivity; |
32 | 36 |
|
... | ... | |
90 | 94 |
public void onClick(View v) |
91 | 95 |
{ |
92 | 96 |
StateList.goBack(act); |
97 |
dismissDialogs(act); |
|
93 | 98 |
} |
94 | 99 |
}); |
95 | 100 |
|
... | ... | |
111 | 116 |
{ |
112 | 117 |
|
113 | 118 |
} |
119 |
|
|
120 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
121 |
|
|
122 |
private void dismissDialogs(RubikActivity act) |
|
123 |
{ |
|
124 |
FragmentManager mana = act.getSupportFragmentManager(); |
|
125 |
RubikDialogNewRecord diag1 = (RubikDialogNewRecord) mana.findFragmentByTag(RubikDialogNewRecord.getDialogTag()); |
|
126 |
RubikDialogSolved diag2 = (RubikDialogSolved ) mana.findFragmentByTag(RubikDialogSolved.getDialogTag()); |
|
127 |
|
|
128 |
if( diag1 !=null ) diag1.dismiss(); |
|
129 |
if( diag2 !=null ) diag2.dismiss(); |
|
130 |
} |
|
114 | 131 |
} |
src/main/java/org/distorted/states/RubikStatePlay.java | ||
---|---|---|
713 | 713 |
|
714 | 714 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
715 | 715 |
|
716 |
int getLevel() |
|
716 |
public int getLevel()
|
|
717 | 717 |
{ |
718 | 718 |
return mLevelValue; |
719 | 719 |
} |
Also available in: Unified diff
1) report all solved levels to Analytics
2) automatically dismiss the NewRecord and Solved dialogs when one backs from the Done state.