Skip to content

Commit

Permalink
#378 feat (fingerprint gestures) move KeymapListFragment.kt to a tab
Browse files Browse the repository at this point in the history
  • Loading branch information
sds100 committed Sep 10, 2020
1 parent 6077876 commit eb5fcd2
Show file tree
Hide file tree
Showing 11 changed files with 564 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class KeymapListViewModel internal constructor(

val selectionProvider: ISelectionProvider = SelectionProvider()

val backupEvent = MutableLiveData<Event<Unit>>()

override val loadingContent = MutableLiveData(true)

fun duplicate(vararg id: Long) {
Expand Down Expand Up @@ -80,6 +82,10 @@ class KeymapListViewModel internal constructor(
loadingContent.value = false
}

fun backup() {
backupEvent.value = Event(Unit)
}

suspend fun getDeviceInfoList() = mDeviceInfoRepository.getAll()

@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.sds100.keymapper.ui.adapter

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import io.github.sds100.keymapper.ui.fragment.KeymapListFragment

/**
* Created by sds100 on 26/01/2020.
*/

class HomePagerAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {

private val mTabFragmentsCreators: List<() -> Fragment> = mutableListOf(
{
KeymapListFragment().apply {
isAppBarVisible = false
isInPagerAdapter = true
}
}
)

override fun getItemCount() = mTabFragmentsCreators.size

override fun createFragment(position: Int) = mTabFragmentsCreators[position].invoke()
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package io.github.sds100.keymapper.ui.fragment

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.google.android.material.bottomappbar.BottomAppBar
import io.github.sds100.keymapper.databinding.FragmentRecyclerviewBinding

Expand All @@ -13,9 +15,18 @@ abstract class DefaultRecyclerViewFragment : RecyclerViewFragment<FragmentRecycl
override val appBar: BottomAppBar
get() = binding.appBar

open val noItemsText: String? = null
open val itemCount: LiveData<Int> = MutableLiveData()

override fun bind(inflater: LayoutInflater, container: ViewGroup?) =
FragmentRecyclerviewBinding.inflate(inflater, container, false).apply {
progressCallback = this.progressCallback
lifecycleOwner = viewLifecycleOwner

noItemsText = this@DefaultRecyclerViewFragment.noItemsText

this@DefaultRecyclerViewFragment.itemCount.observe(viewLifecycleOwner, {
itemCount = it
})
}
}
Loading

0 comments on commit eb5fcd2

Please sign in to comment.