Search in sources :

Example 51 with UnifiedTrack

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

Aggregations

UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)51 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)25 RecyclerView (android.support.v7.widget.RecyclerView)17 View (android.view.View)17 Track (com.sdsmdg.harjot.MusicDNA.models.Track)16 ImageView (android.widget.ImageView)14 TextView (android.widget.TextView)14 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)11 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)11 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)11 TextPaint (android.text.TextPaint)9 Playlist (com.sdsmdg.harjot.MusicDNA.models.Playlist)8 CustomLocalBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog)7 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)6 HomeActivity (com.sdsmdg.harjot.MusicDNA.activities.HomeActivity)6 CustomGeneralBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog)6 Button (android.widget.Button)5 VisualizerView (com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView)4 Dialog (android.app.Dialog)3 Handler (android.os.Handler)3