Search in sources :

Example 1 with StreamMusicFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment in project MusicDNA by harjot-oberai.

the class HomeActivity method updateStreamingList.

private void updateStreamingList(String query) {
    if (!isLocalVisible) {
        mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
        if ((settings.isStreamOnlyOnWifiEnabled() && mWifi.isConnected()) || (!settings.isStreamOnlyOnWifiEnabled())) {
            new Thread(new CancelCall()).start();
            if (!query.equals("")) {
                streamRecyclerContainer.setVisibility(View.VISIBLE);
                startLoadingIndicator();
                Retrofit client = new Retrofit.Builder().baseUrl(Config.API_URL).addConverterFactory(GsonConverterFactory.create()).build();
                StreamService ss = client.create(StreamService.class);
                call = ss.getTracks(query, 75);
                call.enqueue(new Callback<List<Track>>() {

                    @Override
                    public void onResponse(Call<List<Track>> call, Response<List<Track>> response) {
                        if (response.isSuccessful()) {
                            streamingTrackList = response.body();
                            sAdapter = new StreamTracksHorizontalAdapter(streamingTrackList, ctx);
                            LinearLayoutManager mLayoutManager = new LinearLayoutManager(ctx, LinearLayoutManager.HORIZONTAL, false);
                            soundcloudRecyclerView.setLayoutManager(mLayoutManager);
                            soundcloudRecyclerView.setItemAnimator(new DefaultItemAnimator());
                            soundcloudRecyclerView.setAdapter(sAdapter);
                            if (streamingTrackList.size() == 0) {
                                streamRecyclerContainer.setVisibility(GONE);
                            } else {
                                streamRecyclerContainer.setVisibility(View.VISIBLE);
                            }
                            stopLoadingIndicator();
                            (soundcloudRecyclerView.getAdapter()).notifyDataSetChanged();
                            StreamMusicFragment sFrag = (StreamMusicFragment) fragMan.findFragmentByTag("stream");
                            if (sFrag != null) {
                                sFrag.dataChanged();
                            }
                        } else {
                            stopLoadingIndicator();
                        }
                        Log.d("RETRO", response.body() + "");
                    }

                    @Override
                    public void onFailure(Call<List<Track>> call, Throwable t) {
                        Log.d("RETRO1", t.getMessage());
                    }
                });
            } else {
                stopLoadingIndicator();
                streamRecyclerContainer.setVisibility(GONE);
            }
        } else {
            stopLoadingIndicator();
            streamRecyclerContainer.setVisibility(GONE);
        }
    }
}
Also used : StreamService(com.sdsmdg.harjot.MusicDNA.interfaces.StreamService) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) StreamTracksHorizontalAdapter(com.sdsmdg.harjot.MusicDNA.adapters.horizontalrecycleradapters.StreamTracksHorizontalAdapter) StreamMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment) Retrofit(retrofit2.Retrofit) ColorStateList(android.content.res.ColorStateList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with StreamMusicFragment

use of com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment in project MusicDNA by harjot-oberai.

the class HomeActivity method showFragment.

public void showFragment(String type) {
    if (!type.equals("viewAlbum") && !type.equals("folderContent") && !type.equals("viewArtist") && !type.equals("playlist") && !type.equals("newPlaylist") && !type.equals("About") && !type.equals("Edit"))
        hideAllFrags();
    if (!searchView.isIconified()) {
        searchView.setQuery("", true);
        searchView.setIconified(true);
        streamRecyclerContainer.setVisibility(GONE);
        new Thread(new CancelCall()).start();
    }
    if (type.equals("local") && !isLocalVisible) {
        navigationView.setCheckedItem(R.id.nav_local);
        isLocalVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        LocalMusicViewPagerFragment newFragment = (LocalMusicViewPagerFragment) fm.findFragmentByTag("local");
        if (newFragment == null) {
            newFragment = new LocalMusicViewPagerFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "local").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("queue") && !isQueueVisible) {
        hideAllFrags();
        isQueueVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        QueueFragment newFragment = (QueueFragment) fm.findFragmentByTag("queue");
        if (newFragment == null) {
            newFragment = new QueueFragment();
        }
        fm.beginTransaction().add(R.id.equalizer_queue_frag_container, newFragment, "queue").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("stream") && !isStreamVisible) {
        isStreamVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        StreamMusicFragment newFragment = (StreamMusicFragment) fm.findFragmentByTag("stream");
        if (newFragment == null) {
            newFragment = new StreamMusicFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "stream").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("playlist") && !isPlaylistVisible) {
        isPlaylistVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        ViewPlaylistFragment newFragment = (ViewPlaylistFragment) fm.findFragmentByTag("playlist");
        if (newFragment == null) {
            newFragment = new ViewPlaylistFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "playlist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("equalizer") && !isEqualizerVisible) {
        isEqualizerVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        EqualizerFragment newFragment = (EqualizerFragment) fm.findFragmentByTag("equalizer");
        if (newFragment == null) {
            newFragment = new EqualizerFragment();
        }
        fm.beginTransaction().add(R.id.equalizer_queue_frag_container, newFragment, "equalizer").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("favourite") && !isFavouriteVisible) {
        navigationView.setCheckedItem(R.id.nav_fav);
        isFavouriteVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        FavouritesFragment newFragment = (FavouritesFragment) fm.findFragmentByTag("favourite");
        if (newFragment == null) {
            newFragment = new FavouritesFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "favourite").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("newPlaylist") && !isNewPlaylistVisible) {
        navigationView.setCheckedItem(R.id.nav_playlists);
        isNewPlaylistVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        NewPlaylistFragment newFragment = (NewPlaylistFragment) fm.findFragmentByTag("newPlaylist");
        if (newFragment == null) {
            newFragment = new NewPlaylistFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "newPlaylist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("allPlaylists") && !isAllPlaylistVisible) {
        navigationView.setCheckedItem(R.id.nav_playlists);
        isAllPlaylistVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        AllPlaylistsFragment newFragment = (AllPlaylistsFragment) fm.findFragmentByTag("allPlaylists");
        if (newFragment == null) {
            newFragment = new AllPlaylistsFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allPlaylists").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("folderContent") && !isFolderContentVisible) {
        isFolderContentVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        FolderContentFragment newFragment = (FolderContentFragment) fm.findFragmentByTag("folderContent");
        if (newFragment == null) {
            newFragment = new FolderContentFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "folderContent").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("allFolders") && !isAllFolderVisible) {
        navigationView.setCheckedItem(R.id.nav_folder);
        isAllFolderVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        FolderFragment newFragment = (FolderFragment) fm.findFragmentByTag("allFolders");
        if (newFragment == null) {
            newFragment = new FolderFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allFolders").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("allSavedDNAs") && !isAllSavedDnaVisisble) {
        navigationView.setCheckedItem(R.id.nav_view);
        isAllSavedDnaVisisble = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        ViewSavedDNA newFragment = (ViewSavedDNA) fm.findFragmentByTag("allSavedDNAs");
        if (newFragment == null) {
            newFragment = new ViewSavedDNA();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "allSavedDNAs").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("viewAlbum") && !isAlbumVisible) {
        isAlbumVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        ViewAlbumFragment newFragment = (ViewAlbumFragment) fm.findFragmentByTag("viewAlbum");
        if (newFragment == null) {
            newFragment = new ViewAlbumFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "viewAlbum").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("viewArtist") && !isArtistVisible) {
        isArtistVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        ViewArtistFragment newFragment = (ViewArtistFragment) fm.findFragmentByTag("viewArtist");
        if (newFragment == null) {
            newFragment = new ViewArtistFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "viewArtist").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("recent") && !isRecentVisible) {
        navigationView.setCheckedItem(R.id.nav_recent);
        isRecentVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        RecentsFragment newFragment = (RecentsFragment) fm.findFragmentByTag("recent");
        if (newFragment == null) {
            newFragment = new RecentsFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "recent").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("settings") && !isSettingsVisible) {
        isSettingsVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        SettingsFragment newFragment = (SettingsFragment) fm.findFragmentByTag("settings");
        if (newFragment == null) {
            newFragment = new SettingsFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.fragContainer, newFragment, "settings").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("About") && !isAboutVisible) {
        setTitle("About");
        isAboutVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        AboutFragment newFragment = (AboutFragment) fm.findFragmentByTag("About");
        if (newFragment == null) {
            newFragment = new AboutFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "About").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    } else if (type.equals("Edit") && !isEditVisible) {
        isEditVisible = true;
        android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
        EditLocalSongFragment newFragment = (EditLocalSongFragment) fm.findFragmentByTag("Edit");
        if (newFragment == null) {
            newFragment = new EditLocalSongFragment();
        }
        fm.beginTransaction().setCustomAnimations(R.anim.slide_left, R.anim.slide_right, R.anim.slide_left, R.anim.slide_right).add(R.id.content_frag, newFragment, "Edit").show(newFragment).addToBackStack(null).commitAllowingStateLoss();
    }
}
Also used : QueueFragment(com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment) StreamMusicFragment(com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment) SettingsFragment(com.sdsmdg.harjot.MusicDNA.fragments.SettingsFragment.SettingsFragment) FolderFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllFoldersFragment.FolderFragment) ViewAlbumFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewAlbumFragment.ViewAlbumFragment) RecentsFragment(com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment) EditLocalSongFragment(com.sdsmdg.harjot.MusicDNA.fragments.EditSongFragment.EditLocalSongFragment) AboutFragment(com.sdsmdg.harjot.MusicDNA.fragments.AboutFragment.AboutFragment) NewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.NewPlaylistFragment.NewPlaylistFragment) AllPlaylistsFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment) ViewSavedDNA(com.sdsmdg.harjot.MusicDNA.fragments.ViewSavedDNAsFragment.ViewSavedDNA) EqualizerFragment(com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment) FavouritesFragment(com.sdsmdg.harjot.MusicDNA.fragments.FavouritesFragment.FavouritesFragment) LocalMusicViewPagerFragment(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment) ViewArtistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewArtistFragment.ViewArtistFragment) ViewPlaylistFragment(com.sdsmdg.harjot.MusicDNA.fragments.ViewPlaylistFragment.ViewPlaylistFragment) FolderContentFragment(com.sdsmdg.harjot.MusicDNA.fragments.FolderContentFragment.FolderContentFragment)

