Search in sources :

Example 1 with CustomGeneralBottomSheetDialog

use of com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog in project MusicDNA by harjot-oberai.

the class RecentsFragment method onViewCreated.

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

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    fragIcon = (ImageView) view.findViewById(R.id.recents_frag_icon);
    fragIcon.setImageTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    fragTitle = (TextView) view.findViewById(R.id.recents_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    addToQueueIcon = (ImageView) view.findViewById(R.id.add_recents_to_queue_icon);
    addToQueueIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.addRecentsToQueue();
        }
    });
    backdrop = (ImageView) view.findViewById(R.id.recents_backdrop);
    if (HomeActivity.recentlyPlayed.getRecentlyPlayed().size() > 0) {
        UnifiedTrack ut = HomeActivity.recentlyPlayed.getRecentlyPlayed().get(0);
        if (ut.getType()) {
            LocalTrack lt = ut.getLocalTrack();
            imgLoader.DisplayImage(lt.getPath(), backdrop);
        } else {
            Track t = ut.getStreamTrack();
            Picasso.with(getContext()).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(backdrop);
        }
    }
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    noContent = (LinearLayout) view.findViewById(R.id.no_recents_content);
    recentRecycler = (RecyclerView) view.findViewById(R.id.view_recent_recycler);
    rtAdpater = new RecentsTrackAdapter(HomeActivity.recentlyPlayed.getRecentlyPlayed(), this, getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    recentRecycler.setLayoutManager(mLayoutManager2);
    recentRecycler.setItemAnimator(new DefaultItemAnimator());
    recentRecycler.setAdapter(rtAdpater);
    recentRecycler.addOnItemTouchListener(new ClickItemTouchListener(recentRecycler) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            UnifiedTrack ut = HomeActivity.recentlyPlayed.getRecentlyPlayed().get(position);
            boolean isRepeat = false;
            int pos = 0;
            for (int i = 0; i < HomeActivity.queue.getQueue().size(); i++) {
                UnifiedTrack ut1 = HomeActivity.queue.getQueue().get(i);
                if (ut1.getType() && ut.getType() && ut1.getLocalTrack().getTitle().equals(ut.getLocalTrack().getTitle())) {
                    isRepeat = true;
                    pos = i;
                    break;
                }
                if (!ut1.getType() && !ut.getType() && ut1.getStreamTrack().getTitle().equals(ut.getStreamTrack().getTitle())) {
                    isRepeat = true;
                    pos = i;
                    break;
                }
            }
            if (!isRepeat) {
                if (ut.getType()) {
                    LocalTrack track = ut.getLocalTrack();
                    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.onRecentItemClicked(true);
                } else {
                    Track track = ut.getStreamTrack();
                    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.onRecentItemClicked(false);
                }
            } else {
                mCallback.onRecentFromQueue(pos);
            }
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, int position, long id) {
            if (position != -1) {
                final UnifiedTrack ut = HomeActivity.recentlyPlayed.getRecentlyPlayed().get(position);
                CustomGeneralBottomSheetDialog generalBottomSheetDialog = new CustomGeneralBottomSheetDialog();
                generalBottomSheetDialog.setPosition(position);
                generalBottomSheetDialog.setTrack(ut);
                generalBottomSheetDialog.setFragment("Recents");
                generalBottomSheetDialog.show(getActivity().getSupportFragmentManager(), "general_bottom_sheet_dialog");
            }
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    shuffleFab = (FloatingActionButton) view.findViewById(R.id.play_all_fab_recent);
    if (HomeActivity.recentlyPlayed != null && HomeActivity.recentlyPlayed.getRecentlyPlayed().size() > 0) {
        noContent.setVisibility(View.INVISIBLE);
        shuffleFab.setVisibility(View.VISIBLE);
    } else {
        noContent.setVisibility(View.VISIBLE);
        shuffleFab.setVisibility(View.INVISIBLE);
    }
    shuffleFab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    shuffleFab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (HomeActivity.recentlyPlayed.getRecentlyPlayed().size() > 0) {
                HomeActivity.queue.getQueue().clear();
                for (int i = 0; i < HomeActivity.recentlyPlayed.getRecentlyPlayed().size(); i++) {
                    HomeActivity.queue.getQueue().add(HomeActivity.recentlyPlayed.getRecentlyPlayed().get(i));
                }
                Random r = new Random();
                mCallback.onRecentFromQueue(r.nextInt(HomeActivity.queue.getQueue().size()));
            }
        }
    });
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(rtAdpater);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(recentRecycler);
}
Also used : SimpleItemTouchHelperCallback(com.sdsmdg.harjot.MusicDNA.itemtouchhelpers.SimpleItemTouchHelperCallback) 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) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) Random(java.util.Random) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track)

Example 2 with CustomGeneralBottomSheetDialog

use of com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog 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 3 with CustomGeneralBottomSheetDialog

use of com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog 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)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 RecyclerView (android.support.v7.widget.RecyclerView)3 View (android.view.View)3 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)3 CustomGeneralBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog)3 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)2 Track (com.sdsmdg.harjot.MusicDNA.models.Track)2 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 LocalTrackRecyclerAdapter (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalTrackRecyclerAdapter)1 SimpleItemTouchHelperCallback (com.sdsmdg.harjot.MusicDNA.itemtouchhelpers.SimpleItemTouchHelperCallback)1 Random (java.util.Random)1