Search in sources :

Example 6 with Playlist

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

the class AllPlaylistsFragment method onViewCreated.

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

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    allPlaylistFragmentTitle = (TextView) view.findViewById(R.id.all_playlist_fragment_title);
    if (SplashActivity.tf4 != null)
        allPlaylistFragmentTitle.setTypeface(SplashActivity.tf4);
    playlistFragIcon = (ImageView) view.findViewById(R.id.all_playlist_frag_icon);
    playlistFragIcon.setImageTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    initializeHeaderImages(view);
    bottomMarginLayout = view.findViewById(R.id.bottom_margin_layout);
    if (HomeActivity.isReloaded)
        bottomMarginLayout.getLayoutParams().height = 0;
    else
        bottomMarginLayout.getLayoutParams().height = CommonUtils.dpTopx(65, getContext());
    noPlaylistContent = (LinearLayout) view.findViewById(R.id.noPlaylistContent);
    allPlaylistRecycler = (RecyclerView) view.findViewById(R.id.all_playlists_recycler);
    addPlaylistFAB = (FloatingActionButton) view.findViewById(R.id.new_playlist_fab);
    addPlaylistFAB.setBackgroundTintList(ColorStateList.valueOf(HomeActivity.themeColor));
    addPlaylistFAB.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mCallback.newPlaylistListener();
        }
    });
    if (SplashActivity.tf4 != null)
        ((TextView) view.findViewById(R.id.noPlaylistContentText)).setTypeface(SplashActivity.tf4);
    if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
        allPlaylistRecycler.setVisibility(View.INVISIBLE);
        noPlaylistContent.setVisibility(View.VISIBLE);
    } else {
        allPlaylistRecycler.setVisibility(View.VISIBLE);
        noPlaylistContent.setVisibility(View.INVISIBLE);
    }
    vpAdapter = new ViewAllPlaylistsRecyclerAdapter(HomeActivity.allPlaylists.getPlaylists(), getContext());
    mLayoutManager2 = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    allPlaylistRecycler.setLayoutManager(mLayoutManager2);
    allPlaylistRecycler.setItemAnimator(new DefaultItemAnimator());
    allPlaylistRecycler.setAdapter(vpAdapter);
    allPlaylistRecycler.addOnItemTouchListener(new ClickItemTouchListener(allPlaylistRecycler) {

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

        @Override
        public boolean onLongClick(RecyclerView parent, View view, final int position, long id) {
            PopupMenu popup = new PopupMenu(getContext(), view);
            popup.getMenuInflater().inflate(R.menu.playlist_popup, popup.getMenu());
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    if (item.getTitle().equals("Play")) {
                        HomeActivity.tempPlaylist = HomeActivity.allPlaylists.getPlaylists().get(position);
                        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.onPlaylistMenuPLayAll();
                    } else if (item.getTitle().equals("Add to Queue")) {
                        Playlist pl = HomeActivity.allPlaylists.getPlaylists().get(position);
                        for (UnifiedTrack ut : pl.getSongList()) {
                            HomeActivity.queue.addToQueue(ut);
                        }
                    } else if (item.getTitle().equals("Delete")) {
                        HomeActivity.allPlaylists.getPlaylists().remove(position);
                        if (vpAdapter != null) {
                            vpAdapter.notifyItemRemoved(position);
                        }
                        if (HomeActivity.allPlaylists.getPlaylists().size() == 0) {
                            noPlaylistContent.setVisibility(View.VISIBLE);
                        }
                        new HomeActivity.SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                        homeActivity.pAdapter.notifyItemRemoved(position);
                    } else if (item.getTitle().equals("Rename")) {
                        HomeActivity.renamePlaylistNumber = position;
                        mCallback.onPlaylistRename();
                    }
                    return true;
                }
            });
            popup.show();
            return true;
        }

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }
    });
}
Also used : HomeActivity(com.sdsmdg.harjot.MusicDNA.activities.HomeActivity) MenuItem(android.view.MenuItem) 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) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) RecyclerView(android.support.v7.widget.RecyclerView) ClickItemTouchListener(com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener) PopupMenu(android.support.v7.widget.PopupMenu)

Example 7 with Playlist

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

the class AllPlaylistsFragment method initializeHeaderImages.

