Search in sources :

Example 26 with LocalTrack

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

the class FavouritesFragment method updateFavFragment.

@Override
public void updateFavFragment() {
    if (HomeActivity.favouriteTracks.getFavourite().size() > 0) {
        UnifiedTrack ut = HomeActivity.favouriteTracks.getFavourite().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)

Example 27 with LocalTrack

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

the class FolderFragment method initializeHeaderImages.

public void initializeHeaderImages(View v) {
    imgView[0] = (ImageView) v.findViewById(R.id.all_folder_img_1);
    imgView[1] = (ImageView) v.findViewById(R.id.all_folder_img_2);
    imgView[2] = (ImageView) v.findViewById(R.id.all_folder_img_3);
    imgView[3] = (ImageView) v.findViewById(R.id.all_folder_img_4);
    imgView[4] = (ImageView) v.findViewById(R.id.all_folder_img_5);
    imgView[5] = (ImageView) v.findViewById(R.id.all_folder_img_6);
    imgView[6] = (ImageView) v.findViewById(R.id.all_folder_img_7);
    imgView[7] = (ImageView) v.findViewById(R.id.all_folder_img_8);
    imgView[8] = (ImageView) v.findViewById(R.id.all_folder_img_9);
    imgView[9] = (ImageView) v.findViewById(R.id.all_folder_img_10);
    int numFolders = HomeActivity.allMusicFolders.getMusicFolders().size();
    MusicFolder mf1, mf2;
    if (numFolders == 0) {
        for (int i = 0; i < 10; i++) {
            imgLoader.DisplayImage("folder" + i, imgView[i]);
        }
    } else if (numFolders == 1) {
        mf1 = HomeActivity.allMusicFolders.getMusicFolders().get(0);
        for (int i = 0; i < Math.min(10, mf1.getLocalTracks().size()); i++) {
            imgLoader.DisplayImage(mf1.getLocalTracks().get(i).getPath(), imgView[i]);
        }
        if (mf1.getLocalTracks().size() < 10) {
            for (int i = mf1.getLocalTracks().size(); i < 10; i++) {
                imgLoader.DisplayImage("folder" + i, imgView[i]);
            }
        }
    } else {
        mf1 = HomeActivity.allMusicFolders.getMusicFolders().get(0);
        mf2 = HomeActivity.allMusicFolders.getMusicFolders().get(1);
        for (int i = 0; i < Math.min(10, mf1.getLocalTracks().size()); i++) {
            imgLoader.DisplayImage(mf1.getLocalTracks().get(i).getPath(), imgView[i]);
        }
        if (mf1.getLocalTracks().size() < 10) {
            if (mf2.getLocalTracks().size() >= (10 - mf1.getLocalTracks().size())) {
                for (int i = mf1.getLocalTracks().size(); i < 10; i++) {
                    LocalTrack lt = mf2.getLocalTracks().get(i - mf1.getLocalTracks().size());
                    imgLoader.DisplayImage(lt.getPath(), imgView[i]);
                }
            } else {
                for (int i = mf1.getLocalTracks().size(); i < mf1.getLocalTracks().size() + mf2.getLocalTracks().size(); i++) {
                    LocalTrack lt = mf2.getLocalTracks().get(i - mf1.getLocalTracks().size());
                    imgLoader.DisplayImage(lt.getPath(), imgView[i]);
                }
                for (int i = mf1.getLocalTracks().size() + mf2.getLocalTracks().size(); i < 10; i++) {
                    imgLoader.DisplayImage("folder" + i, imgView[i]);
                }
            }
        }
    }
}
Also used : LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) MusicFolder(com.sdsmdg.harjot.MusicDNA.models.MusicFolder)

Example 28 with LocalTrack

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

the class FolderRecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    MusicFolder mf = musicFolders.get(position);
    List<LocalTrack> list = mf.getLocalTracks();
    //        holder.playListName.setText(mf.getFolderName() + " (" + mf.getLocalTracks().size() + ")");
    holder.playListName.setText(mf.getFolderName());
    if (list.size() >= 3) {
        String[] names = new String[3];
        for (int i = 0; i < 3; i++) {
            names[i] = list.get(i).getTitle();
            imgLoader.DisplayImage(list.get(i).getPath(), holder.img[i]);
            holder.name[i].setText(names[i]);
        }
        holder.continuedSymbol.setVisibility(View.VISIBLE);
    } else {
        int sz = list.size();
        String[] names = new String[3];
        for (int i = 0; i < sz; i++) {
            names[i] = list.get(i).getTitle();
            imgLoader.DisplayImage(list.get(i).getPath(), holder.img[i]);
            holder.name[i].setText(names[i]);
        }
    }
}
Also used : LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) MusicFolder(com.sdsmdg.harjot.MusicDNA.models.MusicFolder)

Example 29 with LocalTrack

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

the class HomeActivity method addArtistToQueue.

@Override
public void addArtistToQueue() {
    List<LocalTrack> list = tempArtist.getArtistSongs();
    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 30 with LocalTrack

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

the class HomeActivity method onQueueItemClicked.

////////////////////////////////////////////////////////////////////////////////////////////////
/*
     *  QueueFragment callbacks START
     *  onQueueItemClicked() -> when a song is selected from queue.
     *  onQueueSave() -> queue save as playlist fab is clicked.
     *  onQueueClear() -> when queue clear option is selected.
     */
@Override
public void onQueueItemClicked(final int position) {
    if (isPlayerVisible && isQueueVisible)
        showPlayer3();
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        @Override
        public void run() {
            queueCurrentIndex = position;
            UnifiedTrack ut = queue.getQueue().get(position);
            if (ut.getType()) {
                LocalTrack track = ut.getLocalTrack();
                localSelectedTrack = track;
                streamSelected = false;
                localSelected = true;
                queueCall = false;
                isReloaded = false;
                onLocalTrackSelected(position);
            } else {
                Track track = ut.getStreamTrack();
                selectedTrack = track;
                streamSelected = true;
                localSelected = false;
                queueCall = false;
                isReloaded = false;
                onTrackSelected(position);
            }
        }
    }, 500);
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) Handler(android.os.Handler) 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)

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