Search in sources :

Example 51 with PopupMenu

use of android.support.v7.widget.PopupMenu in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method onAudioSubClick.

public void onAudioSubClick(View anchor) {
    if (anchor == null) {
        initOverlay();
        anchor = mHudBinding.playerOverlayTracks;
    }
    final AppCompatActivity context = this;
    final PopupMenu popupMenu = new PopupMenu(this, anchor);
    final Menu menu = popupMenu.getMenu();
    popupMenu.getMenuInflater().inflate(R.menu.audiosub_tracks, menu);
    // FIXME network subs cannot be enabled & screen cast display is broken with picker
    menu.findItem(R.id.video_menu_subtitles_picker).setEnabled(mDisplayManager.isPrimary() && enableSubs);
    menu.findItem(R.id.video_menu_subtitles_download).setEnabled(enableSubs);
    menu.findItem(R.id.video_menu_video_track).setVisible(mService.getVideoTracksCount() > 2);
    menu.findItem(R.id.video_menu_audio_track).setEnabled(mService.getAudioTracksCount() > 0);
    menu.findItem(R.id.video_menu_subtitles).setEnabled(mService.getSpuTracksCount() > 0);
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.video_menu_audio_track) {
                selectAudioTrack();
                return true;
            } else if (item.getItemId() == R.id.video_menu_video_track) {
                selectVideoTrack();
                return true;
            } else if (item.getItemId() == R.id.video_menu_subtitles) {
                selectSubtitles();
                return true;
            } else if (item.getItemId() == R.id.video_menu_subtitles_picker) {
                if (mUri == null)
                    return false;
                mShowingDialog = true;
                final Intent filePickerIntent = new Intent(context, FilePickerActivity.class);
                filePickerIntent.setData(Uri.parse(FileUtils.getParent(mUri.toString())));
                context.startActivityForResult(filePickerIntent, 0);
                return true;
            } else if (item.getItemId() == R.id.video_menu_subtitles_download) {
                if (mUri == null)
                    return false;
                MediaUtils.getSubs(VideoPlayerActivity.this, mService.getCurrentMediaWrapper(), new SubtitlesDownloader.Callback() {

                    @Override
                    public void onRequestEnded(boolean success) {
                        if (success)
                            getSubtitles();
                    }
                });
            }
            hideOverlay(true);
            return false;
        }
    });
    popupMenu.show();
    showOverlay();
}
Also used : SwipeDragItemTouchHelperCallback(org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback) AppCompatActivity(android.support.v7.app.AppCompatActivity) MenuItem(android.view.MenuItem) Intent(android.content.Intent) PopupMenu(android.support.v7.widget.PopupMenu) Menu(android.view.Menu) PopupMenu(android.support.v7.widget.PopupMenu)

Example 52 with PopupMenu

use of android.support.v7.widget.PopupMenu in project vlc-android by GeoffreyMetais.

the class VideoPlayerActivity method onPopupMenu.

@Override
public void onPopupMenu(View anchor, final int position, MediaWrapper media) {
    final PopupMenu popupMenu = new PopupMenu(this, anchor);
    popupMenu.getMenuInflater().inflate(R.menu.audio_player, popupMenu.getMenu());
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.audio_player_mini_remove) {
                if (mService != null) {
                    mPlaylistAdapter.remove(position);
                    mService.remove(position);
                    return true;
                }
            }
            return false;
        }
    });
    popupMenu.show();
}
Also used : MenuItem(android.view.MenuItem) PopupMenu(android.support.v7.widget.PopupMenu)

Example 53 with PopupMenu

use of android.support.v7.widget.PopupMenu in project fuckView by w568w.

the class FullScreenListPopupWindow method init.

private void init(final Context context) {
    listView.setFocusableInTouchMode(true);
    listView.setAdapter(new BaseAdapter() {

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, final ViewGroup parent) {
            TextView textView;
            if (convertView == null || convertView instanceof TextView) {
                textView = new TextView(context);
            } else {
                textView = (TextView) convertView;
            }
            textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
            textView.setPadding(0, 12, 0, 12);
            final ViewDumper.ViewItem item = (ViewDumper.ViewItem) getItem(position);
            // 文字前空格
            textView.setText(tab(item.level) + item.simpleClassName);
            textView.setClickable(true);
            textView.setLongClickable(true);
            textView.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    hide();
                    // 红框
                    final RedBoundPopupWindow redBound = new RedBoundPopupWindow(getActivity(), item.bounds, item.wh);
                    redBound.show();
                    v.postDelayed(new Runnable() {

                        @Override
                        public void run() {
                            redBound.hide();
                            show();
                        }
                    }, 1000);
                }
            });
            textView.setOnLongClickListener(new View.OnLongClickListener() {

                @Override
                public boolean onLongClick(View v) {
                    PopupMenu popupMenu = new PopupMenu(context, v);
                    popupMenu.getMenu().add(R.string.popup_mark_it);
                    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                        @Override
                        public boolean onMenuItemClick(MenuItem item) {
                            if (item.getTitle().equals(context.getString(R.string.popup_mark_it))) {
                                ViewDumper.ViewItem item1 = list.get(position);
                                Point p = item1.bounds;
                                MainActivity.appendPreferences("\n" + new ViewModel(pkg, " " + MainActivity.ALL_SPLIT + " " + MainActivity.ALL_SPLIT + p.x + "," + p.y + "$$", "", "*").toString(), MainActivity.LIST_NAME);
                                Toast.makeText(getActivity(), R.string.rule_saved, Toast.LENGTH_SHORT).show();
                            }
                            return true;
                        }
                    });
                    popupMenu.show();
                    return true;
                }
            });
            return textView;
        }

        private String tab(int num) {
            String tab = "";
            for (int i = 0; i < num; i++) {
                tab += " ";
            }
            return tab;
        }
    });
    listView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                hide();
                popupView.show();
                return true;
            }
            return false;
        }
    });
}
Also used : ViewDumper(ml.qingsu.fuckview.utils.dumper.ViewDumper) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) Point(android.graphics.Point) ViewModel(ml.qingsu.fuckview.models.ViewModel) TextView(android.widget.TextView) View(android.view.View) Point(android.graphics.Point) KeyEvent(android.view.KeyEvent) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter) PopupMenu(android.support.v7.widget.PopupMenu)

Example 54 with PopupMenu

use of android.support.v7.widget.PopupMenu in project fuckView by w568w.

the class FullScreenPopupWindow method onCreateView.

@Override
protected View onCreateView(final Context context) {
    absoluteLayout = new AbsoluteLayout(context);
    absoluteLayout.setBackgroundColor(Color.argb(120, 0, 0, 0));
    absoluteLayout.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() != MotionEvent.ACTION_UP) {
                return false;
            }
            // 获得点击的View
            View v = getTouchView((int) motionEvent.getX(), (int) motionEvent.getY());
            if (v != null) {
                // 调用点击处理
                onClick(v);
            }
            return true;
        }

        private void onClick(final View view) {
            // 确定为红框标识
            if (view.getTag() instanceof ViewDumper.ViewItem) {
                System.out.println(getPath((ViewDumper.ViewItem) view.getTag()));
                // 先储存它原有的样式
                final Drawable drawable = view.getBackground();
                // 弹出菜单
                android.support.v7.widget.PopupMenu popupMenu = new android.support.v7.widget.PopupMenu(view.getContext(), view);
                popupMenu.getMenu().add(R.string.popup_mark_it);
                popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                    @Override
                    public boolean onMenuItemClick(MenuItem item) {
                        if (item.getTitle().equals(context.getString(R.string.popup_mark_it))) {
                            ViewDumper.ViewItem item1 = (ViewDumper.ViewItem) view.getTag();
                            Point p = item1.bounds;
                            MainActivity.appendPreferences("\n" + new ViewModel(pkg, " " + MainActivity.ALL_SPLIT + " " + MainActivity.ALL_SPLIT + p.x + "," + p.y + "$$", "", "*").toString(), MainActivity.LIST_NAME);
                            Toast.makeText(getActivity(), R.string.rule_saved, Toast.LENGTH_SHORT).show();
                        }
                        return true;
                    }
                });
                popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {

                    @Override
                    public void onDismiss(PopupMenu menu) {
                        view.setBackgroundDrawable(drawable);
                        params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL;
                        updateLayout();
                    }
                });
                popupMenu.setGravity(Gravity.CENTER);
                view.setBackgroundColor(Color.argb(120, 255, 0, 0));
                updateLayout();
                popupMenu.show();
            }
        }
    });
    absoluteLayout.setFocusableInTouchMode(true);
    absoluteLayout.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
                hide();
                popupView.show();
                return true;
            }
            return false;
        }
    });
    return absoluteLayout;
}
Also used : ViewDumper(ml.qingsu.fuckview.utils.dumper.ViewDumper) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) PopupMenu(android.support.v7.widget.PopupMenu) MenuItem(android.view.MenuItem) Point(android.graphics.Point) ViewModel(ml.qingsu.fuckview.models.ViewModel) TextView(android.widget.TextView) View(android.view.View) AbsoluteLayout(android.widget.AbsoluteLayout) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent) KeyEvent(android.view.KeyEvent) PopupMenu(android.support.v7.widget.PopupMenu)

Example 55 with PopupMenu

use of android.support.v7.widget.PopupMenu in project RoMote by wseemann.

the class ChannelFragment method showMenu.

private void showMenu(final View v) {
    PopupMenu popup = new PopupMenu(getActivity(), v);
    // This activity implements OnMenuItemClickListener
    popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch(item.getItemId()) {
                case R.id.action_share:
                    Channel channel = (Channel) v.getTag();
                    Intent intent = new Intent();
                    intent.setAction(Intent.ACTION_SEND);
                    intent.putExtra(Intent.EXTRA_TEXT, "Install this Roku channel (" + channel.getTitle() + "):\n\n" + "http://romote/" + channel.getId() + "\n\n" + "Sent using RoMote.");
                    intent.setType("text/plain");
                    startActivity(intent);
                    return true;
                default:
                    return false;
            }
        }
    });
    popup.inflate(R.menu.channel_menu);
    popup.show();
}
Also used : Channel(com.jaku.model.Channel) MenuItem(android.view.MenuItem) Intent(android.content.Intent) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

PopupMenu (android.support.v7.widget.PopupMenu)142 MenuItem (android.view.MenuItem)116 View (android.view.View)86 TextView (android.widget.TextView)63 RecyclerView (android.support.v7.widget.RecyclerView)54 ImageView (android.widget.ImageView)40 Intent (android.content.Intent)32 PopupMenu (android.widget.PopupMenu)31 List (java.util.List)27 ArrayList (java.util.ArrayList)26 MenuInflater (android.view.MenuInflater)23 Menu (android.view.Menu)22 Bundle (android.os.Bundle)20 LayoutInflater (android.view.LayoutInflater)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 Context (android.content.Context)18 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)18 AdapterView (android.widget.AdapterView)17 DialogInterface (android.content.DialogInterface)16 ViewGroup (android.view.ViewGroup)15