Example usage for android.provider MediaStore UNKNOWN_STRING

List of usage examples for android.provider MediaStore UNKNOWN_STRING

Introduction

In this page you can find the example usage for android.provider MediaStore UNKNOWN_STRING.

Prototype

String UNKNOWN_STRING

To view the source code for android.provider MediaStore UNKNOWN_STRING.

Click Source Link

Document

The string that is used when a media attribute is not known.

Usage

From source file:Main.java

public static String createLyricName(String song, String artist) {
    StringBuilder sb = new StringBuilder();
    if (artist != null && artist.length() > 0 && !MediaStore.UNKNOWN_STRING.equals(artist)) {
        sb.append(artist);/*from  w  w  w. ja v  a2  s.  c o m*/
        sb.append(" - ");
    }
    sb.append(song);
    sb.append(".lrc");
    return sb.toString();
}

From source file:com.cyanogenmod.eleven.utils.SongPopupMenuHelper.java

@Override
protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
    super.updateMenuIds(type, set);

    // Don't show more by artist if it is an unknown artist
    if (MediaStore.UNKNOWN_STRING.equals(mSong.mArtistName)) {
        set.remove(FragmentMenuItems.MORE_BY_ARTIST);
    }//from   ww  w  . j av  a 2s  .  c  om
}

From source file:com.andryr.musicplayer.loaders.AlbumLoader.java

@Override
public List<Album> loadInBackground() {

    mAlbumList = new ArrayList<>();

    Cursor cursor = getAlbumCursor();

    if (cursor != null && cursor.moveToFirst()) {
        int idCol = cursor.getColumnIndex(BaseColumns._ID);

        int albumNameCol = cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ALBUM);
        int artistCol = cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.ARTIST);
        int yearCol = cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.FIRST_YEAR);

        int songsNbCol = cursor.getColumnIndex(MediaStore.Audio.AlbumColumns.NUMBER_OF_SONGS);

        do {//from  w  w  w  .  j  av  a2  s  .  c  om

            long id = cursor.getLong(idCol);

            String name = cursor.getString(albumNameCol);
            if (name == null || name.equals(MediaStore.UNKNOWN_STRING)) {
                name = getContext().getString(R.string.unknown_album);
                id = -1;
            }
            String artist = cursor.getString(artistCol);
            int year = cursor.getInt(yearCol);
            int count = cursor.getInt(songsNbCol);

            mAlbumList.add(new Album(id, name, artist, year, count));

        } while (cursor.moveToNext());

    }

    if (cursor != null) {
        cursor.close();
    }
    return mAlbumList;
}

From source file:com.cyanogenmod.eleven.utils.AlbumPopupMenuHelper.java

@Override
protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
    super.updateMenuIds(type, set);

    // Don't show more by artist if it is an unknown artist
    if (MediaStore.UNKNOWN_STRING.equals(mAlbum.mArtistName)) {
        set.remove(FragmentMenuItems.MORE_BY_ARTIST);
    }//from w ww  .  j a va  2 s  .  co  m
}

From source file:com.massivcode.androidmusicplayer.fragments.SongsFragment.java

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    View header = getActivity().getLayoutInflater().inflate(R.layout.header, null, false);
    header.findViewById(R.id.songs_playAll_btn).setOnClickListener((View.OnClickListener) getActivity());
    mListView.addHeaderView(header);//from  w w  w. j av  a 2s. com

    if (Build.VERSION.SDK_INT < 23) {
        Cursor cursor = getActivity().getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                MusicInfoLoadUtil.projection, MediaStore.Audio.Media.ARTIST + " != ? AND "
                        + MediaStore.Audio.Media.TITLE + " NOT LIKE '%" + "hangout" + "%'",
                new String[] { MediaStore.UNKNOWN_STRING }, null);
        mAdapter = new SongAdapter(getActivity().getApplicationContext(), cursor, true);
        mListView.setAdapter(mAdapter);
    } else {
        if (getActivity().checkSelfPermission(
                Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
            if (mAdapter == null) {
                EventBus.getDefault().post(new InitEvent());
            }
        }
    }

    mListView.setOnItemClickListener((AdapterView.OnItemClickListener) getActivity());

    if (mSaveState != null) {
        MusicInfo musicInfo = mSaveState.getMusicInfo();
        MusicEvent musicEvent = new MusicEvent();
        musicEvent.setMusicInfo(musicInfo);
        mAdapter.swapMusicEvent(musicEvent);
        mAdapter.notifyDataSetChanged();
    }
}

From source file:com.massivcode.androidmusicplayer.fragments.SongsFragment.java

public void onEvent(Event event) {

    if (event instanceof MusicEvent) {
        //            Log.d(TAG, "? ?? .");
        mAdapter.swapMusicEvent((MusicEvent) event);
        mAdapter.notifyDataSetChanged();
    } else if (event instanceof PlayBack) {
        //            Log.d(TAG, "? ?? .");

        final PlayBack playback = (PlayBack) event;

        if (mPlayBack == null || mPlayBack.isPlaying() != playback.isPlaying()) {
            mPlayBack = playback;//from ww  w.java2  s  .c  o m
            mAdapter.swapPlayback((PlayBack) event);
            mAdapter.notifyDataSetChanged();
        }

    } else if (event instanceof SaveState) {
        if (((SaveState) event).getMusicInfo() != null) {
            mSaveState = (SaveState) event;
        }
    } else if (event instanceof InitEvent) {
        Log.d(TAG, "initEvent : SongsFragment");
        Cursor cursor = getActivity().getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
                MusicInfoLoadUtil.projection, MediaStore.Audio.Media.ARTIST + " != ? ",
                new String[] { MediaStore.UNKNOWN_STRING }, null);
        mAdapter = new SongAdapter(getActivity().getApplicationContext(), cursor, true);
        mListView.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();
    }

}

From source file:org.yammp.fragment.AlbumFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {

    if (mCursor == null)
        return;/*from   w  w  w  . j  a v  a2s . c om*/

    menu.add(hashCode(), PLAY_SELECTION, 0, R.string.play_selection);
    menu.add(hashCode(), DELETE_ITEMS, 0, R.string.delete_music);
    menu.add(hashCode(), DELETE_LYRICS, 0, R.string.delete_lyrics);

    AdapterContextMenuInfo adapterinfo = (AdapterContextMenuInfo) info;
    mSelectedPosition = adapterinfo.position;
    mCursor.moveToPosition(mSelectedPosition);
    try {
        mSelectedId = mCursor.getLong(mIdIdx);
    } catch (IllegalArgumentException ex) {
        mSelectedId = adapterinfo.id;
    }

    mCurrentArtistNameForAlbum = mCursor.getString(mArtistIdx);

    mCurrentAlbumName = mCursor.getString(mAlbumIdx);
    if (mCurrentAlbumName != null && !MediaStore.UNKNOWN_STRING.equals(mCurrentAlbumName)) {
        menu.add(hashCode(), SEARCH, 0, android.R.string.search_go);
        menu.setHeaderTitle(mCurrentAlbumName);
    } else {
        menu.setHeaderTitle(R.string.unknown_album);
    }

}

From source file:org.yammp.app.ArtistFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {

    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) info;

    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    mSelectedGroupPosition = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int gpos = mSelectedGroupPosition;
    mSelectedGroupId = mGroupCursor.getLong(mGroupArtistIdIdx);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mGroupSelected = true;/*  w  w w.j av a  2s.  com*/
        mChildSelected = false;
        getSherlockActivity().getMenuInflater().inflate(R.menu.music_browser_item, menu);
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - mListView.getHeaderViewsCount();
        mGroupCursor.moveToPosition(gpos);
        mCurrentGroupArtistName = mGroupCursor.getString(mGroupArtistIdx);
        if (mCurrentGroupArtistName == null || MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) {
            menu.setHeaderTitle(getString(R.string.unknown_artist));
            menu.findItem(R.id.search).setEnabled(false);
            menu.findItem(R.id.search).setVisible(false);
        } else {
            menu.setHeaderTitle(mCurrentGroupArtistName);
        }
    }
}

From source file:com.cyanogenmod.eleven.ui.fragments.QueueFragment.java

/**
 * {@inheritDoc}//w w  w . j a v a 2  s  .com
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mPopupMenuHelper = new PopupMenuHelper(getActivity(), getFragmentManager()) {
        private Song mSong;
        private int mSelectedPosition;
        private MusicPlaybackTrack mSelectedTrack;

        @Override
        public PopupMenuType onPreparePopupMenu(int position) {
            mSelectedPosition = position;
            mSong = mAdapter.getItem(mSelectedPosition);
            mSelectedTrack = MusicUtils.getTrack(mSelectedPosition);

            return PopupMenuType.Queue;
        }

        @Override
        protected long[] getIdList() {
            return new long[] { mSong.mSongId };
        }

        @Override
        protected long getSourceId() {
            if (mSelectedTrack == null) {
                return -1;
            }

            return mSelectedTrack.mSourceId;
        }

        @Override
        protected Config.IdType getSourceType() {
            if (mSelectedTrack == null) {
                return Config.IdType.NA;
            }

            return mSelectedTrack.mSourceType;
        }

        @Override
        protected String getArtistName() {
            return mSong.mArtistName;
        }

        @Override
        protected void onDeleteClicked() {
            DeleteDialog.newInstance(mSong.mSongName, new long[] { getId() }, null).show(getFragmentManager(),
                    "DeleteDialog");
        }

        @Override
        protected void playNext() {
            NowPlayingCursor queue = (NowPlayingCursor) QueueLoader.makeQueueCursor(getActivity());
            queue.removeItem(mSelectedPosition);
            queue.close();
            queue = null;
            MusicUtils.playNext(getIdList(), getSourceId(), getSourceType());
            refreshQueue();
        }

        @Override
        protected void removeFromQueue() {
            MusicUtils.removeTrackAtPosition(getId(), mSelectedPosition);
            refreshQueue();
        }

        @Override
        protected void updateMenuIds(PopupMenuType type, TreeSet<Integer> set) {
            super.updateMenuIds(type, set);

            // Don't show more by artist if it is an unknown artist
            if (MediaStore.UNKNOWN_STRING.equals(mSong.mArtistName)) {
                set.remove(FragmentMenuItems.MORE_BY_ARTIST);
            }
        }
    };

    // Create the adapter
    mAdapter = new SongAdapter(getActivity(), R.layout.edit_queue_list_item, -1, Config.IdType.NA);
    mAdapter.setPopupMenuClickedListener(new IPopupMenuCallback.IListener() {
        @Override
        public void onPopupMenuClicked(View v, int position) {
            mPopupMenuHelper.showPopupMenu(v, position);
        }
    });
}

From source file:org.yammp.app.MusicBrowserActivity.java

private void updateNowplaying() {
    if (mService == null)
        return;//from  w ww .  j  a va 2  s.c  o  m
    try {
        if (mService.getAudioId() > -1 || mService.getPath() != null) {
            setTitle(mService.getTrackName());
            if (mService.getArtistName() != null
                    && !MediaStore.UNKNOWN_STRING.equals(mService.getArtistName())) {
                mActionBar.setSubtitle(mService.getArtistName());
            } else if (mService.getAlbumName() != null
                    && !MediaStore.UNKNOWN_STRING.equals(mService.getAlbumName())) {
                mActionBar.setSubtitle(mService.getAlbumName());
            } else {
                mActionBar.setSubtitle(R.string.unknown_artist);
            }
        } else {
            setTitle(R.string.music_library);
            mActionBar.setSubtitle(R.string.touch_to_shuffle_all);
        }
        if (mAlbumArtLoader != null) {
            mAlbumArtLoader.cancel(true);
        }
        mAlbumArtLoader = new AsyncAlbumArtLoader();
        mAlbumArtLoader.execute();
    } catch (RemoteException e) {
        e.printStackTrace();
    }
}