Search in sources :

Example 61 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MusicDNA by harjot-oberai.

the class LocalMusicFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    shuffleFab = (FloatingActionButton) view.findViewById(R.id.play_all_fab_local);
    if (HomeActivity.localTrackList.size() == 0) {
        shuffleFab.setVisibility(View.INVISIBLE);
    }
    shuffleFab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    shuffleFab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HomeActivity.queue.getQueue().clear();
            for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
                UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
                HomeActivity.queue.getQueue().add(ut);
            }
            if (HomeActivity.queue.getQueue().size() > 0) {
                Random r = new Random();
                int tmp = r.nextInt(HomeActivity.queue.getQueue().size());
                HomeActivity.queueCurrentIndex = tmp;
                LocalTrack track = HomeActivity.localTrackList.get(tmp);
                HomeActivity.localSelectedTrack = track;
                HomeActivity.streamSelected = false;
                HomeActivity.localSelected = true;
                HomeActivity.queueCall = false;
                HomeActivity.isReloaded = false;
                mCallback.onLocalTrackSelected(-1);
            }
        }
    });
    lv = (RecyclerView) view.findViewById(R.id.localMusicList);
    adapter = new LocalTrackRecyclerAdapter(HomeActivity.finalLocalSearchResultList, getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    lv.setLayoutManager(mLayoutManager2);
    lv.setItemAnimator(new DefaultItemAnimator());
    lv.setAdapter(adapter);
    lv.addOnItemTouchListener(new ClickItemTouchListener(lv) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            if (position >= 0) {
                HomeActivity.queue.getQueue().clear();
                for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
                    UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
                    HomeActivity.queue.getQueue().add(ut);
                }
                HomeActivity.queueCurrentIndex = getPosition(HomeActivity.finalLocalSearchResultList.get(position));
                LocalTrack track = HomeActivity.finalLocalSearchResultList.get(position);
                HomeActivity.localSelectedTrack = track;
                HomeActivity.streamSelected = false;
                HomeActivity.localSelected = true;
                HomeActivity.queueCall = false;
                HomeActivity.isReloaded = false;
                mCallback.onLocalTrackSelected(-1);
            }
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
            if (position >= 0) {
                CustomLocalBottomSheetDialog localBottomSheetDialog = new CustomLocalBottomSheetDialog();
                localBottomSheetDialog.setPosition(position);
                localBottomSheetDialog.setLocalTrack(activity.finalLocalSearchResultList.get(position));
                localBottomSheetDialog.show(activity.getSupportFragmentManager(), "local_song_bottom_sheet");
            }
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    Button mEndButton = new Button(getContext());
    mEndButton.setBackgroundColor(HomeActivity.themeColor);
    mEndButton.setTextColor(Color.WHITE);
    showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(1).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.songs_tab_alt_showcase, getActivity())).setContentTitle("All Songs").setContentText("All local Songs listed here.Click to Play.Long click for more options").build();
    showCase.setButtonText("Next");
    showCase.setButtonPosition(HomeActivity.lps);
    showCase.overrideButtonClick(new View.OnClickListener() {

        int count1 = 0;

        @Override
        public void onClick(View v) {
            count1++;
            switch(count1) {
                case 1:
                    RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                    lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
                    lps.setMargins(margin, margin, margin, 5 + HomeActivity.navBarHeightSizeinDp);
                    showCase.setTarget(new ViewTarget(shuffleFab.getId(), getActivity()));
                    showCase.setContentTitle("Shuffle");
                    showCase.setContentText("Play all songs, shuffled randomly");
                    showCase.setButtonText("Done");
                    showCase.setButtonPosition(lps);
                    break;
                case 2:
                    showCase.hide();
                    break;
            }
        }
    });
}
Also used : LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) Random(java.util.Random) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RelativeLayout(android.widget.RelativeLayout) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView)

Example 62 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MusicDNA by harjot-oberai.

