导航菜单

页面标题

页面副标题

Clash Legends v0.0.1 - LotteryActivity.java 源代码

正在查看: Clash Legends v0.0.1 应用的 LotteryActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.clash.legends.ui.activities;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.viewpager.widget.ViewPager;
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.ui.adapters.TabAdapter;
import com.clash.legends.ui.fragments.OngoingLotteryFragment;
import com.clash.legends.ui.fragments.ResultLotteryFragment;
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 com.google.android.material.tabs.TabLayout;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

public class LotteryActivity extends AppCompatActivity {
    private TabAdapter adapter;
    ImageView back;
    TextView balInPlay;
    CardView balance;
    Context context;
    RequestQueue dQueue;
    int n = 0;
    Resources resources;
    private TabLayout tabLayout;
    CurrentUser user;
    UserLocalStore userLocalStore;
    private ViewPager viewPager;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558452);
        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();
        this.viewPager = findViewById(2131363743);
        this.tabLayout = findViewById(2131363429);
        TabAdapter tabAdapter = new TabAdapter(getSupportFragmentManager());
        this.adapter = tabAdapter;
        tabAdapter.addFragment(new OngoingLotteryFragment(), this.resources.getString(2131886098));
        this.adapter.addFragment(new ResultLotteryFragment(), this.resources.getString(2131886105));
        this.viewPager.setAdapter(this.adapter);
        this.tabLayout.setupWithViewPager(this.viewPager);
        this.tabLayout.setTabTextColors(-1, getResources().getColor(2131100323));
        try {
            Intent intent = getIntent();
            String N = intent.getStringExtra("N");
            this.n = Integer.parseInt(N);
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        this.viewPager.setCurrentItem(this.n);
        ImageView imageView = (ImageView) findViewById(2131361980);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LotteryActivity.this.m61xaf4df3fe(view);
            }
        });
        UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        this.userLocalStore = userLocalStore;
        this.user = userLocalStore.getLoggedInUser();
        this.balInPlay = (TextView) findViewById(2131362011);
        CardView findViewById = findViewById(2131362007);
        this.balance = findViewById;
        findViewById.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LotteryActivity.this.m62xaed78dff(view);
            }
        });
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.dQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String durl = this.resources.getString(2131886167) + "dashboard/" + this.user.getMemberid();
        JsonObjectRequest drequest = new JsonObjectRequest(durl, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                LotteryActivity.this.m63xae612800((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 user = LotteryActivity.this.userLocalStore.getLoggedInUser();
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(LotteryActivity.this.context));
                return headers;
            }
        };
        drequest.setShouldCache(false);
        this.dQueue.add(drequest);
    }

    void m61xaf4df3fe(View view) {
        Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
        intent.putExtra("N", "0");
        startActivity(intent);
    }

    void m62xaed78dff(View view) {
        if (this.tabLayout.getSelectedTabPosition() == 0) {
            Intent intent = new Intent(getApplicationContext(), (Class<?>) MyWalletActivity.class);
            intent.putExtra("FROM", "ONGOINGLOTTERY");
            startActivity(intent);
        } else if (this.tabLayout.getSelectedTabPosition() == 1) {
            Intent intent2 = new Intent(getApplicationContext(), (Class<?>) MyWalletActivity.class);
            intent2.putExtra("FROM", "RESULTLOTTERY");
            startActivity(intent2);
        }
    }

    void m63xae612800(JSONObject response) {
        String win;
        String joinm;
        String totalMoney;
        try {
            JSONObject memobj = new JSONObject(response.getString("member"));
            String winMoney = memobj.getString("wallet_balance");
            String joinMoney = memobj.getString("join_money");
            if (TextUtils.equals(winMoney, "null")) {
                winMoney = "0";
            }
            if (TextUtils.equals(joinMoney, "null")) {
                joinMoney = "0";
            }
            if (isDouble(winMoney)) {
                win = String.format("%.2f", Double.valueOf(Double.parseDouble(winMoney)));
            } else {
                win = String.valueOf(Integer.parseInt(winMoney));
            }
            if (isDouble(joinMoney)) {
                joinm = String.format("%.2f", Double.valueOf(Double.parseDouble(joinMoney)));
            } else {
                joinm = String.valueOf(Integer.parseInt(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.balInPlay.setText(totalMoney);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    boolean isDouble(String str) {
        try {
            Double.parseDouble(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public void onBackPressed() {
        super.onBackPressed();
        Intent intent = new Intent(getApplicationContext(), (Class<?>) HomeActivity.class);
        intent.putExtra("N", "0");
        startActivity(intent);
    }
}