导航菜单

页面标题

页面副标题

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

正在查看: Clash Legends v0.0.1 应用的 SelectedGameActivity.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.Base64;
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.OnGoingFragment;
import com.clash.legends.ui.fragments.ResultFragment;
import com.clash.legends.ui.fragments.UpcomingFragment;
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 SelectedGameActivity extends AppCompatActivity {
    private TabAdapter adapter;
    ImageView back;
    TextView balInPlay;
    CardView balance;
    Context context;
    RequestQueue dQueue;
    TextView gameTitle;
    int n = 1;
    Resources resources;
    private TabLayout tabLayout;
    CurrentUser user;
    UserLocalStore userLocalStore;
    private ViewPager viewPager;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558476);
        this.viewPager = findViewById(2131363744);
        this.tabLayout = findViewById(2131363430);
        this.gameTitle = (TextView) findViewById(2131362388);
        TabAdapter tabAdapter = new TabAdapter(getSupportFragmentManager());
        this.adapter = tabAdapter;
        tabAdapter.addFragment(new OnGoingFragment(), getResources().getString(2131886652));
        this.adapter.addFragment(new UpcomingFragment(), getResources().getString(2131887051));
        this.adapter.addFragment(new ResultFragment(), getResources().getString(2131886958));
        this.viewPager.setAdapter(this.adapter);
        this.tabLayout.setupWithViewPager(this.viewPager);
        SharedPreferences sp = getSharedPreferences("gameinfo", 0);
        String gamename = sp.getString("gametitle", "");
        this.gameTitle.setText(gamename);
        Intent intentt = getIntent();
        final int selectedTab = intentt.getIntExtra("selected_tab", 1);
        this.viewPager.post(new Runnable() {
            @Override
            public final void run() {
                SelectedGameActivity.this.m160xdc7ccc96(selectedTab);
            }
        });
        ImageView imageView = (ImageView) findViewById(2131361984);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SelectedGameActivity.this.m161xf6984b35(view);
            }
        });
        SharedPreferences spb = getSharedPreferences("SMINFO", 0);
        if (TextUtils.equals(spb.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(2131363744);
        this.tabLayout = findViewById(2131363430);
        TabAdapter tabAdapter2 = new TabAdapter(getSupportFragmentManager());
        this.adapter = tabAdapter2;
        tabAdapter2.addFragment(new OnGoingFragment(), this.resources.getString(2131886652));
        this.adapter.addFragment(new UpcomingFragment(), this.resources.getString(2131887051));
        this.adapter.addFragment(new ResultFragment(), this.resources.getString(2131886958));
        this.viewPager.setAdapter(this.adapter);
        this.tabLayout.setupWithViewPager(this.viewPager);
        this.tabLayout.setTabTextColors(getResources().getColor(2131099832), getResources().getColor(2131100434));
        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 imageView2 = (ImageView) findViewById(2131361984);
        this.back = imageView2;
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SelectedGameActivity.this.m162x10b3c9d4(view);
            }
        });
        TextView textView = (TextView) findViewById(2131362388);
        this.gameTitle = textView;
        textView.setText(gamename);
        UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        this.userLocalStore = userLocalStore;
        this.user = userLocalStore.getLoggedInUser();
        this.balInPlay = (TextView) findViewById(2131362012);
        CardView findViewById = findViewById(2131362008);
        this.balance = findViewById;
        findViewById.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SelectedGameActivity.this.m163x2acf4873(view);
            }
        });
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.dQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String url = this.resources.getString(2131886167) + "dashboard/" + this.user.getMemberid();
        JsonObjectRequest drequest = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                SelectedGameActivity.this.m164x44eac712((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 = SelectedGameActivity.this.userLocalStore.getLoggedInUser();
                String credentials = user.getUsername() + ":" + user.getPassword();
                String str = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(SelectedGameActivity.this.context));
                return headers;
            }
        };
        drequest.setShouldCache(false);
        this.dQueue.add(drequest);
    }

    void m160xdc7ccc96(int selectedTab) {
        this.viewPager.setCurrentItem(selectedTab);
    }

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

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

    void m163x2acf4873(View view) {
        if (this.tabLayout.getSelectedTabPosition() == 0) {
            Intent intent = new Intent(getApplicationContext(), (Class<?>) MyWalletActivity.class);
            intent.putExtra("FROM", "ONGOING");
            startActivity(intent);
        } else if (this.tabLayout.getSelectedTabPosition() == 1) {
            Intent intent2 = new Intent(getApplicationContext(), (Class<?>) MyWalletActivity.class);
            intent2.putExtra("FROM", "UPCOMING");
            startActivity(intent2);
        } else if (this.tabLayout.getSelectedTabPosition() == 2) {
            Intent intent3 = new Intent(getApplicationContext(), (Class<?>) MyWalletActivity.class);
            intent3.putExtra("FROM", "RESULT");
            startActivity(intent3);
        }
    }

    void m164x44eac712(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)));
            }
            SharedPreferences sp1 = getSharedPreferences("currencyinfo", 0);
            sp1.getString("currency", "₹");
            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", "1");
        startActivity(intent);
    }
}