From 5cfb3b8b9c47b44aea147625c72375b3b27144a6 Mon Sep 17 00:00:00 2001 From: SadieYu Date: Wed, 13 May 2015 13:48:31 +0800 Subject: [PATCH] remove getNumColumns method which is already added --- .../views/GridViewWithHeaderAndFooter.java | 28 +++---------------- 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java index 8e1d437..5feea1f 100644 --- a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java +++ b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java @@ -64,7 +64,8 @@ private static class FixedViewInfo { private int mNumColumns = AUTO_FIT; private View mViewForMeasureRowHeight = null; private int mRowHeight = -1; - private static final String LOG_TAG = "grid-view-with-header-and-footer"; + //log tag can be at most 23 characters + private static final String LOG_TAG = "GridViewHeaderAndFooter"; private ArrayList mHeaderViewInfos = new ArrayList(); private ArrayList mFooterViewInfos = new ArrayList(); @@ -839,7 +840,7 @@ public void setOnItemLongClickListener(OnItemLongClickListener listener) { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { if (mOnItemClickListener != null) { - int resPos = position - getHeaderViewCount() * getNumColumnsCompat(); + int resPos = position - getHeaderViewCount() * getNumColumnsCompatible(); if (resPos >= 0) { mOnItemClickListener.onItemClick(parent, view, resPos, id); } @@ -849,32 +850,11 @@ public void onItemClick(AdapterView parent, View view, int position, long id) @Override public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { if (mOnItemLongClickListener != null) { - int resPos = position - getHeaderViewCount() * getNumColumnsCompat(); + int resPos = position - getHeaderViewCount() * getNumColumnsCompatible(); if (resPos >= 0) { mOnItemLongClickListener.onItemLongClick(parent, view, resPos, id); } } return true; } - - private int getNumColumnsCompat() { - if (Build.VERSION.SDK_INT >= 11) { - return getNumColumnsCompatFrom11(); - - } else { - try { - Field numColumns = getClass().getSuperclass().getDeclaredField("mNumColumns"); - numColumns.setAccessible(true); - return numColumns.getInt(this); - } catch (Exception e) { - return 1; - } - } - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - private int getNumColumnsCompatFrom11() { - return getNumColumns(); - } - } \ No newline at end of file