正在查看: St.John's v1.0.9 应用的 TrackOrderActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 TrackOrderActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class TrackOrderActivity extends AppCompatActivity {
private Activity activity;
private ConnectivityManager conMgr;
private TextView mDesc;
private TransparentProgressDialog mProgressbar;
private TextView mShipmentId;
private TextView mStatus;
private int schoolStoreSaleId;
private String transactionId = "";
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_track_order);
this.activity = this;
getSupportActionBar().setTitle("Track Order");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
Bundle extras = getIntent().getExtras();
this.transactionId = extras.getString("TransactionId", "");
this.schoolStoreSaleId = extras.getInt("SchoolStoreSaleId", 0);
initializations();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
private void initializations() {
this.mShipmentId = (TextView) findViewById(R.id.txv_shipment_id);
this.mStatus = (TextView) findViewById(R.id.txv_status);
this.mDesc = (TextView) findViewById(R.id.txv_desc);
this.mShipmentId.setVisibility(8);
this.mStatus.setVisibility(8);
this.mDesc.setVisibility(8);
trackSchoolStoreOrder();
}
private void trackSchoolStoreOrder() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
trackOrder();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void trackOrder() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap hashMap = new HashMap();
hashMap.put("SchoolStoreSaleID", String.valueOf(this.schoolStoreSaleId));
hashMap.put("apikey", Utility.getSchoolApiKey(this));
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).TrackSchoolStoreOrder(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (TrackOrderActivity.this.mProgressbar != null && TrackOrderActivity.this.mProgressbar.isShowing()) {
TrackOrderActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(TrackOrderActivity.this.activity);
return;
}
try {
JSONObject jSONObject = new JSONObject((String) response.body());
if (jSONObject.has("Error")) {
String string = jSONObject.getString("Error");
TrackOrderActivity.this.mShipmentId.setVisibility(8);
TrackOrderActivity.this.mStatus.setVisibility(8);
TrackOrderActivity.this.mDesc.setVisibility(0);
TrackOrderActivity.this.mDesc.setText(string);
return;
}
if (jSONObject.has("ShipmentData")) {
JSONArray jSONArray = jSONObject.getJSONArray("ShipmentData");
if (jSONArray.length() > 0) {
JSONObject jSONObject2 = jSONArray.getJSONObject(0);
if (jSONObject2.has("Shipment")) {
JSONObject jSONObject3 = jSONObject2.getJSONObject("Shipment");
if (jSONObject3.has("Status")) {
JSONObject jSONObject4 = jSONObject3.getJSONObject("Status");
if (jSONObject4.has("Status")) {
TrackOrderActivity.this.mStatus.setText(jSONObject4.getString("Status"));
TrackOrderActivity.this.mStatus.setVisibility(0);
}
if (jSONObject4.has("Instructions")) {
TrackOrderActivity.this.mDesc.setText(jSONObject4.getString("Instructions"));
TrackOrderActivity.this.mDesc.setVisibility(0);
}
}
if (jSONObject3.has("AWB")) {
TrackOrderActivity.this.mShipmentId.setText(jSONObject3.getString("AWB"));
TrackOrderActivity.this.mShipmentId.setVisibility(0);
}
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
public void onFailure(Call<String> call, Throwable th) {
if (TrackOrderActivity.this.mProgressbar != null && TrackOrderActivity.this.mProgressbar.isShowing()) {
TrackOrderActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(TrackOrderActivity.this.activity);
}
});
}
protected void onResume() {
super.onResume();
String string = getSharedPreferences("", 0).getString("usernamekey", "");
Bundle bundle = new Bundle();
bundle.putString("user_name", string);
FirebaseAnalytics.getInstance(this).logEvent("PAGE_SCHOOL_STORE_TRACK_ORDER", bundle);
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
}