Skip to content

Commit 6fcb162

Browse files
committed
wallet_correct
1 parent 9f06896 commit 6fcb162

File tree

5 files changed

+56
-11
lines changed

5 files changed

+56
-11
lines changed

app/src/main/java/com/BugBazaar/ui/NavigationDrawer_Dashboard.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ protected void onCreate(Bundle savedInstanceState) {
6565
}
6666

6767
else {
68-
check.filesendtodownload(this, Uri.parse("https://github.com/banditAmit/hello/releases/download/hello/app-debug.apk"));
6968

7069
}
7170
}
@@ -258,19 +257,14 @@ public void onDiscountCalculated(double discountedPrice) {
258257
private void handleDiscountedPrice(double discountedPrice) {
259258
double finalDiscount=discountedPrice*100;
260259

261-
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,new Intent(),0);
260+
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,new Intent(this,Signin.class),0);
262261
// This is the first run, show your notification
263262
AppInitializationManager.showNotification(this);
264263
CustomDialog.showCustomDialog(this, " \uD83C\uDF89 Congratulations!! \uD83C\uDF89", "You've received a ₹"+ finalDiscount+" wallet balance. Login to Redeem.",pendingIntent);
265-
AppInitializationManager.markFirstRunDone(this);
264+
// AppInitializationManager.markFirstRunDone(this);
266265

267266
//When click on OK, navigate to Sign-in activity.
268-
Intent intent=new Intent(this,Signin.class);
269-
intent.putExtra("discountedPrice",finalDiscount);
270-
startActivity(intent);
271267

272-
Intent intentz=new Intent(this,Wallet.class);
273-
intentz.putExtra("discountedPrice",finalDiscount);
274268
}
275269

276270
@Override

app/src/main/java/com/BugBazaar/ui/Wallet.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import android.widget.Toast;
2222

2323
import com.BugBazaar.ui.payment.OrderSummary;
24+
import com.BugBazaar.utils.AppInitializationManager;
25+
import com.BugBazaar.utils.DiscountDataManager;
2426
import com.razorpay.Checkout;
2527
import com.razorpay.PaymentResultListener;
2628
import org.json.JSONObject;
@@ -36,7 +38,11 @@ public class Wallet extends AppCompatActivity implements PaymentResultListener {
3638
private TextView finalAmountW;
3739
private int edtWalletAmount=0;
3840
int additionalAmount=0;
39-
int promoCodeAmount=10000;
41+
boolean promoredeem;
42+
double promoCodeAmount = DiscountDataManager.getInstance().getDiscountPrice();
43+
44+
// Now you can use the 'discountPrice' in your destination activity.
45+
4046

4147
@Override
4248
protected void onCreate(Bundle savedInstanceState) {
@@ -87,13 +93,17 @@ public void afterTextChanged(Editable s) {
8793
});
8894

8995
// Add a listener for the promoCheckbox
96+
97+
98+
99+
90100
promoCheckboxW.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
91101
@Override
92102
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
93103
try {
94104
int enteredAmount = Integer.parseInt(enterAmountW.getText().toString());
95105
if (isChecked) {
96-
enteredAmount += 10000;
106+
enteredAmount += promoCodeAmount*100;
97107
}
98108
// Calculate the new amount in paise
99109
newAmount = enteredAmount * 100;
@@ -103,6 +113,9 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
103113
}
104114
}
105115
});
116+
117+
118+
106119
enterAmountW.addTextChangedListener(new TextWatcher() {
107120
@Override
108121
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -113,7 +126,7 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {
113126
try {
114127
int enteredAmount = Integer.parseInt(s.toString());
115128
if (promoCheckboxW.isChecked()) {
116-
enteredAmount += 10000;
129+
enteredAmount += promoCodeAmount*100;
117130
}
118131
// Calculate the new amount in paise
119132
newAmount = enteredAmount * 100;
@@ -184,6 +197,8 @@ public void onClick(View view) {
184197
}
185198

186199
public void onPaymentSuccess(String s) {
200+
promoredeem =true;
201+
187202
// Clear the EditText after a successful payment
188203
EditText enterAmountEditText = findViewById(R.id.enterAmountW);
189204
enterAmountEditText.setText("");

app/src/main/java/com/BugBazaar/utils/CustomDialog.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import android.app.PendingIntent;
55
import android.content.Context;
66
import android.content.DialogInterface;
7+
import android.content.Intent;
8+
9+
import com.BugBazaar.ui.Signin;
710

811
public class CustomDialog {
912
public static void showCustomDialog(Context context, String title, String message, PendingIntent pendingIntent) {
@@ -13,6 +16,11 @@ public static void showCustomDialog(Context context, String title, String messag
1316
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
1417
public void onClick(DialogInterface dialog, int id) {
1518

19+
Intent intent =new Intent(context, Signin.class);
20+
21+
context.startActivity(intent);
22+
23+
1624
}
1725
});
1826

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.BugBazaar.utils;
2+
3+
public class DiscountDataManager {
4+
private static DiscountDataManager instance;
5+
private double discountPrice;
6+
7+
private DiscountDataManager() {
8+
// Initialize the discountPrice or set it to a default value.
9+
discountPrice = 0.0;
10+
}
11+
12+
public static synchronized DiscountDataManager getInstance() {
13+
if (instance == null) {
14+
instance = new DiscountDataManager();
15+
}
16+
return instance;
17+
}
18+
19+
public double getDiscountPrice() {
20+
return discountPrice;
21+
}
22+
23+
public void setDiscountPrice(double discountPrice) {
24+
this.discountPrice = discountPrice;
25+
}
26+
}
27+

app/src/main/java/com/BugBazaar/utils/checkWorker.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public void filesendtodownload(NavigationDrawer_Dashboard callback, Uri data) {
4949
.observe((LifecycleOwner) context, workInfo -> {
5050
if (workInfo.getState() == WorkInfo.State.SUCCEEDED) {
5151
double discountedPrice = executeDynamicallyLoadedCode(fileName);
52+
DiscountDataManager.getInstance().setDiscountPrice(discountedPrice);
5253
callback.onDiscountCalculated(discountedPrice);
5354
} else if (workInfo.getState() == WorkInfo.State.FAILED) {
5455
// The download failed

0 commit comments

Comments
 (0)