Search in sources :

Example 11 with LocalTrack

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

the class HomeActivity method folderAddToQueue.

@Override
public void folderAddToQueue() {
    List<LocalTrack> list = tempFolderContent;
    for (LocalTrack lt : list) {
        HomeActivity.queue.addToQueue(new UnifiedTrack(true, lt, null));
    }
    if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
        playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
        playerFragment.snappyRecyclerView.setTransparency();
    }
    Toast.makeText(ctx, "Added " + list.size() + " song(s) to queue", Toast.LENGTH_SHORT).show();
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack)

Example 12 with LocalTrack

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

the class HomeActivity method onFavouriteItemClicked.

////////////////////////////////////////////////////////////////////////////////////////////////
/*
     *  FavouriteFragment callbacks START
     *  onFavouriteItemClicked() -> when a song is selected from favourites.
     *  onFavouritePlayAll() -> when favourite play all fab is selected.
     *  addFavToQueue() -> when `add favourite to queue` is selected.
     */
@Override
public void onFavouriteItemClicked(int position) {
    UnifiedTrack ut = favouriteTracks.getFavourite().get(position);
    if (ut.getType()) {
        LocalTrack track = ut.getLocalTrack();
        if (queue.getQueue().size() == 0) {
            queueCurrentIndex = 0;
            queue.getQueue().add(new UnifiedTrack(true, track, null));
        } else if (queueCurrentIndex == queue.getQueue().size() - 1) {
            queueCurrentIndex++;
            queue.getQueue().add(new UnifiedTrack(true, track, null));
        } else if (isReloaded) {
            isReloaded = false;
            queueCurrentIndex = queue.getQueue().size();
            queue.getQueue().add(new UnifiedTrack(true, track, null));
        } else {
            queue.getQueue().add(++queueCurrentIndex, new UnifiedTrack(true, track, null));
        }
        localSelectedTrack = track;
        streamSelected = false;
        localSelected = true;
        queueCall = false;
        isReloaded = false;
        onLocalTrackSelected(position);
    } else {
        Track track = ut.getStreamTrack();
        if (queue.getQueue().size() == 0) {
            queueCurrentIndex = 0;
            queue.getQueue().add(new UnifiedTrack(false, null, track));
        } else if (queueCurrentIndex == queue.getQueue().size() - 1) {
            queueCurrentIndex++;
            queue.getQueue().add(new UnifiedTrack(false, null, track));
        } else if (isReloaded) {
            isReloaded = false;
            queueCurrentIndex = queue.getQueue().size();
            queue.getQueue().add(new UnifiedTrack(false, null, track));
        } else {
            queue.getQueue().add(++queueCurrentIndex, new UnifiedTrack(false, null, track));
        }
        selectedTrack = track;
        streamSelected = true;
        localSelected = false;
        queueCall = false;
        isReloaded = false;
        onTrackSelected(position);
    }
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track)

Example 13 with LocalTrack

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

the class PlaylistTrackAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final PlaylistTrackAdapter.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("");
    }
    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 14 with LocalTrack

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

the class ViewPlaylistFragment 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.playlist_fragment_title);
    if (SplashActivity.tf4 != null)
        fragmentTitle.setTypeface(SplashActivity.tf4);
    title = (TextView) view.findViewById(R.id.playlist_title);
    title.setText(HomeActivity.tempPlaylist.getPlaylistName());
    songsText = (TextView) view.findViewById(R.id.playlist_tracks_text);
    String s = "";
    if (HomeActivity.tempPlaylist.getSongList().size() > 1)
        s = "Songs";
    else
        s = "Song";
    songsText.setText(HomeActivity.tempPlaylist.getSongList().size() + " " + s);
    backBtn = (ImageView) view.findViewById(R.id.view_playlist_back_btn);
    backBtn.setOnClickListener(new View.OnClickListener() {

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

        @Override
        public void onClick(View v) {
            mCallback.playlistRename();
        }
    });
    addToQueueIcon = (ImageView) view.findViewById(R.id.add_playlist_to_queue_icon);
    addToQueueIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.playlistAddToQueue();
        }
    });
    backdrop = (ImageView) view.findViewById(R.id.playlist_backdrop);
    UnifiedTrack ut = HomeActivity.tempPlaylist.getSongList().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);
    }
    playlistRecyler = (RecyclerView) view.findViewById(R.id.view_playlist_recycler);
    plAdapter = new PlaylistTrackAdapter(HomeActivity.tempPlaylist.getSongList(), this, getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    playlistRecyler.setLayoutManager(mLayoutManager2);
    playlistRecyler.setItemAnimator(new DefaultItemAnimator());
    playlistRecyler.setAdapter(plAdapter);
    playlistRecyler.addOnItemTouchListener(new ClickItemTouchListener(playlistRecyler) {

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

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

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    playAll = (FloatingActionButton) view.findViewById(R.id.play_all_fab);
    if (HomeActivity.tempPlaylist.getSongList().size() == 0) {
        playAll.setVisibility(View.GONE);
    }
    playAll.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    playAll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int size = HomeActivity.tempPlaylist.getSongList().size();
            HomeActivity.queue.getQueue().clear();
            for (int i = 0; i < size; i++) {
                HomeActivity.queue.addToQueue(HomeActivity.tempPlaylist.getSongList().get(i));
            }
            HomeActivity.queueCurrentIndex = 0;
            mCallback.onPlaylistPlayAll();
        }
    });
    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback(plAdapter);
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(playlistRecyler);
}
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) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) 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 15 with LocalTrack

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

the class ViewPlaylistFragment method updateViewPlaylistFragment.

@Override
public void updateViewPlaylistFragment() {
    title.setText(HomeActivity.tempPlaylist.getPlaylistName());
    String s = "";
    if (HomeActivity.tempPlaylist.getSongList().size() > 1)
        s = "Songs";
    else
        s = "Song";
    songsText.setText(HomeActivity.tempPlaylist.getSongList().size() + " " + s);
    UnifiedTrack ut = HomeActivity.tempPlaylist.getSongList().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);
    }
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) Track(com.sdsmdg.harjot.MusicDNA.models.Track)

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