Lint/Android Studio warnings are fixed

This commit is contained in:
serso 2016-04-01 20:56:19 +02:00
parent 41e07b7571
commit 8d724e3e8b
2 changed files with 17 additions and 13 deletions

View File

@ -34,6 +34,7 @@ import android.view.*;
* to switch to the framework's implementation. See the framework SDK * to switch to the framework's implementation. See the framework SDK
* documentation for a class overview. * documentation for a class overview.
*/ */
@SuppressWarnings("unused")
public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Callback { public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Callback {
private Context mContext; private Context mContext;
private MenuBuilder mMenu; private MenuBuilder mMenu;
@ -265,7 +266,7 @@ public class CustomPopupMenu implements MenuBuilder.Callback, MenuPresenter.Call
* *
* @param menu The PopupMenu that was dismissed. * @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 * @param item {@link MenuItem} that was clicked
* @return <code>true</code> if the event was handled, <code>false</code> otherwise. * @return <code>true</code> if the event was handled, <code>false</code> otherwise.
*/ */
public boolean onMenuItemClick(MenuItem item); boolean onMenuItemClick(MenuItem item);
} }
} }

View File

@ -16,6 +16,7 @@
package org.solovyev.android.widget.menu; package org.solovyev.android.widget.menu;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Parcelable; import android.os.Parcelable;
@ -31,12 +32,12 @@ import java.util.ArrayList;
/** /**
* Presents a menu as a small, simple popup anchored to another view. * Presents a menu as a small, simple popup anchored to another view.
*/ */
@SuppressWarnings("unused")
@SuppressLint("PrivateResource")
public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, View.OnKeyListener, public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, View.OnKeyListener,
ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener, ViewTreeObserver.OnGlobalLayoutListener, PopupWindow.OnDismissListener,
MenuPresenter { MenuPresenter {
static final int ITEM_LAYOUT = R.layout.abc_popup_menu_item_layout;
private final Context mContext; private final Context mContext;
private final LayoutInflater mInflater; private final LayoutInflater mInflater;
private final MenuBuilder mMenu; private final MenuBuilder mMenu;
@ -164,6 +165,7 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V
mMenu.close(); mMenu.close();
if (mTreeObserver != null) { if (mTreeObserver != null) {
if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver(); if (!mTreeObserver.isAlive()) mTreeObserver = mAnchorView.getViewTreeObserver();
//noinspection deprecation
mTreeObserver.removeGlobalOnLayoutListener(this); mTreeObserver.removeGlobalOnLayoutListener(this);
mTreeObserver = null; mTreeObserver = null;
} }
@ -224,14 +226,15 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V
@Override @Override
public void onGlobalLayout() { public void onGlobalLayout() {
if (isShowing()) { if (!isShowing()) {
final View anchor = mAnchorView; return;
if (anchor == null || !anchor.isShown()) { }
dismiss(); final View anchor = mAnchorView;
} else if (isShowing()) { if (anchor == null || !anchor.isShown()) {
// Recompute window size and position dismiss();
mPopup.show(); } 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) { public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) { 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; MenuView.ItemView itemView = (MenuView.ItemView) convertView;