diff --git a/app/src/main/java/me/bello/viptv/ui/PlayActivity.java b/app/src/main/java/me/bello/viptv/ui/PlayActivity.java index c22432f..82c4d7d 100644 --- a/app/src/main/java/me/bello/viptv/ui/PlayActivity.java +++ b/app/src/main/java/me/bello/viptv/ui/PlayActivity.java @@ -71,6 +71,8 @@ private MyHandler myHandler = new MyHandler(); private List fromList = new ArrayList<>(); + private PopupWindow channelPopupWindow; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -217,16 +219,20 @@ if (type.equals(AppConst.TYPE_VIDEO)) { return; } - View view = LayoutInflater.from(mContext).inflate(R.layout.pop_tv_channel, null, false); + if (channelPopupWindow != null && channelPopupWindow.isShowing()){ + channelPopupWindow.dismiss(); + return; + } - PopupWindow popupWindow = new PopupWindow(view, 400, + View view = LayoutInflater.from(mContext).inflate(R.layout.pop_tv_channel, null, false); + channelPopupWindow = new PopupWindow(view, 400, ViewGroup.LayoutParams.MATCH_PARENT, true); - popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); - popupWindow.setAnimationStyle(R.style.popLeftAnim); - popupWindow.setOutsideTouchable(true); - popupWindow.setTouchable(true); - popupWindow.setFocusable(true); - popupWindow.showAtLocation(frameLayout, Gravity.LEFT, 0, 0); + channelPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); + channelPopupWindow.setAnimationStyle(R.style.popLeftAnim); + channelPopupWindow.setOutsideTouchable(true); + channelPopupWindow.setTouchable(true); + channelPopupWindow.setFocusable(true); + channelPopupWindow.showAtLocation(frameLayout, Gravity.LEFT, 0, 0); ListView list = view.findViewById(R.id.tv_list_view); TVChannelAdapter adapter = new TVChannelAdapter(mContext, channelList); @@ -251,7 +257,7 @@ } } - popupWindow.dismiss(); + channelPopupWindow.dismiss(); } }); @@ -260,7 +266,7 @@ lp.alpha = 0.5f; getWindow().setAttributes(lp); - popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { + channelPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { lp.alpha = 1f; @@ -285,6 +291,8 @@ */ private void playVideo() { if (type.equals(AppConst.TYPE_VIDEO)) { + videoView.setFocusable(true); + videoView.setFocusableInTouchMode(true); frameLayout.setVisibility(View.GONE); changeImg.setVisibility(View.GONE); if (playUrl.contains(".mp4")) {