导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.activities;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
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.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
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.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 com.google.android.material.textfield.TextInputLayout;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JoiningMatch extends AppCompatActivity {
    ImageView back;
    Context context;
    RequestQueue dQueue;
    RequestQueue jQueue;
    Button join;
    Button joinCancel;
    TextView joinCurrentBalance;
    LinearLayout joinLl;
    TextView joinPosition;
    TextView joinTeam;
    TextView joiningmatchtitle;
    LoadingDialog loadingDialog;
    RequestQueue mQueue;
    TextView matchEntryFeePerPersion;
    TextView notepleaseenteryourusename;
    TextView playerName;
    TextView positiontitle;
    Resources resources;
    TextView selectedposiontitle;
    TextView teamtitle;
    TextView totalPayableBalAmount;
    UserLocalStore userLocalStore;
    String memberId = null;
    String currentBal = null;
    String entryFee = null;
    String matchId = null;
    String matchName = null;
    String pTeam = null;
    String pPosition = null;
    String pPubgId = null;
    String joinStatus = "";
    String gameName = "";
    String pName = "";
    boolean canJoin = true;
    boolean nameCheck = true;
    String playername = null;
    private String pubgId = null;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558450);
        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();
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        this.selectedposiontitle = (TextView) findViewById(2131363319);
        this.teamtitle = (TextView) findViewById(2131363458);
        this.positiontitle = (TextView) findViewById(2131363044);
        this.notepleaseenteryourusename = (TextView) findViewById(2131362852);
        this.joiningmatchtitle = (TextView) findViewById(2131362531);
        this.joinCurrentBalance = (TextView) findViewById(2131362527);
        this.matchEntryFeePerPersion = (TextView) findViewById(2131362689);
        this.totalPayableBalAmount = (TextView) findViewById(2131363538);
        this.joinTeam = (TextView) findViewById(2131362542);
        this.joinPosition = (TextView) findViewById(2131362537);
        this.playerName = (TextView) findViewById(2131363032);
        this.joinCancel = (Button) findViewById(2131362525);
        this.join = (Button) findViewById(2131362532);
        this.joinLl = (LinearLayout) findViewById(2131362533);
        this.joiningmatchtitle.setText(this.resources.getString(2131886497));
        Intent intent = getIntent();
        String teamposition = intent.getStringExtra("TEAMPOSITION");
        this.matchId = intent.getStringExtra("MATCH_ID");
        this.matchName = intent.getStringExtra("MATCH_NAME");
        this.entryFee = intent.getStringExtra("ENTRY_FEE");
        this.joinStatus = intent.getStringExtra("JOIN_STATUS");
        this.gameName = intent.getStringExtra("GAME_NAME");
        this.pName = intent.getStringExtra("PLAYER_NAME");
        this.playerName.setText(this.gameName + " " + this.resources.getString(2131886113));
        Log.d("joinstatus", "1234rr567" + this.joinStatus + "-----------------------------" + teamposition);
        ImageView imageView = (ImageView) findViewById(2131361978);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                JoiningMatch.this.m56lambda$onCreate$0$comclashlegendsuiactivitiesJoiningMatch(view);
            }
        });
        this.selectedposiontitle.setText(this.resources.getString(2131886990));
        this.teamtitle.setText(this.resources.getString(2131887023));
        this.positiontitle.setText(this.resources.getString(2131886918));
        this.notepleaseenteryourusename.setText(this.resources.getString(2131886494));
        UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        this.userLocalStore = userLocalStore;
        CurrentUser user = userLocalStore.getLoggedInUser();
        this.memberId = user.getMemberid();
        this.pubgId = this.pName;
        try {
            JSONArray arr = new JSONArray(teamposition);
            JSON_PARSE_DATA_AFTER_WEBCALLextra(arr, this.pubgId);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.dQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        String durl = this.resources.getString(2131886167) + "dashboard/" + user.getMemberid();
        JsonObjectRequest drequest = new JsonObjectRequest(durl, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                JoiningMatch.this.m57lambda$onCreate$1$comclashlegendsuiactivitiesJoiningMatch((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 = JoiningMatch.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(JoiningMatch.this.context));
                return headers;
            }
        };
        drequest.setShouldCache(false);
        this.dQueue.add(drequest);
        this.joinCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                JoiningMatch.this.m58lambda$onCreate$3$comclashlegendsuiactivitiesJoiningMatch(view);
            }
        });
    }

    void m56lambda$onCreate$0$comclashlegendsuiactivitiesJoiningMatch(View view) {
        Intent intent1 = new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class);
        startActivity(intent1);
    }

    void m57lambda$onCreate$1$comclashlegendsuiactivitiesJoiningMatch(JSONObject response) {
        String win;
        String joinm;
        String totalMoney;
        this.loadingDialog.dismiss();
        Log.d("respons", response.toString());
        try {
            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)));
                }
                SpannableStringBuilder builder = new SpannableStringBuilder();
                builder.append((CharSequence) Html.fromHtml(this.resources.getString(2131887107))).append(" ", new ImageSpan(getApplicationContext(), 2131231393, 1), 0).append((CharSequence) " ").append((CharSequence) Html.fromHtml("<b>" + totalMoney));
                this.joinCurrentBalance.setText(builder);
            } catch (JSONException e) {
                e = e;
                e.printStackTrace();
            }
        } catch (JSONException e2) {
            e = e2;
        }
    }

    void m58lambda$onCreate$3$comclashlegendsuiactivitiesJoiningMatch(View view) {
        startActivity(new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class));
    }

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

    public void JSON_PARSE_DATA_AFTER_WEBCALLextra(final JSONArray array, String pubgId) {
        SpannableStringBuilder builder = new SpannableStringBuilder();
        builder.append((CharSequence) Html.fromHtml(this.resources.getString(2131886539))).append("  ", new ImageSpan(getApplicationContext(), 2131231393, 1), 0).append((CharSequence) " ").append((CharSequence) Html.fromHtml("<b>" + this.entryFee));
        this.matchEntryFeePerPersion.setText(builder);
        SpannableStringBuilder builder2 = new SpannableStringBuilder();
        builder2.append((CharSequence) Html.fromHtml(this.resources.getString(2131887041))).append("  ", new ImageSpan(getApplicationContext(), 2131231393, 1), 0).append((CharSequence) " ").append((CharSequence) Html.fromHtml("<b>" + (Integer.parseInt(this.entryFee) * array.length())));
        this.totalPayableBalAmount.setText(builder2);
        this.joinLl.removeAllViews();
        final String[] pidlist = new String[array.length()];
        for (int i = 0; i < array.length(); i++) {
            try {
                JSONObject json = array.getJSONObject(i);
                View view = getLayoutInflater().inflate(2131558778, (ViewGroup) null);
                TextView joinTeam = (TextView) view.findViewById(2131362542);
                TextView joinPosition = (TextView) view.findViewById(2131362537);
                final TextView joinPlayerName = (TextView) view.findViewById(2131362538);
                final int finalI = i;
                if (i == 0) {
                    if (!TextUtils.equals(this.joinStatus, "true")) {
                        if (!TextUtils.equals(pubgId, "")) {
                            joinPlayerName.setText(pubgId);
                            joinPlayerName.setTextColor(getResources().getColor(2131100323));
                            joinPlayerName.setBackgroundColor(-1);
                        }
                        pidlist[finalI] = pubgId;
                        joinPlayerName.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public final void onClick(View view2) {
                                JoiningMatch.this.m53x8c3724c9(joinPlayerName, pidlist, finalI, view2);
                            }
                        });
                    } else {
                        joinPlayerName.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public final void onClick(View view2) {
                                JoiningMatch.this.m55xb89dcda6(joinPlayerName, pidlist, finalI, view2);
                            }
                        });
                    }
                } else {
                    joinPlayerName.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public final void onClick(View view2) {
                            JoiningMatch.this.m51x12645396(joinPlayerName, pidlist, finalI, view2);
                        }
                    });
                }
                this.pTeam = json.getString("team");
                this.pPosition = json.getString("position");
                joinTeam.setText(this.resources.getString(2131887024) + " " + this.pTeam);
                joinPosition.setText(this.pPosition);
                this.joinLl.addView(view);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        this.join.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(android.view.View r18) {
                throw new UnsupportedOperationException("Method not decompiled: com.clash.legends.ui.activities.JoiningMatch.AnonymousClass3.onClick(android.view.View):void");
            }
        });
    }

    void m53x8c3724c9(final TextView joinPlayerName, final String[] pidlist, final int finalI, View v) {
        final Dialog builder1 = new Dialog(this);
        builder1.setContentView(2131558496);
        final EditText newplayername = (EditText) builder1.findViewById(2131362815);
        TextInputLayout pnamehint = builder1.findViewById(2131363492);
        pnamehint.setHint(this.gameName + " " + this.resources.getString(2131886113));
        Button newok = (Button) builder1.findViewById(2131362814);
        Button newcancel = (Button) builder1.findViewById(2131362812);
        if (TextUtils.equals(joinPlayerName.getText().toString().trim(), this.resources.getString(2131886149))) {
            newplayername.setText("");
        } else {
            newplayername.setText(joinPlayerName.getText().toString().trim());
        }
        newok.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                JoiningMatch.this.m52x1948098b(newplayername, joinPlayerName, pidlist, finalI, builder1, view);
            }
        });
        newcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                builder1.dismiss();
            }
        });
        builder1.show();
    }

    void m52x1948098b(EditText newplayername, TextView joinPlayerName, String[] pidlist, int finalI, Dialog builder1, View v1) {
        if (TextUtils.isEmpty(newplayername.getText().toString().trim())) {
            newplayername.setError(this.resources.getString(2131886894));
            return;
        }
        String trim = newplayername.getText().toString().trim();
        this.playername = trim;
        joinPlayerName.setText(trim);
        joinPlayerName.setTextColor(getResources().getColor(2131100323));
        joinPlayerName.setBackgroundColor(-1);
        pidlist[finalI] = this.playername;
        this.playername = "";
        builder1.dismiss();
    }

    void m55xb89dcda6(final TextView joinPlayerName, final String[] pidlist, final int finalI, View v) {
        final Dialog builder12 = new Dialog(this);
        builder12.setContentView(2131558496);
        final EditText newplayername = (EditText) builder12.findViewById(2131362815);
        TextInputLayout pnamehint = builder12.findViewById(2131363492);
        pnamehint.setHint(this.gameName + " " + this.resources.getString(2131886113));
        Button newok = (Button) builder12.findViewById(2131362814);
        Button newcancel = (Button) builder12.findViewById(2131362812);
        if (TextUtils.equals(joinPlayerName.getText().toString().trim(), this.resources.getString(2131886149))) {
            newplayername.setText("");
        } else {
            newplayername.setText(joinPlayerName.getText().toString().trim());
        }
        newok.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                JoiningMatch.this.m54x45aeb268(newplayername, joinPlayerName, pidlist, finalI, builder12, view);
            }
        });
        newcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                builder12.dismiss();
            }
        });
        builder12.show();
    }

    void m54x45aeb268(EditText newplayername, TextView joinPlayerName, String[] pidlist, int finalI, Dialog builder12, View v12) {
        if (TextUtils.isEmpty(newplayername.getText().toString().trim())) {
            newplayername.setError(this.resources.getString(2131886894));
            return;
        }
        String trim = newplayername.getText().toString().trim();
        this.playername = trim;
        joinPlayerName.setText(trim);
        joinPlayerName.setTextColor(getResources().getColor(2131100323));
        joinPlayerName.setBackgroundColor(-1);
        pidlist[finalI] = this.playername;
        this.playername = "";
        builder12.dismiss();
    }

    void m51x12645396(final TextView joinPlayerName, final String[] pidlist, final int finalI, View v) {
        final Dialog builder13 = new Dialog(this);
        builder13.setContentView(2131558496);
        final EditText newplayername = (EditText) builder13.findViewById(2131362815);
        TextInputLayout pnamehint = builder13.findViewById(2131363492);
        pnamehint.setHint(this.gameName + " " + this.resources.getString(2131886113));
        Button newok = (Button) builder13.findViewById(2131362814);
        Button newcancel = (Button) builder13.findViewById(2131362812);
        if (TextUtils.equals(joinPlayerName.getText().toString().trim(), this.resources.getString(2131886149))) {
            newplayername.setText("");
        } else {
            newplayername.setText(joinPlayerName.getText().toString().trim());
        }
        newok.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                JoiningMatch.this.m50x9f753858(newplayername, joinPlayerName, pidlist, finalI, builder13, view);
            }
        });
        newcancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                builder13.dismiss();
            }
        });
        builder13.show();
    }

    void m50x9f753858(EditText newplayername, TextView joinPlayerName, String[] pidlist, int finalI, Dialog builder13, View v13) {
        if (TextUtils.isEmpty(newplayername.getText().toString().trim())) {
            newplayername.setError(this.resources.getString(2131886894));
            return;
        }
        String trim = newplayername.getText().toString().trim();
        this.playername = trim;
        joinPlayerName.setText(trim);
        joinPlayerName.setTextColor(getResources().getColor(2131100323));
        joinPlayerName.setBackgroundColor(-1);
        pidlist[finalI] = this.playername;
        builder13.dismiss();
    }

    void joinmatch(final String matchId, String memberId, final String matchName, JSONArray finalJsonArray) {
        this.canJoin = true;
        Log.d(String.valueOf(true), "YO");
        this.loadingDialog.show();
        this.jQueue = Volley.newRequestQueue(getApplicationContext());
        String jurl = this.resources.getString(2131886167) + "join_match_process";
        final UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("submit", "joinnow");
            jsonObject.put("match_id", matchId);
            jsonObject.put("member_id", memberId);
            jsonObject.put("join_status", this.joinStatus);
            jsonObject.put("teamposition", finalJsonArray);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.e(jurl, jsonObject.toString());
        JsonObjectRequest jrequest = new JsonObjectRequest(jurl, jsonObject, new Response.Listener<JSONObject>() {
            public void onResponse(JSONObject response) {
                JoiningMatch.this.loadingDialog.dismiss();
                try {
                    if (response.getString("status").matches("true")) {
                        Intent intent = new Intent(JoiningMatch.this.getApplicationContext(), (Class<?>) SuccessJoinActivity.class);
                        intent.putExtra("MATCH_NAME", matchName);
                        intent.putExtra("MATCH_ID", matchId);
                        JoiningMatch.this.startActivity(intent);
                    } else {
                        Toast.makeText((Context) JoiningMatch.this, (CharSequence) response.getString("message"), 0).show();
                    }
                } catch (JSONException e2) {
                    e2.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            public void onErrorResponse(VolleyError error) {
                Log.e("**VolleyError", "error" + error.getMessage());
            }
        }) {
            protected Map<String, String> getParams() throws AuthFailureError {
                return super.getParams();
            }

            public Map<String, String> getHeaders() throws AuthFailureError {
                Map<String, String> headers = new HashMap<>();
                CurrentUser user = userLocalStore.getLoggedInUser();
                String token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(JoiningMatch.this.context));
                return headers;
            }
        };
        this.jQueue.add(jrequest);
    }
}