按首字母排序文件夹
This commit is contained in:
parent
18b5e28367
commit
d8bf779c8f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -68,6 +68,7 @@ android {
|
|||
|
||||
|
||||
dependencies {
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
|
||||
// 语种切换框架:https://github.com/getActivity/MultiLanguages
|
||||
implementation 'com.github.getActivity:MultiLanguages:8.0'
|
||||
//权限申请
|
||||
|
|
|
@ -122,7 +122,7 @@ class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
|
|||
finalPlanAdapter.setCoupon(null)
|
||||
finalPlanAdapter.setCoupon(data)
|
||||
selectItemAndLoadInfo(
|
||||
finalPlanAdapter.dataList[0],
|
||||
finalPlanAdapter.getItemData(0),
|
||||
finalPlanAdapter,
|
||||
0
|
||||
)
|
||||
|
@ -138,7 +138,7 @@ class ActivateActivity : BaseActivity<ActivityActivateBinding>() {
|
|||
viewBinding.couponDescribeView.text =
|
||||
getString(R.string.coupon_not_use)
|
||||
selectItemAndLoadInfo(
|
||||
finalPlanAdapter.dataList[0],
|
||||
finalPlanAdapter.getItemData(0),
|
||||
finalPlanAdapter,
|
||||
0
|
||||
)
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.coldmint.rust.pro.databinding.ActivityFileBinding
|
|||
import com.coldmint.rust.pro.interfaces.BookmarkListener
|
||||
import com.coldmint.rust.pro.viewmodel.FileManagerViewModel
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import me.zhanghai.android.fastscroll.FastScrollerBuilder
|
||||
import java.io.File
|
||||
import java.lang.Exception
|
||||
import java.util.*
|
||||
|
@ -878,6 +879,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
// initAction()
|
||||
// }
|
||||
// }
|
||||
private lateinit var menuBinding: MenuBinding
|
||||
private val viewModel: FileManagerViewModel by lazy {
|
||||
ViewModelProvider(this).get(FileManagerViewModel::class.java)
|
||||
}
|
||||
|
@ -890,6 +892,12 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
viewBinding.recyclerView.layoutManager = LinearLayoutManager(this@FileManagerActivity)
|
||||
loadTitle()
|
||||
loadObserve()
|
||||
FastScrollerBuilder(viewBinding.recyclerView).useMd2Style()
|
||||
.setPopupTextProvider(adapter).build()
|
||||
viewBinding.swipeRefreshLayout.setOnRefreshListener {
|
||||
viewModel.loadFiles(viewModel.getCurrentPath())
|
||||
viewBinding.swipeRefreshLayout.isRefreshing = false
|
||||
}
|
||||
viewModel.loadFiles()
|
||||
} else {
|
||||
val bundle = intent.getBundleExtra("data")
|
||||
|
@ -907,6 +915,11 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuBinding = MenuBinding.inflate(menu, menuInflater)
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载观察者
|
||||
*/
|
||||
|
@ -926,7 +939,6 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
if (file == null) {
|
||||
viewModel.returnDirects()
|
||||
} else {
|
||||
Toast.makeText(this,file.absolutePath,Toast.LENGTH_SHORT).show()
|
||||
if (file.isDirectory) {
|
||||
viewModel.currentPathLiveData.value = file.absolutePath
|
||||
} else {
|
||||
|
@ -940,7 +952,7 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
adapter?.setNewDataList(it)
|
||||
}
|
||||
}
|
||||
viewModel.currentPathLiveData.observe(this){
|
||||
viewModel.currentPathLiveData.observe(this) {
|
||||
viewModel.loadFiles(it)
|
||||
}
|
||||
}
|
||||
|
@ -962,4 +974,25 @@ class FileManagerActivity : BaseActivity<ActivityFileBinding>() {
|
|||
override fun getViewBindingObject(): ActivityFileBinding {
|
||||
return ActivityFileBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
||||
|
||||
class MenuBinding private constructor(
|
||||
val menu: Menu,
|
||||
val reloadFileItem: MenuItem,
|
||||
val photoAlbumItem: MenuItem,
|
||||
val systemFileManagerItem: MenuItem
|
||||
) {
|
||||
companion object {
|
||||
//填充
|
||||
fun inflate(menu: Menu, inflater: MenuInflater): MenuBinding {
|
||||
inflater.inflate(R.menu.menu_files, menu)
|
||||
return MenuBinding(
|
||||
menu,
|
||||
menu.findItem(R.id.reloadFile),
|
||||
menu.findItem(R.id.photo_album),
|
||||
menu.findItem(R.id.system_file_manager)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -63,7 +63,6 @@ class RecyclingStationActivity : BaseActivity<ActivityRecyclingStationBinding>()
|
|||
}
|
||||
if (fileArrayList.size > 0) {
|
||||
val fileAdapter = FileAdapter(this@RecyclingStationActivity, fileArrayList)
|
||||
fileAdapter.setSortType(FileAdapter.SortType.ModifyDate)
|
||||
fileAdapter.setItemEvent { i, fileItemBinding, viewHolder, file ->
|
||||
fileItemBinding.more.setOnClickListener {
|
||||
if (file == null) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.coldmint.rust.pro.base.BaseAdapter
|
|||
import com.coldmint.rust.pro.databean.Bookmark
|
||||
import com.coldmint.rust.pro.databinding.AttachFileItemBinding
|
||||
|
||||
class BookmarkAdapter(val context: Context, var dataList: MutableList<Bookmark>) :
|
||||
class BookmarkAdapter(val context: Context, dataList: MutableList<Bookmark>) :
|
||||
BaseAdapter<AttachFileItemBinding, Bookmark>(context, dataList) {
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.coldmint.rust.pro.tool.TextStyleMaker
|
|||
* @author Cold Mint
|
||||
* @date 2021/12/12 20:50
|
||||
*/
|
||||
class CommentAdapter(val context: Context, val dataList: MutableList<WebModCommentData.Data>) :
|
||||
class CommentAdapter(val context: Context, dataList: MutableList<WebModCommentData.Data>) :
|
||||
BaseAdapter<ItemCommentBinding, WebModCommentData.Data>(context, dataList) {
|
||||
|
||||
override fun getViewBindingObject(
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.coldmint.rust.pro.tool.GlobalMethod
|
|||
*/
|
||||
class CommunityServiceAdapter(
|
||||
val context: Context,
|
||||
val dataList: MutableList<CommunityServiceInfo>
|
||||
dataList: MutableList<CommunityServiceInfo>
|
||||
) :
|
||||
BaseAdapter<ItemServiceBinding, CommunityServiceInfo>(context, dataList) {
|
||||
|
||||
|
|
|
@ -14,14 +14,16 @@ import com.bumptech.glide.Glide
|
|||
import com.coldmint.rust.core.tool.FileOperator
|
||||
import com.coldmint.rust.pro.base.BaseAdapter
|
||||
import com.coldmint.rust.pro.databinding.FileItemBinding
|
||||
import com.github.promeg.pinyinhelper.Pinyin
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import me.zhanghai.android.fastscroll.PopupTextProvider
|
||||
import java.io.File
|
||||
import java.lang.StringBuilder
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.ArrayList
|
||||
|
||||
class FileAdapter(private val context: Context, private var dataList: MutableList<File?>) :
|
||||
BaseAdapter<FileItemBinding, File?>(context, dataList) {
|
||||
class FileAdapter(private val context: Context, dataList: MutableList<File?>) :
|
||||
BaseAdapter<FileItemBinding, File?>(context, dataList), PopupTextProvider {
|
||||
|
||||
/**
|
||||
* 获取选中目录
|
||||
|
@ -39,73 +41,6 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
var isCopyFile = false
|
||||
private set
|
||||
|
||||
enum class SortType {
|
||||
FileName, ModifyDate, FileVolume
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置排序方式
|
||||
* @param type SortType?
|
||||
*/
|
||||
fun setSortType(type: SortType?) {
|
||||
when (type) {
|
||||
SortType.FileName -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
dataList.sortedWith(java.util.Comparator<File?> { o1, o2 ->
|
||||
if (o1 == null) {
|
||||
return@Comparator -1
|
||||
}
|
||||
if (o2 == null) {
|
||||
return@Comparator 1
|
||||
}
|
||||
if (o1.isDirectory && o2.isFile) {
|
||||
-1
|
||||
} else if (o1.isFile && o2.isDirectory) {
|
||||
1
|
||||
} else {
|
||||
o1.name.compareTo(o2.name)
|
||||
}
|
||||
})
|
||||
}
|
||||
SortType.ModifyDate -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
dataList.sortedWith(java.util.Comparator<File?> { o1, o2 ->
|
||||
if (o1 == null) {
|
||||
return@Comparator -1
|
||||
}
|
||||
if (o2 == null) {
|
||||
return@Comparator 1
|
||||
}
|
||||
val diff = o1.lastModified() - o2.lastModified()
|
||||
if (diff > 0) {
|
||||
1
|
||||
} else if (diff < 0) {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
})
|
||||
}
|
||||
SortType.FileVolume -> if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
dataList.sortedWith(java.util.Comparator<File?> { o1, o2 ->
|
||||
if (o1 == null) {
|
||||
return@Comparator -1
|
||||
}
|
||||
if (o2 == null) {
|
||||
return@Comparator 1
|
||||
}
|
||||
val diff = o1.length() - o2.length()
|
||||
if (diff > 0) {
|
||||
1
|
||||
} else if (diff < 0) {
|
||||
-1
|
||||
} else {
|
||||
0
|
||||
}
|
||||
})
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清除选中目录
|
||||
|
@ -131,22 +66,22 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
}
|
||||
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* 转换后符号将id数组转换为字符串数组
|
||||
*
|
||||
* @param context 上下文环境
|
||||
* @param ints 数组
|
||||
* @return 数据数组
|
||||
*/
|
||||
fun conversionSymbol(context: Context, ints: IntArray): Array<String> {
|
||||
val list: MutableList<String> = ArrayList()
|
||||
for (r in ints) {
|
||||
val s = context.getText(r).toString()
|
||||
list.add(s)
|
||||
}
|
||||
return list.toTypedArray()
|
||||
// /**
|
||||
// *
|
||||
// * @param isDescend Boolean
|
||||
// */
|
||||
// fun sortData(isDescend : Boolean){
|
||||
// dataList.sortByDescending {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun setNewDataList(dataList: MutableList<File?>) {
|
||||
dataList.sortBy {
|
||||
val name = it?.name ?: "#"
|
||||
getInitial(name)
|
||||
}
|
||||
super.setNewDataList(dataList)
|
||||
}
|
||||
|
||||
override fun getViewBindingObject(
|
||||
|
@ -160,7 +95,7 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
override fun onBingView(
|
||||
data: File?,
|
||||
viewBinding: FileItemBinding,
|
||||
viewviewBinding: BaseAdapter.ViewHolder<FileItemBinding>,
|
||||
viewHolder: BaseAdapter.ViewHolder<FileItemBinding>,
|
||||
position: Int
|
||||
) {
|
||||
if (data == null) {
|
||||
|
@ -171,22 +106,11 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
} else {
|
||||
viewBinding.more.isVisible = true
|
||||
viewBinding.fileName.text = data.name
|
||||
val update_time = data.lastModified()
|
||||
val timeStringBuilder = StringBuilder()
|
||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
||||
timeStringBuilder.append(formatter.format(update_time))
|
||||
if (data.isDirectory) {
|
||||
val tem = data.listFiles()
|
||||
if (tem != null) {
|
||||
val fileNum = data.listFiles().size
|
||||
if (fileNum > 0) {
|
||||
timeStringBuilder.append(" ")
|
||||
timeStringBuilder.append(
|
||||
String.format(
|
||||
(context.getText(R.string.filenum) as String),
|
||||
fileNum
|
||||
)
|
||||
)
|
||||
viewBinding.fileIcon.setImageDrawable(
|
||||
GlobalMethod.tintDrawable(
|
||||
context.getDrawable(
|
||||
|
@ -233,4 +157,11 @@ class FileAdapter(private val context: Context, private var dataList: MutableLis
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun getPopupText(position: Int): String {
|
||||
val file = dataList[position]
|
||||
val name = file?.name ?: "#"
|
||||
return getInitial(name).toString()
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import com.coldmint.rust.pro.databean.FunctionInfo
|
|||
import com.coldmint.rust.pro.databinding.ItemFunBinding
|
||||
import com.coldmint.rust.pro.databinding.ItemServiceBinding
|
||||
|
||||
class FunAdapter(val context: Context, val dataList: MutableList<FunctionInfo>) :
|
||||
class FunAdapter(val context: Context, dataList: MutableList<FunctionInfo>) :
|
||||
BaseAdapter<ItemFunBinding, FunctionInfo>(context, dataList) {
|
||||
override fun getViewBindingObject(
|
||||
layoutInflater: LayoutInflater,
|
||||
|
|
|
@ -15,7 +15,7 @@ import com.coldmint.rust.pro.databinding.ModListItemBinding
|
|||
/*模组适配器
|
||||
* 此适配器只能使用于ModFragment成员变量按需传递。
|
||||
* */
|
||||
class ModAdapter(private val context: Context, var dataList: MutableList<ModClass>) :
|
||||
class ModAdapter(private val context: Context, dataList: MutableList<ModClass>) :
|
||||
BaseAdapter<ModListItemBinding, ModClass>(context, dataList) {
|
||||
|
||||
init {
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.coldmint.rust.pro.tool.GlobalMethod
|
|||
* @author Cold Mint
|
||||
* @date 2021/12/19 20:32
|
||||
*/
|
||||
class PlanAdapter(context: Context, val dataList: MutableList<PlanDataBean.Data>) :
|
||||
class PlanAdapter(context: Context, dataList: MutableList<PlanDataBean.Data>) :
|
||||
BaseAdapter<ItemPlanBinding, PlanDataBean.Data>(context, dataList) {
|
||||
private val money: String = context.getString(R.string.money)
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.lang.StringBuilder
|
|||
*/
|
||||
class ReportAdapter(
|
||||
val context: Context,
|
||||
val dataList: MutableList<ReportItemDataBean.Data>
|
||||
dataList: MutableList<ReportItemDataBean.Data>
|
||||
) :
|
||||
BaseAdapter<ItemReportBinding, ReportItemDataBean.Data>(context, dataList) {
|
||||
override fun getViewBindingObject(
|
||||
|
|
|
@ -16,7 +16,7 @@ import com.coldmint.rust.pro.tool.GlobalMethod
|
|||
* @author Cold Mint
|
||||
* @date 2021/11/20 18:38
|
||||
*/
|
||||
class ScreenshotAdapter(val context: Context, val dataList: ArrayList<String>) :
|
||||
class ScreenshotAdapter(val context: Context, dataList: ArrayList<String>) :
|
||||
BaseAdapter<ScreenshotItemBinding, String>(context, dataList) {
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.coldmint.rust.pro.databinding.ModActionItemBinding
|
|||
* @property mutableList MutableList<String>
|
||||
* @constructor
|
||||
*/
|
||||
class TemplateActionAdapter(context: Context, val dataList: MutableList<String>) :
|
||||
class TemplateActionAdapter(context: Context, dataList: MutableList<String>) :
|
||||
BaseAdapter<ModActionItemBinding, String>(context, dataList) {
|
||||
|
||||
override fun getViewBindingObject(
|
||||
|
@ -29,8 +29,5 @@ class TemplateActionAdapter(context: Context, val dataList: MutableList<String>)
|
|||
position: Int
|
||||
) {
|
||||
viewBinding.operation.text = data
|
||||
// holder.modActionItemBinding.root.setOnClickListener {
|
||||
// actionListener?.onClickItem(string)
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ import java.io.File
|
|||
|
||||
class TemplateListAdapter(
|
||||
val context: Context,
|
||||
val dataList: ArrayList<TemplatePackage>,
|
||||
dataList: ArrayList<TemplatePackage>,
|
||||
private val language: String,
|
||||
private val rootPath: String
|
||||
) : BaseAdapter<TemplateListItemBinding, TemplatePackage>(context, dataList) {
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.ArrayList
|
|||
|
||||
|
||||
//模板制作适配器
|
||||
class TemplateMakerAdapter(val context: Context, private val dataList: MutableList<CodeData>) :
|
||||
class TemplateMakerAdapter(val context: Context, dataList: MutableList<CodeData>) :
|
||||
BaseAdapter<MarkItemBinding, CodeData>(context, dataList) {
|
||||
private var tags = ArrayList<String>()
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import kotlin.Exception
|
|||
|
||||
class UnitAdapter(
|
||||
private val context: Context,
|
||||
private val dataList: MutableList<SourceFile>,
|
||||
dataList: MutableList<SourceFile>,
|
||||
val key: String
|
||||
) : BaseAdapter<UnitItemBinding, SourceFile>(context, dataList) {
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
import java.lang.StringBuilder
|
||||
import java.util.ArrayList
|
||||
|
||||
class ValueAdapter(context: Context, var dataList: ArrayList<ValueTypeDataBean>) :
|
||||
class ValueAdapter(context: Context, dataList: ArrayList<ValueTypeDataBean>) :
|
||||
BaseAdapter<ValueItemBinding, ValueTypeDataBean>(context, dataList) {
|
||||
|
||||
override fun getViewBindingObject(
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.coldmint.rust.pro.base.BaseAdapter
|
|||
import com.coldmint.rust.pro.databinding.WebModItemBinding
|
||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||
|
||||
class WebModAdapter(val context: Context, val dataList: MutableList<WebModListData.Data>) :
|
||||
class WebModAdapter(val context: Context, dataList: MutableList<WebModListData.Data>) :
|
||||
BaseAdapter<WebModItemBinding, WebModListData.Data>(context, dataList) {
|
||||
|
||||
override fun getViewBindingObject(
|
||||
|
|
|
@ -3,11 +3,8 @@ package com.coldmint.rust.pro.base
|
|||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.Typeface
|
||||
import android.icu.text.CaseMap
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.renderscript.Element
|
||||
import android.text.SpannableString
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.Spanned
|
||||
import android.view.LayoutInflater
|
||||
|
@ -15,20 +12,17 @@ import android.view.ViewGroup
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.coldmint.rust.pro.R
|
||||
import com.coldmint.rust.pro.databinding.ActivityWebModInfoBinding
|
||||
import com.coldmint.rust.pro.interfaces.ItemChangeEvent
|
||||
import com.coldmint.rust.pro.interfaces.ItemEvent
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.text.style.StyleSpan
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.text.toSpannable
|
||||
import com.coldmint.dialog.CoreDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.github.promeg.pinyinhelper.Pinyin
|
||||
|
||||
|
||||
abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
||||
private val context: Context,
|
||||
private var dataList: MutableList<DataType>
|
||||
protected var dataList: MutableList<DataType>
|
||||
) :
|
||||
RecyclerView.Adapter<BaseAdapter.ViewHolder<ViewBindingType>>() {
|
||||
private val layoutInflater: LayoutInflater = LayoutInflater.from(context)
|
||||
|
@ -42,6 +36,23 @@ abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
|||
private val bold = StyleSpan(Typeface.BOLD)
|
||||
|
||||
|
||||
/**
|
||||
* 获取列表项目的首字母
|
||||
*/
|
||||
fun getInitial(string: String): Char {
|
||||
return if (string.isBlank()) {
|
||||
'#'
|
||||
} else {
|
||||
val char = string[0]
|
||||
if (Pinyin.isChinese(char)) {
|
||||
val pinyin = Pinyin.toPinyin(char)
|
||||
pinyin[0].uppercaseChar()
|
||||
} else {
|
||||
char.uppercaseChar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立搜索标题,注意当[BaseAdapter.keyWord]为空时永远返回null
|
||||
* @param title String 标题
|
||||
|
@ -78,11 +89,22 @@ abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
|||
}
|
||||
|
||||
/**
|
||||
* 设置数据列表
|
||||
* 设置数据列表(会刷新列表代价很大)
|
||||
* @param dataList MutableList<DataType>
|
||||
*/
|
||||
fun setNewDataList(dataList: MutableList<DataType>) {
|
||||
open fun setNewDataList(dataList: MutableList<DataType>) {
|
||||
this.dataList = dataList
|
||||
handler.post {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取列表项目数据
|
||||
* @return MutableList<DataType>
|
||||
*/
|
||||
fun getItemData(index: Int): DataType {
|
||||
return dataList[index]
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,32 +193,6 @@ abstract class BaseAdapter<ViewBindingType : ViewBinding, DataType>(
|
|||
}
|
||||
}
|
||||
}.show()
|
||||
|
||||
// var checked = false
|
||||
// val dialog = MaterialAlertDialogBuilder(context)
|
||||
// if (checkBoxPrompt != null) {
|
||||
// dialog.checkBoxPrompt(text = checkBoxPrompt, onToggle = {
|
||||
// checked = it
|
||||
// })
|
||||
// }
|
||||
// dialog.title(R.string.delete_title).message(
|
||||
// text = String.format(
|
||||
// context.getString(R.string.delete_prompt),
|
||||
// name
|
||||
// )
|
||||
// ).positiveButton(R.string.dialog_ok).positiveButton {
|
||||
// if (onClickPositiveButton == null) {
|
||||
// removeItem(index)
|
||||
// } else {
|
||||
// if (onClickPositiveButton.invoke(dialog, checked)) {
|
||||
// removeItem(index)
|
||||
// }
|
||||
// }
|
||||
// }.negativeButton(R.string.dialog_cancel).cancelable(cancelable)
|
||||
// handler.post {
|
||||
// dialog.show()
|
||||
// }
|
||||
// return dialog
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,13 +25,21 @@ class FileManagerViewModel : BaseViewModel() {
|
|||
private var rootPath: String = directs
|
||||
|
||||
/**
|
||||
* 当前打开的目录
|
||||
* 当前打开的目录(获取目录的话,请使用[FileManagerViewModel.getCurrentPath]方法])
|
||||
*/
|
||||
val currentPathLiveData: MutableLiveData<String> by lazy {
|
||||
MutableLiveData(rootPath)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前打开的目录
|
||||
* @return String
|
||||
*/
|
||||
fun getCurrentPath(): String {
|
||||
return currentPathLiveData.value ?: rootPath
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载状态
|
||||
*/
|
||||
|
@ -58,7 +66,7 @@ class FileManagerViewModel : BaseViewModel() {
|
|||
|
||||
/**
|
||||
* 加载文件列表
|
||||
* @param path String
|
||||
* @param path String 默认加载根目录
|
||||
*/
|
||||
fun loadFiles(path: String = rootPath) {
|
||||
viewModelScope.launch {
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Tue Jul 19 19:07:29 CST 2022
|
||||
sdk.dir=D\:\\Android_SDK
|
||||
#Tue Jul 19 20:26:21 CST 2022
|
||||
sdk.dir=D\:\\Document\\AndroidSdk
|
||||
|
|
Loading…
Reference in New Issue
Block a user