Search in sources :

Example 11 with UnifiedTrack

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

the class HomeActivity method showAddToPlaylistDialog.

public void showAddToPlaylistDialog(final UnifiedTrack track) {
    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.add_to_playlist_dialog);
    dialog.setTitle("Add to Playlist");
    ListView lv = (ListView) dialog.findViewById(R.id.playlist_list);
    AddToPlaylistAdapter adapter;
    if (allPlaylists.getPlaylists() != null && allPlaylists.getPlaylists().size() != 0) {
        adapter = new AddToPlaylistAdapter(allPlaylists.getPlaylists(), ctx);
        lv.setAdapter(adapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Playlist temp = allPlaylists.getPlaylists().get(position);
                boolean isRepeat = false;
                for (UnifiedTrack ut : temp.getSongList()) {
                    if (track.getType() && ut.getType() && track.getLocalTrack().getTitle().equals(ut.getLocalTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    } else if (!track.getType() && !ut.getType() && track.getStreamTrack().getTitle().equals(ut.getStreamTrack().getTitle())) {
                        isRepeat = true;
                        break;
                    }
                }
                if (!isRepeat) {
                    temp.addSong(track);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    Toast.makeText(ctx, "Added to Playlist : " + temp.getPlaylistName(), Toast.LENGTH_SHORT).show();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                } else {
                    Toast.makeText(ctx, "Song already present in Playlist", Toast.LENGTH_SHORT).show();
                }
            }
        });
    } else {
        lv.setVisibility(GONE);
    }
    // set the custom dialog components - text, image and button
    final EditText text = (EditText) dialog.findViewById(R.id.new_playlist_name);
    ImageView image = (ImageView) dialog.findViewById(R.id.confirm_button);
    // if button is clicked, close the custom dialog
    image.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (text.getText().toString().trim().equals("")) {
                text.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (text.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        text.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    List<UnifiedTrack> l = new ArrayList<UnifiedTrack>();
                    l.add(track);
                    Playlist pl = new Playlist(l, text.getText().toString().trim());
                    allPlaylists.addPlaylist(pl);
                    playlistsRecycler.setVisibility(View.VISIBLE);
                    playlistNothingText.setVisibility(View.INVISIBLE);
                    pAdapter.notifyDataSetChanged();
                    dialog.dismiss();
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) AddToPlaylistAdapter(com.sdsmdg.harjot.MusicDNA.adapters.playlistdialogadapter.AddToPlaylistAdapter) ImageView(android.widget.ImageView) VisualizerView(com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) WheelView(com.lantouzi.wheelview.WheelView) ListView(android.widget.ListView) TextPaint(android.text.TextPaint) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) ListView(android.widget.ListView) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) AdapterView(android.widget.AdapterView) ColorStateList(android.content.res.ColorStateList) ArrayList(java.util.ArrayList) List(java.util.List) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView)

Example 12 with UnifiedTrack

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

the class HomeActivity method onShuffleDisabled.

@Override
public void onShuffleDisabled() {
    UnifiedTrack ut1 = queue.getQueue().get(queueCurrentIndex);
    for (int i = 0; i < queue.getQueue().size(); i++) {
        UnifiedTrack ut = queue.getQueue().get(i);
        if (!originalQueue.getQueue().contains(ut)) {
            originalQueue.getQueue().add(ut);
        }
    }
    queue.getQueue().clear();
    for (UnifiedTrack ut : originalQueue.getQueue()) {
        queue.addToQueue(ut);
    }
    for (int i = 0; i < queue.getQueue().size(); i++) {
        if (ut1.equals(queue.getQueue().get(i))) {
            queueCurrentIndex = i;
            break;
        }
    }
    new SaveQueue().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) TextPaint(android.text.TextPaint)

Example 13 with UnifiedTrack

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

the class HomeActivity method addFavToQueue.

@Override
public void addFavToQueue() {
    for (UnifiedTrack ut : favouriteTracks.getFavourite()) {
        queue.addToQueue(ut);
    }
    if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
        playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
        playerFragment.snappyRecyclerView.setTransparency();
    }
    Toast.makeText(ctx, "Added " + favouriteTracks.getFavourite().size() + " song(s) to queue", Toast.LENGTH_SHORT).show();
}
Also used : UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 14 with UnifiedTrack

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

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

the class HomeActivity method onQueueItemClicked2.

public void onQueueItemClicked2(int position) {
    if (position <= (queue.getQueue().size() - 1)) {
        queueCurrentIndex = position;
        UnifiedTrack ut = queue.getQueue().get(position);
        if (ut.getType()) {
            LocalTrack track = ut.getLocalTrack();
            localSelectedTrack = track;
            streamSelected = false;
            localSelected = true;
            queueCall = true;
            isReloaded = false;
            onLocalTrackSelected(position);
        } else {
            Track track = ut.getStreamTrack();
            selectedTrack = track;
            streamSelected = true;
            localSelected = false;
            queueCall = true;
            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)

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