public void initializeHeaderImages(View v) {
    imgView[0] = (ImageView) v.findViewById(R.id.all_playlist_img_1);
    imgView[1] = (ImageView) v.findViewById(R.id.all_playlist_img_2);
    imgView[2] = (ImageView) v.findViewById(R.id.all_playlist_img_3);
    imgView[3] = (ImageView) v.findViewById(R.id.all_playlist_img_4);
    imgView[4] = (ImageView) v.findViewById(R.id.all_playlist_img_5);
    imgView[5] = (ImageView) v.findViewById(R.id.all_playlist_img_6);
    imgView[6] = (ImageView) v.findViewById(R.id.all_playlist_img_7);
    imgView[7] = (ImageView) v.findViewById(R.id.all_playlist_img_8);
    imgView[8] = (ImageView) v.findViewById(R.id.all_playlist_img_9);
    imgView[9] = (ImageView) v.findViewById(R.id.all_playlist_img_10);
    int numPlaylists = HomeActivity.allPlaylists.getPlaylists().size();
    Playlist pl1, pl2;
    if (numPlaylists == 0) {
        for (int i = 0; i < 10; i++) {
            imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
        }
    } else if (numPlaylists == 1) {
        pl1 = HomeActivity.allPlaylists.getPlaylists().get(0);
        for (int i = 0; i < Math.min(10, pl1.getSongList().size()); i++) {
            UnifiedTrack ut = pl1.getSongList().get(i);
            if (ut.getType())
                imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
            else
                imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
        }
        if (pl1.getSongList().size() < 10) {
            for (int i = pl1.getSongList().size(); i < 10; i++) {
                imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
            }
        }
    } else {
        pl1 = HomeActivity.allPlaylists.getPlaylists().get(0);
        pl2 = HomeActivity.allPlaylists.getPlaylists().get(1);
        for (int i = 0; i < Math.min(10, pl1.getSongList().size()); i++) {
            UnifiedTrack ut = pl1.getSongList().get(i);
            if (ut.getType())
                imgLoader.DisplayImage(pl1.getSongList().get(i).getLocalTrack().getPath(), imgView[i]);
            else
                imgLoader.DisplayImage(pl1.getSongList().get(i).getStreamTrack().getArtworkURL(), imgView[i]);
        }
        if (pl1.getSongList().size() < 10) {
            if (pl2.getSongList().size() >= (10 - pl1.getSongList().size())) {
                for (int i = pl1.getSongList().size(); i < 10; i++) {
                    UnifiedTrack ut = pl2.getSongList().get(i - pl1.getSongList().size());
                    if (ut.getType())
                        imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
                    else
                        imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
                }
            } else {
                for (int i = pl1.getSongList().size(); i < pl1.getSongList().size() + pl2.getSongList().size(); i++) {
                    UnifiedTrack ut = pl2.getSongList().get(i - pl1.getSongList().size());
                    if (ut.getType())
                        imgLoader.DisplayImage(ut.getLocalTrack().getPath(), imgView[i]);
                    else
                        imgLoader.DisplayImage(ut.getStreamTrack().getArtworkURL(), imgView[i]);
                }
                for (int i = pl1.getSongList().size() + pl2.getSongList().size(); i < 10; i++) {
                    imgLoader.DisplayImage("all_playlist" + i, imgView[i]);
                }
            }
        }
    }
}
Also used : Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 8 with Playlist

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

the class HomeActivity method playlistAddToQueue.

@Override
public void playlistAddToQueue() {
    Playlist pl = HomeActivity.allPlaylists.getPlaylists().get(tempPlaylistNumber);
    for (UnifiedTrack ut : pl.getSongList()) {
        HomeActivity.queue.addToQueue(ut);
    }
    if (playerFragment != null && playerFragment.snappyRecyclerView != null) {
        playerFragment.snappyRecyclerView.getAdapter().notifyDataSetChanged();
        playerFragment.snappyRecyclerView.setTransparency();
    }
    Toast.makeText(ctx, "Added " + pl.getSongList().size() + " song(s) to queue", Toast.LENGTH_SHORT).show();
}
Also used : Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)

Example 9 with Playlist

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

the class HomeActivity method newPlaylistNameDialog.

