正在查看: Clash Legends v0.0.1 应用的 MyOrderActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 MyOrderActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.ui.activities;
import android.content.Context;
import android.content.SharedPreferences;
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.ImageView;
import android.widget.TextView;
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.OrderData;
import com.clash.legends.ui.adapters.OrderAdapter;
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 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 MyOrderActivity extends AppCompatActivity {
ImageView back;
Context context;
LoadingDialog loadingDialog;
List<OrderData> mData;
RequestQueue mQueue;
private StaggeredGridLayoutManager manager;
OrderAdapter myAdapter;
TextView myordertitle;
TextView noorder;
Resources resources;
RecyclerView rv;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(2131558458);
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(2131362774);
this.myordertitle = textView;
textView.setText(this.resources.getString(2131886608));
LoadingDialog loadingDialog = new LoadingDialog(this);
this.loadingDialog = loadingDialog;
loadingDialog.show();
ImageView imageView = (ImageView) findViewById(2131362001);
this.back = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
MyOrderActivity.this.m106x490188b7(view);
}
});
this.rv = findViewById(2131362915);
this.noorder = (TextView) findViewById(2131362845);
this.mData = new ArrayList();
StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(1, 1);
this.manager = staggeredGridLayoutManager;
this.rv.setLayoutManager(staggeredGridLayoutManager);
RequestQueue newRequestQueue = Volley.newRequestQueue(getApplicationContext());
this.mQueue = newRequestQueue;
newRequestQueue.getCache().clear();
final UserLocalStore userLocalStore = new UserLocalStore(getApplicationContext());
CurrentUser user = userLocalStore.getLoggedInUser();
String url = this.resources.getString(2131886167) + "my_order/" + user.getMemberid();
JsonObjectRequest request = new JsonObjectRequest(url, null, new Response.Listener() {
public final void onResponse(Object obj) {
MyOrderActivity.this.m107x488b22b8((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 = 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(MyOrderActivity.this.context));
return headers;
}
};
request.setShouldCache(false);
this.mQueue.add(request);
}
void m106x490188b7(View view) {
onBackPressed();
}
void m107x488b22b8(JSONObject response) {
this.loadingDialog.dismiss();
try {
JSONArray arr = response.getJSONArray("my_orders");
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.rv.setVisibility(8);
this.noorder.setVisibility(0);
return;
}
for (int i = 0; i < array.length(); i++) {
try {
JSONObject json = array.getJSONObject(i);
Log.d("order", json.toString());
OrderData data = new OrderData(json.getString("orders_id"), json.getString("order_no"), json.getString("product_name"), json.getString("product_image"), json.getString("product_price"), json.getString("address"), json.getString("order_status"), json.getString("courier_id"), json.getString("tracking_id"), json.getString("created_date"), json.getString("courier_link"), json.getString("name"), json.getString("add_info"));
this.mData.add(data);
OrderAdapter orderAdapter = new OrderAdapter(this, this.mData);
this.myAdapter = orderAdapter;
orderAdapter.notifyDataSetChanged();
this.rv.setAdapter(this.myAdapter);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
public void onBackPressed() {
super.onBackPressed();
}
}