the class StreamMusicFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    lv = (RecyclerView) view.findViewById(R.id.trackList);
    adapter = new StreamTrackListAdapter(getContext(), HomeActivity.streamingTrackList);
    LinearLayoutManager mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    lv.setLayoutManager(mLayoutManager2);
    lv.setItemAnimator(new DefaultItemAnimator());
    lv.setAdapter(adapter);
    lv.addOnItemTouchListener(new ClickItemTouchListener(lv) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            Track track = HomeActivity.streamingTrackList.get(position);
            if (HomeActivity.queue.getQueue().size() == 0) {
                HomeActivity.queueCurrentIndex = 0;
                HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
            } else if (HomeActivity.queueCurrentIndex == HomeActivity.queue.getQueue().size() - 1) {
                HomeActivity.queueCurrentIndex++;
                HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
            } else if (HomeActivity.isReloaded) {
                HomeActivity.isReloaded = false;
                HomeActivity.queueCurrentIndex = HomeActivity.queue.getQueue().size();
                HomeActivity.queue.getQueue().add(new UnifiedTrack(false, null, track));
            } else {
                HomeActivity.queue.getQueue().add(++HomeActivity.queueCurrentIndex, new UnifiedTrack(false, null, track));
            }
            HomeActivity.selectedTrack = track;
            HomeActivity.streamSelected = true;
            HomeActivity.localSelected = false;
            HomeActivity.queueCall = false;
            HomeActivity.isReloaded = false;
            mCallback.onTrackSelected(position);
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
            CustomGeneralBottomSheetDialog generalBottomSheetDialog = new CustomGeneralBottomSheetDialog();
            generalBottomSheetDialog.setPosition(position);
            generalBottomSheetDialog.setTrack(new UnifiedTrack(false, null, HomeActivity.streamingTrackList.get(position)));
            generalBottomSheetDialog.setFragment("Stream");
            generalBottomSheetDialog.show(getActivity().getSupportFragmentManager(), "general_bottom_sheet_dialog");
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) Track(com.sdsmdg.harjot.MusicDNA.models.Track) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 63 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MusicDNA by harjot-oberai.

the class FolderContentFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    fragmentTitle = (TextView) view.findViewById(R.id.folder_fragment_title);
    if (SplashActivity.tf4 != null)
        fragmentTitle.setTypeface(SplashActivity.tf4);
    title = (TextView) view.findViewById(R.id.folder_title);
    title.setText(HomeActivity.tempMusicFolder.getFolderName());
    songsText = (TextView) view.findViewById(R.id.folder_tracks_text);
    String s = "";
    if (HomeActivity.tempMusicFolder.getLocalTracks().size() > 1)
        s = "Songs";
    else
        s = "Song";
    songsText.setText(HomeActivity.tempMusicFolder.getLocalTracks().size() + " " + s);
    backBtn = (ImageView) view.findViewById(R.id.folder_content_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    addToQueueIcon = (ImageView) view.findViewById(R.id.add_folder_to_queue_icon);
    addToQueueIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.folderAddToQueue();
        }
    });
    backdrop = (ImageView) view.findViewById(R.id.folder_backdrop);
    LocalTrack lt = HomeActivity.tempFolderContent.get(0);
    imgLoader.DisplayImage(lt.getPath(), backdrop);
    folderContentRecycler = (RecyclerView) view.findViewById(R.id.folder_content_recycler);
    fContentAdapter = new LocalTrackRecyclerAdapter(HomeActivity.tempFolderContent, getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    folderContentRecycler.setLayoutManager(mLayoutManager2);
    folderContentRecycler.setItemAnimator(new DefaultItemAnimator());
    folderContentRecycler.setAdapter(fContentAdapter);
    folderContentRecycler.addOnItemTouchListener(new ClickItemTouchListener(folderContentRecycler) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            LocalTrack track = HomeActivity.tempMusicFolder.getLocalTracks().get(position);
            if (HomeActivity.queue.getQueue().size() == 0) {
                HomeActivity.queueCurrentIndex = 0;
                HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
            } else if (HomeActivity.queueCurrentIndex == HomeActivity.queue.getQueue().size() - 1) {
                HomeActivity.queueCurrentIndex++;
                HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
            } else if (HomeActivity.isReloaded) {
                HomeActivity.isReloaded = false;
                HomeActivity.queueCurrentIndex = HomeActivity.queue.getQueue().size();
                HomeActivity.queue.getQueue().add(new UnifiedTrack(true, track, null));
            } else {
                HomeActivity.queue.getQueue().add(++HomeActivity.queueCurrentIndex, new UnifiedTrack(true, track, null));
            }
            HomeActivity.localSelectedTrack = track;
            HomeActivity.streamSelected = false;
            HomeActivity.localSelected = true;
            HomeActivity.queueCall = false;
            HomeActivity.isReloaded = false;
            mCallback.onFolderContentItemClick(position);
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
            UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.tempMusicFolder.getLocalTracks().get(position), null);
            CustomGeneralBottomSheetDialog generalBottomSheetDialog = new CustomGeneralBottomSheetDialog();
            generalBottomSheetDialog.setPosition(position);
            generalBottomSheetDialog.setTrack(ut);
            generalBottomSheetDialog.setFragment("Folder");
            generalBottomSheetDialog.show(getActivity().getSupportFragmentManager(), "general_bottom_sheet_dialog");
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    playAllFAB = (FloatingActionButton) view.findViewById(R.id.folder_play_all_fab);
    playAllFAB.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    playAllFAB.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.onFolderContentPlayAll();
        }
    });
}
Also used : LocalTrackRecyclerAdapter(com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalTrackRecyclerAdapter) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)

