Search in sources :

Example 6 with MusicInfo

use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.

the class PlaylistDetailAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder itemHolder, final int i) {
    if (itemHolder instanceof ItemViewHolder) {
        MusicInfo localItem = arraylist.get(i - 1);
        ((ItemViewHolder) itemHolder).trackNumber.setText(i + "");
        ((ItemViewHolder) itemHolder).title.setText(localItem.musicName);
        ((ItemViewHolder) itemHolder).artist.setText(localItem.artist);
        ((ItemViewHolder) itemHolder).menu.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                MoreFragment morefragment = MoreFragment.newInstance(arraylist.get(i - 1).songId + "", IConstants.MUSICOVERFLOW);
                morefragment.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "music");
            }
        });
    } else if (itemHolder instanceof CommonItemViewHolder) {
        ((CommonItemViewHolder) itemHolder).textView.setText("(共" + arraylist.size() + "首)");
        ((CommonItemViewHolder) itemHolder).select.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, PlaylistSelectActivity.class);
                intent.putParcelableArrayListExtra("ids", arraylist);
                intent.putExtra("playlistid", playlistId);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                mContext.startActivity(intent);
            }
        });
    }
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) Intent(android.content.Intent) MoreFragment(com.wm.remusic.fragment.MoreFragment) MusicInfo(com.wm.remusic.info.MusicInfo) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with MusicInfo

use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.

the class SearchAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    MusicInfo song = searchResults.get(i);
    itemHolder.title.setText(song.musicName);
    itemHolder.songartist.setText(song.artist);
    setOnPopupMenuListener(itemHolder, i);
}
Also used : MusicInfo(com.wm.remusic.info.MusicInfo)

Example 8 with MusicInfo

use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.

the class AddNetPlaylistDialog method onCreateView.

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    //设置无标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    if (getArguments() != null) {
        musics = getArguments().getParcelableArrayList("songs");
        author = getArguments().getString("author");
    }
    playlistInfo = PlaylistInfo.getInstance(mContext);
    playlistsManager = PlaylistsManager.getInstance(mContext);
    View view = inflater.inflate(R.layout.fragment_add_playlist, container);
    LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.create_new_playlist);
    recyclerView = (RecyclerView) view.findViewById(R.id.add_playlist_recyclerview);
    linearLayout.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
            alertDialog.setView((mContext.getLayoutInflater().inflate(R.layout.dialog, null)));
            alertDialog.show();
            Window window = alertDialog.getWindow();
            window.setContentView(R.layout.dialog);
            final EditText editText = (EditText) (window.findViewById(R.id.message));
            editText.requestFocus();
            (window.findViewById(R.id.positiveButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    alertDialog.dismiss();
                }
            });
            (window.findViewById(R.id.negativeButton)).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    dismiss();
                    new Thread(new Runnable() {

                        @Override
                        public void run() {
                            Log.e("addplay", "here");
                            String albumart = null;
                            for (MusicInfo info : musics) {
                                albumart = info.albumData;
                                if (info.islocal) {
                                    if (albumart.equals(MusicUtils.getAlbumdata(MainApplication.context, info.songId)))
                                        break;
                                } else if (!TextUtils.isEmpty(albumart)) {
                                    break;
                                }
                            }
                            long playlistid = editText.getText().hashCode();
                            playlistInfo.addPlaylist(playlistid, editText.getText().toString(), musics.size(), albumart, author);
                            playlistsManager.insertLists(mContext, playlistid, musics);
                            Intent intent = new Intent(IConstants.PLAYLIST_COUNT_CHANGED);
                            MainApplication.context.sendBroadcast(intent);
                        }
                    }).start();
                    alertDialog.dismiss();
                }
            });
        }
    });
    ArrayList<Playlist> playlists = playlistInfo.getPlaylist();
    recyclerView.setLayoutManager(layoutManager);
    AddPlaylistAdapter adapter = new AddPlaylistAdapter(playlists);
    recyclerView.setAdapter(adapter);
    //setItemDecoration();
    return view;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) EditText(android.widget.EditText) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Playlist(com.wm.remusic.info.Playlist) MusicInfo(com.wm.remusic.info.MusicInfo) LinearLayout(android.widget.LinearLayout)

Example 9 with MusicInfo

use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.

the class PlaylistsManager method insertLists.

