导航菜单

页面标题

页面副标题

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

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

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


package com.mcb.stjohnsemschool.fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.mcb.stjohnsemschool.activity.ClassDiaryActivity;
import com.mcb.stjohnsemschool.activity.NewAnnouncementActivity;
import com.mcb.stjohnsemschool.activity.WhatsNewChatActivity;
import com.mcb.stjohnsemschool.adapter.ExaminationAdapter;
import com.mcb.stjohnsemschool.model.CalenderModelClass;
import com.mcb.stjohnsemschool.model.StudentPunchTimingsModel;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.NonScrollListView;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.microsoft.identity.common.java.eststelemetry.SchemaConstants;
import com.microsoft.identity.common.java.telemetry.TelemetryEventStrings;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class TodayUpdatesFragment extends Fragment {
    private String SpinnerdateStr;
    private Activity activity;
    private int announcement;
    private CardView cardView;
    private int chat;
    private ConstraintLayout clAnnounce;
    private ConstraintLayout clChat;
    private ConstraintLayout clDairy;
    private ConnectivityManager conMgr;
    private Context context;
    private int dairy;
    private TextView dairy_updatesText;
    SimpleDateFormat dateFormat;
    String formattedDate;
    private SharedPreferences.Editor mEditor;
    private TransparentProgressDialog mProgressbar;
    private SharedPreferences mSharedPref;
    private String monthStr;
    private NonScrollListView nonScroll_examination;
    private TextView number_announcemntText;
    private RecyclerView recycle_examination;
    private RelativeLayout relativeLayout;
    private CardView total_view;
    private TextView txt_NomessageCount;
    private TextView txt_clock_in;
    private TextView txt_clockin_time;
    private TextView txt_clockout;
    private TextView txt_clockout_time;
    private TextView txt_dairy_static;
    private TextView txt_date;
    private TextView txt_messageCount;
    private TextView txt_nolatestannouncement;
    private TextView txt_present_school;
    private String yearStr;
    private String dbName = "";
    private String studentEnrollmentId = SchemaConstants.Value.FALSE;
    private String OrganizationId = SchemaConstants.Value.FALSE;
    private String BranchId = SchemaConstants.Value.FALSE;
    private String ClassId = SchemaConstants.Value.FALSE;
    private String academicYearId = SchemaConstants.Value.FALSE;
    private String latestDairyDate = "";
    private String academicYear = "";
    private String branchSectionId = SchemaConstants.Value.FALSE;
    private String isExam = TelemetryEventStrings.Value.FALSE;
    private ArrayList<JSONObject> mCalenderList = new ArrayList<>();
    private ArrayList<CalenderModelClass> mCalenderListDup = new ArrayList<>();
    private ArrayList<StudentPunchTimingsModel> timingsModels = new ArrayList<>();
    Date currentDate = new Date();

    public TodayUpdatesFragment() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy");
        this.dateFormat = simpleDateFormat;
        this.formattedDate = simpleDateFormat.format(this.currentDate);
    }

    public void onCreate(Bundle bundle) {
        setHasOptionsMenu(true);
        super.onCreate(bundle);
    }

    public void onStart() {
        super.onStart();
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        return layoutInflater.inflate(2131558763, viewGroup, false);
    }

    public void onActivityCreated(Bundle bundle) {
        super.onActivityCreated(bundle);
        FragmentActivity activity = getActivity();
        this.activity = activity;
        this.context = activity.getApplicationContext();
        setHasOptionsMenu(true);
        this.mProgressbar = new TransparentProgressDialog(this.activity, 2131231479);
        SharedPreferences sharedPreferences = this.context.getSharedPreferences("", 0);
        this.cardView = getView().findViewById(2131362230);
        this.total_view = getView().findViewById(2131363853);
        this.clAnnounce = getView().findViewById(2131362153);
        this.clDairy = getView().findViewById(2131362151);
        this.clChat = getView().findViewById(2131362152);
        this.nonScroll_examination = (NonScrollListView) getView().findViewById(2131363169);
        this.dairy_updatesText = (TextView) getView().findViewById(2131363187);
        this.number_announcemntText = (TextView) getView().findViewById(2131363186);
        this.txt_messageCount = (TextView) getView().findViewById(2131363188);
        this.txt_NomessageCount = (TextView) getView().findViewById(2131363908);
        this.txt_dairy_static = (TextView) getView().findViewById(2131363904);
        this.txt_nolatestannouncement = (TextView) getView().findViewById(2131363896);
        this.txt_present_school = (TextView) getView().findViewById(2131363910);
        this.relativeLayout = (RelativeLayout) getView().findViewById(2131363419);
        this.txt_clockin_time = (TextView) getView().findViewById(2131363901);
        this.txt_clockout_time = (TextView) getView().findViewById(2131363903);
        this.txt_clockout = (TextView) getView().findViewById(2131363902);
        this.txt_clock_in = (TextView) getView().findViewById(2131363900);
        this.txt_date = (TextView) getView().findViewById(2131363905);
        this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
        this.OrganizationId = sharedPreferences.getString("orgnizationIdKey", this.OrganizationId);
        this.academicYearId = sharedPreferences.getString("academicyearIdKey", this.academicYearId);
        this.BranchId = sharedPreferences.getString("BranchIdKey", this.BranchId);
        this.ClassId = sharedPreferences.getString("ClassidKey", this.ClassId);
        this.academicYear = sharedPreferences.getString("AcademicYearKey", this.academicYear);
        this.branchSectionId = sharedPreferences.getString("BranchSectionIDKey", SchemaConstants.Value.FALSE);
        this.dbName = sharedPreferences.getString("DBName", "").toUpperCase();
        this.announcement = sharedPreferences.getInt("isAnnouncement", 0);
        this.dairy = sharedPreferences.getInt("isDairy", 0);
        this.chat = sharedPreferences.getInt("isChat", 0);
        this.mEditor = sharedPreferences.edit();
        punchinTimes();
        this.clAnnounce.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TodayUpdatesFragment.this.startActivity(new Intent(TodayUpdatesFragment.this.context, (Class<?>) NewAnnouncementActivity.class));
            }
        });
        this.clDairy.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TodayUpdatesFragment.this.startActivity(new Intent(TodayUpdatesFragment.this.context, (Class<?>) ClassDiaryActivity.class));
            }
        });
        this.clChat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TodayUpdatesFragment.this.startActivity(new Intent(TodayUpdatesFragment.this.context, (Class<?>) WhatsNewChatActivity.class));
            }
        });
    }

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

    private void getPunchinTimes() {
        OkHttpClient okHttpClient = new OkHttpClient();
        String str = "studentEnrollmentID:" + Integer.parseInt(this.studentEnrollmentId) + ",academicYearID :" + Integer.parseInt(this.academicYearId) + ",date :\"" + this.formattedDate + "\"\n";
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("query", "query GetAttandanceByStudentPunchTimings_Android {\n    getAttandanceByStudentPunchTimings_Android(\n" + str + "    ) {\n        month\n        monthName\n        monthYear\n        type\n        date\n        timing\n        date1\n        checkInTime\n        checkOutTime\n        year\n        dispalyDate\n    }\n}");
            jSONObject.put("variables", new JSONObject());
            okHttpClient.newCall(new Request.Builder().url("https://parentapi.myclassboard.com/AppGraph/").header("apikey", ApiInterface.API_KEY).header("DataValue", Constants.DB_NAME).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jSONObject.toString())).build()).enqueue(new Callback() {
                public void onFailure(Call call, IOException iOException) {
                    TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                TodayUpdatesFragment.this.mProgressbar.dismiss();
                            }
                            Utility.showAlertDialog(TodayUpdatesFragment.this.activity);
                        }
                    });
                }

                public void onResponse(Call call, Response response) throws IOException {
                    if (TodayUpdatesFragment.this.getActivity() != null) {
                        final String string = response.body().string();
                        TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    TodayUpdatesFragment.this.timingsModels.clear();
                                    JSONArray jSONArray = new JSONObject(string).getJSONObject("data").getJSONArray("getAttandanceByStudentPunchTimings_Android");
                                    if (jSONArray.length() <= 0) {
                                        TodayUpdatesFragment.this.txt_present_school.setText("No data available");
                                        TodayUpdatesFragment.this.relativeLayout.setVisibility(8);
                                        TodayUpdatesFragment.this.txt_date.setText(TodayUpdatesFragment.this.formattedDate);
                                    } else {
                                        JSONObject jSONObject2 = new JSONObject(jSONArray.get(0).toString());
                                        TodayUpdatesFragment.this.txt_present_school.setText(jSONObject2.getString("type"));
                                        TodayUpdatesFragment.this.txt_present_school.setVisibility(0);
                                        TodayUpdatesFragment.this.txt_date.setText(jSONObject2.getString("dispalyDate"));
                                        if (!jSONObject2.getString("type").toUpperCase().equals("ABSENT") && !jSONObject2.getString("type").toUpperCase().equals("HOLIDAY")) {
                                            if (jSONArray.length() == 1) {
                                                if (!jSONObject2.getString("checkInTime").toString().equals("null") && !jSONObject2.getString("checkInTime").toString().equals("")) {
                                                    TodayUpdatesFragment.this.txt_clockin_time.setText(jSONObject2.getString("checkInTime"));
                                                    TodayUpdatesFragment.this.txt_clockin_time.setVisibility(0);
                                                    TodayUpdatesFragment.this.txt_clock_in.setVisibility(0);
                                                }
                                                TodayUpdatesFragment.this.txt_clockin_time.setVisibility(8);
                                                TodayUpdatesFragment.this.txt_clock_in.setVisibility(8);
                                                TodayUpdatesFragment.this.txt_clockout_time.setVisibility(8);
                                                TodayUpdatesFragment.this.txt_clockout.setVisibility(8);
                                            } else if (jSONArray.length() == 2) {
                                                JSONObject jSONObject3 = new JSONObject(jSONArray.get(1).toString());
                                                if (!jSONObject2.getString("checkInTime").toString().equals("null") && !jSONObject2.getString("checkInTime").toString().equals("")) {
                                                    TodayUpdatesFragment.this.txt_clockin_time.setText(jSONObject2.getString("checkInTime"));
                                                    TodayUpdatesFragment.this.txt_clockin_time.setVisibility(0);
                                                    TodayUpdatesFragment.this.txt_clock_in.setVisibility(0);
                                                    if (!jSONObject3.getString("checkOutTime").toString().equals("null") && !jSONObject3.getString("checkOutTime").toString().equals("")) {
                                                        TodayUpdatesFragment.this.txt_clockout_time.setText(jSONObject3.getString("checkOutTime"));
                                                        TodayUpdatesFragment.this.txt_clockout_time.setVisibility(0);
                                                        TodayUpdatesFragment.this.txt_clockout.setVisibility(0);
                                                    }
                                                    TodayUpdatesFragment.this.txt_clockout_time.setVisibility(8);
                                                    TodayUpdatesFragment.this.txt_clockout.setVisibility(8);
                                                }
                                                TodayUpdatesFragment.this.txt_clockin_time.setVisibility(8);
                                                TodayUpdatesFragment.this.txt_clock_in.setVisibility(8);
                                                if (!jSONObject3.getString("checkOutTime").toString().equals("null")) {
                                                    TodayUpdatesFragment.this.txt_clockout_time.setText(jSONObject3.getString("checkOutTime"));
                                                    TodayUpdatesFragment.this.txt_clockout_time.setVisibility(0);
                                                    TodayUpdatesFragment.this.txt_clockout.setVisibility(0);
                                                }
                                                TodayUpdatesFragment.this.txt_clockout_time.setVisibility(8);
                                                TodayUpdatesFragment.this.txt_clockout.setVisibility(8);
                                            }
                                        }
                                        TodayUpdatesFragment.this.relativeLayout.setVisibility(8);
                                    }
                                    TodayUpdatesFragment.this.allDiaryCounts();
                                    if (TodayUpdatesFragment.this.mProgressbar == null || !TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                        return;
                                    }
                                    TodayUpdatesFragment.this.mProgressbar.dismiss();
                                } catch (Exception e) {
                                    if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                        TodayUpdatesFragment.this.mProgressbar.dismiss();
                                    }
                                    e.printStackTrace();
                                }
                            }
                        });
                    }
                }
            });
        } catch (JSONException e) {
            System.out.println(e.toString());
        }
    }

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

    private void getAllDiaryCounts() {
        OkHttpClient okHttpClient = new OkHttpClient();
        String str = "studentEnrollmentID:" + Integer.parseInt(this.studentEnrollmentId) + ",academicYearID :" + Integer.parseInt(this.academicYearId);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("query", "query GetStudentDairyCount_Android {\n    getStudentDairyCount_Android(\n" + str + "    ) {\n        homeWorkCount\n        homeWorkSubmittedCount\n        classWorkCount\n        assignmentCount\n        announcementCount\n        messageCount\n        diaryCount\n        latestDairyDate\n    }\n}");
            jSONObject.put("variables", new JSONObject());
            okHttpClient.newCall(new Request.Builder().url("https://parentapi.myclassboard.com/AppGraph/").header("apikey", ApiInterface.API_KEY).header("DataValue", Constants.DB_NAME).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jSONObject.toString())).build()).enqueue(new Callback() {
                public void onFailure(Call call, IOException iOException) {
                    TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                TodayUpdatesFragment.this.mProgressbar.dismiss();
                            }
                            Utility.showAlertDialog(TodayUpdatesFragment.this.activity);
                        }
                    });
                }

                public void onResponse(Call call, Response response) throws IOException {
                    if (TodayUpdatesFragment.this.getActivity() != null) {
                        final String string = response.body().string();
                        TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                throw new UnsupportedOperationException("Method not decompiled: com.mcb.stjohnsemschool.fragment.TodayUpdatesFragment.AnonymousClass5.AnonymousClass2.run():void");
                            }
                        });
                    }
                }
            });
        } catch (JSONException e) {
            System.out.println(e.toString());
        }
    }

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

    private void getExamLists() {
        OkHttpClient okHttpClient = new OkHttpClient();
        String str = "organisationID :25,studentEnrollmentID :" + Integer.parseInt(this.studentEnrollmentId) + ",academicYearID :" + Integer.parseInt(this.academicYearId);
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("query", "query GetExamsList_Android {\n    getExamsList_Android(\n" + str + "    ) {\n  messageType\n  createdDate\n  date\n  date1\n  messageID\n  title\n  description1\n  messageFrom\n  messageTo\n  filePath\n  fileName\n  fromDate\n  todate\n  toId\n  description\n  fromId\n  isHoliday\n  photo\n  eventTypeID\n  eventTypeName\n  isExam\n    }\n}");
            jSONObject.put("variables", new JSONObject());
            okHttpClient.newCall(new Request.Builder().url("https://parentapi.myclassboard.com/AppGraph/").header("apikey", ApiInterface.API_KEY).header("DataValue", Constants.DB_NAME).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jSONObject.toString())).build()).enqueue(new Callback() {
                public void onFailure(Call call, IOException iOException) {
                    TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                TodayUpdatesFragment.this.mProgressbar.dismiss();
                            }
                            Utility.showAlertDialog(TodayUpdatesFragment.this.activity);
                        }
                    });
                }

                public void onResponse(Call call, Response response) throws IOException {
                    if (TodayUpdatesFragment.this.getActivity() != null) {
                        final String string = response.body().string();
                        TodayUpdatesFragment.this.getActivity().runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                try {
                                    JSONArray jSONArray = new JSONObject(string).getJSONObject("data").getJSONArray("getExamsList_Android");
                                    if (jSONArray.length() > 0) {
                                        for (int i = 0; i < jSONArray.length(); i++) {
                                            TodayUpdatesFragment.this.mCalenderList.add(jSONArray.getJSONObject(i));
                                        }
                                    }
                                    if (TodayUpdatesFragment.this.mCalenderList.size() <= 0) {
                                        TodayUpdatesFragment.this.cardView.setVisibility(8);
                                    } else {
                                        TodayUpdatesFragment.this.nonScroll_examination.setAdapter((ListAdapter) new ExaminationAdapter(TodayUpdatesFragment.this.context, TodayUpdatesFragment.this.mCalenderList));
                                        TodayUpdatesFragment.this.cardView.setVisibility(0);
                                    }
                                    if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                        TodayUpdatesFragment.this.mProgressbar.dismiss();
                                    }
                                    TodayUpdatesFragment.this.total_view.setVisibility(0);
                                } catch (Exception e) {
                                    if (TodayUpdatesFragment.this.mProgressbar != null && TodayUpdatesFragment.this.mProgressbar.isShowing()) {
                                        TodayUpdatesFragment.this.mProgressbar.dismiss();
                                    }
                                    e.printStackTrace();
                                }
                            }
                        });
                    }
                }
            });
        } catch (JSONException e) {
            System.out.println(e.toString());
        }
    }
}