导航菜单

页面标题

页面副标题

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

正在查看: Clash Legends v0.0.1 应用的 LudoNotificationActivity.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 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.UserLocalStore;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class LudoNotificationActivity extends AppCompatActivity {
    ImageView back;
    LinearLayout ll;
    LoadingDialog loadingDialog;
    LinearLayout nonotification;
    ScrollView notilist;
    CurrentUser user;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(2131558456);
        LoadingDialog loadingDialog = new LoadingDialog(this);
        this.loadingDialog = loadingDialog;
        loadingDialog.show();
        ImageView imageView = (ImageView) findViewById(2131362002);
        this.back = imageView;
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                LudoNotificationActivity.this.m86x965e7b48(view);
            }
        });
        this.ll = (LinearLayout) findViewById(2131362864);
        this.notilist = (ScrollView) findViewById(2131362865);
        this.nonotification = (LinearLayout) findViewById(2131362843);
        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) + "notification_list/" + gameid;
        JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
            public final void onResponse(Object obj) {
                LudoNotificationActivity.this.m87x234b9267((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 m86x965e7b48(View v) {
        onBackPressed();
    }

    void m87x234b9267(JSONObject response) {
        this.loadingDialog.dismiss();
        try {
            JSONArray arr = response.getJSONArray("notifications");
            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.notilist.setVisibility(8);
            this.nonotification.setVisibility(0);
            return;
        }
        for (int i = 0; i < array.length(); i++) {
            try {
                JSONObject json = array.getJSONObject(i);
                View view = getLayoutInflater().inflate(2131558727, (ViewGroup) null);
                TextView title = (TextView) view.findViewById(2131362862);
                TextView msg = (TextView) view.findViewById(2131362860);
                TextView time = (TextView) view.findViewById(2131362861);
                title.setText(json.getString("heading"));
                msg.setText(json.getString("content"));
                time.setText(json.getString("date_created"));
                this.ll.addView(view);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
}