导航菜单

页面标题

页面副标题

St.John's v1.0.9 - ViewDynamicFormActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 ViewDynamicFormActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.adapter.ViewDynamicFormsAdapter;
import com.mcb.stjohnsemschool.model.ViewDynamicFormModelClass;
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 ViewDynamicFormActivity extends AppCompatActivity {
    private Activity activity;
    private Context context;
    private int formId;
    private ListView mDynamicForm;
    private TransparentProgressDialog mProgressbar;
    private String formName = "";
    private String userId = "0";
    private String studentEnrolmentId = "0";
    private String orgId = "0";
    private String academicYearId = "0";
    private String branchId = "0";
    private String entryDate = "";

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_view_dynamic_form);
        this.activity = this;
        this.context = getApplicationContext();
        this.mProgressbar = new TransparentProgressDialog(this.activity, R.drawable.spinner_loading_imag);
        Bundle extras = getIntent().getExtras();
        this.formName = extras.getString("FormName", this.formName);
        this.entryDate = extras.getString("EntryDate", this.entryDate);
        this.formId = extras.getInt("FormId", this.formId);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle(this.formName);
        getSupportActionBar().setSubtitle("Form filled on " + this.entryDate);
        SharedPreferences sharedPreferences = this.context.getSharedPreferences("", 0);
        this.userId = sharedPreferences.getString("UseridKey", this.userId);
        this.studentEnrolmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrolmentId);
        this.orgId = sharedPreferences.getString("orgnizationIdKey", this.orgId);
        this.branchId = sharedPreferences.getString("branchid", this.branchId);
        this.academicYearId = sharedPreferences.getString("academicyearIdKey", this.academicYearId);
        initializations();
    }

    private void initializations() {
        ListView listView = (ListView) findViewById(R.id.lst_view_dynamic_form);
        this.mDynamicForm = listView;
        listView.setDividerHeight(0);
        getDynamicForms();
    }

    private void getDynamicForms() {
        ConnectivityManager connectivityManager = (ConnectivityManager) this.context.getSystemService("connectivity");
        if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
            getStudentDynamicFormData();
        } else {
            Toast.makeText(this.context, "Check your Network Connection", 0).show();
        }
    }

    private void getStudentDynamicFormData() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentDynamicFormData(Integer.parseInt(this.studentEnrolmentId), Integer.parseInt(this.branchId), Integer.parseInt(this.academicYearId), this.formId, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<ViewDynamicFormModelClass>>() {
            public void onResponse(Call<ArrayList<ViewDynamicFormModelClass>> call, Response<ArrayList<ViewDynamicFormModelClass>> response) {
                if (ViewDynamicFormActivity.this.mProgressbar != null && ViewDynamicFormActivity.this.mProgressbar.isShowing()) {
                    ViewDynamicFormActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(ViewDynamicFormActivity.this.activity);
                    return;
                }
                ViewDynamicFormActivity.this.mDynamicForm.setAdapter(new ViewDynamicFormsAdapter(ViewDynamicFormActivity.this.context, (ArrayList) response.body()));
            }

            public void onFailure(Call<ArrayList<ViewDynamicFormModelClass>> call, Throwable th) {
                if (ViewDynamicFormActivity.this.mProgressbar != null && ViewDynamicFormActivity.this.mProgressbar.isShowing()) {
                    ViewDynamicFormActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(ViewDynamicFormActivity.this.activity);
            }
        });
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 16908332) {
            finish();
        }
        return super.onOptionsItemSelected(menuItem);
    }

    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_VIEW_DYNAMIC_FORMS", bundle);
    }

    protected void onStop() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
            this.mProgressbar.dismiss();
        }
        super.onStop();
    }
}