kotlin conversion
This commit is contained in:
parent
8e6ab40d93
commit
b2c15ef186
316 changed files with 13055 additions and 22983 deletions
|
@ -1,41 +0,0 @@
|
|||
package code.name.monkey.retromusic.misc;
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout;
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
* https://stackoverflow.com/a/33891727
|
||||
*/
|
||||
|
||||
public abstract class AppBarStateChangeListener implements AppBarLayout.OnOffsetChangedListener {
|
||||
|
||||
private State mCurrentState = State.IDLE;
|
||||
|
||||
@Override
|
||||
public final void onOffsetChanged(AppBarLayout appBarLayout, int i) {
|
||||
if (i == 0) {
|
||||
if (mCurrentState != State.EXPANDED) {
|
||||
onStateChanged(appBarLayout, State.EXPANDED);
|
||||
}
|
||||
mCurrentState = State.EXPANDED;
|
||||
} else if (Math.abs(i) >= appBarLayout.getTotalScrollRange()) {
|
||||
if (mCurrentState != State.COLLAPSED) {
|
||||
onStateChanged(appBarLayout, State.COLLAPSED);
|
||||
}
|
||||
mCurrentState = State.COLLAPSED;
|
||||
} else {
|
||||
if (mCurrentState != State.IDLE) {
|
||||
onStateChanged(appBarLayout, State.IDLE);
|
||||
}
|
||||
mCurrentState = State.IDLE;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void onStateChanged(AppBarLayout appBarLayout, State state);
|
||||
|
||||
public enum State {
|
||||
EXPANDED,
|
||||
COLLAPSED,
|
||||
IDLE
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
* https://stackoverflow.com/a/33891727
|
||||
*/
|
||||
|
||||
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)
|
||||
}
|
||||
mCurrentState = State.EXPANDED
|
||||
} else if (Math.abs(i) >= appBarLayout.totalScrollRange) {
|
||||
if (mCurrentState != State.COLLAPSED) {
|
||||
onStateChanged(appBarLayout, State.COLLAPSED)
|
||||
}
|
||||
mCurrentState = State.COLLAPSED
|
||||
} else {
|
||||
if (mCurrentState != State.IDLE) {
|
||||
onStateChanged(appBarLayout, State.IDLE)
|
||||
}
|
||||
mCurrentState = State.IDLE
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun onStateChanged(appBarLayout: AppBarLayout, state: State)
|
||||
|
||||
enum class State {
|
||||
EXPANDED,
|
||||
COLLAPSED,
|
||||
IDLE
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package code.name.monkey.retromusic.misc;
|
||||
|
||||
import android.animation.Animator;
|
||||
|
||||
|
||||
public abstract class SimpleAnimatorListener implements Animator.AnimatorListener {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
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) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
package code.name.monkey.retromusic.misc;
|
||||
|
||||
import android.widget.SeekBar;
|
||||
|
||||
|
||||
public abstract class SimpleOnSeekbarChangeListener implements SeekBar.OnSeekBarChangeListener {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import android.widget.SeekBar
|
||||
|
||||
|
||||
abstract class SimpleOnSeekbarChangeListener : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
package code.name.monkey.retromusic.misc;
import android.content.Context;
import android.os.AsyncTask;
import androidx.annotation.Nullable;
import java.lang.ref.WeakReference;
public abstract class WeakContextAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> {
private WeakReference<Context> contextWeakReference;
public WeakContextAsyncTask(Context context) {
contextWeakReference = new WeakReference<>(context);
}
@Nullable
protected Context getContext() {
return contextWeakReference.get();
}
}
|
|
@ -0,0 +1 @@
|
|||
package code.name.monkey.retromusic.misc
import android.content.Context
import android.os.AsyncTask
import java.lang.ref.WeakReference
abstract class WeakContextAsyncTask<Params, Progress, Result>(context: Context) : AsyncTask<Params, Progress, Result>() {
private val contextWeakReference: WeakReference<Context> = WeakReference(context)
protected val context: Context?
get() = contextWeakReference.get()
}
|
|
@ -1,72 +0,0 @@
|
|||
|
||||
package code.name.monkey.retromusic.misc;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.loader.content.AsyncTaskLoader;
|
||||
|
||||
/**
|
||||
* <a href="http://code.google.com/p/android/issues/detail?id=14944">Issue
|
||||
* 14944</a>
|
||||
*
|
||||
* @author Alexander Blom
|
||||
*/
|
||||
public abstract class WrappedAsyncTaskLoader<D> extends AsyncTaskLoader<D> {
|
||||
|
||||
private D mData;
|
||||
|
||||
/**
|
||||
* Constructor of <code>WrappedAsyncTaskLoader</code>
|
||||
*
|
||||
* @param context The {@link Context} to use.
|
||||
*/
|
||||
public WrappedAsyncTaskLoader(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void deliverResult(D data) {
|
||||
if (!isReset()) {
|
||||
this.mData = data;
|
||||
super.deliverResult(data);
|
||||
} else {
|
||||
// An asynchronous query came in while the loader is stopped
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void onStartLoading() {
|
||||
super.onStartLoading();
|
||||
if (this.mData != null) {
|
||||
deliverResult(this.mData);
|
||||
} else if (takeContentChanged() || this.mData == null) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void onStopLoading() {
|
||||
super.onStopLoading();
|
||||
// Attempt to cancel the current load task if possible
|
||||
cancelLoad();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void onReset() {
|
||||
super.onReset();
|
||||
// Ensure the loader is stopped
|
||||
onStopLoading();
|
||||
this.mData = null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package code.name.monkey.retromusic.misc
|
||||
|
||||
import android.content.Context
|
||||
import androidx.loader.content.AsyncTaskLoader
|
||||
|
||||
/**
|
||||
* [Issue
|
||||
* 14944](http://code.google.com/p/android/issues/detail?id=14944)
|
||||
*
|
||||
* @author Alexander Blom
|
||||
*/
|
||||
abstract class WrappedAsyncTaskLoader<D>
|
||||
/**
|
||||
* Constructor of `WrappedAsyncTaskLoader`
|
||||
*
|
||||
* @param context The [Context] to use.
|
||||
*/
|
||||
(context: Context) : AsyncTaskLoader<D>(context) {
|
||||
|
||||
private var mData: D? = null
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
override fun deliverResult(data: D?) {
|
||||
if (!isReset) {
|
||||
this.mData = data
|
||||
super.deliverResult(data)
|
||||
} else {
|
||||
// An asynchronous query came in while the loader is stopped
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
override fun onStartLoading() {
|
||||
super.onStartLoading()
|
||||
if (this.mData != null) {
|
||||
deliverResult(this.mData)
|
||||
} else if (takeContentChanged() || this.mData == null) {
|
||||
forceLoad()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
override fun onStopLoading() {
|
||||
super.onStopLoading()
|
||||
// Attempt to cancel the current load task if possible
|
||||
cancelLoad()
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
override fun onReset() {
|
||||
super.onReset()
|
||||
// Ensure the loader is stopped
|
||||
onStopLoading()
|
||||
this.mData = null
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue