Search in sources :

Example 31 with UnifiedTrack

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

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

the class LocalMusicFragment 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());
    shuffleFab = (FloatingActionButton) view.findViewById(R.id.play_all_fab_local);
    if (HomeActivity.localTrackList.size() == 0) {
        shuffleFab.setVisibility(View.INVISIBLE);
    }
    shuffleFab.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    shuffleFab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            HomeActivity.queue.getQueue().clear();
            for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
                UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
                HomeActivity.queue.getQueue().add(ut);
            }
            if (HomeActivity.queue.getQueue().size() > 0) {
                Random r = new Random();
                int tmp = r.nextInt(HomeActivity.queue.getQueue().size());
                HomeActivity.queueCurrentIndex = tmp;
                LocalTrack track = HomeActivity.localTrackList.get(tmp);
                HomeActivity.localSelectedTrack = track;
                HomeActivity.streamSelected = false;
                HomeActivity.localSelected = true;
                HomeActivity.queueCall = false;
                HomeActivity.isReloaded = false;
                mCallback.onLocalTrackSelected(-1);
            }
        }
    });
    lv = (RecyclerView) view.findViewById(R.id.localMusicList);
    adapter = new LocalTrackRecyclerAdapter(HomeActivity.finalLocalSearchResultList, getContext());
    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) {
            if (position >= 0) {
                HomeActivity.queue.getQueue().clear();
                for (int i = 0; i < HomeActivity.localTrackList.size(); i++) {
                    UnifiedTrack ut = new UnifiedTrack(true, HomeActivity.localTrackList.get(i), null);
                    HomeActivity.queue.getQueue().add(ut);
                }
                HomeActivity.queueCurrentIndex = getPosition(HomeActivity.finalLocalSearchResultList.get(position));
                LocalTrack track = HomeActivity.finalLocalSearchResultList.get(position);
                HomeActivity.localSelectedTrack = track;
                HomeActivity.streamSelected = false;
                HomeActivity.localSelected = true;
                HomeActivity.queueCall = false;
                HomeActivity.isReloaded = false;
                mCallback.onLocalTrackSelected(-1);
            }
            return true;
        }

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

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
    Button mEndButton = new Button(getContext());
    mEndButton.setBackgroundColor(HomeActivity.themeColor);
    mEndButton.setTextColor(Color.WHITE);
    showCase = new ShowcaseView.Builder(getActivity()).blockAllTouches().singleShot(1).setStyle(R.style.CustomShowcaseTheme).useDecorViewAsParent().replaceEndButton(mEndButton).setContentTitlePaint(HomeActivity.tp).setTarget(new ViewTarget(R.id.songs_tab_alt_showcase, getActivity())).setContentTitle("All Songs").setContentText("All local Songs listed here.Click to Play.Long click for more options").build();
    showCase.setButtonText("Next");
    showCase.setButtonPosition(HomeActivity.lps);
    showCase.overrideButtonClick(new View.OnClickListener() {

        int count1 = 0;

        @Override
        public void onClick(View v) {
            count1++;
            switch(count1) {
                case 1:
                    RelativeLayout.LayoutParams lps = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                    lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                    lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
                    lps.setMargins(margin, margin, margin, 5 + HomeActivity.navBarHeightSizeinDp);
                    showCase.setTarget(new ViewTarget(shuffleFab.getId(), getActivity()));
                    showCase.setContentTitle("Shuffle");
                    showCase.setContentText("Play all songs, shuffled randomly");
                    showCase.setButtonText("Done");
                    showCase.setButtonPosition(lps);
                    break;
                case 2:
                    showCase.hide();
                    break;
            }
        }
    });
}
Also used : LocalTrack(com.sdsmdg.harjot.MusicDNA.models.LocalTrack) ViewTarget(com.github.amlcurran.showcaseview.targets.ViewTarget) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) Random(java.util.Random) Button(android.widget.Button) FloatingActionButton(android.support.design.widget.FloatingActionButton) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RelativeLayout(android.widget.RelativeLayout) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView)

Example 33 with UnifiedTrack

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

the class PlayerFragment method removeFromFavourite.

public void removeFromFavourite() {
    UnifiedTrack ut;
    if (homeActivity.localSelected)
        ut = new UnifiedTrack(true, localTrack, null);
    else
        ut = new UnifiedTrack(false, null, track);
    for (int i = 0; i < homeActivity.favouriteTracks.getFavourite().size(); i++) {
        UnifiedTrack ut1 = homeActivity.favouriteTracks.getFavourite().get(i);
        if (ut.getType() && ut1.getType()) {
            if (ut.getLocalTrack().getTitle().equals(ut1.getLocalTrack().getTitle())) {
                homeActivity.favouriteTracks.getFavourite().remove(i);
                break;
            }
        } else if (!ut.getType() && !ut1.getType()) {
            if (ut.getStreamTrack().getTitle().equals(ut1.getStreamTrack().getTitle())) {
                homeActivity.favouriteTracks.getFavourite().remove(i);
                break;
            }
        }
    }
    mCallback.onAddedtoFavfromPlayer();
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 34 with UnifiedTrack

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

the class FavouriteTrackAdapter method onItemMove.

@Override
public void onItemMove(int fromPosition, int toPosition) {
    UnifiedTrack prev = favouriteList.remove(fromPosition);
    favouriteList.add(toPosition, prev);
    notifyItemMoved(fromPosition, toPosition);
    mCallback2.updateFavFragment();
    new HomeActivity.SaveFavourites().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 35 with UnifiedTrack

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

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