Skip to content

Commit 0829c33

Browse files
committed
Pre-commencement
1 parent 6000409 commit 0829c33

File tree

2 files changed

+45
-27
lines changed

2 files changed

+45
-27
lines changed

app/src/main/java/in/krharsh17/programmersdate/Constants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public interface Constants {
1313
int upperMatchPoints = 10;
1414
int lowerMatchPoints = 5;
1515
int poseTotalChecks = 480;
16-
int poseUpperMatchCriteria = 250;
17-
int poseLowerMatchCriteria = 150;
16+
int poseUpperMatchCriteria = 350;
17+
int poseLowerMatchCriteria = 250;
1818
String TAG = "DEFAULT";
1919

2020
DatabaseReference couplesRef = FirebaseDatabase.getInstance().getReference().child("couples");
@@ -91,6 +91,6 @@ public interface Constants {
9191

9292
int REQUEST_CAMERA_PERMISSION = 1;
9393

94-
long startTime = 1580380200;
94+
long startTime = 1580381400;
9595

9696
}

app/src/main/java/in/krharsh17/programmersdate/home/MainActivity.java

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.animation.Animator;
44
import android.annotation.SuppressLint;
5+
import android.app.Dialog;
56
import android.os.Bundle;
67
import android.os.CountDownTimer;
78
import android.os.Handler;
@@ -56,7 +57,7 @@ public class MainActivity extends AppCompatActivity implements Constants {
5657
boolean appRunning = false;
5758

5859
long timeLimit;
59-
60+
Dialog dialog;
6061
Map map;
6162
ViewPager bottomPager;
6263
private boolean areOverlaysShown = true;
@@ -70,6 +71,7 @@ public class MainActivity extends AppCompatActivity implements Constants {
7071
ArrayList<LatLng> levelLatLng;
7172

7273
Thread timer;
74+
private boolean blocked = false;
7375

7476
@Override
7577
protected void onCreate(Bundle savedInstanceState) {
@@ -106,6 +108,11 @@ protected int getHorizontalSnapPreference() {
106108
}
107109
};
108110
coupleId = new SharedPrefManager(this).getCoupleId();
111+
112+
dialog = new Dialog(MainActivity.this);
113+
dialog.setContentView(R.layout.dialog_complete);
114+
dialog.setCancelable(false);
115+
dialog.setCanceledOnTouchOutside(false);
109116
}
110117

111118

@@ -130,30 +137,31 @@ public void onCoupleFetched(Couple couple) {
130137
attachCoupleListener();
131138
ViewUtils.removeDialog();
132139
startTimer();
133-
134-
if (!currentCouple.isEnabled()) {
135-
if (ViewUtils.completeShowing) {
136-
ViewUtils.removeDialog();
137-
ViewUtils.completeShowing = false;
138-
}
139-
} else {
140-
ViewUtils.showCompleteDialog(MainActivity.this);
141-
}
142-
143-
140+
// if (!currentCouple.isEnabled()) {
141+
// dialog.show();
142+
// blocked = true;
143+
// } else {
144+
// if(blocked){
145+
// dialog.cancel();
146+
// blocked = false;
147+
// }
148+
// }
144149
FirebaseDatabase.getInstance().getReference().child("settings").child("gameRunning").addValueEventListener(new ValueEventListener() {
145150
@Override
146151
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
147152
Log.i(TAG, "onDataChange: ");
148153
if (dataSnapshot != null && dataSnapshot.getValue() != null) {
149154
boolean gameRunning = dataSnapshot.getValue(Boolean.class);
150155
if (gameRunning) {
156+
151157
if (ViewUtils.completeShowing) {
152158
ViewUtils.removeDialog();
153159
ViewUtils.completeShowing = false;
154160
}
155161
} else {
156-
ViewUtils.showCompleteDialog(MainActivity.this);
162+
163+
if (!ViewUtils.completeShowing)
164+
ViewUtils.showCompleteDialog(MainActivity.this);
157165
}
158166
}
159167
}
@@ -175,8 +183,6 @@ public void onErrorOccured(String message) {
175183
new CoupleManager(MainActivity.this).syncWithServer(this);
176184
ViewUtils.showToast(MainActivity.this, "Some error occured!", ViewUtils.DURATION_SHORT);
177185
}
178-
179-
180186
levelRecycler.setLayoutManager(linearLayoutManagerThree);
181187
levelRecycler.setHasFixedSize(true);
182188
levelRecycler.setLayoutFrozen(true);
@@ -212,7 +218,6 @@ public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
212218
if (dataSnapshot != null && dataSnapshot.getValue() != null)
213219
setCurrentCouple(dataSnapshot.getValue(Couple.class));
214220
}
215-
216221
@Override
217222
public void onCancelled(@NonNull DatabaseError databaseError) {
218223

@@ -258,14 +263,15 @@ public void setCurrentCouple(Couple currentCouple) {
258263
bottomPager.setCurrentItem(currentCouple.getCurrentLevel() - 1, true);
259264
refreshMap();
260265

261-
if (!currentCouple.isEnabled()) {
262-
ViewUtils.showCompleteDialog(MainActivity.this);
263-
} else {
264-
if (ViewUtils.completeShowing) {
265-
ViewUtils.removeDialog();
266-
ViewUtils.completeShowing = false;
267-
}
268-
}
266+
// if (!currentCouple.isEnabled() && !blocked) {
267+
// dialog.show();
268+
// blocked = true;
269+
// } else {
270+
// if (blocked) {
271+
// dialog.cancel();
272+
// blocked = false;
273+
// }
274+
// }
269275

270276
currentLevel = currentCouple.getCurrentLevel();
271277
new Handler().postDelayed(new Runnable() {
@@ -422,6 +428,18 @@ protected void onPause() {
422428
map.disableGPS();
423429
appRunning = false;
424430
Log.i(TAG, "onPause: ");
431+
new CoupleManager(MainActivity.this).getCouple().setOnFetchedListener(new CoupleManager.OnFetchedListener() {
432+
@Override
433+
public void onCoupleFetched(Couple couple) {
434+
couple.setEnabled(false);
435+
couplesRef.child(couple.getId()).setValue(couple);
436+
}
437+
438+
@Override
439+
public void onErrorOccured(String message) {
440+
441+
}
442+
});
425443
}
426444

427445
@Override

0 commit comments

Comments
 (0)