正在查看: St.John's v1.0.9 应用的 TransportNotificationsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 TransportNotificationsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.adapter.TransportNotificationsAdapter;
import com.mcb.stjohnsemschool.model.TransportNotificationsModelClass;
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.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class TransportNotificationsActivity extends AppCompatActivity {
private Activity activity;
private ConnectivityManager conMgr;
private Typeface fontFace;
private TextView mNoData;
private ListView mNotifications;
private TransparentProgressDialog mProgressbar;
private SharedPreferences mSharedPref;
private String studentEnrollmentId = "0";
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_transport_notifications);
this.fontFace = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
this.activity = this;
getSupportActionBar().setTitle("Transport Notifications");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
SharedPreferences sharedPreferences = getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
initializations();
}
private void initializations() {
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
this.mNotifications = (ListView) findViewById(R.id.lst_notification);
this.mNoData = (TextView) findViewById(R.id.txv_no_data);
this.mNotifications.setDividerHeight(0);
this.mNoData.setTypeface(this.fontFace);
getTransportNotificationsGPS();
}
private void getTransportNotificationsGPS() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getTransportGPSNotifications();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void getTransportGPSNotifications() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).GetTransportNotificationsGPS(Integer.parseInt(this.studentEnrollmentId), Utility.getSchoolApiKey(this)).enqueue(new Callback<ArrayList<TransportNotificationsModelClass>>() {
public void onResponse(Call<ArrayList<TransportNotificationsModelClass>> call, Response<ArrayList<TransportNotificationsModelClass>> response) {
if (TransportNotificationsActivity.this.mProgressbar != null && TransportNotificationsActivity.this.mProgressbar.isShowing()) {
TransportNotificationsActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(TransportNotificationsActivity.this.activity);
return;
}
new ArrayList();
ArrayList arrayList = (ArrayList) response.body();
TransportNotificationsActivity.this.mNotifications.setAdapter(new TransportNotificationsAdapter(TransportNotificationsActivity.this.getApplicationContext(), arrayList));
if (arrayList.size() > 0) {
TransportNotificationsActivity.this.mNotifications.setVisibility(0);
TransportNotificationsActivity.this.mNoData.setVisibility(8);
} else {
TransportNotificationsActivity.this.mNotifications.setVisibility(8);
TransportNotificationsActivity.this.mNoData.setVisibility(0);
}
}
public void onFailure(Call<ArrayList<TransportNotificationsModelClass>> call, Throwable th) {
if (TransportNotificationsActivity.this.mProgressbar != null && TransportNotificationsActivity.this.mProgressbar.isShowing()) {
TransportNotificationsActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(TransportNotificationsActivity.this.activity);
}
});
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public void onBackPressed() {
if (ProfileActivity.mActivityObj == null) {
startActivity(new Intent(getApplicationContext(), (Class<?>) ProfileActivity.class));
}
finish();
}
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_TRANSPORT_NOTIFICATIONS", bundle);
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
}