Search in sources :

Example 21 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.

the class NewPlaylistRecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    LocalTrack track = localTracks.get(position);
    holder.title.setText(track.getTitle());
    holder.artist.setText(track.getArtist());
    LocalTrack lt = localTracks.get(position);
    if (HomeActivity.finalSelectedTracks.contains(lt)) {
        holder.cb.setChecked(true);
    } else {
        holder.cb.setChecked(false);
    }
    imgLoader.DisplayImage(track.getPath(), holder.art);
}
Also used : LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack)

Example 22 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.

the class RecentsTrackAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecentsTrackAdapter.MyViewHolder holder, int position) {
    UnifiedTrack ut = songList.get(position);
    if (ut.getType()) {
        LocalTrack lt = ut.getLocalTrack();
        imgLoader.DisplayImage(lt.getPath(), holder.art);
        holder.title.setText(lt.getTitle());
        holder.artist.setText(lt.getArtist());
    } else {
        Track t = ut.getStreamTrack();
        Picasso.with(ctx).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(holder.art);
        holder.title.setText(t.getTitle());
        holder.artist.setText("");
    }
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 23 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.

the class QueueRecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
    if (HomeActivity.queueCurrentIndex == position && !HomeActivity.isReloaded) {
        holder.title.setTextColor(HomeActivity.themeColor);
        holder.title.setTypeface(null, Typeface.BOLD);
        holder.indicator.setVisibility(View.VISIBLE);
        if (PlayerFragment.mMediaPlayer != null) {
            if (PlayerFragment.mMediaPlayer.isPlaying()) {
                holder.indicator.play();
            } else {
                holder.indicator.pause();
            }
        }
    } else {
        holder.title.setTextColor(Color.WHITE);
        holder.title.setTypeface(null, Typeface.NORMAL);
        holder.indicator.setVisibility(View.INVISIBLE);
    }
    holder.holderImg.setColorFilter(HomeActivity.themeColor);
    holder.indicator.setDrawColor(HomeActivity.themeColor);
    UnifiedTrack ut = queue.get(position);
    if (ut.getType()) {
        LocalTrack lt = ut.getLocalTrack();
        imgLoader.DisplayImage(lt.getPath(), holder.art);
        holder.title.setText(lt.getTitle());
        holder.artist.setText(lt.getArtist());
    } else {
        Track t = ut.getStreamTrack();
        Picasso.with(ctx).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(holder.art);
        holder.title.setText(t.getTitle());
        holder.artist.setText("");
    }
    holder.holderImg.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
                mDragStartListener.onDragStarted(holder);
            }
            return false;
        }
    });
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) MotionEvent(android.view.MotionEvent)

Example 24 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack 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 25 with LocalTrack

use of com.sdsmdg.harjot.MusicDNA.models.LocalTrack in project MusicDNA by harjot-oberai.

the class FavouriteTrackAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
    UnifiedTrack ut = favouriteList.get(position);
    if (ut.getType()) {
        LocalTrack lt = ut.getLocalTrack();
        imgLoader.DisplayImage(lt.getPath(), holder.art);
        holder.title.setText(lt.getTitle());
        holder.artist.setText(lt.getArtist());
    } else {
        Track t = ut.getStreamTrack();
        Picasso.with(ctx).load(t.getArtworkURL()).resize(100, 100).error(R.drawable.ic_default).placeholder(R.drawable.ic_default).into(holder.art);
        holder.title.setText(t.getTitle());
        holder.artist.setText("");
    }
    holder.holderImg.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
                mDragStartListener.onDragStarted(holder);
            }
            return false;
        }
    });
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) MotionEvent(android.view.MotionEvent)

Aggregations

LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)32 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)24 Track (com.sdsmdg.harjot.MusicDNA.models.Track)15 RecyclerView (android.support.v7.widget.RecyclerView)12 View (android.view.View)12 ImageView (android.widget.ImageView)11 TextView (android.widget.TextView)11 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)8 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)8 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)8 TextPaint (android.text.TextPaint)4 CustomLocalBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog)4 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)3 MotionEvent (android.view.MotionEvent)3 CustomGeneralBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog)3 LocalTrackRecyclerAdapter (com.sdsmdg.harjot.MusicDNA.fragments.LocalMusicFragments.LocalTrackRecyclerAdapter)3 SimpleItemTouchHelperCallback (com.sdsmdg.harjot.MusicDNA.itemtouchhelpers.SimpleItemTouchHelperCallback)3 FileNotFoundException (java.io.FileNotFoundException)3 Random (java.util.Random)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2