导航菜单

页面标题

页面副标题

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

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

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


package com.clash.legends.ui.activities;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
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.UserLocalStore;
import com.squareup.picasso.Picasso;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class FriendsActivity extends AppCompatActivity {
    ImageView back;
    ScrollView frdlist;
    LinearLayout ll;
    LoadingDialog loadingDialog;
    LinearLayout nofrdslist;
    CurrentUser user;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558446);
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        ImageView imageView = (ImageView) findViewById(2131361997);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                FriendsActivity.this.m43xed245a4a(view);
            }
        });
        this.ll = (LinearLayout) findViewById(2131362373);
        this.frdlist = (ScrollView) findViewById(2131362371);
        this.nofrdslist = (LinearLayout) findViewById(2131362834);
        RequestQueue jQueue = Volley.newRequestQueue(this);
        jQueue.getCache().clear();
        final UserLocalStore userLocalStore = new UserLocalStore(this);
        this.user = userLocalStore.getLoggedInUser();
        SharedPreferences sp = getSharedPreferences("gameinfo", 0);
        String gameid = sp.getString("gameid", "");
        Log.d("id", gameid);
        String url = getResources().getString(2131886167) + "budy_list/" + gameid;
        JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                FriendsActivity.this.m44xecadf44b((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 token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                return headers;
            }
        };
        request.setShouldCache(false);
        jQueue.add(request);
    }

    void m43xed245a4a(View v) {
        onBackPressed();
    }

    void m44xecadf44b(JSONObject response) {
        this.loadingDialog.dismiss();
        try {
            JSONArray arr = response.getJSONArray("member_list");
            JSON_PARSE_DATA_AFTER_WEBCALL(arr);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array) {
        if (TextUtils.equals(String.valueOf(array.length()), "0")) {
            this.frdlist.setVisibility(8);
            this.nofrdslist.setVisibility(0);
            return;
        }
        for (int i = 0; i < array.length(); i++) {
            try {
                final JSONObject json = array.getJSONObject(i);
                View view = getLayoutInflater().inflate(2131558616, (ViewGroup) null);
                TextView name = (TextView) view.findViewById(2131362792);
                ImageView iv = (ImageView) view.findViewById(2131362507);
                CardView requestToPlay = view.findViewById(2131363159);
                name.setText(json.getString("first_name") + " " + json.getString("last_name"));
                if (!TextUtils.equals(json.getString("profile_image"), "") && !TextUtils.equals(json.getString("profile_image"), "null")) {
                    Picasso.get().load(json.getString("profile_image")).placeholder(2131230869).fit().into(iv);
                }
                requestToPlay.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view2) {
                        FriendsActivity.this.m42x758ff15(json, view2);
                    }
                });
                this.ll.addView(view);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    void m42x758ff15(JSONObject finalJson, View v) {
        try {
            sendRequest(finalJson.getString("member_id"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    public void sendRequest(String memberId) {
        this.loadingDialog.show();
        RequestQueue jQueue = Volley.newRequestQueue(this);
        jQueue.getCache().clear();
        final UserLocalStore userLocalStore = new UserLocalStore(this);
        this.user = userLocalStore.getLoggedInUser();
        SharedPreferences sp = getSharedPreferences("gameinfo", 0);
        String gameid = sp.getString("gameid", "");
        Log.d("id", gameid);
        String url = getResources().getString(2131886167) + "budy_play_request/" + memberId + "/" + gameid;
        JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                FriendsActivity.this.m45xd1007e60((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 token = "Bearer " + user.getToken();
                headers.put("Content-Type", "application/json");
                headers.put("Authorization", token);
                return headers;
            }
        };
        request.setShouldCache(false);
        jQueue.add(request);
    }

    void m45xd1007e60(JSONObject response) {
        this.loadingDialog.dismiss();
        try {
            Toast.makeText(getApplicationContext(), response.getString("message"), 0).show();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}