fix highlight bug in navigation bar
This commit is contained in:
parent
930f7e8aa3
commit
b779004a2c
3 changed files with 10 additions and 27 deletions
|
|
@ -12,11 +12,6 @@ public class PlaylistSong extends Song {
|
||||||
this.playlistId = playlistId;
|
this.playlistId = playlistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistSong(String id, String title, int trackNumber, int year, long duration, String albumId, String albumName, String artistId, String artistName, final String playlistId) {
|
|
||||||
super("", title, trackNumber, year, duration, "", albumName, "", artistName);
|
|
||||||
this.playlistId = playlistId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
super.writeToParcel(dest, flags);
|
super.writeToParcel(dest, flags);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemDto.getCollectionType() == null || !itemDto.getCollectionType().equals("music")) continue;
|
if (itemDto.getCollectionType() == null || !itemDto.getCollectionType().equals("music")) continue;
|
||||||
int test = itemDto.getId().hashCode();
|
|
||||||
menu.add(R.id.navigation_drawer_menu_category_sections, itemDto.getId().hashCode(), menu.size(), itemDto.getName());
|
menu.add(R.id.navigation_drawer_menu_category_sections, itemDto.getId().hashCode(), menu.size(), itemDto.getName());
|
||||||
menu.getItem(menu.size() - 1).setIcon(R.drawable.ic_album_white_24dp);
|
menu.getItem(menu.size() - 1).setIcon(R.drawable.ic_album_white_24dp);
|
||||||
}
|
}
|
||||||
|
|
@ -130,11 +129,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
|
||||||
navigationView.setNavigationItemSelectedListener(menuItem -> {
|
navigationView.setNavigationItemSelectedListener(menuItem -> {
|
||||||
drawerLayout.closeDrawers();
|
drawerLayout.closeDrawers();
|
||||||
switch (menuItem.getItemId()) {
|
switch (menuItem.getItemId()) {
|
||||||
case R.id.nav_library:
|
|
||||||
QueryUtil.currentLibrary = null;
|
|
||||||
navigationView.setCheckedItem(R.id.nav_library);
|
|
||||||
setCurrentFragment(LibraryFragment.newInstance());
|
|
||||||
break;
|
|
||||||
case R.id.nav_settings:
|
case R.id.nav_settings:
|
||||||
new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, SettingsActivity.class)), 200);
|
new Handler().postDelayed(() -> startActivity(new Intent(MainActivity.this, SettingsActivity.class)), 200);
|
||||||
break;
|
break;
|
||||||
|
|
@ -143,17 +137,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setCheckable must be applied to the items on creation
|
|
||||||
// it also applies a tacky background color for the checked item
|
|
||||||
// this is a hack to check the current item without that
|
|
||||||
for (int i = 0; i < navigationView.getMenu().size(); i++) {
|
|
||||||
if (navigationView.getMenu().getItem(i) == menuItem) {
|
|
||||||
navigationView.getMenu().getItem(i).setChecked(true);
|
|
||||||
} else {
|
|
||||||
navigationView.getMenu().getItem(i).setChecked(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (BaseItemDto itemDto : libraries) {
|
for (BaseItemDto itemDto : libraries) {
|
||||||
if (menuItem.getItemId() == itemDto.getId().hashCode()) {
|
if (menuItem.getItemId() == itemDto.getId().hashCode()) {
|
||||||
QueryUtil.currentLibrary = itemDto;
|
QueryUtil.currentLibrary = itemDto;
|
||||||
|
|
@ -162,6 +145,18 @@ public class MainActivity extends AbsSlidingMusicPanelActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setCheckable must be applied to the items on creation
|
||||||
|
// it also applies a tacky background color for the checked item
|
||||||
|
// this is a hack to check the current item without that
|
||||||
|
if (menuItem.getItemId() == R.id.nav_settings || menuItem.getItemId() == R.id.nav_about) return true;
|
||||||
|
for (int i = 0; i < navigationView.getMenu().size(); i++) {
|
||||||
|
if (navigationView.getMenu().getItem(i) == menuItem) {
|
||||||
|
navigationView.getMenu().getItem(i).setChecked(true);
|
||||||
|
} else {
|
||||||
|
navigationView.getMenu().getItem(i).setChecked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,7 @@
|
||||||
|
|
||||||
<group
|
<group
|
||||||
android:id="@+id/navigation_drawer_menu_category_sections"
|
android:id="@+id/navigation_drawer_menu_category_sections"
|
||||||
android:checkableBehavior="single">
|
android:checkableBehavior="single" />
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/nav_library"
|
|
||||||
android:icon="@drawable/ic_library_music_white_24dp"
|
|
||||||
android:title="@string/all" />
|
|
||||||
|
|
||||||
</group>
|
|
||||||
|
|
||||||
<group
|
<group
|
||||||
android:id="@+id/navigation_drawer_menu_category_other"
|
android:id="@+id/navigation_drawer_menu_category_other"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue