导航菜单

页面标题

页面副标题

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

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

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


package com.mcb.stjohnsemschool.activity;

import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.mcb.stjohnsemschool.model.SavePtmModel;
import com.mcb.stjohnsemschool.model.StudentsUpcomingsPTMSaveDetailsModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.NonScrollListView;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SavePtmActivity extends AppCompatActivity {
    private Context context;
    private String currentMonth;
    private String dayOfMonthStr;
    private String mAcadamicYearId;
    private String mBranchSectionId;
    private String mClassId;
    private TransparentProgressDialog mProgressbar;
    private String mPtmDate;
    private SharedPreferences mSharedPref;
    private String mStudentEnrollmentID;
    private Button mSubmitBt;
    private EditText mSuggestionsEt;
    private String mUserId;
    private NonScrollListView nonScrollListView;
    private int ptmScheduleId;
    private String spinnerMonth;
    private ArrayList<StudentsUpcomingsPTMSaveDetailsModel> studentsUpcomingsPTMSaveDetailList = new ArrayList<>();

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_save_ptm);
        this.context = getApplicationContext();
        setUpIds();
    }

    private void setUpIds() {
        this.mSharedPref = getSharedPreferences("", 0);
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.mUserId = this.mSharedPref.getString("UseridKey", this.mUserId);
        this.mClassId = this.mSharedPref.getString("ClassidKey", this.mClassId);
        this.mBranchSectionId = this.mSharedPref.getString("BranchSectionIDKey", this.mBranchSectionId);
        this.mStudentEnrollmentID = this.mSharedPref.getString("studentEnrollmentIdKey", this.mStudentEnrollmentID);
        this.mAcadamicYearId = this.mSharedPref.getString("academicyearIdKey", this.mAcadamicYearId);
        this.ptmScheduleId = getIntent().getExtras().getInt("ptm_schedule_id");
        this.mPtmDate = getIntent().getExtras().getString("ptm_date", "");
        getSupportActionBar().setTitle("PTM (" + this.mPtmDate + ")");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowTitleEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        this.mSuggestionsEt = (EditText) findViewById(R.id.edt_parent_suggestion);
        Button button = (Button) findViewById(R.id.btn_submit_suggestion);
        this.mSubmitBt = button;
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!SavePtmActivity.this.mSuggestionsEt.getText().toString().isEmpty()) {
                    SavePtmActivity.this.savePTMDetails();
                } else {
                    Toast.makeText(SavePtmActivity.this.getApplicationContext(), "Enter Suggestions", 0).show();
                }
            }
        });
    }

    public void savePTMDetails() {
        ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService("connectivity");
        if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
            savePtm();
        } else {
            Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
        }
    }

    private void savePtm() {
        String format = new SimpleDateFormat("MM/dd/yyyy", Locale.US).format(new Date(this.mPtmDate));
        Log.e("Save", "sending date==========" + format);
        HashMap hashMap = new HashMap();
        hashMap.put("PTMScheduleID", String.valueOf(this.ptmScheduleId));
        hashMap.put("StudentEnrollmentID", this.mStudentEnrollmentID);
        hashMap.put("UserID", this.mUserId);
        hashMap.put("AcademicYearID", String.valueOf(this.mAcadamicYearId));
        hashMap.put("AttendedDate", format);
        hashMap.put("ParentSuggestions", this.mSuggestionsEt.getText().toString());
        hashMap.put("apikey", Utility.getSchoolApiKey(getApplicationContext()));
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null) {
            transparentProgressDialog.show();
        }
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).savePTMParentSuggestions(hashMap).enqueue(new Callback<SavePtmModel>() {
            public void onResponse(Call<SavePtmModel> call, Response<SavePtmModel> response) {
                if (SavePtmActivity.this.mProgressbar != null && SavePtmActivity.this.mProgressbar.isShowing()) {
                    SavePtmActivity.this.mProgressbar.dismiss();
                }
                if (response != null && response.body() != null) {
                    SavePtmModel savePtmModel = (SavePtmModel) response.body();
                    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper((Context) SavePtmActivity.this, R.style.MyDialogTheme));
                    builder.setMessage(savePtmModel.getMessage()).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            SavePtmActivity.this.finish();
                        }
                    }).setCancelable(false);
                    builder.create().show();
                    return;
                }
                Utility.showAlertDialog(SavePtmActivity.this);
            }

            public void onFailure(Call<SavePtmModel> call, Throwable th) {
                if (SavePtmActivity.this.mProgressbar == null || !SavePtmActivity.this.mProgressbar.isShowing()) {
                    return;
                }
                SavePtmActivity.this.mProgressbar.dismiss();
            }
        });
    }

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