mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge pull request #10360 from TeamNewPipe/improvement/tabSelected
Simplify `MainActivity.tabSelected(MenuItem)`
This commit is contained in:
commit
e6747066ae
@ -219,14 +219,14 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
|
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
|
||||||
final StreamingService service = NewPipe.getService(currentServiceId);
|
final StreamingService service = NewPipe.getService(currentServiceId);
|
||||||
|
|
||||||
int kioskId = 0;
|
int kioskMenuItemId = 0;
|
||||||
|
|
||||||
for (final String ks : service.getKioskList().getAvailableKiosks()) {
|
for (final String ks : service.getKioskList().getAvailableKiosks()) {
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
.add(R.id.menu_tabs_group, kioskId, 0, KioskTranslator
|
.add(R.id.menu_tabs_group, kioskMenuItemId, 0, KioskTranslator
|
||||||
.getTranslatedKioskName(ks, this))
|
.getTranslatedKioskName(ks, this))
|
||||||
.setIcon(KioskTranslator.getKioskIcon(ks));
|
.setIcon(KioskTranslator.getKioskIcon(ks));
|
||||||
kioskId++;
|
kioskMenuItemId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
drawerLayoutBinding.navigation.getMenu()
|
drawerLayoutBinding.navigation.getMenu()
|
||||||
@ -306,20 +306,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
NavigationHelper.openStatisticFragment(getSupportFragmentManager());
|
NavigationHelper.openStatisticFragment(getSupportFragmentManager());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
final int currentServiceId = ServiceHelper.getSelectedServiceId(this);
|
final StreamingService currentService = ServiceHelper.getSelectedService(this);
|
||||||
final StreamingService service = NewPipe.getService(currentServiceId);
|
int kioskMenuItemId = 0;
|
||||||
String serviceName = "";
|
for (final String kioskId : currentService.getKioskList().getAvailableKiosks()) {
|
||||||
|
if (kioskMenuItemId == item.getItemId()) {
|
||||||
int kioskId = 0;
|
NavigationHelper.openKioskFragment(getSupportFragmentManager(),
|
||||||
for (final String ks : service.getKioskList().getAvailableKiosks()) {
|
currentService.getServiceId(), kioskId);
|
||||||
if (kioskId == item.getItemId()) {
|
break;
|
||||||
serviceName = ks;
|
|
||||||
}
|
}
|
||||||
kioskId++;
|
kioskMenuItemId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationHelper.openKioskFragment(getSupportFragmentManager(), currentServiceId,
|
|
||||||
serviceName);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user