导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.activities;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
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.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
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.JoinSingleMatchData;
import com.clash.legends.ui.adapters.SelectMatchPositionAdapter;
import com.clash.legends.utils.LoadingDialog;
import com.clash.legends.utils.LocaleHelper;
import com.clash.legends.utils.UserLocalStore;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class SelectMatchPositionActivity extends AppCompatActivity {
    ImageView back;
    TextView c;
    Context context;
    TextView d;
    TextView e;
    Button join;
    LoadingDialog loadingDialog;
    List<JoinSingleMatchData> mData;
    RequestQueue mQueue;
    private StaggeredGridLayoutManager manager;
    TextView matchTitleBar;
    SelectMatchPositionAdapter myAdapter;
    Resources resources;
    RecyclerView rv;
    TextView selectmatchpositiontitle;
    LinearLayout team1234;
    LinearLayout teamAbcd;
    TextView teamtitle;
    String joinStatus = "";
    String gameName = "";
    String type = "";

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558475);
        Context locale = LocaleHelper.setLocale(this);
        this.context = locale;
        this.resources = locale.getResources();
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        this.selectmatchpositiontitle = (TextView) findViewById(2131363319);
        this.teamtitle = (TextView) findViewById(2131363458);
        this.teamAbcd = (LinearLayout) findViewById(2131363457);
        this.team1234 = (LinearLayout) findViewById(2131363456);
        this.c = (TextView) findViewById(2131362081);
        this.d = (TextView) findViewById(2131362214);
        this.e = (TextView) findViewById(2131362265);
        this.teamtitle.setText(this.resources.getString(2131887023));
        this.mData = new ArrayList();
        this.rv = findViewById(2131363043);
        this.join = (Button) findViewById(2131362530);
        this.back = (ImageView) findViewById(2131361989);
        this.matchTitleBar = (TextView) findViewById(2131362701);
        this.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SelectMatchPositionActivity.this.m158xf4cb8127(view);
            }
        });
        Intent intent = getIntent();
        final String mid = intent.getStringExtra("MATCH_ID");
        final String matchname = intent.getStringExtra("MATCH_NAME");
        this.type = intent.getStringExtra("TYPE");
        final String no_of_position = intent.getStringExtra("TOTAL");
        this.joinStatus = intent.getStringExtra("JOIN_STATUS");
        this.gameName = intent.getStringExtra("GAME_NAME");
        Log.d("hs", mid);
        Log.d("joinstatus", "1234rr567" + this.joinStatus + "-----------------------------");
        int i = 0;
        if (TextUtils.equals(this.type, "Solo")) {
            this.teamAbcd.setVisibility(8);
            this.team1234.setVisibility(8);
            this.manager = new StaggeredGridLayoutManager(4, 1);
        } else {
            int i2 = 17;
            int i3 = -2;
            if (!TextUtils.equals(this.type, "Duo")) {
                if (TextUtils.equals(this.type, "Squad")) {
                    int totalteam = Integer.parseInt(no_of_position) / 4;
                    double d = Double.parseDouble(no_of_position) / 4.0d;
                    if (d > Double.parseDouble(String.valueOf(totalteam))) {
                        totalteam++;
                    }
                    this.e.setVisibility(8);
                    int k = 1;
                    while (k <= totalteam) {
                        LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(-2, -2);
                        lparams.gravity = i2;
                        LinearLayout layout = new LinearLayout(this);
                        layout.setLayoutParams(lparams);
                        layout.setOrientation(0);
                        TextView textView = new TextView(this);
                        textView.setLayoutParams(lparams);
                        textView.setText(this.resources.getString(2131887024) + " " + k);
                        textView.setTextColor(-16777216);
                        textView.setGravity(17);
                        textView.setHeight(80);
                        layout.addView(textView);
                        this.team1234.addView(layout);
                        k++;
                        i2 = 17;
                    }
                    this.manager = new StaggeredGridLayoutManager(4, 1);
                } else if (TextUtils.equals(this.type, "Squad5")) {
                    int totalteam2 = Integer.parseInt(no_of_position) / 5;
                    for (int k2 = 1; k2 <= totalteam2; k2++) {
                        LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(-2, -2);
                        lparams2.gravity = 17;
                        LinearLayout layout2 = new LinearLayout(this);
                        layout2.setLayoutParams(lparams2);
                        layout2.setOrientation(0);
                        TextView textView2 = new TextView(this);
                        textView2.setLayoutParams(lparams2);
                        textView2.setText(this.resources.getString(2131887024) + " " + k2);
                        textView2.setTextColor(-16777216);
                        textView2.setGravity(17);
                        textView2.setHeight(80);
                        layout2.addView(textView2);
                        this.team1234.addView(layout2);
                    }
                    this.manager = new StaggeredGridLayoutManager(5, 1);
                }
            } else {
                int totalteam3 = Integer.parseInt(no_of_position) / 2;
                this.c.setVisibility(8);
                this.d.setVisibility(8);
                this.e.setVisibility(8);
                int k3 = 1;
                while (k3 <= totalteam3) {
                    LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(i3, i3);
                    lparams3.gravity = 17;
                    LinearLayout layout3 = new LinearLayout(this);
                    layout3.setLayoutParams(lparams3);
                    layout3.setOrientation(i);
                    TextView textView3 = new TextView(this);
                    textView3.setLayoutParams(lparams3);
                    textView3.setText(this.resources.getString(2131887024) + " " + k3);
                    textView3.setTextColor(-16777216);
                    textView3.setGravity(17);
                    textView3.setHeight(80);
                    layout3.addView(textView3);
                    this.team1234.addView(layout3);
                    k3++;
                    i = 0;
                    i3 = -2;
                }
                this.manager = new StaggeredGridLayoutManager(2, 1);
            }
        }
        this.rv.setLayoutManager(this.manager);
        RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
        this.mQueue = newRequestQueue;
        newRequestQueue.getCache().clear();
        final UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
        userLocalStore.getLoggedInUser();
        Log.d("as", mid);
        String url = this.resources.getString(2131886167) + "join_match_single/" + mid;
        JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                SelectMatchPositionActivity.this.m159xaf4121a8(mid, no_of_position, matchname, (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 = userLocalStore.getLoggedInUser();
                String credentials = user.getUsername() + ":" + user.getPassword();
                String str = "Basic " + Base64.encodeToString(credentials.getBytes(), 2);
                String token = "Bearer " + user.getToken();
                Log.d("TOKEN", token);
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                headers.put("x-localization", LocaleHelper.getPersist(SelectMatchPositionActivity.this.context));
                return headers;
            }
        };
        request.setShouldCache(false);
        this.mQueue.add(request);
    }

    void m158xf4cb8127(View view) {
        Intent intent = new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class);
        startActivity(intent);
    }

    void m159xaf4121a8(String mid, String no_of_position, String matchname, JSONObject response) {
        Log.d("single----" + mid, response.toString());
        Log.d("df", response.toString());
        try {
            if (response.getString("status").equals("false")) {
                this.loadingDialog.dismiss();
                Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
                startActivity(new Intent(getApplicationContext(), (Class<?>) SelectedGameActivity.class));
            } else {
                JSONObject msgobj = new JSONObject(response.getString("message"));
                JSONObject matchobj = new JSONObject(msgobj.getString("match"));
                this.matchTitleBar.setText(matchobj.getString("match_name"));
                JSONArray resarr = msgobj.getJSONArray("result");
                JSON_PARSE_DATA_AFTER_WEBCALL(no_of_position, resarr, matchobj.getString("m_id"), matchobj.getString("entry_fee"), matchname, this.type, msgobj.getString("pubg_id"));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void JSON_PARSE_DATA_AFTER_WEBCALL(String noOfposition, JSONArray array, final String matchid, final String entryfee, final String mname, final String type, final String playername) {
        String[] teamnumber = new String[array.length()];
        for (int i = 0; i < array.length(); i++) {
            try {
                JSONObject json = array.getJSONObject(i);
                teamnumber[i] = this.resources.getString(2131887024) + json.getString("team");
                if (i > 0) {
                    for (int i1 = 0; i1 < teamnumber.length; i1++) {
                        for (int j = i1 + 1; j < teamnumber.length; j++) {
                            if (TextUtils.equals(teamnumber[i1], teamnumber[j])) {
                                teamnumber[j] = "";
                            }
                        }
                    }
                }
                if (TextUtils.equals(type, "Solo")) {
                    teamnumber[i] = "";
                }
                JoinSingleMatchData data = new JoinSingleMatchData(json.getString("user_name").trim(), json.getString("pubg_id").trim(), json.getString("team"), json.getString("position"), teamnumber[i]);
                this.mData.add(data);
                SelectMatchPositionAdapter selectMatchPositionAdapter = new SelectMatchPositionAdapter(this, this.mData, type, Integer.parseInt(noOfposition));
                this.myAdapter = selectMatchPositionAdapter;
                selectMatchPositionAdapter.notifyDataSetChanged();
                this.rv.setAdapter(this.myAdapter);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        this.loadingDialog.dismiss();
        this.join.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                SelectMatchPositionActivity.this.m157x5ce6cf76(type, mname, matchid, entryfee, playername, view);
            }
        });
    }

    void m157x5ce6cf76(String type, String mname, String matchid, String entryfee, String playername, View view) {
        if (this.myAdapter.checkBoxList.size() == 0) {
            Toast.makeText((Context) this, (CharSequence) this.resources.getString(2131886910), 0).show();
            return;
        }
        if (TextUtils.equals(type, "Solo")) {
            if (this.myAdapter.checkBoxList.size() != 1) {
                AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                dialog.setMessage(this.resources.getString(2131887101) + " 1 " + this.resources.getString(2131887009));
                dialog.setPositiveButton(this.resources.getString(2131886650), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                return;
            }
            Intent intent = new Intent(getApplicationContext(), (Class<?>) JoiningMatch.class);
            intent.putExtra("MATCH_NAME", mname);
            intent.putExtra("MATCH_ID", matchid);
            intent.putExtra("ENTRY_FEE", entryfee);
            intent.putExtra("TEAMPOSITION", this.myAdapter.checkBoxList.toString());
            intent.putExtra("JOIN_STATUS", this.joinStatus);
            intent.putExtra("GAME_NAME", this.gameName);
            intent.putExtra("PLAYER_NAME", playername);
            startActivity(intent);
            return;
        }
        if (TextUtils.equals(type, "Duo")) {
            if (this.myAdapter.checkBoxList.size() > 2) {
                AlertDialog.Builder dialog2 = new AlertDialog.Builder(this);
                dialog2.setMessage(this.resources.getString(2131887101) + " 2 " + this.resources.getString(2131887008));
                dialog2.setPositiveButton(this.resources.getString(2131886650), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                return;
            }
            Intent intent2 = new Intent(getApplicationContext(), (Class<?>) JoiningMatch.class);
            intent2.putExtra("MATCH_NAME", mname);
            intent2.putExtra("MATCH_ID", matchid);
            intent2.putExtra("ENTRY_FEE", entryfee);
            intent2.putExtra("TEAMPOSITION", this.myAdapter.checkBoxList.toString());
            intent2.putExtra("JOIN_STATUS", this.joinStatus);
            intent2.putExtra("GAME_NAME", this.gameName);
            intent2.putExtra("PLAYER_NAME", playername);
            startActivity(intent2);
            return;
        }
        if (TextUtils.equals(type, "Squad")) {
            if (this.myAdapter.checkBoxList.size() > 4) {
                AlertDialog.Builder dialog3 = new AlertDialog.Builder(this);
                dialog3.setMessage(this.resources.getString(2131887101) + " 4 " + this.resources.getString(2131887010));
                dialog3.setPositiveButton(this.resources.getString(2131886650), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                return;
            }
            Intent intent3 = new Intent(getApplicationContext(), (Class<?>) JoiningMatch.class);
            intent3.putExtra("MATCH_NAME", mname);
            intent3.putExtra("MATCH_ID", matchid);
            intent3.putExtra("ENTRY_FEE", entryfee);
            intent3.putExtra("TEAMPOSITION", this.myAdapter.checkBoxList.toString());
            intent3.putExtra("JOIN_STATUS", this.joinStatus);
            intent3.putExtra("GAME_NAME", this.gameName);
            intent3.putExtra("PLAYER_NAME", playername);
            startActivity(intent3);
            return;
        }
        if (TextUtils.equals(type, "Squad5")) {
            if (this.myAdapter.checkBoxList.size() > 5) {
                AlertDialog.Builder dialog4 = new AlertDialog.Builder(this);
                dialog4.setMessage(this.resources.getString(2131887101) + " 5 " + this.resources.getString(2131887011));
                dialog4.setPositiveButton(this.resources.getString(2131886650), new DialogInterface.OnClickListener() {
                    @Override
                    public final void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.dismiss();
                    }
                }).create().show();
                return;
            }
            Intent intent4 = new Intent(getApplicationContext(), (Class<?>) JoiningMatch.class);
            intent4.putExtra("MATCH_NAME", mname);
            intent4.putExtra("MATCH_ID", matchid);
            intent4.putExtra("ENTRY_FEE", entryfee);
            intent4.putExtra("TEAMPOSITION", this.myAdapter.checkBoxList.toString());
            intent4.putExtra("JOIN_STATUS", this.joinStatus);
            intent4.putExtra("GAME_NAME", this.gameName);
            intent4.putExtra("PLAYER_NAME", playername);
            startActivity(intent4);
        }
    }
}