adding a grid item layout file

This commit is contained in:
tibbi 2020-10-29 20:12:02 +01:00
parent 2749e68402
commit c80b981a51
2 changed files with 62 additions and 10 deletions

View File

@ -67,6 +67,10 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
private var dateFormat = ""
private var timeFormat = ""
private val config = activity.config
private val viewType = config.getFolderViewType(listItems.firstOrNull { !it.isSectionTitle }?.mPath ?: "")
private val isListViewType = viewType == VIEW_TYPE_LIST
init {
setupDragListener(true)
initDrawables()
@ -138,7 +142,15 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val layout = if (viewType == TYPE_SECTION) R.layout.item_section else R.layout.item_file_dir_list
val layout = if (viewType == TYPE_SECTION) {
R.layout.item_section
} else {
if (isListViewType) {
R.layout.item_file_dir_list
} else {
R.layout.item_file_dir_grid
}
}
return createViewHolder(layout, parent)
}
@ -696,20 +708,20 @@ class ItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem
item_name.setTextColor(textColor)
item_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
item_details.setTextColor(textColor)
item_details.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
item_details?.setTextColor(textColor)
item_details?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
item_date.setTextColor(textColor)
item_date.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
item_date?.setTextColor(textColor)
item_date?.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
if (listItem.isDirectory) {
item_icon.setImageDrawable(folderDrawable)
item_details.text = getChildrenCnt(listItem)
item_date.beGone()
item_details?.text = getChildrenCnt(listItem)
item_date?.beGone()
} else {
item_details.text = listItem.size.formatSize()
item_date.beVisible()
item_date.text = listItem.modified.formatDate(activity, dateFormat, timeFormat)
item_details?.text = listItem.size.formatSize()
item_date?.beVisible()
item_date?.text = listItem.modified.formatDate(activity, dateFormat, timeFormat)
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
val options = RequestOptions()

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/item_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:foreground="@drawable/selector"
android:paddingTop="@dimen/tiny_margin"
android:paddingBottom="@dimen/tiny_margin">
<RelativeLayout
android:id="@+id/item_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingEnd="@dimen/activity_margin">
<ImageView
android:id="@+id/item_icon"
android:layout_width="@dimen/file_picker_icon_size"
android:layout_height="@dimen/file_picker_icon_size"
android:layout_centerVertical="true"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_folder_vector" />
<TextView
android:id="@+id/item_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/item_icon"
android:ellipsize="end"
android:maxLines="2"
android:paddingStart="@dimen/tiny_margin"
android:paddingTop="@dimen/small_margin"
tools:text="Directory" />
</RelativeLayout>
</FrameLayout>