Aggregations

StreamMusicFragment (com.sdsmdg.harjot.MusicDNA.fragments.StreamFragment.StreamMusicFragment)2 ColorStateList (android.content.res.ColorStateList)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 StreamTracksHorizontalAdapter (com.sdsmdg.harjot.MusicDNA.adapters.horizontalrecycleradapters.StreamTracksHorizontalAdapter)1 AboutFragment (com.sdsmdg.harjot.MusicDNA.fragments.AboutFragment.AboutFragment)1 FolderFragment (com.sdsmdg.harjot.MusicDNA.fragments.AllFoldersFragment.FolderFragment)1 AllPlaylistsFragment (com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment)1 EditLocalSongFragment (com.sdsmdg.harjot.MusicDNA.fragments.EditSongFragment.EditLocalSongFragment)1 EqualizerFragment (com.sdsmdg.harjot.MusicDNA.fragments.EqualizerFragment.EqualizerFragment)1 FavouritesFragment (com.sdsmdg.harjot.MusicDNA.fragments.FavouritesFragment.FavouritesFragment)1 FolderContentFragment (com.sdsmdg.harjot.MusicDNA.fragments.FolderContentFragment.FolderContentFragment)1 LocalMusicViewPagerFragment (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalMusicViewPagerFragment)1 NewPlaylistFragment (com.sdsmdg.harjot.MusicDNA.fragments.NewPlaylistFragment.NewPlaylistFragment)1 QueueFragment (com.sdsmdg.harjot.MusicDNA.fragments.QueueFragment.QueueFragment)1 RecentsFragment (com.sdsmdg.harjot.MusicDNA.fragments.RecentsFragment.RecentsFragment)1 SettingsFragment (com.sdsmdg.harjot.MusicDNA.fragments.SettingsFragment.SettingsFragment)1 ViewAlbumFragment (com.sdsmdg.harjot.MusicDNA.fragments.ViewAlbumFragment.ViewAlbumFragment)1 ViewArtistFragment (com.sdsmdg.harjot.MusicDNA.fragments.ViewArtistFragment.ViewArtistFragment)1 ViewPlaylistFragment (com.sdsmdg.harjot.MusicDNA.fragments.ViewPlaylistFragment.ViewPlaylistFragment)1