导航菜单

页面标题

页面副标题

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

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

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


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.ColorDrawable;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide;
import com.google.android.exoplayer2.extractor.ts.TsExtractor;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.adapter.DetailAdapter;
import com.mcb.stjohnsemschool.adapter.StudentCommentsListAdapter;
import com.mcb.stjohnsemschool.fragment.FileUploadFragmentDialog;
import com.mcb.stjohnsemschool.interfaces.OnImageCapturedInterface;
import com.mcb.stjohnsemschool.model.Commdatum;
import com.mcb.stjohnsemschool.model.DetailedConversionModel;
import com.mcb.stjohnsemschool.model.Doc;
import com.mcb.stjohnsemschool.model.FilePathModelClass;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.ExpandedListViewCustom;
import com.mcb.stjohnsemschool.utils.FileUtils;
import com.mcb.stjohnsemschool.utils.Filename;
import com.mcb.stjohnsemschool.utils.RoundedTransformation;
import com.mcb.stjohnsemschool.utils.SmartTextView;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.squareup.picasso.Picasso;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class StaffPostToStudentCommentsActivity extends AppCompatActivity implements View.OnClickListener, OnImageCapturedInterface {
    private int academicYearId;
    private ApiInterface apiService;
    private ConnectivityManager conMgr;
    private Context context;
    private int groupId;
    private int lastScrollPosition;
    private Dialog mAttachmentDialog;
    private ImageView mAttachmentsIv;
    private EditText mCommentEt;
    private TextView mCommentsCountTv;
    private LinearLayout mCommentsListLl;
    private SmartTextView mDescTv;
    private ImageView mDialogAttachmentIv;
    private String mOrgId;
    private TransparentProgressDialog mProgressbar;
    private ScrollView mScrollView;
    private ImageButton mSendIb;
    private String mStudentEnrollmentID;
    private TextView mTopicTv;
    private String mUserId;
    private DetailedConversionModel mainModel;
    private EditText messageEt;
    private Activity myActivity;
    private Switch notiSwitch;
    private OnImageCapturedInterface onImageCaptured;
    private int topicId;
    private ArrayList<FilePathModelClass> videoOrImgList;
    private ArrayList<FilePathModelClass> videoOrImgList1;
    private String filePath = "";
    private MultipartBody.Part filePart = null;
    private boolean isComment = false;
    private boolean isFromBrowse = false;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_staff_to_student_comments);
        this.onImageCaptured = this;
        this.context = getApplicationContext();
        this.myActivity = this;
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        setTitle("Staff Post");
        setUpIds();
    }

    private void setUpIds() {
        Intent intent = getIntent();
        this.topicId = intent.getIntExtra("topic_id", 0);
        this.groupId = intent.getIntExtra(FirebaseAnalytics.Param.GROUP_ID, 0);
        setTitle(intent.getStringExtra("GroupName"));
        SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("", 0);
        this.apiService = (ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class);
        this.mUserId = sharedPreferences.getString("UseridKey", "0");
        this.mStudentEnrollmentID = sharedPreferences.getString("studentEnrollmentIdKey", this.mStudentEnrollmentID);
        this.mOrgId = sharedPreferences.getString("orgnizationIdKey", this.mOrgId);
        this.academicYearId = Integer.parseInt(sharedPreferences.getString("academicyearIdKey", "0"));
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.mScrollView = (ScrollView) findViewById(R.id.scroll_view);
        this.mTopicTv = (TextView) findViewById(R.id.txv_topic);
        this.mDescTv = findViewById(R.id.txv_desc);
        this.mCommentsCountTv = (TextView) findViewById(R.id.txv_comments_count);
        this.mCommentsListLl = (LinearLayout) findViewById(R.id.lst_comments);
        this.notiSwitch = (Switch) findViewById(R.id.switch_notification);
        this.mCommentEt = (EditText) findViewById(R.id.edt_comment);
        ImageView imageView = (ImageView) findViewById(R.id.img_attachment);
        this.mAttachmentsIv = imageView;
        imageView.setOnClickListener(this);
        ImageButton imageButton = (ImageButton) findViewById(R.id.img_send);
        this.mSendIb = imageButton;
        imageButton.setOnClickListener(this);
        this.notiSwitch.setVisibility(8);
        this.notiSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
                StaffPostToStudentCommentsActivity.this.saveSchoolConversationNotificationSettings(z);
            }
        });
        this.mScrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
            @Override
            public void onScrollChanged() {
                int scrollY = StaffPostToStudentCommentsActivity.this.mScrollView.getScrollY();
                int i = StaffPostToStudentCommentsActivity.this.lastScrollPosition > scrollY ? StaffPostToStudentCommentsActivity.this.lastScrollPosition - scrollY : 0;
                if (scrollY > StaffPostToStudentCommentsActivity.this.lastScrollPosition) {
                    i = scrollY - StaffPostToStudentCommentsActivity.this.lastScrollPosition;
                }
                if (i > 150) {
                    StaffPostToStudentCommentsActivity.this.lastScrollPosition = scrollY;
                    StaffPostToStudentCommentsActivity.this.resetVideos();
                }
            }
        });
        createAttachmentDialog();
    }

    private void createAttachmentDialog() {
        Dialog dialog = new Dialog(this, android.R.style.Theme.Dialog);
        this.mAttachmentDialog = dialog;
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        this.mAttachmentDialog.getWindow().setGravity(17);
        this.mAttachmentDialog.requestWindowFeature(1);
        this.mAttachmentDialog.setContentView(R.layout.dialog_chat_attachement);
        ImageView imageView = (ImageView) this.mAttachmentDialog.findViewById(R.id.img_attached);
        this.mDialogAttachmentIv = imageView;
        imageView.setImageBitmap(null);
        this.messageEt = (EditText) this.mAttachmentDialog.findViewById(R.id.edt_message);
        ((ImageButton) this.mAttachmentDialog.findViewById(R.id.imgb_send)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String trim = StaffPostToStudentCommentsActivity.this.messageEt.getText().toString().trim();
                if (trim.length() > 0) {
                    if (Utility.hasNetworkConnection(StaffPostToStudentCommentsActivity.this.getApplicationContext())) {
                        Constants.hideKeyboard(StaffPostToStudentCommentsActivity.this);
                        StaffPostToStudentCommentsActivity.this.mCommentEt.setText("");
                        StaffPostToStudentCommentsActivity.this.saveSchoolConversationComment(trim);
                        return;
                    }
                    Toast.makeText(StaffPostToStudentCommentsActivity.this.getApplicationContext(), "Please check your internet connection", 0).show();
                    return;
                }
                Toast.makeText(StaffPostToStudentCommentsActivity.this.getApplicationContext(), "Enter Message", 0).show();
            }
        });
    }

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

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131362646) {
            this.filePart = null;
            ArrayList arrayList = new ArrayList();
            this.isFromBrowse = false;
            FileUploadFragmentDialog fileUploadFragmentDialog = new FileUploadFragmentDialog(arrayList, false, this.onImageCaptured);
            fileUploadFragmentDialog.show(getSupportFragmentManager(), fileUploadFragmentDialog.getTag());
            return;
        }
        if (id != 2131362709) {
            return;
        }
        if (this.mCommentEt.getText().toString().trim().length() > 0) {
            String obj = this.mCommentEt.getText().toString();
            this.mCommentEt.setText("");
            Constants.hideKeyboard(this);
            ConnectivityManager connectivityManager = (ConnectivityManager) getApplicationContext().getSystemService("connectivity");
            this.conMgr = connectivityManager;
            if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
                saveSchoolConversationComment(obj);
                return;
            } else {
                Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
                return;
            }
        }
        Toast.makeText(getApplicationContext(), "Enter Message", 0).show();
    }

    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i2 != 100 || intent == null) {
            return;
        }
        ArrayList<String> stringArrayListExtra = intent.getStringArrayListExtra("FilePaths");
        if (intent.hasExtra("IsFromBrowse")) {
            this.isFromBrowse = intent.getBooleanExtra("IsFromBrowse", false);
        }
        if (stringArrayListExtra.size() > 0) {
            this.filePath = stringArrayListExtra.get(0);
        }
        String str = this.filePath;
        if (str == null || str.length() <= 0) {
            return;
        }
        getFileNameByPath();
    }

    public void onFileCaptured(ArrayList<String> arrayList) {
        if (arrayList == null || arrayList.size() <= 0) {
            return;
        }
        String str = arrayList.get(0);
        this.filePath = str;
        if (str == null || str.length() <= 0) {
            return;
        }
        getFileNameByPath();
    }

    private void getFileNameByPath() {
        File file = new File(this.filePath);
        this.filePart = MultipartBody.Part.createFormData("file", file.getName(), RequestBody.create(MediaType.parse("*/*"), file));
        Filename filename = new Filename(this.filePath, '/', '.');
        filename.filename();
        String extension = filename.extension();
        this.mDialogAttachmentIv.setImageBitmap(null);
        if (extension.equalsIgnoreCase("pdf")) {
            this.mDialogAttachmentIv.setBackgroundResource(R.drawable.pdf_icon);
        } else if (extension.equalsIgnoreCase("xls") || extension.equalsIgnoreCase("xlsx")) {
            this.mDialogAttachmentIv.setBackgroundResource(R.drawable.excel_icon);
        } else if (extension.equalsIgnoreCase("doc") || extension.equalsIgnoreCase("docx")) {
            this.mDialogAttachmentIv.setBackgroundResource(R.drawable.doc_icon);
        } else if (extension.equalsIgnoreCase("ppt") || extension.equalsIgnoreCase("pptx")) {
            this.mDialogAttachmentIv.setBackgroundResource(R.drawable.ppt_icon);
        } else {
            Glide.with(this).load(getBitmap(this.filePath)).into(this.mDialogAttachmentIv);
        }
        try {
            Dialog dialog = this.mAttachmentDialog;
            if (dialog == null || dialog.isShowing()) {
                return;
            }
            if (this.mCommentEt.getText().toString().trim().length() > 0) {
                this.messageEt.setText("" + this.mCommentEt.getText().toString());
                EditText editText = this.messageEt;
                editText.setSelection(editText.getText().length());
            } else {
                this.messageEt.setText("");
            }
            this.mAttachmentDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Bitmap getBitmap(String str) {
        try {
            File file = new File(str);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inPreferredConfig = Bitmap.Config.ARGB_8888;
            return BitmapFactory.decodeStream(new FileInputStream(file), null, options);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    protected void onResume() {
        super.onResume();
        getSchoolConversationTopicsView();
    }

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

    private void getSchoolConversationStaffTopicsView() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getSchoolConversationStaffTopicsView(Integer.parseInt(this.mStudentEnrollmentID), this.academicYearId, Integer.parseInt(this.mOrgId), this.topicId, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<DetailedConversionModel>>() {
            public void onResponse(Call<ArrayList<DetailedConversionModel>> call, Response<ArrayList<DetailedConversionModel>> response) {
                if (StaffPostToStudentCommentsActivity.this.mProgressbar != null && StaffPostToStudentCommentsActivity.this.mProgressbar.isShowing()) {
                    StaffPostToStudentCommentsActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(StaffPostToStudentCommentsActivity.this.myActivity);
                    return;
                }
                new ArrayList();
                ArrayList arrayList = (ArrayList) response.body();
                if (arrayList.size() > 0) {
                    StaffPostToStudentCommentsActivity.this.mainModel = (DetailedConversionModel) arrayList.get(0);
                    StaffPostToStudentCommentsActivity staffPostToStudentCommentsActivity = StaffPostToStudentCommentsActivity.this;
                    staffPostToStudentCommentsActivity.updateUI(staffPostToStudentCommentsActivity.mainModel);
                }
            }

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

    public void updateUI(final DetailedConversionModel detailedConversionModel) {
        if (detailedConversionModel != null) {
            ImageView imageView = (ImageView) findViewById(R.id.img);
            TextView textView = (TextView) findViewById(R.id.txv_Name);
            TextView textView2 = (TextView) findViewById(R.id.txv_class);
            TextView textView3 = (TextView) findViewById(R.id.txv_date_time);
            this.notiSwitch.setChecked(detailedConversionModel.isNotificationEnabled());
            textView.setText(detailedConversionModel.getName());
            textView2.setText(detailedConversionModel.getUserDetails());
            textView3.setText(detailedConversionModel.getCreatedDate());
            if (detailedConversionModel.getPhoto() != null && detailedConversionModel.getPhoto().length() > 0) {
                Picasso.get().load(detailedConversionModel.getPhoto()).error(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(40, 40).centerCrop().into(imageView);
            } else {
                Picasso.get().load(R.drawable.nopicture).error(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(40, 40).centerCrop().into(imageView);
            }
            this.mTopicTv.setText(detailedConversionModel.getSchoolConversationTopicName());
            this.mDescTv.setSmartText(detailedConversionModel.getTopicDescription());
            this.mDescTv.setDetectMentions(false);
            this.mDescTv.setDetectHashTags(false);
            this.mCommentsCountTv.setText(detailedConversionModel.getNoOfComments() + " Comments");
            this.mCommentsCountTv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    if (detailedConversionModel.getNoOfComments().intValue() > 0) {
                        StaffPostToStudentCommentsActivity.this.showConversationCommentStudentDialog(detailedConversionModel.getCommdata());
                    }
                }
            });
            addMainAttachmentsToUI(detailedConversionModel.getDocs());
            addCommentsToUI(detailedConversionModel.getCommdata());
            if (this.isComment) {
                try {
                    this.mScrollView.post(new Runnable() {
                        @Override
                        public void run() {
                            StaffPostToStudentCommentsActivity.this.mScrollView.fullScroll(TsExtractor.TS_STREAM_TYPE_HDMV_DTS);
                        }
                    });
                } catch (Exception e) {
                    e.printStackTrace();
                }
                this.isComment = false;
            }
        }
    }

    private void addMainAttachmentsToUI(List<Doc> list) {
        ExpandedListViewCustom findViewById = findViewById(R.id.listview_files);
        ExpandedListViewCustom findViewById2 = findViewById(R.id.listview__videos);
        ArrayList arrayList = new ArrayList();
        arrayList.clear();
        ArrayList<FilePathModelClass> arrayList2 = new ArrayList<>();
        this.videoOrImgList = arrayList2;
        arrayList2.clear();
        for (Doc doc : list) {
            String filePath = doc.getFilePath();
            if (filePath != null) {
                filePath = filePath.trim();
            }
            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(doc.getFileName());
            String extension = new Filename(doc.getFilePath(), '/', '.').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")) {
                this.videoOrImgList.add(filePathModelClass);
            } else {
                arrayList.add(filePathModelClass);
            }
        }
        findViewById.setAdapter(new DetailAdapter(getApplicationContext(), this, arrayList, "Announcements"));
        findViewById2.setAdapter(new DetailAdapter(getApplicationContext(), this, this.videoOrImgList, "Announcements"));
    }

    public void saveSchoolConversationComment(String str) {
        try {
            DetailedConversionModel detailedConversionModel = this.mainModel;
            int intValue = detailedConversionModel != null ? detailedConversionModel.getCreatedBy().intValue() : 0;
            Dialog dialog = this.mAttachmentDialog;
            if (dialog != null && dialog.isShowing()) {
                this.mAttachmentDialog.dismiss();
            }
            RequestBody create = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.mainModel.getSchoolConversationTopicID()));
            RequestBody create2 = RequestBody.create(MediaType.parse("text/plain"), str);
            RequestBody create3 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.mUserId));
            RequestBody create4 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(intValue));
            RequestBody create5 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.mOrgId));
            RequestBody create6 = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(this.mStudentEnrollmentID));
            RequestBody create7 = RequestBody.create(MediaType.parse("text/plain"), Utility.getSchoolApiKey(this.context));
            TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
            if (transparentProgressDialog != null) {
                transparentProgressDialog.show();
            }
            this.apiService.saveSchoolConversationCommentToStaff(this.filePart, create3, create4, create5, create, create6, create2, create7).enqueue(new Callback<String>() {
                public void onResponse(Call<String> call, Response<String> response) {
                    if (StaffPostToStudentCommentsActivity.this.mProgressbar != null && StaffPostToStudentCommentsActivity.this.mProgressbar.isShowing()) {
                        StaffPostToStudentCommentsActivity.this.mProgressbar.dismiss();
                    }
                    try {
                        if (response.code() == 200) {
                            if (StaffPostToStudentCommentsActivity.this.isFromBrowse && StaffPostToStudentCommentsActivity.this.filePath != null && StaffPostToStudentCommentsActivity.this.filePath.length() > 0) {
                                FileUtils.deleteFile(StaffPostToStudentCommentsActivity.this.getApplicationContext(), StaffPostToStudentCommentsActivity.this.filePath);
                            }
                            StaffPostToStudentCommentsActivity.this.mCommentEt.setText("");
                            StaffPostToStudentCommentsActivity.this.filePart = null;
                            StaffPostToStudentCommentsActivity.this.isComment = true;
                            StaffPostToStudentCommentsActivity.this.getSchoolConversationTopicsView();
                            return;
                        }
                        Toast.makeText(StaffPostToStudentCommentsActivity.this.getApplicationContext(), "" + response.message(), 0).show();
                    } catch (Exception e) {
                        Toast.makeText(StaffPostToStudentCommentsActivity.this.getApplicationContext(), "Unable to get Server Response,Retry!", 0).show();
                        e.printStackTrace();
                    }
                }

                public void onFailure(Call<String> call, Throwable th) {
                    if (StaffPostToStudentCommentsActivity.this.mProgressbar == null || !StaffPostToStudentCommentsActivity.this.mProgressbar.isShowing()) {
                        return;
                    }
                    StaffPostToStudentCommentsActivity.this.mProgressbar.dismiss();
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
            TransparentProgressDialog transparentProgressDialog2 = this.mProgressbar;
            if (transparentProgressDialog2 == null || !transparentProgressDialog2.isShowing()) {
                return;
            }
            this.mProgressbar.dismiss();
        }
    }

    public void resetVideos() {
        ArrayList<FilePathModelClass> arrayList = this.videoOrImgList1;
        if (arrayList != null && arrayList.size() > 0) {
            Iterator<FilePathModelClass> it = this.videoOrImgList1.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);
                }
            }
        }
        ArrayList<FilePathModelClass> arrayList2 = this.videoOrImgList;
        if (arrayList2 == null || arrayList2.size() <= 0) {
            return;
        }
        Iterator<FilePathModelClass> it2 = this.videoOrImgList.iterator();
        while (it2.hasNext()) {
            FilePathModelClass next2 = it2.next();
            if (next2.getPlayerView() != null && next2.getPlayerView().getPlayer() != null) {
                next2.getPlayerView().getPlayer().setPlayWhenReady(false);
                next2.getDownloadImage().setVisibility(0);
                next2.getImage().setVisibility(0);
                next2.getVideoView().setVisibility(8);
            }
        }
    }

    private void releaseVideos() {
        ArrayList<FilePathModelClass> arrayList = this.videoOrImgList1;
        if (arrayList != null && arrayList.size() > 0) {
            Iterator<FilePathModelClass> it = this.videoOrImgList1.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);
                }
            }
        }
        ArrayList<FilePathModelClass> arrayList2 = this.videoOrImgList;
        if (arrayList2 == null || arrayList2.size() <= 0) {
            return;
        }
        Iterator<FilePathModelClass> it2 = this.videoOrImgList.iterator();
        while (it2.hasNext()) {
            FilePathModelClass next2 = it2.next();
            if (next2.getPlayerView() != null && next2.getPlayerView().getPlayer() != null) {
                next2.getPlayerView().getPlayer().setPlayWhenReady(false);
                next2.getDownloadImage().setVisibility(0);
                next2.getImage().setVisibility(0);
                next2.getVideoView().setVisibility(8);
            }
        }
    }

    private void addCommentsToUI(List<Commdatum> list) {
        this.mCommentsListLl.removeAllViews();
        for (Commdatum commdatum : list) {
            View inflate = LayoutInflater.from(getApplicationContext()).inflate(R.layout.list_item_staff_post_to_student_comment, (ViewGroup) null);
            ImageView imageView = (ImageView) inflate.findViewById(R.id.img);
            if (commdatum.getPhotoUpload() != null && commdatum.getPhotoUpload().length() > 0) {
                Picasso.get().load(commdatum.getPhotoUpload()).error(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(40, 40).centerCrop().into(imageView);
            } else {
                Picasso.get().load(R.drawable.nopicture).error(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(40, 40).centerCrop().into(imageView);
            }
            ((TextView) inflate.findViewById(R.id.txv_Name)).setText(commdatum.getStudentName());
            ((TextView) inflate.findViewById(R.id.txv_date_time)).setText(commdatum.getCommentCreatedDate());
            ((TextView) inflate.findViewById(R.id.txv_student_code)).setText(commdatum.getClassName() + "  " + commdatum.getSection());
            SmartTextView findViewById = inflate.findViewById(R.id.txv_desc);
            findViewById.setSmartText(commdatum.getComments());
            findViewById.setDetectMentions(false);
            findViewById.setDetectHashTags(false);
            ExpandedListViewCustom findViewById2 = inflate.findViewById(R.id.listview_files);
            ExpandedListViewCustom findViewById3 = inflate.findViewById(R.id.listview__videos);
            ArrayList arrayList = new ArrayList();
            arrayList.clear();
            ArrayList<FilePathModelClass> arrayList2 = new ArrayList<>();
            this.videoOrImgList1 = arrayList2;
            arrayList2.clear();
            String filePath = commdatum.getFilePath();
            if (filePath != null) {
                filePath = filePath.trim();
            }
            String replace = filePath.replace("\\", "/").replace(" ", "%20");
            String substring = replace.substring(replace.lastIndexOf("/") + 1);
            if (substring != null && !substring.equalsIgnoreCase("null") && substring.length() > 0) {
                FilePathModelClass filePathModelClass = new FilePathModelClass();
                filePathModelClass.setFileName(substring);
                filePathModelClass.setFilePath(replace);
                filePathModelClass.setDisplayFileName(commdatum.getFileName());
                String extension = new Filename(commdatum.getFilePath(), '/', '.').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")) {
                    this.videoOrImgList1.add(filePathModelClass);
                } else {
                    arrayList.add(filePathModelClass);
                }
                findViewById2.setAdapter(new DetailAdapter(getApplicationContext(), this, arrayList, "Announcements"));
                findViewById3.setAdapter(new DetailAdapter(getApplicationContext(), this, this.videoOrImgList1, "Announcements"));
            }
            this.mCommentsListLl.addView(inflate);
        }
    }

    public void showConversationCommentStudentDialog(List<Commdatum> list) {
        Dialog dialog = new Dialog(this);
        View inflate = getLayoutInflater().inflate(R.layout.comment_list_dialog, (ViewGroup) null);
        ((TextView) inflate.findViewById(R.id.txv_title)).setText("Comments");
        ((ListView) inflate.findViewById(R.id.lst_list)).setAdapter((ListAdapter) new StudentCommentsListAdapter(getApplicationContext(), list));
        dialog.setContentView(inflate);
        try {
            dialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

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

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

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

    private void saveConversationNotificationSettings(boolean z) {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("StudentEnrollmentID", this.mStudentEnrollmentID);
        hashMap.put("AcademicYearID", String.valueOf(this.academicYearId));
        hashMap.put("SchoolChatGroupID", String.valueOf(this.groupId));
        hashMap.put("SchoolConversationTopicID", String.valueOf(this.topicId));
        hashMap.put("EnableNotifications", String.valueOf(z ? 1 : 0));
        hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).SaveSchoolConversationNotificationSettings(hashMap).enqueue(new Callback<String>() {
            public void onResponse(Call<String> call, Response<String> response) {
                if (StaffPostToStudentCommentsActivity.this.mProgressbar != null && StaffPostToStudentCommentsActivity.this.mProgressbar.isShowing()) {
                    StaffPostToStudentCommentsActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(StaffPostToStudentCommentsActivity.this.myActivity);
                }
            }

            public void onFailure(Call<String> call, Throwable th) {
                if (StaffPostToStudentCommentsActivity.this.mProgressbar != null && StaffPostToStudentCommentsActivity.this.mProgressbar.isShowing()) {
                    StaffPostToStudentCommentsActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(StaffPostToStudentCommentsActivity.this.myActivity);
            }
        });
    }
}