正在查看: Clash Legends v0.0.1 应用的 MyWalletActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 MyWalletActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.android.volley.AuthFailureError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.clash.legends.models.CurrentUser;
import com.clash.legends.models.TransactionDetails;
import com.clash.legends.ui.adapters.TransactionAdapter;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.LoadAdError;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import me.toptas.fancyshowcase.FancyShowCaseQueue;
import me.toptas.fancyshowcase.FancyShowCaseView;
import me.toptas.fancyshowcase.FocusShape;
import me.toptas.fancyshowcase.listener.DismissListener;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class MyWalletActivity extends AppCompatActivity {
Button addBtn;
ImageView back;
TextView balance;
Context context;
RequestQueue dQueue;
TextView earnings;
TextView earningtitle;
TextView joinMoneyTv;
LoadingDialog loadingDialog;
List<TransactionDetails> mData;
RequestQueue mQueue;
TransactionAdapter myAdapter;
TextView mywallettitle;
TextView payouts;
TextView payoutstitle;
SwipeRefreshLayout pullToRefresh;
Resources resources;
TextView totalbalancetitle;
RecyclerView transactionRv;
UserLocalStore userLocalStore;
TextView wallethistorytitle;
TextView winMoneyTv;
Button withdrawBtn;
String winMoney = "";
String joinMoney = "";
String from = "";
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null && Objects.equals(intent.getAction(), "reload")) {
MyWalletActivity.this.dashBoard();
}
}
};
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558463);
SharedPreferences sp = getSharedPreferences("SMINFO", 0);
if (TextUtils.equals(sp.getString("baner", "no"), "yes")) {
final AdView mAdView = findViewById(2131361885);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
mAdView.setAdListener(new AdListener() {
public void onAdLoaded() {
mAdView.setVisibility(0);
}
public void onAdFailedToLoad(LoadAdError adError) {
mAdView.setVisibility(8);
}
public void onAdOpened() {
}
public void onAdClicked() {
}
public void onAdLeftApplication() {
}
public void onAdClosed() {
}
});
}
Context locale = LocaleHelper.setLocale(this);
this.context = locale;
this.resources = locale.getResources();
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
this.mywallettitle = (TextView) findViewById(2131362791);
this.totalbalancetitle = (TextView) findViewById(2131363536);
this.earningtitle = (TextView) findViewById(2131362267);
this.payoutstitle = (TextView) findViewById(2131362999);
this.wallethistorytitle = (TextView) findViewById(2131363777);
this.balance = (TextView) findViewById(2131362009);
this.winMoneyTv = (TextView) findViewById(2131363793);
this.joinMoneyTv = (TextView) findViewById(2131362534);
this.earnings = (TextView) findViewById(2131362266);
this.payouts = (TextView) findViewById(2131362998);
this.mywallettitle.setText(this.resources.getString(2131886617));
this.totalbalancetitle.setText(this.resources.getString(2131887039));
this.earningtitle.setText(this.resources.getString(2131886422));
this.payoutstitle.setText(this.resources.getString(2131886694));
this.wallethistorytitle.setText(this.resources.getString(2131887071));
Intent intent = getIntent();
this.from = intent.getStringExtra("FROM");
ImageView imageView = (ImageView) findViewById(2131361993);
this.back = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MyWalletActivity.this.m136x4401d12e(view);
}
});
this.addBtn = (Button) findViewById(2131361889);
this.withdrawBtn = (Button) findViewById(2131363812);
this.addBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MyWalletActivity.this.m137x35ab774d(view);
}
});
this.withdrawBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MyWalletActivity.this.m138x27551d6c(view);
}
});
IntentFilter intentFilter = new IntentFilter("reload");
registerReceiver(this.broadcastReceiver, intentFilter);
this.userLocalStore = new UserLocalStore(getApplicationContext());
SwipeRefreshLayout findViewById = findViewById(2131363106);
this.pullToRefresh = findViewById;
findViewById.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
public final void onRefresh() {
MyWalletActivity.this.m139x18fec38b();
}
});
this.transactionRv = findViewById(2131363546);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
layoutManager.setStackFromEnd(false);
layoutManager.setReverseLayout(false);
this.transactionRv.setLayoutManager(layoutManager);
this.mData = new ArrayList();
dashBoard();
new FancyShowCaseQueue().add(addView(this.addBtn, this.resources.getString(2131886999), "4")).add(addView(this.withdrawBtn, this.resources.getString(2131887000), "5")).show();
}
void m136x4401d12e(View view) {
onBackPressed();
}
void m137x35ab774d(View v) {
Intent intent1 = new Intent(getApplicationContext(), (Class<?>) AddMoneyActivity.class);
startActivity(intent1);
}
void m138x27551d6c(View v) {
Intent intent12 = new Intent(getApplicationContext(), (Class<?>) WithdrawMoneyActivity.class);
startActivity(intent12);
}
void m139x18fec38b() {
this.pullToRefresh.setRefreshing(true);
refresh();
this.pullToRefresh.setRefreshing(false);
}
public void dashBoard() {
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.dQueue = newRequestQueue;
newRequestQueue.getCache().clear();
UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
this.userLocalStore = userLocalStore;
CurrentUser user = userLocalStore.getLoggedInUser();
String durl = this.resources.getString(2131886167) + "dashboard/" + user.getMemberid();
JsonObjectRequest drequest = new JsonObjectRequest(durl, null, new Response.Listener() {
public final void onResponse(Object obj) {
MyWalletActivity.this.m134x43ee96b((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("**VolleyError", "error" + volleyError.getMessage());
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
CurrentUser user2 = MyWalletActivity.this.userLocalStore.getLoggedInUser();
String credentials = user2.getUsername() + ":" + user2.getPassword();
String str = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
String token = "Bearer " + user2.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
headers.put("x-localization", LocaleHelper.getPersist(MyWalletActivity.this.context));
return headers;
}
};
drequest.setShouldCache(false);
this.dQueue.add(drequest);
RequestQueue newRequestQueue2 = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue2;
newRequestQueue2.getCache().clear();
String url = this.resources.getString(2131886167) + "transaction";
JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
public final void onResponse(Object obj) {
MyWalletActivity.this.m135xe79235a9((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("VolleyError", "error" + volleyError.getMessage());
}
}) {
protected Map<String, String> getParams() throws AuthFailureError {
return super.getParams();
}
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
CurrentUser user2 = MyWalletActivity.this.userLocalStore.getLoggedInUser();
String token = "Bearer " + user2.getToken();
headers.put("Content-Type", "application/json");
headers.put("Authorization", token);
headers.put("x-localization", LocaleHelper.getPersist(MyWalletActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
}
void m134x43ee96b(JSONObject response) {
String win;
String joinm;
String totalMoney;
this.loadingDialog.dismiss();
try {
JSONObject memobj = new JSONObject(response.getString("member"));
Log.d("MEMOBJ", String.valueOf(memobj));
this.winMoney = memobj.getString("wallet_balance");
this.joinMoney = memobj.getString("join_money");
if (TextUtils.equals(this.winMoney, "null")) {
this.winMoney = "0";
}
if (TextUtils.equals(this.joinMoney, "null")) {
this.joinMoney = "0";
}
if (isDouble(this.winMoney)) {
win = String.format("%.2f", Double.valueOf(Double.parseDouble(this.winMoney)));
} else {
win = String.valueOf(Integer.parseInt(this.winMoney));
}
if (isDouble(this.joinMoney)) {
joinm = String.format("%.2f", Double.valueOf(Double.parseDouble(this.joinMoney)));
} else {
joinm = String.valueOf(Integer.parseInt(this.joinMoney));
}
if (win.startsWith("0")) {
if (isDouble(joinm)) {
totalMoney = String.valueOf(Double.parseDouble(joinm));
} else {
totalMoney = String.valueOf(Integer.parseInt(joinm));
}
} else if (joinm.startsWith("-")) {
if (isDouble(win)) {
totalMoney = String.valueOf(Double.parseDouble(win));
} else {
totalMoney = String.valueOf(Integer.parseInt(win));
}
} else if (isDouble(win) && isDouble(joinm)) {
totalMoney = String.valueOf(Double.parseDouble(win) + Double.parseDouble(joinm));
} else {
totalMoney = String.valueOf(Integer.parseInt(win) + Integer.parseInt(joinm));
}
if (isDouble(totalMoney)) {
totalMoney = String.format("%.2f", Double.valueOf(Double.parseDouble(totalMoney)));
}
this.balance.setText(totalMoney);
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append((CharSequence) Html.fromHtml(this.resources.getString(2131887079))).append(" ", new ImageSpan(getApplicationContext(), 2131231392, 1), 0).append((CharSequence) " ").append((CharSequence) Html.fromHtml("<b>" + win));
this.winMoneyTv.setText(builder);
SpannableStringBuilder builder2 = new SpannableStringBuilder();
builder2.append((CharSequence) Html.fromHtml(this.resources.getString(2131886493))).append(" ", new ImageSpan(getApplicationContext(), 2131231392, 1), 0).append((CharSequence) " ").append((CharSequence) Html.fromHtml("<b>" + joinm));
this.joinMoneyTv.setText(builder2);
JSONObject totwinobj = new JSONObject(response.getString("tot_win"));
if (!TextUtils.equals(totwinobj.getString("total_win"), "null")) {
if (isDouble(totwinobj.getString("total_win"))) {
this.earnings.setText(String.format("%.2f", Double.valueOf(Double.parseDouble(totwinobj.getString("total_win")))));
} else {
this.earnings.setText(totwinobj.getString("total_win"));
}
} else {
this.earnings.setText("0");
}
JSONObject totwithobj = new JSONObject(response.getString("tot_withdraw"));
if (!TextUtils.equals(totwithobj.getString("tot_withdraw"), "null")) {
if (isDouble(totwithobj.getString("tot_withdraw"))) {
this.payouts.setText(String.format("%.2f", Double.valueOf(Double.parseDouble(totwithobj.getString("tot_withdraw")))));
return;
} else {
this.payouts.setText(totwithobj.getString("tot_withdraw"));
return;
}
}
this.payouts.setText("0");
} catch (JSONException e) {
e.printStackTrace();
}
}
void m135xe79235a9(JSONObject response) {
try {
JSONArray arr = response.getJSONArray("transaction");
JSON_PARSE_DATA_AFTER_WEBCALL(arr);
} catch (JSONException e) {
e.printStackTrace();
}
this.loadingDialog.dismiss();
}
boolean isDouble(String str) {
try {
Double.parseDouble(str);
return true;
} catch (NumberFormatException e) {
return false;
}
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
this.mData.clear();
this.transactionRv.removeAllViews();
for (int i = 0; i < array.length(); i++) {
try {
JSONObject json = array.getJSONObject(i);
Log.d("Array", json.toString());
if (!TextUtils.equals(json.getString("deposit"), "0") || !TextUtils.equals(json.getString("withdraw"), "0")) {
TransactionDetails data = new TransactionDetails(json.getString("transaction_id"), json.getString("note"), json.getString("match_id"), json.getString("note_id"), json.getString("date"), json.getString("join_money"), json.getString("win_money"), json.getString("deposit"), json.getString("withdraw"));
this.mData.add(data);
TransactionAdapter transactionAdapter = new TransactionAdapter(this, this.mData);
this.myAdapter = transactionAdapter;
transactionAdapter.notifyDataSetChanged();
this.transactionRv.setAdapter(this.myAdapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void refresh() {
finish();
overridePendingTransition(0, 0);
startActivity(getIntent());
overridePendingTransition(0, 0);
this.pullToRefresh.setRefreshing(false);
}
public void onBackPressed() {
super.onBackPressed();
if (TextUtils.equals(this.from, "EARN")) {
Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
intent.putExtra("N", "0");
startActivity(intent);
return;
}
if (TextUtils.equals(this.from, "PLAY")) {
Intent intent2 = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
intent2.putExtra("N", "1");
startActivity(intent2);
return;
}
if (TextUtils.equals(this.from, "ME")) {
Intent intent3 = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
intent3.putExtra("N", "2");
startActivity(intent3);
return;
}
if (TextUtils.equals(this.from, "ONGOING")) {
Intent intent4 = new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class);
intent4.putExtra("N", "0");
startActivity(intent4);
return;
}
if (TextUtils.equals(this.from, "UPCOMING")) {
Intent intent5 = new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class);
intent5.putExtra("N", "1");
startActivity(intent5);
return;
}
if (TextUtils.equals(this.from, "RESULT")) {
Intent intent6 = new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class);
intent6.putExtra("N", "2");
startActivity(intent6);
} else if (TextUtils.equals(this.from, "ONGOINGLOTTERY")) {
Intent intent7 = new Intent(getApplicationContext(), (Class<?>) LotteryActivity.class);
intent7.putExtra("N", "0");
startActivity(intent7);
} else if (TextUtils.equals(this.from, "RESULTLOTTERY")) {
Intent intent8 = new Intent(getApplicationContext(), (Class<?>) LotteryActivity.class);
intent8.putExtra("N", "1");
startActivity(intent8);
} else {
Intent intent9 = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
intent9.putExtra("N", "2");
startActivity(intent9);
}
}
public FancyShowCaseView addView(View view, String title, String n) {
FancyShowCaseView view1 = new FancyShowCaseView.Builder(this).focusOn(view).title(title).titleSize(20, 1).focusShape(FocusShape.CIRCLE).enableAutoTextPosition().roundRectRadius(10).focusBorderSize(1).showOnce(n).focusBorderColor(getResources().getColor(2131100324)).dismissListener(new DismissListener() {
public void onDismiss(String s) {
}
public void onSkipped(String s) {
}
}).build();
return view1;
}
}