Search in sources :

Example 66 with NonNull

use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.

the class SearchAdapter method setAlbumPopupMenu.

private void setAlbumPopupMenu(ItemHolder itemHolder, final int position) {
    final Album album = (Album) searchResults.get(position);
    itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu menu = new PopupMenu(mContext, v);
            menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.popup_album_addto_queue:
                            getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.NA);
                                }
                            });
                            break;
                        case R.id.popup_album_addto_playlist:
                            getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {

                                @Override
                                public void call(long[] ids) {
                                    ListenerUtil.showAddPlaylistDialog(mContext, ids);
                                }
                            });
                            break;
                        case R.id.popup_album_goto_artist:
                            NavigationUtil.goToArtist(mContext, album.artistId, album.artistName);
                            break;
                        case R.id.popup_artist_delete:
                            AlbumSongLoader.getSongsForAlbum(mContext, album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {

                                @Override
                                public void call(List<Song> songs) {
                                    long[] ids = new long[songs.size()];
                                    int i = 0;
                                    for (Song song : songs) {
                                        ids[i] = song.id;
                                        i++;
                                    }
                                    if (ids.length == 1) {
                                        ListenerUtil.showDeleteDialog(mContext, songs.get(0).title, ids, new MaterialDialog.SingleButtonCallback() {

                                            @Override
                                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                                searchResults.remove(position);
                                                notifyDataSetChanged();
                                            }
                                        });
                                    } else {
                                        String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, album.songCount);
                                        ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {

                                            @Override
                                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                                searchResults.remove(position);
                                                notifyDataSetChanged();
                                            }
                                        });
                                    }
                                }
                            });
                            break;
                    }
                    return false;
                }
            });
            menu.inflate(R.menu.popup_album);
            menu.show();
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Album(io.hefuyi.listener.mvp.model.Album) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Song(io.hefuyi.listener.mvp.model.Song) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) List(java.util.List) PopupMenu(android.widget.PopupMenu)

Example 67 with NonNull

use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.

the class PlaylistDetailFragment method showRenamePlaylistDialog.

private void showRenamePlaylistDialog(String oldName) {
    new MaterialDialog.Builder(getActivity()).title(R.string.rename_playlist).positiveText("确定").negativeText(R.string.cancel).input(null, oldName, false, new MaterialDialog.InputCallback() {

        @Override
        public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
            MusicPlayer.renamePlaylist(getActivity(), playlistID, input.toString());
            collapsingToolbarLayout.setTitle(input.toString());
            playlistName = input.toString();
            RxBus.getInstance().post(new PlaylistUpdateEvent());
            Toast.makeText(getActivity(), R.string.rename_playlist_success, Toast.LENGTH_SHORT).show();
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) PlaylistUpdateEvent(io.hefuyi.listener.event.PlaylistUpdateEvent) NonNull(android.support.annotation.NonNull)

Example 68 with NonNull

use of android.support.annotation.NonNull in project cameraview by google.

the class AspectRatioFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS);
    if (ratios == null) {
        throw new RuntimeException("No ratios");
    }
    final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO);
    final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current);
    return new AlertDialog.Builder(getActivity()).setAdapter(adapter, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int position) {
            mListener.onAspectRatioSelected(ratios[position]);
        }
    }).create();
}
Also used : AspectRatio(com.google.android.cameraview.AspectRatio) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) NonNull(android.support.annotation.NonNull)

Example 69 with NonNull

use of android.support.annotation.NonNull in project flexbox-layout by google.

the class FlexboxLayout method createOrders.

@NonNull
private List<Order> createOrders(int childCount) {
    List<Order> orders = new ArrayList<>(childCount);
    for (int i = 0; i < childCount; i++) {
        View child = getChildAt(i);
        LayoutParams params = (LayoutParams) child.getLayoutParams();
        Order order = new Order();
        order.order = params.order;
        order.index = i;
        orders.add(order);
    }
    return orders;
}
Also used : ArrayList(java.util.ArrayList) View(android.view.View) NonNull(android.support.annotation.NonNull)

Example 70 with NonNull

use of android.support.annotation.NonNull in project react-native-image-picker by marcshilling.

the class ButtonsHelper method getCustomButtons.

@NonNull
private static LinkedList<Item> getCustomButtons(@NonNull final ReadableMap options) {
    LinkedList<Item> result = new LinkedList<>();
    if (!options.hasKey("customButtons")) {
        return result;
    }
    final ReadableArray customButtons = options.getArray("customButtons");
    for (int i = 0; i < customButtons.size(); i++) {
        final ReadableMap button = customButtons.getMap(i);
        final String title = button.getString("title");
        final String action = button.getString("name");
        result.add(new Item(title, action));
    }
    return result;
}
Also used : ReadableArray(com.facebook.react.bridge.ReadableArray) ReadableMap(com.facebook.react.bridge.ReadableMap) LinkedList(java.util.LinkedList) NonNull(android.support.annotation.NonNull)

Aggregations

NonNull (android.support.annotation.NonNull)747 View (android.view.View)94 TextView (android.widget.TextView)90 ArrayList (java.util.ArrayList)83 Intent (android.content.Intent)53 ContentValues (android.content.ContentValues)46 Bundle (android.os.Bundle)46 Test (org.junit.Test)45 AlertDialog (android.support.v7.app.AlertDialog)41 Cursor (android.database.Cursor)38 List (java.util.List)34 IOException (java.io.IOException)32 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)31 LayoutInflater (android.view.LayoutInflater)29 RecyclerView (android.support.v7.widget.RecyclerView)28 ImageView (android.widget.ImageView)28 File (java.io.File)28 DialogAction (com.afollestad.materialdialogs.DialogAction)25 HashMap (java.util.HashMap)25 Bitmap (android.graphics.Bitmap)24