Search in sources :

Example 1 with UnifiedTrack

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

the class ViewAlbumFragment method onViewCreated.

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

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    backDrop = (ImageView) view.findViewById(R.id.album_backdrop);
    imgLoader.DisplayImage(HomeActivity.tempAlbum.getAlbumSongs().get(0).getPath(), backDrop);
    fragTitle = (TextView) view.findViewById(R.id.album_fragment_title);
    if (SplashActivity.tf4 != null)
        fragTitle.setTypeface(SplashActivity.tf4);
    albumTitle = (TextView) view.findViewById(R.id.album_title);
    albumTitle.setText(HomeActivity.tempAlbum.getName());
    albumTracksText = (TextView) view.findViewById(R.id.album_tracks_text);
    addToQueueIcon = (ImageView) view.findViewById(R.id.add_album_to_queue_icon);
    addToQueueIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.addAlbumToQueue();
        }
    });
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    int tmp = HomeActivity.tempAlbum.getAlbumSongs().size();
    String details1;
    if (tmp == 1) {
        details1 = "1 Song ";
    } else {
        details1 = tmp + " Songs ";
    }
    albumTracksText.setText(details1);
    fab = (FloatingActionButton) view.findViewById(R.id.play_all_from_album);
    fab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    rv = (RecyclerView) view.findViewById(R.id.album_songs_recycler);
    aslAdapter = new LocalTrackRecyclerAdapter(HomeActivity.tempAlbum.getAlbumSongs(), getContext());
    LinearLayoutManager mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    rv.setLayoutManager(mLayoutManager2);
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(aslAdapter);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HomeActivity.queue.getQueue().clear();
            for (int i = 0; i < HomeActivity.tempAlbum.getAlbumSongs().size(); i++) {
                UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.tempAlbum.getAlbumSongs().get(i), null);
                HomeActivity.queue.getQueue().add(ut);
            }
            mCallback.onAlbumPlayAll();
        }
    });
    rv.addOnItemTouchListener(new ClickItemTouchListener(rv) {

        @Override
        public boolean onClick(RecyclerView parent, View view, int position, long id) {
            LocalTrack track = HomeActivity.tempAlbum.getAlbumSongs().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.onAlbumSongClick();
            return true;
        }

        @Override
        public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
            CustomLocalBottomSheetDialog localBottomSheetDialog = new CustomLocalBottomSheetDialog();
            localBottomSheetDialog.setPosition(position);
            localBottomSheetDialog.setLocalTrack(activity.tempAlbum.getAlbumSongs().get(position));
            localBottomSheetDialog.setFragment("Album");
            localBottomSheetDialog.show(activity.getSupportFragmentManager(), "local_song_bottom_sheet");
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
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) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)

Example 2 with UnifiedTrack

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

the class PlaylistTrackAdapter method onItemMove.

@Override
public void onItemMove(int fromPosition, int toPosition) {
    UnifiedTrack prev = songList.remove(fromPosition);
    songList.add(toPosition, prev);
    notifyItemMoved(fromPosition, toPosition);
    if (homeActivity.pAdapter != null)
        homeActivity.pAdapter.notifyDataSetChanged();
    homeActivity.updateAllPlaylistFragment();
    mCallback2.updateViewPlaylistFragment();
    new HomeActivity.SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 3 with UnifiedTrack

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

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

the class PlayListsHorizontalAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    Playlist pl = playlists.get(position);
    List<UnifiedTrack> list = pl.getSongList();
    for (int i = 0; i < 4; i++) {
        holder.img[i].setImageBitmap(null);
    }
    if (list.size() >= 4) {
        for (int i = 0; i < 4; i++) {
            if (list.get(i).getType()) {
                imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
            } else {
                imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
            }
        }
    } else {
        int sz = list.size();
        for (int i = 0; i < sz; i++) {
            if (list.get(i).getType()) {
                imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
            } else {
                imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
            }
        }
    }
    holder.playlistName.setText(pl.getPlaylistName());
    if (pl.getSongList().size() > 1)
        holder.playlistSize.setText(String.valueOf(pl.getSongList().size()) + " Songs");
    else
        holder.playlistSize.setText(String.valueOf(pl.getSongList().size()) + " Song");
}
Also used : Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 5 with UnifiedTrack

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

the class ViewAllPlaylistsRecyclerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    Playlist p = playlists.get(position);
    List<UnifiedTrack> list = p.getSongList();
    if (SplashActivity.tf3 != null)
        holder.playListName.setTypeface(SplashActivity.tf3);
    holder.playListName.setText(p.getPlaylistName());
    if (list.size() >= 3) {
        String[] names = new String[3];
        for (int i = 0; i < 3; i++) {
            if (list.get(i).getType()) {
                names[i] = list.get(i).getLocalTrack().getTitle();
                imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
            } else {
                names[i] = list.get(i).getStreamTrack().getTitle();
                imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), 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++) {
            if (list.get(i).getType()) {
                names[i] = list.get(i).getLocalTrack().getTitle();
                imgLoader.DisplayImage(list.get(i).getLocalTrack().getPath(), holder.img[i]);
            } else {
                names[i] = list.get(i).getStreamTrack().getTitle();
                imgLoader.DisplayImage(list.get(i).getStreamTrack().getArtworkURL(), holder.img[i]);
            }
            holder.name[i].setText(names[i]);
        }
    }
}
Also used : Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) 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