Search in sources :

Example 1 with FilesFragment

use of org.gateshipone.malp.application.fragments.serverfragments.FilesFragment 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();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NavigationView(android.support.design.widget.NavigationView) SharedPreferences(android.content.SharedPreferences) Bundle(android.os.Bundle) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) AlbumTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumTracksFragment) ArtworkSettingsFragment(org.gateshipone.malp.application.fragments.ArtworkSettingsFragment) ServerPropertiesFragment(org.gateshipone.malp.application.fragments.serverfragments.ServerPropertiesFragment) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) Fragment(android.support.v4.app.Fragment) ArtistsFragment(org.gateshipone.malp.application.fragments.serverfragments.ArtistsFragment) SettingsFragment(org.gateshipone.malp.application.fragments.SettingsFragment) InformationSettingsFragment(org.gateshipone.malp.application.fragments.InformationSettingsFragment) AlbumsFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumsFragment) SearchFragment(org.gateshipone.malp.application.fragments.serverfragments.SearchFragment) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) EditProfileFragment(org.gateshipone.malp.application.fragments.EditProfileFragment) PlaylistTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) AppBarLayout(android.support.design.widget.AppBarLayout) DrawerLayout(android.support.v4.widget.DrawerLayout) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment) Toolbar(android.support.v7.widget.Toolbar)

Example 2 with FilesFragment

use of org.gateshipone.malp.application.fragments.serverfragments.FilesFragment in project malp by gateship-one.

the class MainActivity method openPath.

@Override
public void openPath(String path) {
    // Create fragment and give it an argument for the selected directory
    FilesFragment newFragment = new FilesFragment();
    Bundle args = new Bundle();
    args.putString(FilesFragment.EXTRA_FILENAME, path);
    newFragment.setArguments(args);
    FragmentManager fragmentManager = getSupportFragmentManager();
    android.support.v4.app.FragmentTransaction transaction = fragmentManager.beginTransaction();
    newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
    newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));
    transaction.addToBackStack("FilesFragment" + path);
    transaction.replace(R.id.fragment_container, newFragment);
    // Commit the transaction
    transaction.commit();
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) Slide(android.transition.Slide) Bundle(android.os.Bundle) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction)

Example 3 with FilesFragment

use of org.gateshipone.malp.application.fragments.serverfragments.FilesFragment 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;
}
Also used : InformationSettingsFragment(org.gateshipone.malp.application.fragments.InformationSettingsFragment) NowPlayingView(org.gateshipone.malp.application.views.NowPlayingView) Bundle(android.os.Bundle) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) SearchFragment(org.gateshipone.malp.application.fragments.serverfragments.SearchFragment) ServerPropertiesFragment(org.gateshipone.malp.application.fragments.serverfragments.ServerPropertiesFragment) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) CurrentPlaylistView(org.gateshipone.malp.application.views.CurrentPlaylistView) TextView(android.widget.TextView) NowPlayingView(org.gateshipone.malp.application.views.NowPlayingView) AlbumTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumTracksFragment) ArtworkSettingsFragment(org.gateshipone.malp.application.fragments.ArtworkSettingsFragment) ServerPropertiesFragment(org.gateshipone.malp.application.fragments.serverfragments.ServerPropertiesFragment) FilesFragment(org.gateshipone.malp.application.fragments.serverfragments.FilesFragment) ProfilesFragment(org.gateshipone.malp.application.fragments.ProfilesFragment) Fragment(android.support.v4.app.Fragment) ArtistsFragment(org.gateshipone.malp.application.fragments.serverfragments.ArtistsFragment) SettingsFragment(org.gateshipone.malp.application.fragments.SettingsFragment) InformationSettingsFragment(org.gateshipone.malp.application.fragments.InformationSettingsFragment) AlbumsFragment(org.gateshipone.malp.application.fragments.serverfragments.AlbumsFragment) SearchFragment(org.gateshipone.malp.application.fragments.serverfragments.SearchFragment) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) EditProfileFragment(org.gateshipone.malp.application.fragments.EditProfileFragment) PlaylistTracksFragment(org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment) FragmentManager(android.support.v4.app.FragmentManager) ArtworkSettingsFragment(org.gateshipone.malp.application.fragments.ArtworkSettingsFragment) SettingsFragment(org.gateshipone.malp.application.fragments.SettingsFragment) InformationSettingsFragment(org.gateshipone.malp.application.fragments.InformationSettingsFragment) FragmentTransaction(android.support.v4.app.FragmentTransaction) MyMusicTabsFragment(org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment) DrawerLayout(android.support.v4.widget.DrawerLayout) SavedPlaylistsFragment(org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment)

Aggregations

Bundle (android.os.Bundle)3 FragmentTransaction (android.support.v4.app.FragmentTransaction)3 FilesFragment (org.gateshipone.malp.application.fragments.serverfragments.FilesFragment)3 NavigationView (android.support.design.widget.NavigationView)2 Fragment (android.support.v4.app.Fragment)2 FragmentManager (android.support.v4.app.FragmentManager)2 DrawerLayout (android.support.v4.widget.DrawerLayout)2 ArtworkSettingsFragment (org.gateshipone.malp.application.fragments.ArtworkSettingsFragment)2 EditProfileFragment (org.gateshipone.malp.application.fragments.EditProfileFragment)2 InformationSettingsFragment (org.gateshipone.malp.application.fragments.InformationSettingsFragment)2 ProfilesFragment (org.gateshipone.malp.application.fragments.ProfilesFragment)2 SettingsFragment (org.gateshipone.malp.application.fragments.SettingsFragment)2 AlbumTracksFragment (org.gateshipone.malp.application.fragments.serverfragments.AlbumTracksFragment)2 AlbumsFragment (org.gateshipone.malp.application.fragments.serverfragments.AlbumsFragment)2 ArtistsFragment (org.gateshipone.malp.application.fragments.serverfragments.ArtistsFragment)2 MyMusicTabsFragment (org.gateshipone.malp.application.fragments.serverfragments.MyMusicTabsFragment)2 PlaylistTracksFragment (org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment)2 SavedPlaylistsFragment (org.gateshipone.malp.application.fragments.serverfragments.SavedPlaylistsFragment)2 SearchFragment (org.gateshipone.malp.application.fragments.serverfragments.SearchFragment)2 ServerPropertiesFragment (org.gateshipone.malp.application.fragments.serverfragments.ServerPropertiesFragment)2