public synchronized void insertLists(Context context, long playlistid, ArrayList<MusicInfo> musicInfos) {
    final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
    database.beginTransaction();
    int len = musicInfos.size();
    try {
        for (int i = 0; i < len; i++) {
            MusicInfo info = musicInfos.get(i);
            ContentValues values = new ContentValues(11);
            values.put(PlaylistsColumns.PLAYLIST_ID, playlistid);
            values.put(PlaylistsColumns.TRACK_ID, info.songId);
            values.put(PlaylistsColumns.TRACK_ORDER, getPlaylist(playlistid).size());
            values.put(PlaylistsColumns.TRACK_NAME, info.musicName);
            values.put(PlaylistsColumns.ALBUM_ID, info.albumId);
            values.put(PlaylistsColumns.ALBUM_NAME, info.albumName);
            values.put(PlaylistsColumns.ALBUM_ART, info.albumData);
            values.put(PlaylistsColumns.ARTIST_NAME, info.artist);
            values.put(PlaylistsColumns.ARTIST_ID, info.artistId);
            values.put(PlaylistsColumns.PATH, info.data);
            values.put(PlaylistsColumns.IS_LOCAL, info.islocal);
            database.insertWithOnConflict(PlaylistsColumns.NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
        }
        database.setTransactionSuccessful();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        database.endTransaction();
    }
    PlaylistInfo playlistInfo = PlaylistInfo.getInstance(context);
    String albumart = null;
    for (int i = len - 1; i >= 0; i--) {
        MusicInfo info = musicInfos.get(i);
        albumart = info.albumData;
        if (info.islocal) {
            String art = MusicUtils.getAlbumdata(MainApplication.context, info.songId);
            if (art != null) {
                break;
            } else {
                albumart = null;
            }
        } else if (!albumart.isEmpty()) {
            break;
        }
    }
    if (albumart != null) {
        playlistInfo.update(playlistid, getPlaylist(playlistid).size(), albumart);
    } else {
        playlistInfo.update(playlistid, getPlaylist(playlistid).size());
    }
}
Also used : ContentValues(android.content.ContentValues) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) MusicInfo(com.wm.remusic.info.MusicInfo)

Example 10 with MusicInfo

use of com.wm.remusic.info.MusicInfo in project remusic by aa112901.

the class PlaylistsManager method getMusicInfos.

public ArrayList<MusicInfo> getMusicInfos(final long playlistid) {
    ArrayList<MusicInfo> results = new ArrayList<>();
    Cursor cursor = null;
    try {
        cursor = mMusicDatabase.getReadableDatabase().query(PlaylistsColumns.NAME, null, PlaylistsColumns.PLAYLIST_ID + " = " + String.valueOf(playlistid), null, null, null, PlaylistsColumns.TRACK_ORDER + " ASC ", null);
        if (cursor != null && cursor.moveToFirst()) {
            results.ensureCapacity(cursor.getCount());
            do {
                MusicInfo info = new MusicInfo();
                info.songId = cursor.getLong(1);
                info.musicName = cursor.getString(2);
                info.albumId = cursor.getInt(3);
                info.albumName = cursor.getString(4);
                info.albumData = cursor.getString(5);
                info.artistId = cursor.getLong(6);
                info.artist = cursor.getString(7);
                info.islocal = cursor.getInt(8) > 0;
                results.add(info);
            } while (cursor.moveToNext());
        }
        return results;
    } finally {
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) MusicInfo(com.wm.remusic.info.MusicInfo)

Aggregations

MusicInfo (com.wm.remusic.info.MusicInfo)25 Intent (android.content.Intent)10 ArrayList (java.util.ArrayList)9 View (android.view.View)7 TextView (android.widget.TextView)7 Uri (android.net.Uri)6 RecyclerView (android.support.v7.widget.RecyclerView)6 DialogInterface (android.content.DialogInterface)5 AsyncTask (android.os.AsyncTask)5 HashMap (java.util.HashMap)5 AlertDialog (android.support.v7.app.AlertDialog)4 MusicFlowAdapter (com.wm.remusic.adapter.MusicFlowAdapter)4 Cursor (android.database.Cursor)3 ImageView (android.widget.ImageView)3 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 ContentResolver (android.content.ContentResolver)2 Handler (android.os.Handler)2 LinearLayout (android.widget.LinearLayout)2 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)2