Fix crashes on home screen shortcuts and going to artist page

This commit is contained in:
h4h13 2019-03-05 08:10:57 +05:30
parent 240874f312
commit 263620310f
38 changed files with 214 additions and 222 deletions

View file

@ -32,8 +32,8 @@ android {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic" applicationId "code.name.monkey.retromusic"
versionCode 297 versionCode 299
versionName '3.1.240' versionName '3.1.250'
multiDexEnabled true multiDexEnabled true

View file

@ -1 +1 @@
<html> <head> <style type="text/css"> * { word-wrap: break-word; } {style-placeholder} a { color: #{link-color}; } a:active { color: #{link-color-active}; } ul { list-style-position: outside; padding-left: 0; padding-right: 0; margin-left: 1em; } li { padding-top: 8px; } </style> </head> <body> <h3 style="text-align:center;"> Subscribe to <a href="https://www.youtube.com/user/PewDiePie/">PewDiePie</a> 👊 </h3> <h4>v3.1.240</h4> <ul> <li>Fix Search not showing from home screen</li> <li>Fix Volume controls color issue</li> <li>Fix Seek bar alignment</li> <li>Added tiny theme</li> <li>Improved full theme appearances</li> <li>Now playing theme preview updated</li> <li>Fix composer error</li> </ul> <h4>v3.1.200</h4> <ul> <li>Added composer sort and editing</li> <li>Fix Crash in Album tag editor while selecting options</li> <li>Added Filter song length</li> <li>Added Favourites playlist icon will be accent color</li> <li>Added Colorful settings icons</li> <li>Added Corners for dialog</li> </ul> <h4>v3.0.570</h4> <ul> <li>Fix Album/Artist square image</li> <li>Fix Delete dialog text format</li> <li>Fix Profile picture not showing after coming back from folders</li> <li>Fix Play button color i Simple and Plain themes</li> <li>Fix Sleep timer dialog crashing</li> <li>Fix Share song dialog title and text</li> </ul> <p>If you see entire app white or dark or black select same theme in settings to fix </p> <p style="line-height:150%"><a href="https://github.com/h4h13/RetroMusicPlayer/wiki/FAQ">FAQ's</a> </p> <p style="line-height:150%">*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again. </p> </body> <html> <head> <style type="text/css"> * { word-wrap: break-word; } {style-placeholder} a { color: #{link-color}; } a:active { color: #{link-color-active}; } ul { list-style-position: outside; padding-left: 0; padding-right: 0; margin-left: 1em; } li { padding-top: 8px; } </style> </head> <body> <h4>v3.1.240</h4> <ul> <li>Fix Search not showing from home screen</li> <li>Fix Volume controls color issue</li> <li>Fix Seek bar alignment</li> <li>Added tiny theme</li> <li>Improved full theme appearances</li> <li>Now playing theme preview updated</li> <li>Fix composer error</li> </ul> <h4>v3.1.200</h4> <ul> <li>Added composer sort and editing</li> <li>Fix Crash in Album tag editor while selecting options</li> <li>Added Filter song length</li> <li>Added Favourites playlist icon will be accent color</li> <li>Added Colorful settings icons</li> <li>Added Corners for dialog</li> </ul> <h4>v3.0.570</h4> <ul> <li>Fix Album/Artist square image</li> <li>Fix Delete dialog text format</li> <li>Fix Profile picture not showing after coming back from folders</li> <li>Fix Play button color i Simple and Plain themes</li> <li>Fix Sleep timer dialog crashing</li> <li>Fix Share song dialog title and text</li> </ul> <p>If you see entire app white or dark or black select same theme in settings to fix </p> <p style="line-height:150%"><a href="https://github.com/h4h13/RetroMusicPlayer/wiki/FAQ">FAQ's</a> </p> <p style="line-height:150%">*If you face any UI related issues you clear app data and cache, if its not working try to uninstall and install again. </p> </body>

View file

@ -98,7 +98,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
return MaterialDialog(activity!!).show { return MaterialDialog(activity!!).show {
title(text = parentFolder!!.absolutePath) title(text = parentFolder!!.absolutePath)
listItems(items = contentsArray(), waitForPositiveButton = false) { dialog, index, text -> listItems(items = contentsArray(), waitForPositiveButton = false) { dialog, index, text ->
onSelection(dialog, index, text) onSelection(index)
} }
noAutoDismiss() noAutoDismiss()
positiveButton(R.string.add_action) { positiveButton(R.string.add_action) {
@ -111,7 +111,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
} }
} }
private fun onSelection(materialDialog: MaterialDialog, i: Int, s: String) { private fun onSelection(i: Int) {
if (canGoUp && i == 0) { if (canGoUp && i == 0) {
parentFolder = parentFolder!!.parentFile parentFolder = parentFolder!!.parentFile
if (parentFolder!!.absolutePath == "/storage/emulated") { if (parentFolder!!.absolutePath == "/storage/emulated") {
@ -139,7 +139,7 @@ class BlacklistFolderChooserDialog : DialogFragment() {
dialog?.apply { dialog?.apply {
setTitle(parentFolder!!.absolutePath) setTitle(parentFolder!!.absolutePath)
listItems(items = contentsArray()) { dialog, index, text -> listItems(items = contentsArray()) { dialog, index, text ->
onSelection(dialog, index, text) onSelection(index)
} }
} }
} }

View file

@ -56,7 +56,9 @@ class RemoveFromPlaylistDialog : RoundedBottomSheetDialogFragment() {
text = content text = content
setTextColor(ThemeStore.textColorSecondary(context)) setTextColor(ThemeStore.textColorSecondary(context))
setOnClickListener { setOnClickListener {
PlaylistsUtil.removeFromPlaylist(activity!!, songs as ArrayList<PlaylistSong>) val playlistSongs = ArrayList<PlaylistSong>()
playlistSongs.addAll(songs as ArrayList<PlaylistSong>)
PlaylistsUtil.removeFromPlaylist(activity!!, playlistSongs)
dismiss() dismiss()
} }
} }

View file

@ -39,9 +39,9 @@ class SongShareDialog : RoundedBottomSheetDialogFragment() {
@SuppressLint("StringFormatInvalid") @SuppressLint("StringFormatInvalid")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val song = arguments!!.getParcelable<Song>("song") val song: Song = arguments!!.getParcelable("song") ?: return
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
dialogTitle.setTextColor(ThemeStore.textColorPrimary(context!!))
audioText.apply { audioText.apply {
text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName) text = getString(R.string.currently_listening_to_x_by_x, song.title, song.artistName)
setTextColor(ThemeStore.textColorSecondary(context!!)) setTextColor(ThemeStore.textColorSecondary(context!!))

View file

@ -41,7 +41,7 @@ import java.util.concurrent.TimeUnit
class ArtistImage(val artistName: String, val skipOkHttpCache: Boolean) class ArtistImage(val artistName: String, val skipOkHttpCache: Boolean)
class ArtistImageFetcher(private val context: Context, private val lastFMRestClient: LastFMRestClient, private val okHttp: OkHttpClient, private val model: ArtistImage, width: Int, height: Int) : DataFetcher<InputStream> { class ArtistImageFetcher(private val context: Context, private val lastFMRestClient: LastFMRestClient, private val okHttp: OkHttpClient, private val model: ArtistImage) : DataFetcher<InputStream> {
@Volatile @Volatile
private var isCancelled: Boolean = false private var isCancelled: Boolean = false
private var call: Call<LastFmArtist>? = null private var call: Call<LastFmArtist>? = null
@ -120,7 +120,7 @@ class ArtistImageFetcher(private val context: Context, private val lastFMRestCli
class ArtistImageLoader(private val context: Context, private val lastFMClient: LastFMRestClient, private val okhttp: OkHttpClient) : ModelLoader<ArtistImage, InputStream> { class ArtistImageLoader(private val context: Context, private val lastFMClient: LastFMRestClient, private val okhttp: OkHttpClient) : ModelLoader<ArtistImage, InputStream> {
override fun buildLoadData(model: ArtistImage, width: Int, height: Int, options: Options): ModelLoader.LoadData<InputStream>? { override fun buildLoadData(model: ArtistImage, width: Int, height: Int, options: Options): ModelLoader.LoadData<InputStream>? {
return ModelLoader.LoadData(ObjectKey(model.artistName), ArtistImageFetcher(context, lastFMClient, okhttp, model, width, height)) return ModelLoader.LoadData(ObjectKey(model.artistName), ArtistImageFetcher(context, lastFMClient, okhttp, model))
} }
override fun handles(model: ArtistImage): Boolean { override fun handles(model: ArtistImage): Boolean {

View file

@ -14,17 +14,14 @@
package code.name.monkey.retromusic.helper.menu package code.name.monkey.retromusic.helper.menu
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.view.MenuItem import android.view.MenuItem
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import java.util.ArrayList
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.App import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
import code.name.monkey.retromusic.dialogs.RenamePlaylistDialog import code.name.monkey.retromusic.dialogs.RenamePlaylistDialog
@ -35,6 +32,7 @@ import code.name.monkey.retromusic.model.AbsCustomPlaylist
import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PlaylistsUtil import code.name.monkey.retromusic.util.PlaylistsUtil
import java.util.*
object PlaylistMenuHelper { object PlaylistMenuHelper {

View file

@ -12,14 +12,32 @@
* See the GNU General Public License for more details. * See the GNU General Public License for more details.
*/ */
package code.name.monkey.retromusic.model package code.name.monkey.retromusic.model;
import android.content.Context import android.content.Context;
import io.reactivex.Observable import android.os.Parcel;
import java.util.*
abstract class AbsCustomPlaylist(id: Int, name: String) : Playlist(id, name) { import java.util.ArrayList;
abstract fun getSongs(context: Context): Observable<ArrayList<Song>> import androidx.annotation.NonNull;
import io.reactivex.Observable;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public abstract class AbsCustomPlaylist extends Playlist {
public AbsCustomPlaylist(int id, String name) {
super(id, name);
}
public AbsCustomPlaylist() {
}
public AbsCustomPlaylist(Parcel in) {
super(in);
}
@NonNull
public abstract Observable<ArrayList<Song>> getSongs(Context context);
} }

View file

@ -16,15 +16,13 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context; import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import com.kabouzeid.gramophone.R; import androidx.annotation.DrawableRes;
import com.kabouzeid.gramophone.model.AbsCustomPlaylist; import androidx.annotation.Nullable;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.model.AbsCustomPlaylist;
/**
* @author Karim Abou Zeid (kabouzeid)
*/
public abstract class AbsSmartPlaylist extends AbsCustomPlaylist { public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
@DrawableRes @DrawableRes
public final int iconRes; public final int iconRes;

View file

@ -16,45 +16,21 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context; import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.provider.HistoryStore;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.HistoryStore;
import io.reactivex.Observable;
/** /**
* @author Karim Abou Zeid (kabouzeid) * @author Karim Abou Zeid (kabouzeid)
*/ */
public class HistoryPlaylist extends AbsSmartPlaylist { public class HistoryPlaylist extends AbsSmartPlaylist {
public HistoryPlaylist(@NonNull Context context) {
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
}
@NonNull
@Override
public ArrayList<Song> getSongs(@NonNull Context context) {
return TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(context);
}
@Override
public void clear(@NonNull Context context) {
HistoryStore.getInstance(context).clear();
}
@Override
public int describeContents() {
return 0;
}
protected HistoryPlaylist(Parcel in) {
super(in);
}
public static final Creator<HistoryPlaylist> CREATOR = new Creator<HistoryPlaylist>() { public static final Creator<HistoryPlaylist> CREATOR = new Creator<HistoryPlaylist>() {
public HistoryPlaylist createFromParcel(Parcel source) { public HistoryPlaylist createFromParcel(Parcel source) {
return new HistoryPlaylist(source); return new HistoryPlaylist(source);
@ -64,4 +40,28 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
return new HistoryPlaylist[size]; return new HistoryPlaylist[size];
} }
}; };
public HistoryPlaylist(@NonNull Context context) {
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
}
protected HistoryPlaylist(Parcel in) {
super(in);
}
@NonNull
@Override
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getRecentlyPlayedTracks(context);
}
@Override
public void clear(@NonNull Context context) {
HistoryStore.getInstance(context).clear();
}
@Override
public int describeContents() {
return 0;
}
} }

View file

@ -16,27 +16,40 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context; import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.loader.LastAddedLoader;
import com.kabouzeid.gramophone.model.Song;
import java.util.ArrayList; import java.util.ArrayList;
/** import androidx.annotation.NonNull;
* @author Karim Abou Zeid (kabouzeid) import code.name.monkey.retromusic.R;
*/ import code.name.monkey.retromusic.loaders.LastAddedSongsLoader;
import code.name.monkey.retromusic.model.Song;
import io.reactivex.Observable;
public class LastAddedPlaylist extends AbsSmartPlaylist { public class LastAddedPlaylist extends AbsSmartPlaylist {
public static final Creator<LastAddedPlaylist> CREATOR = new Creator<LastAddedPlaylist>() {
public LastAddedPlaylist createFromParcel(Parcel source) {
return new LastAddedPlaylist(source);
}
public LastAddedPlaylist[] newArray(int size) {
return new LastAddedPlaylist[size];
}
};
public LastAddedPlaylist(@NonNull Context context) { public LastAddedPlaylist(@NonNull Context context) {
super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp); super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp);
} }
protected LastAddedPlaylist(Parcel in) {
super(in);
}
@NonNull @NonNull
@Override @Override
public ArrayList<Song> getSongs(@NonNull Context context) { public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
return LastAddedLoader.getLastAddedSongs(context); return LastAddedSongsLoader.INSTANCE.getLastAddedSongs(context);
} }
@Override @Override
@ -52,18 +65,4 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
public int describeContents() { public int describeContents() {
return 0; return 0;
} }
protected LastAddedPlaylist(Parcel in) {
super(in);
}
public static final Creator<LastAddedPlaylist> CREATOR = new Creator<LastAddedPlaylist>() {
public LastAddedPlaylist createFromParcel(Parcel source) {
return new LastAddedPlaylist(source);
}
public LastAddedPlaylist[] newArray(int size) {
return new LastAddedPlaylist[size];
}
};
} }

View file

@ -16,45 +16,21 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context; import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
import com.kabouzeid.gramophone.model.Song;
import com.kabouzeid.gramophone.provider.SongPlayCountStore;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.TopAndRecentlyPlayedTracksLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.providers.SongPlayCountStore;
import io.reactivex.Observable;
/** /**
* @author Karim Abou Zeid (kabouzeid) * @author Karim Abou Zeid (kabouzeid)
*/ */
public class MyTopTracksPlaylist extends AbsSmartPlaylist { public class MyTopTracksPlaylist extends AbsSmartPlaylist {
public MyTopTracksPlaylist(@NonNull Context context) {
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
}
@NonNull
@Override
public ArrayList<Song> getSongs(@NonNull Context context) {
return TopAndRecentlyPlayedTracksLoader.getTopTracks(context);
}
@Override
public void clear(@NonNull Context context) {
SongPlayCountStore.getInstance(context).clear();
}
@Override
public int describeContents() {
return 0;
}
protected MyTopTracksPlaylist(Parcel in) {
super(in);
}
public static final Creator<MyTopTracksPlaylist> CREATOR = new Creator<MyTopTracksPlaylist>() { public static final Creator<MyTopTracksPlaylist> CREATOR = new Creator<MyTopTracksPlaylist>() {
public MyTopTracksPlaylist createFromParcel(Parcel source) { public MyTopTracksPlaylist createFromParcel(Parcel source) {
return new MyTopTracksPlaylist(source); return new MyTopTracksPlaylist(source);
@ -64,4 +40,28 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist {
return new MyTopTracksPlaylist[size]; return new MyTopTracksPlaylist[size];
} }
}; };
public MyTopTracksPlaylist(@NonNull Context context) {
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
}
protected MyTopTracksPlaylist(Parcel in) {
super(in);
}
@NonNull
@Override
public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
return TopAndRecentlyPlayedTracksLoader.INSTANCE.getTopTracks(context);
}
@Override
public void clear(@NonNull Context context) {
SongPlayCountStore.getInstance(context).clear();
}
@Override
public int describeContents() {
return 0;
}
} }

View file

@ -16,24 +16,39 @@ package code.name.monkey.retromusic.model.smartplaylist;
import android.content.Context; import android.content.Context;
import android.os.Parcel; import android.os.Parcel;
import android.support.annotation.NonNull;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.loader.SongLoader;
import com.kabouzeid.gramophone.model.Song;
import java.util.ArrayList; import java.util.ArrayList;
import androidx.annotation.NonNull;
import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.loaders.SongLoader;
import code.name.monkey.retromusic.model.Song;
import io.reactivex.Observable;
public class ShuffleAllPlaylist extends AbsSmartPlaylist { public class ShuffleAllPlaylist extends AbsSmartPlaylist {
public static final Creator<ShuffleAllPlaylist> CREATOR = new Creator<ShuffleAllPlaylist>() {
public ShuffleAllPlaylist createFromParcel(Parcel source) {
return new ShuffleAllPlaylist(source);
}
public ShuffleAllPlaylist[] newArray(int size) {
return new ShuffleAllPlaylist[size];
}
};
public ShuffleAllPlaylist(@NonNull Context context) { public ShuffleAllPlaylist(@NonNull Context context) {
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp); super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
} }
protected ShuffleAllPlaylist(Parcel in) {
super(in);
}
@NonNull @NonNull
@Override @Override
public ArrayList<Song> getSongs(@NonNull Context context) { public Observable<ArrayList<Song>> getSongs(@NonNull Context context) {
return SongLoader.getAllSongs(context); return SongLoader.INSTANCE.getAllSongs(context);
} }
@Override @Override
@ -45,18 +60,4 @@ public class ShuffleAllPlaylist extends AbsSmartPlaylist {
public int describeContents() { public int describeContents() {
return 0; return 0;
} }
protected ShuffleAllPlaylist(Parcel in) {
super(in);
}
public static final Creator<ShuffleAllPlaylist> CREATOR = new Creator<ShuffleAllPlaylist>() {
public ShuffleAllPlaylist createFromParcel(Parcel source) {
return new ShuffleAllPlaylist(source);
}
public ShuffleAllPlaylist[] newArray(int size) {
return new ShuffleAllPlaylist[size];
}
};
} }

View file

@ -21,6 +21,7 @@ import android.text.Html
import android.util.AttributeSet import android.util.AttributeSet
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog
import code.name.monkey.retromusic.providers.BlacklistStore import code.name.monkey.retromusic.providers.BlacklistStore
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
@ -60,9 +61,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
return MaterialDialog(context!!).show { return MaterialDialog(context!!).show {
title(code.name.monkey.retromusic.R.string.blacklist) title(code.name.monkey.retromusic.R.string.blacklist)
positiveButton(android.R.string.ok) { positiveButton(android.R.string.ok) {
dismiss(); dismiss()
} }
neutralButton(code.name.monkey.retromusic.R.string.clear_action) { neutralButton(text = getString(R.string.clear_action)) {
MaterialDialog(context).show { MaterialDialog(context).show {
title(code.name.monkey.retromusic.R.string.clear_blacklist) title(code.name.monkey.retromusic.R.string.clear_blacklist)
message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist) message(code.name.monkey.retromusic.R.string.do_you_want_to_clear_the_blacklist)
@ -73,7 +74,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
negativeButton(android.R.string.cancel) negativeButton(android.R.string.cancel)
} }
} }
negativeButton(code.name.monkey.retromusic.R.string.add_action) { negativeButton(R.string.add_action) {
val dialog = BlacklistFolderChooserDialog.create() val dialog = BlacklistFolderChooserDialog.create()
dialog.setCallback(this@BlacklistPreferenceDialog) dialog.setCallback(this@BlacklistPreferenceDialog)
dialog.show(childFragmentManager, "FOLDER_CHOOSER"); dialog.show(childFragmentManager, "FOLDER_CHOOSER");

View file

@ -38,12 +38,12 @@ class MaterialListPreference : ListPreference {
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
override fun getDialogLayoutResource(): Int { override fun getDialogLayoutResource(): Int {
return mLayoutRes; return mLayoutRes
} }
override fun onGetDefaultValue(a: TypedArray, index: Int): Any { override fun onGetDefaultValue(a: TypedArray, index: Int): String {
// Default value from attribute. Fallback value is set to 0. // Default value from attribute. Fallback value is set to 0.
return a.getString(index) return a.getString(index)!!
} }
fun setCustomValue(any: Any) { fun setCustomValue(any: Any) {

View file

@ -17,7 +17,6 @@ package code.name.monkey.retromusic.providers.interfaces
import code.name.monkey.retromusic.model.* import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
import io.reactivex.Observable import io.reactivex.Observable
import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
/** /**

View file

@ -422,7 +422,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
playlistSongs = ((AbsCustomPlaylist) playlist).getSongs(getApplicationContext()).blockingFirst(); playlistSongs = ((AbsCustomPlaylist) playlist).getSongs(getApplicationContext()).blockingFirst();
} else { } else {
//noinspection unchecked //noinspection unchecked
playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.getId()).blockingFirst(); playlistSongs = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(getApplicationContext(), playlist.id).blockingFirst();
} }
if (!playlistSongs.isEmpty()) { if (!playlistSongs.isEmpty()) {
if (shuffleMode == SHUFFLE_MODE_SHUFFLE) { if (shuffleMode == SHUFFLE_MODE_SHUFFLE) {

View file

@ -277,8 +277,8 @@ public class WearBrowserService extends MediaBrowserService {
int size = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, playlist).blockingFirst().size(); int size = PlaylistSongsLoader.INSTANCE.getPlaylistSongList(mContext, playlist).blockingFirst().size();
String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song"); String songCount = String.format("%d %s", size, size > 1 ? "Songs" : "Song");
fillMediaItems(mediaItems, fillMediaItems(mediaItems,
Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.getId()), Integer.toString(TYPE_PLAYLIST_ALL_SONGS) + Long.toString(playlist.id),
playlist.getName(), playlist.name,
songCount, songCount,
Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"), Uri.parse("android.resource://code.name.monkey.retromusic/drawable/ic_queue_music_white_24dp"),
MediaBrowser.MediaItem.FLAG_BROWSABLE); MediaBrowser.MediaItem.FLAG_BROWSABLE);

View file

@ -206,7 +206,7 @@ open class BugReportActivity : AbsThemeActivity() {
val bugDescription = inputDescription!!.text!!.toString() val bugDescription = inputDescription!!.text!!.toString()
val extraInfo = ExtraInfo() val extraInfo = ExtraInfo()
onSaveExtraInfo(extraInfo) onSaveExtraInfo()
val report = Report(bugTitle, bugDescription, deviceInfo, extraInfo) val report = Report(bugTitle, bugDescription, deviceInfo, extraInfo)
val target = GithubTarget("h4h13", "RetroMusicPlayer") val target = GithubTarget("h4h13", "RetroMusicPlayer")
@ -214,7 +214,7 @@ open class BugReportActivity : AbsThemeActivity() {
ReportIssueAsyncTask.report(this, report, target, login) ReportIssueAsyncTask.report(this, report, target, login)
} }
private fun onSaveExtraInfo(extraInfo: ExtraInfo) {} private fun onSaveExtraInfo() {}
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == android.R.id.home) { if (item.itemId == android.R.id.home) {

View file

@ -98,7 +98,7 @@ class SongTagEditorActivity : AbsTagEditorActivity(), TextWatcher {
override fun getSongPaths(): List<String> { override fun getSongPaths(): List<String> {
val paths = ArrayList<String>(1) val paths = ArrayList<String>(1)
paths.add(SongLoader.getSong(this, id).blockingFirst().data!!) paths.add(SongLoader.getSong(this, id).blockingFirst().data)
return paths return paths
} }

View file

@ -212,7 +212,6 @@ open class AlbumAdapter(protected val activity: AppCompatActivity,
} }
companion object { companion object {
val TAG: String = AlbumAdapter::class.java.simpleName
val TAG = AlbumAdapter::class.java.simpleName!!
} }
} }

View file

@ -1,12 +1,9 @@
package code.name.monkey.retromusic.ui.fragments.mainactivity package code.name.monkey.retromusic.ui.fragments.mainactivity
import android.os.Bundle import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import android.view.Menu import android.view.Menu
import android.view.MenuInflater import android.view.MenuInflater
import androidx.recyclerview.widget.LinearLayoutManager
import java.util.ArrayList
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.mvp.contract.PlaylistContract import code.name.monkey.retromusic.mvp.contract.PlaylistContract
@ -14,6 +11,7 @@ import code.name.monkey.retromusic.mvp.presenter.PlaylistPresenter
import code.name.monkey.retromusic.ui.adapter.playlist.PlaylistAdapter import code.name.monkey.retromusic.ui.adapter.playlist.PlaylistAdapter
import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewFragment import code.name.monkey.retromusic.ui.fragments.base.AbsLibraryPagerRecyclerViewFragment
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import java.util.*
class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistContract.PlaylistView { class PlaylistsFragment : AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, LinearLayoutManager>(), PlaylistContract.PlaylistView {

View file

@ -43,7 +43,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
presenter!!.loadSongs() presenter.loadSongs()
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
@ -99,7 +99,7 @@ class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdap
} }
override fun onDestroy() { override fun onDestroy() {
presenter!!.unsubscribe() presenter.unsubscribe()
super.onDestroy() super.onDestroy()
} }

View file

@ -153,7 +153,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Call
playerToolbar.apply { playerToolbar.apply {
inflateMenu(code.name.monkey.retromusic.R.menu.menu_player) inflateMenu(code.name.monkey.retromusic.R.menu.menu_player)
setNavigationIcon(code.name.monkey.retromusic.R.drawable.ic_close_white_24dp) setNavigationIcon(code.name.monkey.retromusic.R.drawable.ic_close_white_24dp)
setNavigationOnClickListener { v -> activity!!.onBackPressed() } setNavigationOnClickListener { activity!!.onBackPressed() }
setOnMenuItemClickListener(this@ClassicPlayerFragment) setOnMenuItemClickListener(this@ClassicPlayerFragment)
} }
} }

View file

@ -81,7 +81,6 @@ class PlayerFragment : AbsPlayerFragment(), PlayerAlbumCoverFragment.Callbacks {
display?.getMetrics(outMetrics) display?.getMetrics(outMetrics)
val density = resources.displayMetrics.density val density = resources.displayMetrics.density
val dpHeight = outMetrics.heightPixels / density
val dpWidth = outMetrics.widthPixels / density val dpWidth = outMetrics.widthPixels / density
playerAlbumCoverContainer?.layoutParams?.height = RetroUtil.convertDpToPixel((dpWidth - getCutOff()), context!!).toInt() playerAlbumCoverContainer?.layoutParams?.height = RetroUtil.convertDpToPixel((dpWidth - getCutOff()), context!!).toInt()

View file

@ -366,16 +366,16 @@ public class MusicUtil {
public static void toggleFavorite(@NonNull final Context context, @NonNull final Song song) { public static void toggleFavorite(@NonNull final Context context, @NonNull final Song song) {
if (isFavorite(context, song)) { if (isFavorite(context, song)) {
PlaylistsUtil.removeFromPlaylist(context, song, getFavoritesPlaylist(context).blockingFirst().getId()); PlaylistsUtil.removeFromPlaylist(context, song, getFavoritesPlaylist(context).blockingFirst().id);
} else { } else {
PlaylistsUtil.addToPlaylist(context, song, getOrCreateFavoritesPlaylist(context).blockingFirst().getId(), PlaylistsUtil.addToPlaylist(context, song, getOrCreateFavoritesPlaylist(context).blockingFirst().id,
false); false);
} }
} }
public static boolean isFavoritePlaylist(@NonNull final Context context, public static boolean isFavoritePlaylist(@NonNull final Context context,
@NonNull final Playlist playlist) { @NonNull final Playlist playlist) {
return playlist.getName() != null && playlist.getName().equals(context.getString(R.string.favorites)); return playlist.name != null && playlist.name.equals(context.getString(R.string.favorites));
} }
private static Observable<Playlist> getFavoritesPlaylist(@NonNull final Context context) { private static Observable<Playlist> getFavoritesPlaylist(@NonNull final Context context) {
@ -397,7 +397,7 @@ public class MusicUtil {
//getFavoritesPlaylist(context).blockingFirst().id.subscribe(MusicUtil::setPlaylist); //getFavoritesPlaylist(context).blockingFirst().id.subscribe(MusicUtil::setPlaylist);
//return PlaylistsUtil.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id); //return PlaylistsUtil.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.id);
return PlaylistsUtil return PlaylistsUtil
.doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().getId(), song.getId()); .doPlaylistContains(context, getFavoritesPlaylist(context).blockingFirst().id, song.getId());
} }
public static boolean isArtistNameUnknown(@Nullable String artistName) { public static boolean isArtistNameUnknown(@Nullable String artistName) {

View file

@ -19,7 +19,6 @@ import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.media.audiofx.AudioEffect; import android.media.audiofx.AudioEffect;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -76,7 +75,7 @@ public class NavigationUtil {
intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, i); intent.putExtra(ArtistDetailActivity.EXTRA_ARTIST_ID, i);
//noinspection unchecked //noinspection unchecked
ActivityCompat.startActivity(activity, intent, ActivityCompat.startActivity(activity, intent,
ActivityOptionsCompat.makeSceneTransitionAnimation(activity, (Pair<View, String>) null).toBundle()); ActivityOptionsCompat.makeSceneTransitionAnimation(activity, null).toBundle());
} }
public static void goToPlaylistNew(@NonNull Activity activity, @NonNull Playlist playlist) { public static void goToPlaylistNew(@NonNull Activity activity, @NonNull Playlist playlist) {

View file

@ -99,7 +99,7 @@ public class PlaylistsUtil {
final StringBuilder selection = new StringBuilder(); final StringBuilder selection = new StringBuilder();
selection.append(MediaStore.Audio.Playlists._ID + " IN ("); selection.append(MediaStore.Audio.Playlists._ID + " IN (");
for (int i = 0; i < playlists.size(); i++) { for (int i = 0; i < playlists.size(); i++) {
selection.append(playlists.get(i).getId()); selection.append(playlists.get(i).id);
if (i < playlists.size() - 1) { if (i < playlists.size() - 1) {
selection.append(","); selection.append(",");
} }

View file

@ -120,7 +120,7 @@ object ViewUtil {
val top = v.top + ty val top = v.top + ty
val bottom = v.bottom + ty val bottom = v.bottom + ty
return x >= left && x <= right && y >= top && y <= bottom return x in left..right && y >= top && y <= bottom
} }
fun setUpFastScrollRecyclerViewColor(context: Context, fun setUpFastScrollRecyclerViewColor(context: Context,

View file

@ -16,8 +16,6 @@ import code.name.monkey.appthemehelper.R
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.common.views.ATESwitch import code.name.monkey.appthemehelper.common.views.ATESwitch
import java.lang.reflect.Field
/** /**
* @author Aidan Follestad (afollestad) * @author Aidan Follestad (afollestad)
*/ */
@ -26,23 +24,23 @@ class ATESwitchPreference : SwitchPreference {
private var mSwitch: ATESwitch? = null private var mSwitch: ATESwitch? = null
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init()
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init()
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init()
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
init(context, attrs) init()
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init() {
layoutResource = R.layout.ate_preference_custom layoutResource = R.layout.ate_preference_custom
if (COMPAT_MODE) { if (COMPAT_MODE) {
widgetLayoutResource = R.layout.ate_preference_switch widgetLayoutResource = R.layout.ate_preference_switch

View file

@ -19,19 +19,19 @@ class ATEColorPreference(context: Context, attrs: AttributeSet?, defStyleAttr: I
private var border: Int = 0 private var border: Int = 0
constructor(context: Context) : this(context, null, 0) { constructor(context: Context) : this(context, null, 0) {
init(context, null) init()
} }
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) { constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0) {
init(context, attrs) init()
} }
init { init {
init(context, attrs) init()
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init() {
layoutResource = R.layout.ate_preference_custom_support layoutResource = R.layout.ate_preference_custom_support
widgetLayoutResource = R.layout.ate_preference_color widgetLayoutResource = R.layout.ate_preference_color
isPersistent = false isPersistent = false

View file

@ -14,23 +14,23 @@ import code.name.monkey.appthemehelper.R
class ATESwitchPreference : CheckBoxPreference { class ATESwitchPreference : CheckBoxPreference {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init()
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init()
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init()
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
init(context, attrs) init()
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init() {
layoutResource = R.layout.ate_preference_custom_support layoutResource = R.layout.ate_preference_custom_support
widgetLayoutResource = R.layout.ate_preference_switch_support widgetLayoutResource = R.layout.ate_preference_switch_support
} }

View file

@ -14,18 +14,18 @@ import code.name.monkey.appthemehelper.ThemeStore
class ATEEditText : AppCompatEditText { class ATEEditText : AppCompatEditText {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init(context)
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init(context)
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init(context)
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init(context: Context) {
ATH.setTint(this, ThemeStore.accentColor(context)) ATH.setTint(this, ThemeStore.accentColor(context))
setTextColor(ThemeStore.textColorPrimary(context)) setTextColor(ThemeStore.textColorPrimary(context))
} }

View file

@ -16,23 +16,23 @@ import code.name.monkey.appthemehelper.ThemeStore
class ATEProgressBar : ProgressBar { class ATEProgressBar : ProgressBar {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init(context)
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init(context)
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init(context)
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes) {
init(context, attrs) init(context)
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init(context: Context) {
ATH.setTint(this, ThemeStore.accentColor(context)) ATH.setTint(this, ThemeStore.accentColor(context))
} }
} }

View file

@ -12,18 +12,18 @@ import code.name.monkey.appthemehelper.ThemeStore
class ATESecondaryTextView : AppCompatTextView { class ATESecondaryTextView : AppCompatTextView {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init(context)
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init(context)
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init(context)
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init(context: Context) {
setTextColor(ThemeStore.textColorSecondary(context)) setTextColor(ThemeStore.textColorSecondary(context))
} }
} }

View file

@ -15,18 +15,18 @@ import code.name.monkey.appthemehelper.ThemeStore
class ATEStockSwitch : Switch { class ATEStockSwitch : Switch {
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) {
init(context, null) init(context)
} }
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context, attrs) init(context)
} }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context, attrs) init(context)
} }
private fun init(context: Context, attrs: AttributeSet?) { private fun init(context: Context) {
ATH.setTint(this, ThemeStore.accentColor(context)) ATH.setTint(this, ThemeStore.accentColor(context))
} }

View file

@ -23,15 +23,6 @@ object ATHUtil {
} }
} }
fun isInClassPath(clsName: String): Boolean {
try {
return inClassPath(clsName) != null
} catch (t: Throwable) {
return false
}
}
fun inClassPath(clsName: String): Class<*> { fun inClassPath(clsName: String): Class<*> {
try { try {
return Class.forName(clsName) return Class.forName(clsName)

View file

@ -3,27 +3,19 @@ package code.name.monkey.appthemehelper.util
import android.graphics.drawable.ColorDrawable import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.TransitionDrawable import android.graphics.drawable.TransitionDrawable
import android.os.Build
import androidx.annotation.ColorInt
import android.view.View import android.view.View
import android.view.ViewTreeObserver import android.view.ViewTreeObserver
import androidx.annotation.ColorInt
object ViewUtil { object ViewUtil {
fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) { fun removeOnGlobalLayoutListener(v: View, listener: ViewTreeObserver.OnGlobalLayoutListener) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
v.viewTreeObserver.removeGlobalOnLayoutListener(listener)
} else {
v.viewTreeObserver.removeOnGlobalLayoutListener(listener) v.viewTreeObserver.removeOnGlobalLayoutListener(listener)
} }
}
fun setBackgroundCompat(view: View, drawable: Drawable?) { fun setBackgroundCompat(view: View, drawable: Drawable?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
view.background = drawable view.background = drawable
else
view.setBackgroundDrawable(drawable)
} }
fun setBackgroundTransition(view: View, newDrawable: Drawable): TransitionDrawable { fun setBackgroundTransition(view: View, newDrawable: Drawable): TransitionDrawable {