导航菜单

页面标题

页面副标题

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

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

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


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.DB.MyClassBoardDB;
import com.mcb.stjohnsemschool.adapter.DetailAdapter;
import com.mcb.stjohnsemschool.model.AssignmentAttachmentModel;
import com.mcb.stjohnsemschool.model.FilePathModelClass;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.ExpandedListViewCustom;
import com.mcb.stjohnsemschool.utils.Filename;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.mcb.stjohnsemschool.utils.VideoEnabledWebChromeClient;
import com.mcb.stjohnsemschool.utils.VideoEnabledWebView;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class DetailAssignmentActivity extends BaseActivity {
    private Activity activity;
    private ConnectivityManager conMgr;
    private String description;
    private String extension;
    private Typeface fontMuseo;
    private String heading;
    private int isAssignmentDateStarted;
    private int lastScrollPosition;
    private TextView mAssgnCatgryTxt;
    private TextView mAssgnStatusText;
    private TextView mAssignStartText;
    private TextView mAssignementDueText;
    private String mAssinId;
    private TextView mAttachmentText;
    private TextView mDownloadPDFText;
    private SharedPreferences.Editor mEditor;
    private String mExceptionString;
    private TextView mHeadingText;
    private LinearLayout mLL1;
    private ExpandedListViewCustom mListViewFilePath;
    private LinearLayout mMainLL;
    private TextView mMaxmarksText;
    private TransparentProgressDialog mProgressbar;
    private ScrollView mScroll;
    private SharedPreferences mSharedPref;
    private TextView mSubject_Text;
    private TextView mTeacherRemarks;
    private ExpandedListViewCustom mVideoOrImgListView;
    private VideoEnabledWebView mWebView;
    private String subject;
    private VideoEnabledWebChromeClient webChromeClient;
    private ArrayList<FilePathModelClass> mFilePathList = new ArrayList<>();
    private ArrayList<FilePathModelClass> mVideoOrImgPathList = new ArrayList<>();
    private MyClassBoardDB db = null;
    private String mBranchName = "";
    private String userId = "";
    private String studentEnrolmentId = "";
    private String start = "";

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_assignments_details);
        this.activity = this;
        this.fontMuseo = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
        getSupportActionBar().setTitle("Assignments");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setUpIds();
        SharedPreferences sharedPreferences = getSharedPreferences("", 0);
        this.mSharedPref = sharedPreferences;
        this.mEditor = sharedPreferences.edit();
        this.db = new MyClassBoardDB(this);
        this.userId = this.mSharedPref.getString("UseridKey", this.userId);
        this.studentEnrolmentId = this.mSharedPref.getString("studentEnrollmentIdKey", this.studentEnrolmentId);
        String string = this.mSharedPref.getString("branchnameKey", this.mBranchName);
        this.mBranchName = string;
        if (string.length() == 0 || this.mBranchName == null) {
            this.mBranchName = getBranchName();
        }
        if (this.mBranchName.length() > 27) {
            if (!(this.mBranchName.charAt(27) + "").equalsIgnoreCase(" ")) {
                if (!(this.mBranchName.charAt(26) + "").equalsIgnoreCase(" ")) {
                    int lastIndexOf = this.mBranchName.substring(0, 27).lastIndexOf(" ");
                    StringBuilder sb = new StringBuilder();
                    int i = lastIndexOf + 1;
                    sb.append(this.mBranchName.substring(0, i));
                    sb.append("\n");
                    sb.append(this.mBranchName.substring(i));
                    this.mBranchName = sb.toString();
                }
            }
            this.mBranchName = this.mBranchName.substring(0, 27) + "\n" + this.mBranchName.substring(27);
        }
        Bundle extras = getIntent().getExtras();
        this.mAssinId = extras.getString(TtmlNode.ATTR_ID);
        this.heading = extras.getString("heading");
        String string2 = extras.getString("due");
        this.description = extras.getString("description");
        this.subject = extras.getString("subject");
        this.start = extras.getString(TtmlNode.START);
        String string3 = extras.getString("status");
        String string4 = extras.getString("maxmarks");
        String string5 = extras.getString("category");
        String string6 = extras.getString("marks");
        String string7 = extras.getString("teacherRemarks");
        this.isAssignmentDateStarted = extras.getInt("IsAssignmentDateStarted");
        if (string6 == null || string6.length() == 0 || string6.equalsIgnoreCase("null")) {
            string6 = "--";
        }
        this.mHeadingText.setText(Html.fromHtml(this.heading));
        this.mAssignementDueText.setText("Submission Last Date : " + ((Object) Html.fromHtml(string2)));
        this.mSubject_Text.setText("Subject : " + ((Object) Html.fromHtml(this.subject)));
        this.mAssignStartText.setText("Assignment Date : " + ((Object) Html.fromHtml(this.start)));
        this.mAssgnStatusText.setText("Status : " + ((Object) Html.fromHtml(string3)));
        this.mMaxmarksText.setText("MaxMarks : " + ((Object) Html.fromHtml(string4)) + "  Obtained Marks : " + ((Object) Html.fromHtml(string6)));
        TextView textView = this.mAssgnCatgryTxt;
        StringBuilder sb2 = new StringBuilder("Assignment Category Type : ");
        sb2.append((Object) Html.fromHtml(string5));
        textView.setText(sb2.toString());
        if (string7 != null && string7.length() > 0 && !string7.equalsIgnoreCase("null")) {
            this.mTeacherRemarks.setText(Html.fromHtml(string7));
        } else {
            this.mTeacherRemarks.setText("--");
        }
        this.mWebView.getSettings().setJavaScriptEnabled(true);
        this.mWebView.getSettings().setDefaultFontSize(16);
        this.mWebView.setHorizontalScrollBarEnabled(false);
        this.mWebView.setVerticalScrollBarEnabled(false);
        this.mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                if (str.contains("android_asset")) {
                    return false;
                }
                Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
                intent.addFlags(268435456);
                DetailAssignmentActivity.this.startActivity(intent);
                return true;
            }
        });
        try {
            this.mWebView.loadData(Base64.encodeToString(this.description.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        if (Build.VERSION.SDK_INT >= 23) {
            getMultiplePermissions();
        }
        loadDetailAssignmentData();
    }

    private String getBranchName() {
        return this.mSharedPref.getString("branchnameKey", "");
    }

    private void setUpIds() {
        this.mMainLL = (LinearLayout) findViewById(R.id.ll_main);
        this.mLL1 = (LinearLayout) findViewById(R.id.ll1);
        this.mAttachmentText = (TextView) findViewById(R.id.txv_attachment_text);
        this.mAssignementDueText = (TextView) findViewById(R.id.assignment_due_detail);
        this.mSubject_Text = (TextView) findViewById(R.id.assignment_subject_detail);
        this.mHeadingText = (TextView) findViewById(R.id.assignment_heading_detail);
        this.mWebView = findViewById(R.id.assignment_description_detail);
        this.mAssignStartText = (TextView) findViewById(R.id.assignment_start_date);
        this.mAssgnStatusText = (TextView) findViewById(R.id.assignment_status);
        this.mMaxmarksText = (TextView) findViewById(R.id.assignment_maxmarks);
        this.mAssgnCatgryTxt = (TextView) findViewById(R.id.assignment_category);
        this.mTeacherRemarks = (TextView) findViewById(R.id.txv_remarks);
        this.mAssgnCatgryTxt.setVisibility(8);
        this.mAttachmentText.setVisibility(8);
        this.mLL1.setVisibility(8);
        this.mScroll = (ScrollView) findViewById(R.id.scrl);
        this.mAssignementDueText.setTypeface(this.fontMuseo);
        this.mSubject_Text.setTypeface(this.fontMuseo);
        this.mHeadingText.setTypeface(this.fontMuseo);
        this.mAssignStartText.setTypeface(this.fontMuseo);
        this.mAssgnStatusText.setTypeface(this.fontMuseo);
        this.mMaxmarksText.setTypeface(this.fontMuseo);
        this.mTeacherRemarks.setTypeface(this.fontMuseo);
        this.mAssgnCatgryTxt.setTypeface(this.fontMuseo);
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.mListViewFilePath = findViewById(R.id.listview_assignments_filepath);
        this.mVideoOrImgListView = findViewById(R.id.listview_video_assignments_filepath);
        this.mWebView.getSettings().setJavaScriptEnabled(true);
        this.mWebView.getSettings().setDefaultFontSize(16);
        this.mWebView.setHorizontalScrollBarEnabled(false);
        this.mWebView.setVerticalScrollBarEnabled(false);
        this.mWebView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView webView, String str) {
                try {
                    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
                    intent.addFlags(268435456);
                    DetailAssignmentActivity.this.startActivity(intent);
                    return true;
                } catch (Exception e) {
                    e.printStackTrace();
                    return true;
                }
            }
        });
        VideoEnabledWebChromeClient videoEnabledWebChromeClient = new VideoEnabledWebChromeClient(this.mMainLL, (ViewGroup) findViewById(R.id.videoLayout), getLayoutInflater().inflate(R.layout.view_loading_video, (ViewGroup) null), this.mWebView) {
            public void onProgressChanged(WebView webView, int i) {
            }
        };
        this.webChromeClient = videoEnabledWebChromeClient;
        videoEnabledWebChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback() {
            public void toggledFullscreen(boolean z) {
                if (z) {
                    WindowManager.LayoutParams attributes = DetailAssignmentActivity.this.getWindow().getAttributes();
                    attributes.flags |= 1024;
                    attributes.flags |= 128;
                    DetailAssignmentActivity.this.getWindow().setAttributes(attributes);
                    DetailAssignmentActivity.this.getWindow().getDecorView().setSystemUiVisibility(1);
                    return;
                }
                WindowManager.LayoutParams attributes2 = DetailAssignmentActivity.this.getWindow().getAttributes();
                attributes2.flags &= -1025;
                attributes2.flags &= -129;
                DetailAssignmentActivity.this.getWindow().setAttributes(attributes2);
                DetailAssignmentActivity.this.getWindow().getDecorView().setSystemUiVisibility(0);
            }
        });
        this.mWebView.setWebChromeClient(this.webChromeClient);
        this.mScroll.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                int scrollY = DetailAssignmentActivity.this.mScroll.getScrollY();
                int i = DetailAssignmentActivity.this.lastScrollPosition > scrollY ? DetailAssignmentActivity.this.lastScrollPosition - scrollY : 0;
                if (scrollY > DetailAssignmentActivity.this.lastScrollPosition) {
                    i = scrollY - DetailAssignmentActivity.this.lastScrollPosition;
                }
                if (i > 150) {
                    DetailAssignmentActivity.this.lastScrollPosition = scrollY;
                    DetailAssignmentActivity.this.resetVideos();
                }
            }
        });
    }

    public void resetVideos() {
        ArrayList<FilePathModelClass> arrayList = this.mVideoOrImgPathList;
        if (arrayList == null || arrayList.size() <= 0) {
            return;
        }
        Iterator<FilePathModelClass> it = this.mVideoOrImgPathList.iterator();
        while (it.hasNext()) {
            FilePathModelClass next = it.next();
            if (next.getPlayerView() != null && next.getPlayerView().getPlayer() != null) {
                next.getPlayerView().getPlayer().setPlayWhenReady(false);
                next.getDownloadImage().setVisibility(0);
                next.getImage().setVisibility(0);
                next.getVideoView().setVisibility(8);
            }
        }
    }

    private void releaseVideos() {
        ArrayList<FilePathModelClass> arrayList = this.mVideoOrImgPathList;
        if (arrayList == null || arrayList.size() <= 0) {
            return;
        }
        Iterator<FilePathModelClass> it = this.mVideoOrImgPathList.iterator();
        while (it.hasNext()) {
            FilePathModelClass next = it.next();
            if (next.getPlayerView() != null && next.getPlayerView().getPlayer() != null) {
                next.getPlayerView().getPlayer().release();
                next.getDownloadImage().setVisibility(0);
                next.getImage().setVisibility(0);
                next.getVideoView().setVisibility(8);
            }
        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (keyEvent.getKeyCode() != 4 || keyEvent.getAction() != 0) {
            return false;
        }
        setResult(565, new Intent());
        finish();
        overridePendingTransition(R.anim.left_in, R.anim.right_out);
        return true;
    }

    public void onPause() {
        resetVideos();
        super.onPause();
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        int itemId = menuItem.getItemId();
        if (itemId == 16908332) {
            onBackPressed();
            return true;
        }
        if (itemId == 2131361887) {
            try {
                Intent intent = new Intent("android.intent.action.SEND");
                intent.putExtra("android.intent.extra.TEXT", "\nUsing Myclassboard : St Johns EM High School Parent Portal Mobile App\n" + ((Object) Html.fromHtml(this.subject)) + "\n" + ((Object) Html.fromHtml(this.heading)) + "\n" + ((Object) Html.fromHtml(this.description)) + "\nApp available at \n " + getResources().getString(R.string.playstore_url) + getApplicationContext().getPackageName());
                intent.setType("text/plain");
                intent.putExtra("android.intent.extra.SUBJECT", "Using Myclassboard :St Johns EM High School Parent Portal Mobile App");
                startActivity(Intent.createChooser(intent, "Share via..."));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return super.onOptionsItemSelected(menuItem);
    }

    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.share_menu, menu);
        return true;
    }

    public boolean onMenuOpened(int i, Menu menu) {
        if (menu != null && menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method declaredMethod = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                declaredMethod.setAccessible(true);
                declaredMethod.invoke(menu, true);
            } catch (NoSuchMethodException unused) {
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return super.onMenuOpened(i, menu);
    }

    public boolean share(MenuItem menuItem) {
        try {
            Intent intent = new Intent("android.intent.action.SEND");
            intent.putExtra("android.intent.extra.TEXT", "\n Using MyClassBoard :St Johns EM High School Parent Portal Mobile App\n" + ((Object) Html.fromHtml(this.heading)) + "\n" + ((Object) Html.fromHtml(this.description)) + "\n App available at \n " + getResources().getString(R.string.playstore_url) + getApplicationContext().getPackageName());
            intent.setType("text/plain");
            intent.putExtra("android.intent.extra.SUBJECT", "Using MyClassBoard :St Johns EM High School Parent Portal Mobile App");
            startActivity(Intent.createChooser(intent, "Share via..."));
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return true;
        }
    }

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

    private void getAssignmentDetails() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).GetAssignmentDetails(Integer.parseInt(this.mAssinId), Integer.parseInt(this.userId), Utility.getSchoolApiKey(this)).enqueue(new Callback<ArrayList<AssignmentAttachmentModel>>() {
            public void onResponse(Call<ArrayList<AssignmentAttachmentModel>> call, Response<ArrayList<AssignmentAttachmentModel>> response) {
                if (DetailAssignmentActivity.this.mProgressbar != null && DetailAssignmentActivity.this.mProgressbar.isShowing()) {
                    DetailAssignmentActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(DetailAssignmentActivity.this.activity);
                    return;
                }
                DetailAssignmentActivity.this.mFilePathList.clear();
                DetailAssignmentActivity.this.mVideoOrImgPathList.clear();
                ArrayList arrayList = (ArrayList) response.body();
                DetailAssignmentActivity.this.mAttachmentText.setVisibility(8);
                DetailAssignmentActivity.this.mLL1.setVisibility(8);
                if (arrayList == null || arrayList.size() <= 0) {
                    return;
                }
                if (DetailAssignmentActivity.this.isAssignmentDateStarted == 1) {
                    DetailAssignmentActivity.this.mLL1.setVisibility(0);
                    Iterator it = arrayList.iterator();
                    while (it.hasNext()) {
                        AssignmentAttachmentModel assignmentAttachmentModel = (AssignmentAttachmentModel) it.next();
                        String filePath = assignmentAttachmentModel.getFilePath();
                        assignmentAttachmentModel.getFileName();
                        String fileName = assignmentAttachmentModel.getFileName();
                        String replace = filePath.replace("\\", "/").replace(" ", "%20");
                        String substring = replace.substring(replace.lastIndexOf("/") + 1);
                        FilePathModelClass filePathModelClass = new FilePathModelClass();
                        filePathModelClass.setFileName(substring);
                        filePathModelClass.setFilePath(replace);
                        filePathModelClass.setDisplayFileName(fileName);
                        String extension = new Filename(replace, '/', '.').extension();
                        if (extension.equalsIgnoreCase("AVI") || extension.equalsIgnoreCase("MP4") || extension.equalsIgnoreCase("M4P") || extension.equalsIgnoreCase("M4V") || extension.equalsIgnoreCase("WMV") || extension.equalsIgnoreCase("MOV") || extension.equalsIgnoreCase("WEBM") || extension.equalsIgnoreCase("MPG") || extension.equalsIgnoreCase("MP2") || extension.equalsIgnoreCase("MPEG") || extension.equalsIgnoreCase("MPE") || extension.equalsIgnoreCase("MPV") || extension.equalsIgnoreCase("OGG") || extension.equalsIgnoreCase("FLV") || extension.equalsIgnoreCase("MKV") || extension.equalsIgnoreCase("png") || extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg") || extension.equalsIgnoreCase("heic") || extension.equalsIgnoreCase("heif")) {
                            DetailAssignmentActivity.this.mVideoOrImgPathList.add(filePathModelClass);
                        } else {
                            DetailAssignmentActivity.this.mFilePathList.add(filePathModelClass);
                        }
                    }
                    ?? r7 = DetailAssignmentActivity.this;
                    DetailAssignmentActivity.this.mListViewFilePath.setAdapter(new DetailAdapter((Context) r7, (Activity) r7, ((DetailAssignmentActivity) r7).mFilePathList, "Assignments"));
                    ?? r72 = DetailAssignmentActivity.this;
                    DetailAssignmentActivity.this.mVideoOrImgListView.setAdapter(new DetailAdapter((Context) r72, (Activity) r72, ((DetailAssignmentActivity) r72).mVideoOrImgPathList, "Assignments"));
                    return;
                }
                DetailAssignmentActivity.this.mAttachmentText.setVisibility(0);
                DetailAssignmentActivity.this.mAttachmentText.setText("Attachments will be visible on " + ((Object) Html.fromHtml(DetailAssignmentActivity.this.start)));
            }

            public void onFailure(Call<ArrayList<AssignmentAttachmentModel>> call, Throwable th) {
                if (DetailAssignmentActivity.this.mProgressbar != null && DetailAssignmentActivity.this.mProgressbar.isShowing()) {
                    DetailAssignmentActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(DetailAssignmentActivity.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_DETAIL_ASSIGNMENT", bundle);
    }

    protected void onDestroy() {
        releaseVideos();
        super.onDestroy();
    }
}