Commit ca0873b5 authored by yanglin's avatar yanglin

修改app布局以及代码逻辑

parent 28cd9e39
......@@ -9,7 +9,7 @@ android {
compileSdk 34
defaultConfig {
applicationId "com.tttt.datarecoveryrenew"
applicationId "com.xm.test.myfilemaster"
minSdk 25
targetSdk 33
versionCode 1
......
......@@ -111,10 +111,10 @@
</activity> <!-- 病毒扫描,key是和包名绑定的 -->
<meta-data
android:name="com.trustlook.ApiKey"
android:value="b8ade465f682b1ae8bcf942eb4e07aab435ee02a10196283b38daa66" /> <!-- 垃圾清理 -->
android:value="86984b67c2db250b6a0dfd8923ac623c776c8af9ee520ba5d60e8799" /> <!-- 垃圾清理 -->
<meta-data
android:name="com.trustlook.cleansdk.ApiKey"
android:value="b8ade465f682b1ae8bcf942eb4e07aab435ee02a10196283b38daa66" />
android:value="86984b67c2db250b6a0dfd8923ac623c776c8af9ee520ba5d60e8799" />
</application>
</manifest>
\ No newline at end of file
......@@ -33,7 +33,7 @@ class MediaActivity : AppCompatActivity() {
lateinit var mItemCheckedArray: SparseBooleanArray
private var mItemDataList = ArrayList<FileBean>()
private lateinit var mItemAdapter: MediaAdapter
private var mItemAdapter: MediaAdapter? =null
private var mDataList: ArrayList<String> = ArrayList<String>()
private var mCheckedDataList: ArrayList<String> = ArrayList<String>()
......@@ -88,7 +88,7 @@ class MediaActivity : AppCompatActivity() {
WaitDialog.show("please wait..")
mItemDataList = FileUtil.getMediaFiles(this, fileType, 20)
runOnUiThread {
mItemAdapter.setData(mItemDataList)
mItemAdapter?.setData(mItemDataList)
WaitDialog.dismiss()
for (fileBean in mItemDataList){
mDataList.add(fileBean.filePath)
......@@ -118,7 +118,7 @@ class MediaActivity : AppCompatActivity() {
mCancelBtn.visibility = View.VISIBLE
isClickEditBtn = true
mItemAdapter.notifyDataSetChanged()
mItemAdapter?.notifyDataSetChanged()
}
mCancelBtn.setOnClickListener {
cancelBtn()
......@@ -159,7 +159,7 @@ class MediaActivity : AppCompatActivity() {
}else{
mCheckedDataList.remove(mDataList[position])
}
mItemAdapter.notifyDataSetChanged()
mItemAdapter?.notifyDataSetChanged()
mCheckedNumber = mCheckedDataList.size
mModel.setNumber(mCheckedNumber)
}
......@@ -175,11 +175,11 @@ class MediaActivity : AppCompatActivity() {
0
}
mModel.setNumber(mCheckedNumber)
mItemAdapter.notifyDataSetChanged()
mItemAdapter?.notifyDataSetChanged()
}
override fun onBackPressed() {
mItemAdapter.notifyDataSetChanged()
mItemAdapter?.notifyDataSetChanged()
if (isClickEditBtn){
cancelBtn()
}else{
......@@ -195,6 +195,6 @@ class MediaActivity : AppCompatActivity() {
mCancelBtn.visibility = View.GONE
isClickEditBtn = false
mItemAdapter.notifyDataSetChanged()
mItemAdapter?.notifyDataSetChanged()
}
}
\ No newline at end of file
......@@ -34,6 +34,8 @@ class ScanLargeFilesActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setTitle("Scan Large Files")
isNewShow(false)
isCurrantTvShow(false)
mInitView()
}
......
......@@ -71,8 +71,7 @@ class MediaAdapter(
}
if (mFileType.equals("image")){
mViewHolder.image.setImageDrawable(mListData[position].drawable)
// mViewHolder.image.setImageDrawable(mListData[position].drawable)
mViewHolder.image.layoutParams.height = dpToPx
}else{
......
......@@ -16,6 +16,7 @@ import com.test.mydemo3.databinding.ImageItemLayoutBinding
import com.test.mydemo3.util.FileUtil
class SimilarBeanAdapter(context: Context) : RecyclerView.Adapter<SimilarBeanAdapter.AA>() {
private val TAG = "yanglin SimilarBeanAdapter"
private val list = arrayListOf<PicSimilarInfo>()
private var context: Context
var mCheckedLists: MutableList<PicInfo> = mutableListOf<PicInfo>()
......@@ -41,6 +42,7 @@ class SimilarBeanAdapter(context: Context) : RecyclerView.Adapter<SimilarBeanAda
}
override fun getItemCount(): Int {
Log.e(TAG, "getItemCount: ${list.size}", )
return list.size
}
......@@ -58,9 +60,9 @@ class SimilarBeanAdapter(context: Context) : RecyclerView.Adapter<SimilarBeanAda
val layoutParams = holder.binding.imageItemGrid.layoutParams
if (list[position].getmList().size.toFloat() / 4.0 == 1.0){
layoutParams.height = FileUtil.dpToPx(83*(list[position].getmList().size / 4), context)
layoutParams.height = FileUtil.dpToPx(80*(list[position].getmList().size / 4), context)
}else{
layoutParams.height = FileUtil.dpToPx(83*(list[position].getmList().size / 4 + 1 ), context)
layoutParams.height = FileUtil.dpToPx(80*(list[position].getmList().size / 4 + 1 ), context)
}
holder.binding.imageItemGrid.setOnItemClickListener { parent, view, itemPosition, id ->
......
......@@ -18,6 +18,7 @@ import androidx.core.content.FileProvider
import androidx.core.view.isVisible
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.test.mydemo3.MyApplication
import com.test.mydemo3.R
import com.test.mydemo3.activity.BaseActivityViewModel
import com.test.mydemo3.activity.HomeActivity
......@@ -171,6 +172,7 @@ abstract class BaseActivity : BaseAbsView(), BaseActivityListener{
mCurrantFilePathTv.visibility = if (isShow) View.VISIBLE else View.GONE
}
override fun onClick(v: View?) {
when(v?.id){
R.id.btn_cancel ->{
......@@ -196,7 +198,20 @@ abstract class BaseActivity : BaseAbsView(), BaseActivityListener{
mFileAdapter.setEditClickState(isClickEditBtn)
}
R.id.btn_delete ->{
//TODO 删除
val customDialog = CustomDialog(this)
customDialog.setsCancel(View.OnClickListener {
customDialog.dismiss()
}).setsConfirm(View.OnClickListener {
for (fileBean in mFileCheckedItemList!!){
mItemDataList.remove(fileBean)
MyApplication.mCleanSdk?.delete(File(fileBean.filePath))
}
mFileAdapter.setData(mItemDataList)
}).show()
customDialog.isShowEditText(false)
customDialog.setsTitle("Delete")
customDialog.setsHint("Are you sure you want to delete ${mFileCheckedItemList.size} item?")
customDialog.setsRightDelete("Delete")
}
R.id.btn_share ->{
if (switchNumber > 1){
......
......@@ -37,11 +37,16 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
private lateinit var mPdfBtn: View
private lateinit var mTxtBtn: View
private lateinit var mRecentGrid: GridView
private lateinit var mRecentView: View
private var mFileBeanList: ArrayList<FileBean>? = null
private var mIntent: Intent? = null
private var mRecentAdapter: MediaAdapter? = null
private var mRecentImages = ArrayList<FileBean>()
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
......@@ -67,6 +72,7 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
mPdfBtn = mView.findViewById(R.id.btn_pdf)
mTxtBtn = mView.findViewById(R.id.btn_txt)
mRecentGrid = mView.findViewById(R.id.recent_file_grid)
mRecentView = mView.findViewById(R.id.recent_file_view)
mImageBtn.setOnClickListener(this)
mVideoBtn.setOnClickListener(this)
......@@ -80,6 +86,7 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
mPptBtn.setOnClickListener(this)
mPdfBtn.setOnClickListener(this)
mTxtBtn.setOnClickListener(this)
mRecentView.setOnClickListener(this)
mIntent = Intent(context, FileManagerActivity::class.java)
mImageBtn.setOnClickListener{
......@@ -93,11 +100,15 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
intent.putExtra("fileType", "video")
context?.startActivity(intent)
}
val recentImages = MediaUtil.getRecentImages(requireContext(), 4)
mRecentView.setOnClickListener {
val intent = Intent(context, MediaActivity::class.java)
intent.putExtra("fileType", "image")
context?.startActivity(intent)
}
val sparseBooleanArray = SparseBooleanArray()
val recentAdapter = MediaAdapter(recentImages, requireContext(), sparseBooleanArray, "image", 80)
recentAdapter.setItemHeight(80)
mRecentGrid.adapter = recentAdapter
mRecentAdapter = MediaAdapter(mRecentImages, requireContext(), sparseBooleanArray, "image", 80)
mRecentAdapter?.setItemHeight(80)
mRecentGrid.adapter = mRecentAdapter
}
......@@ -137,4 +148,9 @@ class FileManagerFragment : Fragment(), View.OnClickListener {
return true
}
override fun onResume() {
super.onResume()
mRecentImages = MediaUtil.getRecentImages(requireContext(), 4)
mRecentAdapter?.setData(mRecentImages)
}
}
......@@ -5,6 +5,9 @@ import android.content.ContentResolver
import android.content.Context
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.graphics.Path
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.provider.MediaStore
import android.util.TypedValue
import com.test.mydemo3.model.FileBean
......@@ -79,6 +82,7 @@ object MediaUtil {
fileBean.filePath = file.absolutePath
fileBean.fileType = FileUtil.getFileType(file)
fileBean.fileBitmap = BitmapFactory.decodeFile(imagePath)
fileBean.drawable = MediaUtil.getDrawable(context,imagePath)
images.add(fileBean)
count++
}
......@@ -108,7 +112,9 @@ object MediaUtil {
//
// return similarImages
// }
fun getDrawable(context: Context,filePath: String): Drawable{
return BitmapDrawable(context.resources, filePath)
}
}
\ No newline at end of file
......@@ -47,7 +47,6 @@
android:id="@+id/similar_start_animation"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:background="#F8F8F8"
android:layout_below="@+id/top_title_bar">
......
......@@ -9,6 +9,7 @@
android:orientation="vertical"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/recent_file_view"
android:layout_marginTop="12dp"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
......@@ -22,14 +23,14 @@
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:textSize="16dp"
android:text="Recent files"
android:text="Recent images"
android:textColor="#333333"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:src="@mipmap/unfold"
android:src="@mipmap/join_to_image"
android:layout_alignParentEnd="true"/>
<GridView
......@@ -40,6 +41,7 @@
android:layout_marginBottom="16dp"
android:layout_marginStart="16dp"
android:numColumns="4"
android:horizontalSpacing="2dp"
android:columnWidth="80dp"
android:paddingLeft="1dp"
android:scrollbars="none"
......@@ -351,7 +353,12 @@
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/ad_layout"/>
<!-- <include layout="@layout/ad_layout"/>-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@mipmap/ad"/>
</RelativeLayout>
......
......@@ -351,10 +351,15 @@
<RelativeLayout
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
layout="@layout/ad_layout"/>
<!-- <include-->
<!-- layout="@layout/ad_layout"/>-->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@mipmap/ad"/>
</RelativeLayout>
......
......@@ -2,7 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/bg_item_shape"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<TextView
......@@ -23,7 +23,8 @@
android:layout_marginEnd="12dp"
android:columnWidth="82dp"
android:scrollbars="none"
android:padding="1dp"
android:paddingStart="1dp"
android:horizontalSpacing="2dp"
android:layout_marginBottom="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment