From 8d724e3e8b897eb6ef77c6d3e0e8edb6f6a0d88c Mon Sep 17 00:00:00 2001 From: serso Date: Fri, 1 Apr 2016 20:56:19 +0200 Subject: [PATCH] Lint/Android Studio warnings are fixed --- .../android/widget/menu/CustomPopupMenu.java | 5 ++-- .../widget/menu/CustomPopupMenuHelper.java | 25 +++++++++++-------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenu.java b/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenu.java index 2866958b..41027687 100644 --- a/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenu.java +++ b/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenu.java @@ -34,6 +34,7 @@ import android.view.*; * to switch to the framework's implementation. See the framework SDK * documentation for a class overview. */ +@SuppressWarnings("unused") public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Callback { private Context mContext; private MenuBuilder mMenu; @@ -265,7 +266,7 @@ public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Call * * @param menu The PopupMenu that was dismissed. */ - public void onDismiss(CustomPopupMenu menu); + void onDismiss(CustomPopupMenu menu); } /** @@ -280,6 +281,6 @@ public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Call * @param item {@link MenuItem} that was clicked * @return true if the event was handled, false otherwise. */ - public boolean onMenuItemClick(MenuItem item); + boolean onMenuItemClick(MenuItem item); } } \ No newline at end of file diff --git a/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenuHelper.java b/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenuHelper.java index 3f9f3763..4d5f14c7 100644 --- a/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenuHelper.java +++ b/app/src/main/java/org/solovyev/android/widget/menu/CustomPopupMenuHelper.java @@ -16,6 +16,7 @@ package org.solovyev.android.widget.menu; +import android.annotation.SuppressLint; import android.content.Context; import android.content.res.Resources; import android.os.Parcelable; @@ -31,12 +32,12 @@ import java.util.ArrayList; /** * Presents a menu as a small, simple popup anchored to another view. */ +@SuppressWarnings("unused") +@SuppressLint("PrivateResource") public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, View.OnKeyListener, ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener, MenuPresenter { - static final int ITEM_LAYOUT = R.layout.abc_popup_menu_item_layout; - private final Context mContext; private final LayoutInflater mInflater; private final MenuBuilder mMenu; @@ -164,6 +165,7 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V mMenu.close(); if (mTreeObserver != null) { if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); + //noinspection deprecation mTreeObserver.removeGlobalOnLayoutListener(this); mTreeObserver = null; } @@ -224,14 +226,15 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V @Override public void onGlobalLayout() { - if (isShowing()) { - final View anchor = mAnchorView; - if (anchor == null || !anchor.isShown()) { - dismiss(); - } else if (isShowing()) { - // Recompute window size and position - mPopup.show(); - } + if (!isShowing()) { + return; + } + final View anchor = mAnchorView; + if (anchor == null || !anchor.isShown()) { + dismiss(); + } else { + // Recompute window size and position + mPopup.show(); } } @@ -359,7 +362,7 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { - convertView = mInflater.inflate(ITEM_LAYOUT, parent, false); + convertView = mInflater.inflate(R.layout.abc_popup_menu_item_layout, parent, false); } MenuView.ItemView itemView = (MenuView.ItemView) convertView;