add the list view type handling in media activity
This commit is contained in:
parent
216e51beff
commit
c8c09e0911
5 changed files with 55 additions and 24 deletions
|
@ -212,6 +212,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
|
|
||||||
findItem(R.id.increase_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt < 10
|
findItem(R.id.increase_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt < 10
|
||||||
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
|
findItem(R.id.reduce_column_count).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID && config.mediaColumnCnt > 1
|
||||||
|
|
||||||
|
findItem(R.id.toggle_filename).isVisible = config.viewTypeFiles == VIEW_TYPE_GRID
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -272,6 +274,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
RadioGroupDialog(this, items, config.viewTypeFiles) {
|
RadioGroupDialog(this, items, config.viewTypeFiles) {
|
||||||
config.viewTypeFiles = it as Int
|
config.viewTypeFiles = it as Int
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
setupLayoutManager()
|
||||||
|
media_grid.adapter = null
|
||||||
|
setupAdapter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +370,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter)
|
private fun getRecyclerAdapter() = (media_grid.adapter as MediaAdapter)
|
||||||
|
|
||||||
private fun setupLayoutManager() {
|
private fun setupLayoutManager() {
|
||||||
|
if (config.viewTypeFiles == VIEW_TYPE_GRID)
|
||||||
|
setupGridLayoutManager()
|
||||||
|
else
|
||||||
|
setupListLayoutManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
||||||
if (config.scrollHorizontally) {
|
if (config.scrollHorizontally) {
|
||||||
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
layoutManager.orientation = GridLayoutManager.HORIZONTAL
|
||||||
|
@ -402,6 +414,14 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupListLayoutManager() {
|
||||||
|
media_grid.isDragSelectionEnabled = true
|
||||||
|
media_grid.isZoomingEnabled = false
|
||||||
|
|
||||||
|
val layoutManager = media_grid.layoutManager as GridLayoutManager
|
||||||
|
layoutManager.spanCount = 1
|
||||||
|
}
|
||||||
|
|
||||||
private fun increaseColumnCount() {
|
private fun increaseColumnCount() {
|
||||||
config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount
|
config.mediaColumnCnt = ++(media_grid.layoutManager as GridLayoutManager).spanCount
|
||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
|
|
|
@ -250,7 +250,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
itemViews.put(position, holder.bindView(media[position], displayFilenames, scrollVertically))
|
itemViews.put(position, holder.bindView(media[position], displayFilenames || isListViewType, scrollVertically))
|
||||||
toggleItemSelection(selectedPositions.contains(position), position)
|
toggleItemSelection(selectedPositions.contains(position), position)
|
||||||
holder.itemView.tag = holder
|
holder.itemView.tag = holder
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,8 @@
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_marginRight="@dimen/small_margin"
|
android:layout_marginRight="@dimen/small_margin"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:paddingBottom="@dimen/tiny_margin">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/dir_sd_card"
|
android:id="@+id/dir_sd_card"
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
android:id="@+id/media_item_holder"
|
android:id="@+id/media_item_holder"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="1px">
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/small_margin">
|
||||||
|
|
||||||
<com.simplemobiletools.gallery.views.MySquareImageView
|
<com.simplemobiletools.gallery.views.MySquareImageView
|
||||||
android:id="@+id/medium_thumbnail"
|
android:id="@+id/medium_thumbnail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="@dimen/list_view_folder_thumbnail_size"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="@dimen/list_view_folder_thumbnail_size"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/medium_check"
|
android:id="@+id/medium_check"
|
||||||
|
@ -23,31 +24,39 @@
|
||||||
android:padding="@dimen/tiny_margin"
|
android:padding="@dimen/tiny_margin"
|
||||||
android:src="@drawable/ic_check"/>
|
android:src="@drawable/ic_check"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/photo_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_alignBottom="@+id/medium_thumbnail"
|
||||||
|
android:layout_alignTop="@+id/medium_thumbnail"
|
||||||
|
android:layout_toRightOf="@+id/medium_thumbnail"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="3"
|
||||||
|
android:paddingLeft="6dp"
|
||||||
|
android:paddingRight="@dimen/normal_margin"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/play_outline"
|
android:id="@+id/play_outline"
|
||||||
android:layout_width="@dimen/selection_check_size"
|
android:layout_width="@dimen/play_outline_icon_size"
|
||||||
android:layout_height="@dimen/selection_check_size"
|
android:layout_height="@dimen/play_outline_icon_size"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_marginRight="@dimen/small_margin"
|
||||||
android:layout_margin="@dimen/small_margin"
|
android:paddingBottom="6dp"
|
||||||
android:src="@drawable/img_play_outline"
|
android:src="@drawable/img_play_outline"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/photo_name"
|
android:id="@+id/dir_list_divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="1dp"
|
||||||
android:layout_alignLeft="@+id/medium_thumbnail"
|
android:layout_alignBottom="@+id/medium_thumbnail"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_marginTop="2dp"
|
||||||
android:layout_alignRight="@+id/medium_thumbnail"
|
android:layout_toRightOf="@+id/medium_thumbnail"
|
||||||
android:background="@drawable/gradient_background"
|
android:background="@drawable/divider"/>
|
||||||
android:gravity="bottom"
|
|
||||||
android:maxLines="3"
|
|
||||||
android:paddingBottom="@dimen/small_margin"
|
|
||||||
android:paddingLeft="@dimen/small_margin"
|
|
||||||
android:paddingRight="@dimen/small_margin"
|
|
||||||
android:textColor="@android:color/white"
|
|
||||||
android:textSize="@dimen/smaller_text_size"/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<dimen name="dir_tmb_size">150dp</dimen>
|
<dimen name="dir_tmb_size">150dp</dimen>
|
||||||
<dimen name="medium_tmb_size">100dp</dimen>
|
<dimen name="medium_tmb_size">100dp</dimen>
|
||||||
<dimen name="sd_card_icon_size">20dp</dimen>
|
<dimen name="sd_card_icon_size">20dp</dimen>
|
||||||
|
<dimen name="play_outline_icon_size">22dp</dimen>
|
||||||
<dimen name="selection_check_size">26dp</dimen>
|
<dimen name="selection_check_size">26dp</dimen>
|
||||||
<dimen name="play_outline_size_big">150dp</dimen>
|
<dimen name="play_outline_size_big">150dp</dimen>
|
||||||
<dimen name="timer_padding">24dp</dimen>
|
<dimen name="timer_padding">24dp</dimen>
|
||||||
|
|
Loading…
Reference in a new issue