use of org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment in project malp by gateship-one.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// restore drag state
if (savedInstanceState != null) {
mSavedNowPlayingDragStatus = DRAG_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_DRAG_STATUS)];
mSavedNowPlayingViewSwitcherStatus = VIEW_SWITCHER_STATUS.values()[savedInstanceState.getInt(MAINACTIVITY_SAVED_INSTANCE_NOW_PLAYING_VIEW_SWITCHER_CURRENT_VIEW)];
}
setContentView(R.layout.activity_main);
// restore elevation behaviour as pre 24 support lib
AppBarLayout layout = findViewById(R.id.appbar);
layout.setStateListAnimator(null);
ViewCompat.setElevation(layout, 0);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// enable back navigation
final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer != null) {
mDrawerToggle = new ActionBarDrawerToggle(this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
}
int navId = getDefaultViewID();
NavigationView navigationView = findViewById(R.id.nav_view);
if (navigationView != null) {
navigationView.setNavigationItemSelectedListener(this);
navigationView.setCheckedItem(navId);
}
mFAB = findViewById(R.id.andrompd_play_button);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
mUseArtistSort = sharedPref.getBoolean(getString(R.string.pref_use_artist_sort_key), getResources().getBoolean(R.bool.pref_use_artist_sort_default));
registerForContextMenu(findViewById(R.id.main_listview));
if (MPDProfileManager.getInstance(this).getProfiles().size() == 0) {
navId = R.id.nav_profiles;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getResources().getString(R.string.welcome_dialog_title));
builder.setMessage(getResources().getString(R.string.welcome_dialog_text));
builder.setPositiveButton(R.string.dialog_action_ok, (dialog, id) -> {
});
AlertDialog dialog = builder.create();
dialog.show();
}
if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
Fragment fragment = null;
if (navId == R.id.nav_library) {
fragment = new MyMusicTabsFragment();
MyMusicTabsFragment.DEFAULTTAB defaultTab = getDefaultTab();
Bundle args = new Bundle();
args.putInt(MyMusicTabsFragment.MY_MUSIC_REQUESTED_TAB, defaultTab.ordinal());
fragment.setArguments(args);
} else if (navId == R.id.nav_saved_playlists) {
fragment = new SavedPlaylistsFragment();
} else if (navId == R.id.nav_files) {
fragment = new FilesFragment();
} else if (navId == R.id.nav_profiles) {
fragment = new ProfilesFragment();
}
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment);
transaction.commit();
}
}
use of org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment in project malp by gateship-one.
the class MainActivity method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
View coordinatorLayout = findViewById(R.id.main_coordinator_layout);
coordinatorLayout.setVisibility(View.VISIBLE);
NowPlayingView nowPlayingView = findViewById(R.id.now_playing_layout);
if (nowPlayingView != null) {
nowPlayingView.minimize();
}
FragmentManager fragmentManager = getSupportFragmentManager();
// clear backstack
fragmentManager.popBackStackImmediate("", FragmentManager.POP_BACK_STACK_INCLUSIVE);
Fragment fragment = null;
String fragmentTag = "";
if (id == R.id.nav_library) {
// Handle the camera action
fragment = new MyMusicTabsFragment();
fragmentTag = MyMusicTabsFragment.TAG;
} else if (id == R.id.nav_saved_playlists) {
fragment = new SavedPlaylistsFragment();
fragmentTag = SavedPlaylistsFragment.TAG;
} else if (id == R.id.nav_files) {
fragment = new FilesFragment();
fragmentTag = FilesFragment.TAG;
Bundle args = new Bundle();
args.putString(FilesFragment.EXTRA_FILENAME, "");
} else if (id == R.id.nav_search) {
fragment = new SearchFragment();
fragmentTag = SearchFragment.TAG;
} else if (id == R.id.nav_profiles) {
fragment = new ProfilesFragment();
fragmentTag = ProfilesFragment.TAG;
} else if (id == R.id.nav_app_settings) {
fragment = new SettingsFragment();
fragmentTag = SettingsFragment.TAG;
} else if (id == R.id.nav_server_properties) {
fragment = new ServerPropertiesFragment();
fragmentTag = ServerPropertiesFragment.TAG;
} else if (id == R.id.nav_information) {
fragment = new InformationSettingsFragment();
fragmentTag = InformationSettingsFragment.class.getSimpleName();
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
// Do the actual fragment transaction
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.fragment_container, fragment, fragmentTag);
transaction.commit();
return true;
}
Aggregations