mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-02 11:58:27 +00:00
Updated build dependencies, and also switched to a new fastscroller
library for RecyclerView that seems to work more smoothly on older devices. Also, the implementation of it seems pretty simple, and should be relatively easy to debug if problems arise.
This commit is contained in:
parent
5ce66d22a0
commit
93156e99aa
@ -69,9 +69,9 @@ dependencies {
|
||||
implementation(name:'videocache-2.8.0-pre', ext:'aar')
|
||||
implementation 'org.slf4j:slf4j-android:1.7.21'
|
||||
|
||||
implementation "android.arch.persistence.room:runtime:1.0.0-alpha9-1"
|
||||
annotationProcessor "android.arch.persistence.room:compiler:1.0.0-alpha9-1"
|
||||
kapt "android.arch.persistence.room:compiler:1.0.0-alpha9-1"
|
||||
implementation "android.arch.persistence.room:runtime:1.0.0"
|
||||
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"
|
||||
kapt "android.arch.persistence.room:compiler:1.0.0"
|
||||
|
||||
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
|
||||
implementation 'com.google.dagger:dagger:2.11'
|
||||
@ -85,7 +85,7 @@ dependencies {
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
|
||||
implementation 'com.google.android.exoplayer:exoplayer:r2.4.2'
|
||||
implementation 'com.google.android.exoplayer:extension-okhttp:r2.4.2'
|
||||
implementation 'com.github.pluscubed:recycler-fast-scroll:0.3.2@aar'
|
||||
implementation 'com.simplecityapps:recyclerview-fastscroll:1.0.16'
|
||||
implementation 'com.facebook.stetho:stetho:1.5.0'
|
||||
|
||||
implementation 'com.android.support:appcompat-v7:26.1.0'
|
||||
|
@ -9,7 +9,7 @@ import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.data.IAlbum
|
||||
import io.casey.musikcube.remote.data.ICategoryValue
|
||||
@ -43,9 +43,8 @@ class AlbumBrowseActivity : BaseActivity(), Filterable {
|
||||
setTitleFromIntent(R.string.albums_title)
|
||||
enableUpNavigation()
|
||||
|
||||
val fastScroller = findViewById<RecyclerFastScroller>(R.id.fast_scroller)
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, fastScroller, adapter)
|
||||
val recyclerView = findViewById<FastScrollRecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, adapter)
|
||||
|
||||
emptyView = findViewById(R.id.empty_list_view)
|
||||
emptyView.capability = EmptyListView.Capability.OnlineOnly
|
||||
|
@ -9,7 +9,7 @@ import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.data.ICategoryValue
|
||||
import io.casey.musikcube.remote.data.IDataProvider
|
||||
@ -48,9 +48,8 @@ class CategoryBrowseActivity : BaseActivity(), Filterable {
|
||||
setContentView(R.layout.recycler_view_activity)
|
||||
setTitle(categoryTitleStringId)
|
||||
|
||||
val fastScroller = findViewById<RecyclerFastScroller>(R.id.fast_scroller)
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, fastScroller, adapter)
|
||||
val recyclerView = findViewById<FastScrollRecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, adapter)
|
||||
|
||||
emptyView = findViewById(R.id.empty_list_view)
|
||||
emptyView.capability = EmptyListView.Capability.OnlineOnly
|
||||
|
@ -8,7 +8,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.data.IDataProvider
|
||||
import io.casey.musikcube.remote.data.ITrack
|
||||
@ -33,9 +33,8 @@ class PlayQueueActivity : BaseActivity() {
|
||||
|
||||
setContentView(R.layout.recycler_view_activity)
|
||||
|
||||
val fastScroller = findViewById<RecyclerFastScroller>(R.id.fast_scroller)
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, fastScroller, adapter)
|
||||
val recyclerView = findViewById<FastScrollRecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, adapter)
|
||||
|
||||
emptyView = findViewById(R.id.empty_list_view)
|
||||
emptyView.capability = EmptyListView.Capability.OfflineOk
|
||||
@ -45,7 +44,7 @@ class PlayQueueActivity : BaseActivity() {
|
||||
val queryFactory = playback!!.playlistQueryFactory
|
||||
offlineQueue = playback!!.playlistQueryFactory.offline()
|
||||
|
||||
tracks = TrackListSlidingWindow(recyclerView, fastScroller, dataProvider, queryFactory)
|
||||
tracks = TrackListSlidingWindow(recyclerView, dataProvider, queryFactory)
|
||||
tracks.setInitialPosition(intent.getIntExtra(EXTRA_PLAYING_INDEX, -1))
|
||||
tracks.setOnMetadataLoadedListener(slidingWindowListener)
|
||||
|
||||
|
@ -9,7 +9,7 @@ import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.data.IDataProvider
|
||||
import io.casey.musikcube.remote.data.ITrack
|
||||
@ -51,9 +51,8 @@ class TrackListActivity : BaseActivity(), Filterable {
|
||||
|
||||
val queryFactory = createCategoryQueryFactory(categoryType, categoryId)
|
||||
|
||||
val fastScroller = findViewById<RecyclerFastScroller>(R.id.fast_scroller)
|
||||
val recyclerView = findViewById<RecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, fastScroller, adapter)
|
||||
val recyclerView = findViewById<FastScrollRecyclerView>(R.id.recycler_view)
|
||||
setupDefaultRecyclerView(recyclerView, adapter)
|
||||
|
||||
emptyView = findViewById(R.id.empty_list_view)
|
||||
emptyView.let {
|
||||
@ -62,8 +61,7 @@ class TrackListActivity : BaseActivity(), Filterable {
|
||||
it.alternateView = recyclerView
|
||||
}
|
||||
|
||||
tracks = TrackListSlidingWindow(
|
||||
recyclerView, fastScroller, dataProvider, queryFactory)
|
||||
tracks = TrackListSlidingWindow(recyclerView, dataProvider, queryFactory)
|
||||
|
||||
tracks.setOnMetadataLoadedListener(slidingWindowListener)
|
||||
|
||||
|
@ -19,23 +19,20 @@ import android.widget.CheckBox
|
||||
import android.widget.CompoundButton
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import io.casey.musikcube.remote.R
|
||||
import io.casey.musikcube.remote.ui.activity.Filterable
|
||||
import io.casey.musikcube.remote.ui.fragment.TransportFragment
|
||||
import io.casey.musikcube.remote.util.Strings
|
||||
|
||||
var EXTRA_ACTIVITY_TITLE = "extra_title"
|
||||
val EXTRA_ACTIVITY_TITLE = "extra_title"
|
||||
|
||||
fun AppCompatActivity.setupDefaultRecyclerView(
|
||||
recyclerView: RecyclerView,
|
||||
fastScroller: RecyclerFastScroller,
|
||||
adapter: RecyclerView.Adapter<*>) {
|
||||
val layoutManager = LinearLayoutManager(this)
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
recyclerView.adapter = adapter
|
||||
fastScroller.attachRecyclerView(recyclerView)
|
||||
|
||||
val dividerItemDecoration = DividerItemDecoration(this, layoutManager.orientation)
|
||||
|
||||
|
@ -2,16 +2,14 @@ package io.casey.musikcube.remote.ui.model
|
||||
|
||||
import android.support.v7.widget.RecyclerView
|
||||
import android.util.Log
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
import com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener
|
||||
import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
import io.casey.musikcube.remote.data.IDataProvider
|
||||
import io.casey.musikcube.remote.data.ITrack
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class TrackListSlidingWindow(private val recyclerView: RecyclerView,
|
||||
private val fastScroller: RecyclerFastScroller,
|
||||
class TrackListSlidingWindow(private val recyclerView: FastScrollRecyclerView,
|
||||
val dataProvider: IDataProvider,
|
||||
private val queryFactory: TrackListSlidingWindow.QueryFactory)
|
||||
{
|
||||
@ -57,19 +55,14 @@ class TrackListSlidingWindow(private val recyclerView: RecyclerView,
|
||||
notifyMetadataLoaded(0, 0)
|
||||
}
|
||||
|
||||
private val fastScrollerTouch by lazy {
|
||||
View.OnTouchListener { _, event ->
|
||||
if (event != null) {
|
||||
val type = event.actionMasked
|
||||
if (type == MotionEvent.ACTION_DOWN) {
|
||||
fastScrollerActive = true
|
||||
}
|
||||
else if (type == MotionEvent.ACTION_UP) {
|
||||
fastScrollerActive = false
|
||||
requery()
|
||||
}
|
||||
}
|
||||
false
|
||||
private val fastScrollStateChangeListener = object: OnFastScrollStateChangeListener {
|
||||
override fun onFastScrollStop() {
|
||||
fastScrollerActive = false
|
||||
requery()
|
||||
}
|
||||
|
||||
override fun onFastScrollStart() {
|
||||
fastScrollerActive = true
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,8 +101,7 @@ class TrackListSlidingWindow(private val recyclerView: RecyclerView,
|
||||
|
||||
fun pause() {
|
||||
connected = false
|
||||
recyclerView.removeOnScrollListener(_scrollListener)
|
||||
fastScroller.setOnHandleTouchListener(null)
|
||||
recyclerView.removeOnScrollListener(recyclerViewScrollListener)
|
||||
disposables.dispose()
|
||||
disposables = CompositeDisposable()
|
||||
}
|
||||
@ -118,8 +110,8 @@ class TrackListSlidingWindow(private val recyclerView: RecyclerView,
|
||||
disposables.add(dataProvider.observePlayQueue()
|
||||
.subscribe({ requery() }, { /* error */ }))
|
||||
|
||||
recyclerView.addOnScrollListener(_scrollListener)
|
||||
fastScroller.setOnHandleTouchListener(fastScrollerTouch)
|
||||
recyclerView.setStateChangeListener(fastScrollStateChangeListener)
|
||||
recyclerView.addOnScrollListener(recyclerViewScrollListener)
|
||||
connected = true
|
||||
fastScrollerActive = false
|
||||
}
|
||||
@ -209,7 +201,7 @@ class TrackListSlidingWindow(private val recyclerView: RecyclerView,
|
||||
return scrollState != RecyclerView.SCROLL_STATE_IDLE || fastScrollerActive
|
||||
}
|
||||
|
||||
private val _scrollListener = object : RecyclerView.OnScrollListener() {
|
||||
private val recyclerViewScrollListener = object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView?, newState: Int) {
|
||||
scrollState = newState
|
||||
if (!scrolling()) {
|
||||
|
@ -12,6 +12,8 @@ import io.casey.musikcube.remote.util.NetworkUtil
|
||||
import io.casey.musikcube.remote.util.Preconditions
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import io.reactivex.subjects.ReplaySubject
|
||||
import io.reactivex.subjects.Subject
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
@ -293,7 +295,9 @@ class WebSocketService constructor(private val context: Context) {
|
||||
throw Exception("socket disconnected")
|
||||
}
|
||||
else if (socket == null) {
|
||||
throw Exception("socket not connected")
|
||||
val replay = ReplaySubject.create<SocketMessage>()
|
||||
replay.onError(Exception("socket not connected"))
|
||||
return replay
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
@ -11,24 +10,13 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
<RelativeLayout
|
||||
<com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<com.pluscubed.recyclerfastscroll.RecyclerFastScroller
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:rfs_touchTargetWidth="32dp"
|
||||
android:paddingLeft="8dp"
|
||||
android:layout_alignParentRight="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
android:layout_height="match_parent"
|
||||
app:fastScrollAutoHide="true"
|
||||
app:fastScrollAutoHideDelay="1500"
|
||||
app:fastScrollThumbColor="@color/color_accent" />
|
||||
|
||||
<io.casey.musikcube.remote.ui.view.EmptyListView
|
||||
android:id="@+id/empty_list_view"
|
||||
|
@ -1,5 +1,5 @@
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.1.50'
|
||||
ext.kotlin_version = '1.1.51'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
|
Loading…
Reference in New Issue
Block a user