正在查看: Clash Legends v0.0.1 应用的 TopPlayerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 TopPlayerActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.Uri;
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.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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.TopplayerData;
import com.clash.legends.ui.adapters.TopplayerAdapter;
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.squareup.picasso.Picasso;
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 TopPlayerActivity extends AppCompatActivity {
ImageView back;
Context context;
Boolean firsttime = true;
LoadingDialog loadingDialog;
LinearLayout logoll;
List<TopplayerData> mData;
RequestQueue mQueue;
TopplayerAdapter myAdapter;
TextView notoplayer;
RecyclerView recyclerView;
Resources resources;
TextView topplayerstitle;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558488);
SharedPreferences sp = getSharedPreferences("SMINFO", 0);
if (TextUtils.equals(sp.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();
TextView textView = (TextView) findViewById(2131363535);
this.topplayerstitle = textView;
textView.setText(this.resources.getString(2131887037));
this.notoplayer = (TextView) findViewById(2131362867);
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
ImageView imageView = (ImageView) findViewById(2131361992);
this.back = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
TopPlayerActivity.this.m217x88c72acb(view);
}
});
this.logoll = (LinearLayout) findViewById(2131362640);
this.recyclerView = findViewById(2131363534);
LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
layoutManager.setStackFromEnd(false);
layoutManager.setReverseLayout(false);
this.recyclerView.setLayoutManager(layoutManager);
this.mData = new ArrayList();
RequestQueue newRequestQueue = Volley.newRequestQueue(this);
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
String url = this.resources.getString(2131886167) + "top_players";
JsonObjectRequest request = new JsonObjectRequest(0, url, null, new Response.Listener() {
public final void onResponse(Object obj) {
TopPlayerActivity.this.m218xcc52488c((JSONObject) obj);
}
}, new Response.ErrorListener() {
public final void onErrorResponse(VolleyError volleyError) {
Log.e("VolleyError", "error" + volleyError.getMessage());
}
}) {
public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
UserLocalStore userLocalStore = new UserLocalStore(TopPlayerActivity.this.getApplicationContext());
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(TopPlayerActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
}
void m217x88c72acb(View view) {
onBackPressed();
}
void m218xcc52488c(JSONObject response) {
this.loadingDialog.dismiss();
Log.d("response", response.toString());
try {
JSONObject jsnobject = new JSONObject(response.getString("top_players"));
JSONArray arrgame = response.getJSONArray("game");
JSON_PARSE_DATA_AFTER_WEBCALLgame(arrgame, jsnobject);
} catch (JSONException e) {
e.printStackTrace();
}
}
public void JSON_PARSE_DATA_AFTER_WEBCALLgame(JSONArray array, final JSONObject object) {
if (TextUtils.equals(String.valueOf(array.length()), "0")) {
this.logoll.setVisibility(8);
this.recyclerView.setVisibility(8);
this.notoplayer.setVisibility(0);
return;
}
for (int i = 0; i < array.length(); i++) {
try {
final JSONObject json = array.getJSONObject(i);
View view = getLayoutInflater().inflate(2131558809, (ViewGroup) null);
ImageView gamelogo = (ImageView) view.findViewById(2131363533);
Log.d("game_logo", json.getString("game_logo"));
Picasso.get().load(Uri.parse(json.getString("game_logo"))).placeholder(2131230869).fit().into(gamelogo);
gamelogo.setTag(json.getString("game_name"));
if (this.firsttime.booleanValue()) {
this.firsttime = false;
try {
JSONArray arr = object.getJSONArray(json.getString("game_name"));
JSON_PARSE_DATA_AFTER_WEBCALL(arr, json.getString("game_name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
gamelogo.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
TopPlayerActivity.this.m216x8cffffc8(object, json, view2);
}
});
this.logoll.addView(view);
} catch (JSONException e2) {
e2.printStackTrace();
}
}
}
void m216x8cffffc8(JSONObject object, JSONObject finalJson, View v) {
this.mData.clear();
try {
JSONArray arr = object.getJSONArray(finalJson.getString("game_name"));
JSON_PARSE_DATA_AFTER_WEBCALL(arr, finalJson.getString("game_name"));
} catch (JSONException e) {
e.printStackTrace();
}
}
public void JSON_PARSE_DATA_AFTER_WEBCALL(JSONArray array, String gamename) {
for (int i = 0; i < array.length(); i++) {
try {
JSONObject json = array.getJSONObject(i);
if (i != 0) {
gamename = "";
}
TopplayerData data = new TopplayerData(gamename, json.getString("winning"), json.getString("user_name"), json.getString("member_id"), json.getString("pubg_id"));
Log.e("winning", json.getString("winning"));
this.mData.add(data);
TopplayerAdapter topplayerAdapter = new TopplayerAdapter(this, this.mData);
this.myAdapter = topplayerAdapter;
topplayerAdapter.notifyDataSetChanged();
this.recyclerView.setAdapter(this.myAdapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}