Fix loading songs after permission granted
This commit is contained in:
parent
2892c42628
commit
6d9860016e
8 changed files with 27 additions and 20 deletions
|
@ -24,7 +24,7 @@ android {
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|
||||||
applicationId "code.name.monkey.retromusic"
|
applicationId "code.name.monkey.retromusic"
|
||||||
versionCode 434
|
versionCode 435
|
||||||
versionName '3.5.300'
|
versionName '3.5.300'
|
||||||
|
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
|
@ -100,10 +100,16 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
public static final int APP_INTRO_REQUEST = 100;
|
public static final int APP_INTRO_REQUEST = 100;
|
||||||
public static final String EXPAND_PANEL = "expand_panel";
|
public static final String EXPAND_PANEL = "expand_panel";
|
||||||
private static final int APP_UPDATE_REQUEST_CODE = 9002;
|
private static final int APP_UPDATE_REQUEST_CODE = 9002;
|
||||||
|
private final IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
|
||||||
|
private MainActivityFragmentCallbacks currentFragment;
|
||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
public void onReceive(final Context context, final Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
Log.i(TAG, "onReceive: " + action);
|
||||||
|
if (action != null && action.equals(MusicService.MEDIA_STORE_CHANGED)) {
|
||||||
|
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG, true);
|
||||||
|
}
|
||||||
if (action != null && action.equals(Intent.ACTION_SCREEN_OFF)) {
|
if (action != null && action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) {
|
if (PreferenceUtil.getInstance(context).getLockScreen() && MusicPlayerRemote.isPlaying()) {
|
||||||
final Intent activity = new Intent(context, LockScreenActivity.class);
|
final Intent activity = new Intent(context, LockScreenActivity.class);
|
||||||
|
@ -114,8 +120,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final IntentFilter mIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
|
|
||||||
private MainActivityFragmentCallbacks currentFragment;
|
|
||||||
private boolean blockRequestPermissions = false;
|
private boolean blockRequestPermissions = false;
|
||||||
private MaterialCab cab;
|
private MaterialCab cab;
|
||||||
private AppBarLayout mAppBarLayout;
|
private AppBarLayout mAppBarLayout;
|
||||||
|
@ -177,6 +181,7 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
selectedFragment(item.getItemId());
|
selectedFragment(item.getItemId());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
mIntentFilter.addAction(MusicService.MEDIA_STORE_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,8 +213,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
blockRequestPermissions = false;
|
blockRequestPermissions = false;
|
||||||
if (!hasPermissions()) {
|
if (!hasPermissions()) {
|
||||||
requestPermissions();
|
requestPermissions();
|
||||||
} else {
|
|
||||||
selectedFragment(PreferenceUtil.getInstance(this).getLastPage());
|
|
||||||
}
|
}
|
||||||
} else if (requestCode == APP_UPDATE_REQUEST_CODE) {
|
} else if (requestCode == APP_UPDATE_REQUEST_CODE) {
|
||||||
if (resultCode != RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
|
@ -412,12 +415,14 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
mAppBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
|
mAppBarLayout.removeOnOffsetChangedListener(onOffsetChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentFragment(@NonNull Fragment fragment, @NonNull String tag) {
|
public void setCurrentFragment(@NonNull Fragment fragment, @NonNull String tag, boolean force) {
|
||||||
String currentTag = null;
|
String currentTag = null;
|
||||||
if (getSupportFragmentManager().findFragmentByTag(tag) != null) {
|
if (getSupportFragmentManager().findFragmentByTag(tag) != null) {
|
||||||
currentTag = getSupportFragmentManager().findFragmentByTag(tag).getTag();
|
currentTag = getSupportFragmentManager().findFragmentByTag(tag).getTag();
|
||||||
}
|
}
|
||||||
|
if (force) {
|
||||||
|
currentTag = null;
|
||||||
|
}
|
||||||
if (!tag.equals(currentTag)) {
|
if (!tag.equals(currentTag)) {
|
||||||
getSupportFragmentManager()
|
getSupportFragmentManager()
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
|
@ -681,29 +686,29 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
private void selectedFragment(final int itemId) {
|
private void selectedFragment(final int itemId) {
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case R.id.action_album:
|
case R.id.action_album:
|
||||||
setCurrentFragment(AlbumsFragment.newInstance(), AlbumsFragment.TAG);
|
setCurrentFragment(AlbumsFragment.newInstance(), AlbumsFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_artist:
|
case R.id.action_artist:
|
||||||
setCurrentFragment(ArtistsFragment.newInstance(), ArtistsFragment.TAG);
|
setCurrentFragment(ArtistsFragment.newInstance(), ArtistsFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_playlist:
|
case R.id.action_playlist:
|
||||||
setCurrentFragment(PlaylistsFragment.newInstance(), PlaylistsFragment.TAG);
|
setCurrentFragment(PlaylistsFragment.newInstance(), PlaylistsFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_genre:
|
case R.id.action_genre:
|
||||||
setCurrentFragment(GenresFragment.newInstance(), GenresFragment.TAG);
|
setCurrentFragment(GenresFragment.newInstance(), GenresFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_playing_queue:
|
case R.id.action_playing_queue:
|
||||||
setCurrentFragment(PlayingQueueFragment.newInstance(), PlayingQueueFragment.TAG);
|
setCurrentFragment(PlayingQueueFragment.newInstance(), PlayingQueueFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_song:
|
case R.id.action_song:
|
||||||
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG);
|
setCurrentFragment(SongsFragment.newInstance(), SongsFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
case R.id.action_folder:
|
case R.id.action_folder:
|
||||||
setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG);
|
setCurrentFragment(FoldersFragment.newInstance(this), FoldersFragment.TAG, false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
case R.id.action_home:
|
case R.id.action_home:
|
||||||
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG);
|
setCurrentFragment(BannerHomeFragment.newInstance(), BannerHomeFragment.TAG,false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,7 +201,7 @@ class SkuDetailsAdapter(
|
||||||
|
|
||||||
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
|
||||||
val skuDetails = skuDetailsList[i]
|
val skuDetails = skuDetailsList[i]
|
||||||
viewHolder.title.text = skuDetails.title.replace("(Retro Music Player)", "")
|
viewHolder.title.text = skuDetails.title.replace("(Retro Music Player \uD83C\uDFB5)", "")
|
||||||
.trim { it <= ' ' }
|
.trim { it <= ' ' }
|
||||||
viewHolder.text.text = skuDetails.description
|
viewHolder.text.text = skuDetails.description
|
||||||
viewHolder.text.visibility = View.GONE
|
viewHolder.text.visibility = View.GONE
|
||||||
|
|
|
@ -63,6 +63,7 @@ abstract class AbsBaseActivity : AbsThemeActivity() {
|
||||||
|
|
||||||
protected open fun onHasPermissionsChanged(hasPermissions: Boolean) {
|
protected open fun onHasPermissionsChanged(hasPermissions: Boolean) {
|
||||||
// implemented by sub classes
|
// implemented by sub classes
|
||||||
|
println(hasPermissions)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||||
|
|
|
@ -133,6 +133,7 @@ abstract class AbsMusicServiceActivity : AbsBaseActivity(), MusicServiceEventLis
|
||||||
true
|
true
|
||||||
) // just in case we need to know this at some point
|
) // just in case we need to know this at some point
|
||||||
sendBroadcast(intent)
|
sendBroadcast(intent)
|
||||||
|
println("sendBroadcast $hasPermissions")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getPermissionsToRequest(): Array<String> {
|
override fun getPermissionsToRequest(): Array<String> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ class AlbumsFragment :
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||||
MainActivityFragmentCallbacks {
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
lateinit var albumViewModel: AlbumViewModel
|
private lateinit var albumViewModel: AlbumViewModel
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
|
@ -17,7 +17,7 @@ class SongsFragment :
|
||||||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
|
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
|
||||||
MainActivityFragmentCallbacks {
|
MainActivityFragmentCallbacks {
|
||||||
|
|
||||||
lateinit var songViewModel: SongsViewModel
|
private lateinit var songViewModel: SongsViewModel
|
||||||
|
|
||||||
override val emptyMessage: Int
|
override val emptyMessage: Int
|
||||||
get() = R.string.no_songs
|
get() = R.string.no_songs
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<dimen name="list_item_image_icon_padding">8dp</dimen>
|
<dimen name="list_item_image_icon_padding">8dp</dimen>
|
||||||
|
|
||||||
<dimen name="mini_player_height">48dp</dimen>
|
<dimen name="mini_player_height">56dp</dimen>
|
||||||
|
|
||||||
<dimen name="app_widget_classic_height">96dp</dimen>
|
<dimen name="app_widget_classic_height">96dp</dimen>
|
||||||
<dimen name="app_widget_classic_image_size">96dp</dimen>
|
<dimen name="app_widget_classic_image_size">96dp</dimen>
|
||||||
|
|
Loading…
Reference in a new issue