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
* 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 <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;
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,16 +226,17 @@ public class CustomPopupMenuHelper implements AdapterView.OnItemClickListener, V
@Override
public void onGlobalLayout() {
if (isShowing()) {
if (!isShowing()) {
return;
}
final View anchor = mAnchorView;
if (anchor == null || !anchor.isShown()) {
dismiss();
} else if (isShowing()) {
} else {
// Recompute window size and position
mPopup.show();
}
}
}
@Override
public void initForMenu(Context context, MenuBuilder menu) {
@ -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;