public void newPlaylistNameDialog() {
    final Dialog dialog = new Dialog(ctx);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.save_image_dialog);
    TextView titleText = (TextView) dialog.findViewById(R.id.dialog_title);
    titleText.setText("Playlist Name");
    if (SplashActivity.tf4 != null)
        titleText.setTypeface(SplashActivity.tf4);
    Button btn = (Button) dialog.findViewById(R.id.save_image_btn);
    final EditText newName = (EditText) dialog.findViewById(R.id.save_image_filename_text);
    CheckBox cb = (CheckBox) dialog.findViewById(R.id.text_checkbox);
    cb.setVisibility(GONE);
    btn.setBackgroundColor(themeColor);
    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            boolean isNameRepeat = false;
            if (newName.getText().toString().trim().equals("")) {
                newName.setError("Enter Playlist Name!");
            } else {
                for (int i = 0; i < allPlaylists.getPlaylists().size(); i++) {
                    if (newName.getText().toString().equals(allPlaylists.getPlaylists().get(i).getPlaylistName())) {
                        isNameRepeat = true;
                        newName.setError("Playlist with same name exists!");
                        break;
                    }
                }
                if (!isNameRepeat) {
                    UnifiedTrack ut;
                    Playlist pl = new Playlist(newName.getText().toString());
                    for (int i = 0; i < finalSelectedTracks.size(); i++) {
                        ut = new UnifiedTrack(true, finalSelectedTracks.get(i), null);
                        pl.getSongList().add(ut);
                    }
                    allPlaylists.addPlaylist(pl);
                    finalSelectedTracks.clear();
                    if (pAdapter != null) {
                        pAdapter.notifyDataSetChanged();
                        if (allPlaylists.getPlaylists().size() > 0) {
                            playlistsRecycler.setVisibility(View.VISIBLE);
                            playlistNothingText.setVisibility(View.INVISIBLE);
                        }
                    }
                    AllPlaylistsFragment plFrag = (AllPlaylistsFragment) fragMan.findFragmentByTag("allPlaylists");
                    if (plFrag != null) {
                        plFrag.dataChanged();
                    }
                    new SavePlaylists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    dialog.dismiss();
                    onBackPressed();
                }
            }
        }
    });
    dialog.show();
}
Also used : EditText(android.widget.EditText) Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) Button(android.widget.Button) Dialog(android.app.Dialog) CustomLocalBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog) CustomGeneralBottomSheetDialog(com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog) CheckBox(android.widget.CheckBox) UnifiedTrack(com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack) TextView(android.widget.TextView) AllPlaylistsFragment(com.sdsmdg.harjot.MusicDNA.fragments.AllPlaylistsFragment.AllPlaylistsFragment) 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)

Example 10 with Playlist

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

the class AddToPlaylistAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.playlist_list_row, parent, false);
    Playlist pl = allPlaylists.get(position);
    TextView playlistName = (TextView) v.findViewById(R.id.playlist_name_holder);
    playlistName.setText(pl.getPlaylistName());
    return v;
}
Also used : Playlist(com.sdsmdg.harjot.MusicDNA.models.Playlist) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Playlist (com.sdsmdg.harjot.MusicDNA.models.Playlist)10 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)8 View (android.view.View)5 TextView (android.widget.TextView)5 RecyclerView (android.support.v7.widget.RecyclerView)4 ImageView (android.widget.ImageView)4 Dialog (android.app.Dialog)3 NavigationView (android.support.design.widget.NavigationView)3 SearchView (android.support.v7.widget.SearchView)3 AdapterView (android.widget.AdapterView)3 EditText (android.widget.EditText)3 ListView (android.widget.ListView)3 ShowcaseView (com.github.amlcurran.showcaseview.ShowcaseView)3 WheelView (com.lantouzi.wheelview.WheelView)3 CustomGeneralBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomGeneralBottomSheetDialog)3 CustomLocalBottomSheetDialog (com.sdsmdg.harjot.MusicDNA.custombottomsheets.CustomLocalBottomSheetDialog)3 VisualizerView (com.sdsmdg.harjot.MusicDNA.visualizers.VisualizerView)3 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)3 TextPaint (android.text.TextPaint)2 ArrayList (java.util.ArrayList)2