导航菜单

页面标题

页面副标题

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

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

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


package com.mcb.stjohnsemschool.adapter;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide;
import com.google.android.material.card.MaterialCardView;
import com.mcb.stjohnsemschool.activity.LearningAudioActivity;
import com.mcb.stjohnsemschool.activity.LearningLinkActivity;
import com.mcb.stjohnsemschool.activity.LearningTopicDataActivity;
import com.mcb.stjohnsemschool.activity.LearningVideoActivity;
import com.mcb.stjohnsemschool.activity.LearningVideoWebViewActivity;
import com.mcb.stjohnsemschool.activity.PdfViewActivity;
import com.mcb.stjohnsemschool.activity.ViewFileFromUrlActivity;
import com.mcb.stjohnsemschool.model.LearningChapterTopicContentModel;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.Filename;
import com.mcb.stjohnsemschool.utils.Utility;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LearningTopicContentsAdapter extends BaseAdapter {
    private List<String> audioExtensions;
    private int chapterId;
    private ArrayList<LearningChapterTopicContentModel> content;
    private LayoutInflater inflater;
    private Context mContext;
    private String subjectGUID;
    private int topicId;

    public static class ViewHolder {
        MaterialCardView mCV;
        RelativeLayout mContentRL;
        TextView mDetails;
        ImageView mImg;
        ImageView mImgVideo;
        TextView mTitle;
        LinearLayout mVideoLL;
        TextView mVideoTitle;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0L;
    }

    static {
        System.loadLibrary("keys");
    }

    public LearningTopicContentsAdapter(Context context, ArrayList<LearningChapterTopicContentModel> arrayList, String str, int i, int i2) {
        new ArrayList();
        this.mContext = context;
        this.content = arrayList;
        this.subjectGUID = str;
        this.chapterId = i;
        this.topicId = i2;
        this.audioExtensions = Arrays.asList(Constants.audioExtensions);
        this.inflater = (LayoutInflater) this.mContext.getSystemService("layout_inflater");
    }

    @Override
    public int getCount() {
        ArrayList<LearningChapterTopicContentModel> arrayList = this.content;
        if (arrayList == null) {
            return 0;
        }
        return arrayList.size();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        View view2;
        ViewHolder viewHolder;
        String str;
        if (view == null) {
            viewHolder = new ViewHolder();
            view2 = this.inflater.inflate(2131558858, (ViewGroup) null);
            viewHolder.mVideoTitle = (TextView) view2.findViewById(2131364414);
            viewHolder.mTitle = (TextView) view2.findViewById(2131364385);
            viewHolder.mDetails = (TextView) view2.findViewById(2131364048);
            viewHolder.mImgVideo = (ImageView) view2.findViewById(2131362719);
            viewHolder.mImg = (ImageView) view2.findViewById(2131362633);
            viewHolder.mVideoLL = (LinearLayout) view2.findViewById(2131362932);
            viewHolder.mContentRL = (RelativeLayout) view2.findViewById(2131363471);
            viewHolder.mCV = view2.findViewById(2131362216);
            viewHolder.mCV.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view3) {
                    Intent intent;
                    LearningChapterTopicContentModel learningChapterTopicContentModel = (LearningChapterTopicContentModel) view3.getTag();
                    int type = learningChapterTopicContentModel.getType();
                    if (!Utility.hasNetworkConnection(LearningTopicContentsAdapter.this.mContext)) {
                        Toast.makeText(LearningTopicContentsAdapter.this.mContext, "Check your Network Connection", 0).show();
                        return;
                    }
                    if (type == 1) {
                        Intent intent2 = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) LearningTopicDataActivity.class);
                        intent2.addFlags(268435456);
                        intent2.putExtra("SubjectGUID", LearningTopicContentsAdapter.this.subjectGUID);
                        intent2.putExtra("ChapterId", LearningTopicContentsAdapter.this.chapterId);
                        intent2.putExtra("TopicId", LearningTopicContentsAdapter.this.topicId);
                        intent2.putExtra("Id", learningChapterTopicContentModel.getId());
                        intent2.putExtra("Description", learningChapterTopicContentModel.getTopicNote());
                        LearningTopicContentsAdapter.this.mContext.startActivity(intent2);
                        return;
                    }
                    if (type == 2) {
                        Utility.saveVideoViewLog(LearningTopicContentsAdapter.this.mContext, LearningTopicContentsAdapter.this.subjectGUID, LearningTopicContentsAdapter.this.chapterId, LearningTopicContentsAdapter.this.topicId, learningChapterTopicContentModel.getId(), 0);
                        try {
                            String videoUrl = learningChapterTopicContentModel.getVideoUrl();
                            if (!videoUrl.contains("youtu") && !videoUrl.contains("youtube")) {
                                Intent intent3 = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) LearningVideoWebViewActivity.class);
                                intent3.addFlags(268435456);
                                intent3.putExtra("URL", videoUrl);
                                intent3.putExtra("Title", learningChapterTopicContentModel.getVideoTitle());
                                intent3.putExtra("SubjectGUID", LearningTopicContentsAdapter.this.subjectGUID);
                                intent3.putExtra("ChapterId", LearningTopicContentsAdapter.this.chapterId);
                                intent3.putExtra("TopicId", LearningTopicContentsAdapter.this.topicId);
                                intent3.putExtra("ResourceId", learningChapterTopicContentModel.getId());
                                intent3.putExtra("IsLearning", true);
                                intent3.putExtra("IsFile", false);
                                LearningTopicContentsAdapter.this.mContext.startActivity(intent3);
                                return;
                            }
                            Intent intent4 = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) LearningVideoActivity.class);
                            intent4.addFlags(268435456);
                            intent4.putExtra("VIDEO_URL", videoUrl);
                            intent4.putExtra("SubjectGUID", LearningTopicContentsAdapter.this.subjectGUID);
                            intent4.putExtra("ChapterId", LearningTopicContentsAdapter.this.chapterId);
                            intent4.putExtra("TopicId", LearningTopicContentsAdapter.this.topicId);
                            intent4.putExtra("ResourceId", learningChapterTopicContentModel.getId());
                            intent4.putExtra("IsLearning", true);
                            LearningTopicContentsAdapter.this.mContext.startActivity(intent4);
                            return;
                        } catch (Exception e) {
                            e.printStackTrace();
                            Toast.makeText(LearningTopicContentsAdapter.this.mContext, "Not a valid Video", 0).show();
                            return;
                        }
                    }
                    if (type != 3) {
                        if (type == 4) {
                            Utility.saveLinkViewLog(LearningTopicContentsAdapter.this.mContext, LearningTopicContentsAdapter.this.subjectGUID, LearningTopicContentsAdapter.this.chapterId, LearningTopicContentsAdapter.this.topicId, learningChapterTopicContentModel.getId(), 0);
                            try {
                                String link = learningChapterTopicContentModel.getLink();
                                if (!link.startsWith("http://www") && !link.startsWith("https://www")) {
                                    Intent intent5 = new Intent("android.intent.action.VIEW");
                                    intent5.addFlags(268435456);
                                    intent5.setData(Uri.parse(link));
                                    LearningTopicContentsAdapter.this.mContext.startActivity(intent5);
                                    return;
                                }
                                Intent intent6 = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) LearningLinkActivity.class);
                                intent6.addFlags(268435456);
                                intent6.putExtra("Path", link);
                                intent6.putExtra("Title", learningChapterTopicContentModel.getLinkDescription());
                                intent6.putExtra("SubjectGUID", LearningTopicContentsAdapter.this.subjectGUID);
                                intent6.putExtra("ChapterId", LearningTopicContentsAdapter.this.chapterId);
                                intent6.putExtra("TopicId", LearningTopicContentsAdapter.this.topicId);
                                intent6.putExtra("ResourceId", learningChapterTopicContentModel.getId());
                                intent6.putExtra("IsLearning", true);
                                LearningTopicContentsAdapter.this.mContext.startActivity(intent6);
                                return;
                            } catch (Exception e2) {
                                e2.printStackTrace();
                                Toast.makeText(LearningTopicContentsAdapter.this.mContext, "Not a valid Link", 0).show();
                                return;
                            }
                        }
                        return;
                    }
                    Utility.saveFileViewLog(LearningTopicContentsAdapter.this.mContext, LearningTopicContentsAdapter.this.subjectGUID, LearningTopicContentsAdapter.this.chapterId, LearningTopicContentsAdapter.this.topicId, learningChapterTopicContentModel.getId(), 0);
                    try {
                        String filePath = learningChapterTopicContentModel.getFilePath();
                        if (filePath == null || filePath.length() <= 0 || filePath.equalsIgnoreCase("null")) {
                            Toast.makeText(LearningTopicContentsAdapter.this.mContext, "No Docs Found!", 0).show();
                            return;
                        }
                        String extension = new Filename(filePath, '/', '.').extension();
                        if (!extension.equalsIgnoreCase("pdf")) {
                            if (LearningTopicContentsAdapter.this.audioExtensions.contains(extension.toLowerCase())) {
                                intent = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) LearningAudioActivity.class);
                            } else {
                                intent = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) ViewFileFromUrlActivity.class);
                            }
                        } else {
                            intent = new Intent(LearningTopicContentsAdapter.this.mContext, (Class<?>) PdfViewActivity.class);
                        }
                        intent.addFlags(268435456);
                        intent.putExtra("Title", learningChapterTopicContentModel.getFileName());
                        intent.putExtra("URL", filePath);
                        intent.putExtra("SubjectGUID", LearningTopicContentsAdapter.this.subjectGUID);
                        intent.putExtra("ChapterId", LearningTopicContentsAdapter.this.chapterId);
                        intent.putExtra("TopicId", LearningTopicContentsAdapter.this.topicId);
                        intent.putExtra("ResourceId", learningChapterTopicContentModel.getId());
                        intent.putExtra("IsLearning", true);
                        LearningTopicContentsAdapter.this.mContext.startActivity(intent);
                    } catch (Exception e3) {
                        e3.printStackTrace();
                        Toast.makeText(LearningTopicContentsAdapter.this.mContext, "Not a valid Doc", 0).show();
                    }
                }
            });
            view2.setTag(viewHolder);
        } else {
            view2 = view;
            viewHolder = (ViewHolder) view.getTag();
        }
        LearningChapterTopicContentModel learningChapterTopicContentModel = this.content.get(i);
        viewHolder.mCV.setTag(learningChapterTopicContentModel);
        int type = learningChapterTopicContentModel.getType();
        if (type == 1) {
            viewHolder.mVideoLL.setVisibility(8);
            viewHolder.mContentRL.setVisibility(0);
            viewHolder.mTitle.setText("Notes (" + learningChapterTopicContentModel.getExerciseTime() + "min)");
            viewHolder.mImg.setImageResource(2131231349);
        } else if (type == 2) {
            viewHolder.mVideoLL.setVisibility(0);
            viewHolder.mContentRL.setVisibility(8);
            viewHolder.mVideoTitle.setText(learningChapterTopicContentModel.getVideoTitle() + "(" + learningChapterTopicContentModel.getExerciseTime() + "min)");
            String videoUrl = learningChapterTopicContentModel.getVideoUrl();
            if (videoUrl != null && (videoUrl.contains("youtube") || videoUrl.contains("youtu"))) {
                str = Utility.getThumbnailFromYoutubeURL(videoUrl);
            } else {
                str = "https://cdndatastatic.myclassboard.com/img/video_placeholder.jpg";
            }
            Glide.with(this.mContext).load(str).into(viewHolder.mImgVideo);
        } else if (type == 3) {
            viewHolder.mVideoLL.setVisibility(8);
            viewHolder.mContentRL.setVisibility(0);
            viewHolder.mTitle.setText(learningChapterTopicContentModel.getFileName() + "(" + learningChapterTopicContentModel.getExerciseTime() + "min)");
            viewHolder.mImg.setImageResource(2131231049);
        } else if (type == 4) {
            viewHolder.mVideoLL.setVisibility(8);
            viewHolder.mContentRL.setVisibility(0);
            viewHolder.mTitle.setText(learningChapterTopicContentModel.getLinkDescription() + "(" + learningChapterTopicContentModel.getExerciseTime() + "min)");
            viewHolder.mImg.setImageResource(2131231234);
        }
        String lastViewed = learningChapterTopicContentModel.getLastViewed();
        if (lastViewed != null && lastViewed.length() > 0 && !lastViewed.equalsIgnoreCase("null")) {
            viewHolder.mDetails.setText(Html.fromHtml("<b>Last Viewed : </b>" + lastViewed));
            viewHolder.mDetails.setVisibility(0);
            viewHolder.mCV.setStrokeColor(ContextCompat.getColor(this.mContext, 2131099850));
        } else {
            viewHolder.mDetails.setVisibility(8);
            viewHolder.mCV.setStrokeColor(ContextCompat.getColor(this.mContext, 2131099848));
        }
        return view2;
    }
}