Skip to content

Commit

Permalink
remove getNumColumns method which is already added
Browse files Browse the repository at this point in the history
  • Loading branch information
SadieYu committed May 13, 2015
1 parent ea43f20 commit 5cfb3b8
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions src/in/srain/cube/views/GridViewWithHeaderAndFooter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixedViewInfo> mHeaderViewInfos = new ArrayList<FixedViewInfo>();
private ArrayList<FixedViewInfo> mFooterViewInfos = new ArrayList<FixedViewInfo>();
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
}

}

0 comments on commit 5cfb3b8

Please sign in to comment.