| | |
| | | package com.application.zhangshi_app_android.adapter; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.ActivityInfo; |
| | | import android.view.View; |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.core.app.ActivityCompat; |
| | | import androidx.core.app.ActivityOptionsCompat; |
| | | import androidx.core.util.Pair; |
| | | |
| | | import com.android.app_base.base.adapter.BaseRVAdapter; |
| | | import com.application.zhangshi_app_android.R; |
| | | import com.application.zhangshi_app_android.databinding.ItemElectronicFileAddBinding; |
| | | import com.application.zhangshi_app_android.ui.ImagePreviewActivity; |
| | | import com.application.zhangshi_app_android.ui.PlayActivity; |
| | | import com.application.zhangshi_app_android.ui.VideoPlayActivity; |
| | | |
| | | import java.util.HashSet; |
| | |
| | | String item = mDataList.get(position); |
| | | if (item != null) { |
| | | if (item.endsWith(".pdf")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_pdf); |
| | | } else if (item.endsWith(".zip") || item.endsWith(".aar") || item.endsWith(".7z")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_zip); |
| | | } else if (item.endsWith(".doc") || item.endsWith(".docx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_word); |
| | | } else if (item.endsWith(".xls") || item.endsWith(".xlsx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_excel); |
| | | } else if (item.endsWith(".ppt") || item.endsWith(".pptx")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_ppt); |
| | | } else if (item.endsWith(".txt")) { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_txt); |
| | | } else if (item.endsWith(".jpg") || item.endsWith(".jpeg") || item.endsWith(".png") || item.endsWith(".gif")) { |
| | |
| | | holder.itemView.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | new VideoPlayActivity.Builder() |
| | | .setVideoSource(item) |
| | | .setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) |
| | | .start(mContext); |
| | | // new VideoPlayActivity.Builder() |
| | | // .setVideoSource(item) |
| | | // .setActivityOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) |
| | | // .start(mContext); |
| | | PlayActivity.start((Activity) mContext, item,holder.itemView,true); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } else if (item.endsWith(".mp3") || item.endsWith(".m4a")) { |
| | | // holder.getBinding().flPlay.setVisibility(View.VISIBLE); |
| | | |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_audio); |
| | | } else { |
| | | holder.getBinding().ivImage.setImageResource(R.drawable.ic_others); |
| | |
| | | } |
| | | |
| | | if (isShowSelectIcon) { |
| | | holder.getBinding().ivSelect.setVisibility(View.VISIBLE); |
| | | if (selectedItems.contains(item)){ |
| | | holder.getBinding().ivSelect.setVisibility(View.VISIBLE); |
| | | holder.getBinding().ivSelect.setBackgroundResource(R.drawable.ic_checked); |
| | | } else { |
| | | holder.getBinding().ivSelect.setVisibility(View.GONE); |
| | | holder.getBinding().ivSelect.setBackgroundResource(R.drawable.ic_unchecked); |
| | | } |
| | | } else { |
| | | holder.getBinding().ivSelect.setVisibility(View.GONE); |