Example 64 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MusicDNA by harjot-oberai.

the class ArtistFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.setVisibility(View.GONE);
    else
        bottomMarginLayout.setVisibility(View.VISIBLE);
    rv = (RecyclerView) view.findViewById(R.id.artists_recycler);
    arAdapter = new ArtistRecyclerAdapter(HomeActivity.finalArtists);
    llManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    rv.setLayoutManager(llManager);
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(arAdapter);
    rv.addOnItemTouchListener(new ClickItemTouchListener(rv) {

        @Override
        boolean onClick(RecyclerView parent, View view, int position, long id) {
            HomeActivity.tempArtist = HomeActivity.finalArtists.get(position);
            mCallback.onArtistClick();
            return true;
        }

        @Override
        boolean onLongClick(RecyclerView parent, View view, int position, long id) {
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 65 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project MusicDNA by harjot-oberai.

the class FolderFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    backBtn = (ImageView) view.findViewById(R.id.all_folder_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragmentTitle = (TextView) view.findViewById(R.id.all_folder_fragment_title);
    if (SplashActivity.tf4 != null)
        fragmentTitle.setTypeface(SplashActivity.tf4);
    fragIcon = (ImageView) view.findViewById(R.id.all_folder_frag_icon);
    fragIcon.setImageTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    initializeHeaderImages(view);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    allFoldersRecycler = (RecyclerView) view.findViewById(R.id.all_folders_recycler);
    mfAdapter = new FolderRecyclerAdapter(HomeActivity.allMusicFolders.getMusicFolders(), getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    allFoldersRecycler.setLayoutManager(mLayoutManager2);
    allFoldersRecycler.setItemAnimator(new DefaultItemAnimator());
    allFoldersRecycler.setAdapter(mfAdapter);
    allFoldersRecycler.addOnItemTouchListener(new ClickItemTouchListener(allFoldersRecycler) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            mCallback.onFolderClicked(position);
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)103 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)72 RecyclerView (android.support.v7.widget.RecyclerView)63 View (android.view.View)55 TextView (android.widget.TextView)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)16 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)14 GridLayoutManager (android.support.v7.widget.GridLayoutManager)13 Toolbar (android.support.v7.widget.Toolbar)13 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)10 FastAdapter (com.mikepenz.fastadapter.FastAdapter)10 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)10 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)9 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)8 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)8 DividerItemDecoration (de.madcyph3r.example.DividerItemDecoration)8 Button (android.widget.Button)7 Random (java.util.Random)6 Intent (android.content.Intent)5