Code refactor
This commit is contained in:
parent
a8f0867c9d
commit
5394f94973
96 changed files with 384 additions and 1068 deletions
|
@ -15,6 +15,7 @@
|
|||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import kotlin.math.abs
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -26,21 +27,25 @@ abstract class AppBarStateChangeListener : AppBarLayout.OnOffsetChangedListener
|
|||
private var mCurrentState = State.IDLE
|
||||
|
||||
override fun onOffsetChanged(appBarLayout: AppBarLayout, i: Int) {
|
||||
if (i == 0) {
|
||||
if (mCurrentState != State.EXPANDED) {
|
||||
onStateChanged(appBarLayout, State.EXPANDED)
|
||||
when {
|
||||
i == 0 -> {
|
||||
if (mCurrentState != State.EXPANDED) {
|
||||
onStateChanged(appBarLayout, State.EXPANDED)
|
||||
}
|
||||
mCurrentState = State.EXPANDED
|
||||
}
|
||||
mCurrentState = State.EXPANDED
|
||||
} else if (Math.abs(i) >= appBarLayout.totalScrollRange) {
|
||||
if (mCurrentState != State.COLLAPSED) {
|
||||
onStateChanged(appBarLayout, State.COLLAPSED)
|
||||
abs(i) >= appBarLayout.totalScrollRange -> {
|
||||
if (mCurrentState != State.COLLAPSED) {
|
||||
onStateChanged(appBarLayout, State.COLLAPSED)
|
||||
}
|
||||
mCurrentState = State.COLLAPSED
|
||||
}
|
||||
mCurrentState = State.COLLAPSED
|
||||
} else {
|
||||
if (mCurrentState != State.IDLE) {
|
||||
onStateChanged(appBarLayout, State.IDLE)
|
||||
else -> {
|
||||
if (mCurrentState != State.IDLE) {
|
||||
onStateChanged(appBarLayout, State.IDLE)
|
||||
}
|
||||
mCurrentState = State.IDLE
|
||||
}
|
||||
mCurrentState = State.IDLE
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.loaders.AlbumLoader
|
||||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.loaders.SongLoader
|
||||
import java.util.*
|
||||
|
||||
internal class AsyncSearchResultLoader(context: Context, private val query: String) :
|
||||
WrappedAsyncTaskLoader<List<Any>>(context) {
|
||||
|
||||
override fun loadInBackground(): List<Any>? {
|
||||
val results = ArrayList<Any>()
|
||||
if (!TextUtils.isEmpty(query)) {
|
||||
val songs = SongLoader.getSongs(context, query.trim { it <= ' ' })
|
||||
if (!songs.isEmpty()) {
|
||||
results.add(context.resources.getString(R.string.songs))
|
||||
results.addAll(songs)
|
||||
}
|
||||
|
||||
val artists = ArtistLoader.getArtists(context, query.trim { it <= ' ' })
|
||||
if (!artists.isEmpty()) {
|
||||
results.add(context.resources.getString(R.string.artists))
|
||||
results.addAll(artists)
|
||||
}
|
||||
|
||||
val albums = AlbumLoader.getAlbums(context, query.trim { it <= ' ' })
|
||||
if (!albums.isEmpty()) {
|
||||
results.add(context.resources.getString(R.string.albums))
|
||||
results.addAll(albums)
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import android.animation.Animator
|
||||
|
||||
|
||||
abstract class SimpleAnimatorListener : Animator.AnimatorListener {
|
||||
override fun onAnimationStart(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationCancel(animation: Animator) {
|
||||
|
||||
}
|
||||
|
||||
override fun onAnimationRepeat(animation: Animator) {
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue