Search in sources :

Example 1 with MusicInfo

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

the class PlayingActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // handle item selection
    if (item.getItemId() == R.id.menu_share) {
        MusicInfo musicInfo = MusicUtils.getMusicInfo(PlayingActivity.this, MusicPlayer.getCurrentAudioId());
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + musicInfo.data));
        shareIntent.setType("audio/*");
        this.startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
    }
    return super.onOptionsItemSelected(item);
}
Also used : Intent(android.content.Intent) MusicInfo(com.wm.remusic.info.MusicInfo)

Example 2 with MusicInfo

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

the class LocalSearchActivity method onQueryTextChange.

@Override
public boolean onQueryTextChange(final String newText) {
    if (newText.equals(queryString)) {
        return true;
    }
    queryString = newText;
    if (!queryString.trim().equals("")) {
        this.searchResults = new ArrayList();
        List<MusicInfo> songList = SearchUtils.searchSongs(this, queryString);
        searchResults.addAll((songList.size() < 10 ? songList : songList.subList(0, 10)));
    } else {
        searchResults.clear();
        adapter.updateSearchResults(searchResults);
        adapter.notifyDataSetChanged();
    }
    adapter.updateSearchResults(searchResults);
    adapter.notifyDataSetChanged();
    return true;
}
Also used : ArrayList(java.util.ArrayList) MusicInfo(com.wm.remusic.info.MusicInfo)

Example 3 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 4 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 5 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)

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