diff --git a/README-cn.md b/README-cn.md
index dd862db..8076c9b 100644
--- a/README-cn.md
+++ b/README-cn.md
@@ -19,14 +19,14 @@ Github: https://github.com/liaohuqiu
in.srain.cube
grid-view-with-header-footer
jar
- 1.0.11
+ 1.0.12
```
#### Gradle
``` groovy
-compile 'in.srain.cube:grid-view-with-header-footer:1.0.11'
+compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
```
### 使用示例
diff --git a/README.md b/README.md
index be388c0..577bbbb 100644
--- a/README.md
+++ b/README.md
@@ -21,14 +21,14 @@ This library is contained by `CUBE-SDK`: https://github.com/etao-open-source/cub
in.srain.cube
grid-view-with-header-footer
jar
- 1.0.11
+ 1.0.12
```
#### Gradle
``` groovy
-compile 'in.srain.cube:grid-view-with-header-footer:1.0.11'
+compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
```
### Usage
diff --git a/gradle.properties b/gradle.properties
index 56d20fb..19980c7 100755
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-VERSION_NAME=1.0.11
+VERSION_NAME=1.0.12
ANDROID_BUILD_MIN_SDK_VERSION=8
ANDROID_BUILD_TARGET_SDK_VERSION=16
diff --git a/pom.xml b/pom.xml
index af65977..0620d91 100755
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
grid-view-with-header-footer
jar
GridViewWithHeaderAndFooter
- 1.0.11
+ 1.0.12
GridView with Header and Footer
https://github.com/liaohuqiu/android-GridViewWithHeaderAndFooter
diff --git a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java
index dcad52b..ce997f3 100644
--- a/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java
+++ b/src/in/srain/cube/views/GridViewWithHeaderAndFooter.java
@@ -35,7 +35,7 @@
* See {@link GridViewWithHeaderAndFooter#addHeaderView(View, Object, boolean)}
* See {@link GridViewWithHeaderAndFooter#addFooterView(View, Object, boolean)}
*/
-public class GridViewWithHeaderAndFooter extends GridView implements android.widget.AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
+public class GridViewWithHeaderAndFooter extends GridView {
public static boolean DEBUG = false;
private OnItemClickListener mOnItemClickListener;
@@ -70,6 +70,7 @@ private static class FixedViewInfo {
private ArrayList mHeaderViewInfos = new ArrayList();
private ArrayList mFooterViewInfos = new ArrayList();
private ListAdapter mOriginalAdapter;
+ private ItemClickHandler mItemClickHandler;
private void initHeaderGridView() {
}
@@ -418,6 +419,7 @@ public void setAdapter(ListAdapter adapter) {
/**
* Return original adapter for convenience.
+ *
* @return
*/
public ListAdapter getOriginalAdapter() {
@@ -844,33 +846,43 @@ public void notifyDataSetChanged() {
@Override
public void setOnItemClickListener(OnItemClickListener l) {
mOnItemClickListener = l;
- super.setOnItemClickListener(this);
+ super.setOnItemClickListener(getItemClickHandler());
}
@Override
public void setOnItemLongClickListener(OnItemLongClickListener listener) {
mOnItemLongClickListener = listener;
- super.setOnItemLongClickListener(this);
+ super.setOnItemLongClickListener(getItemClickHandler());
}
- @Override
- public void onItemClick(AdapterView> parent, View view, int position, long id) {
- if (mOnItemClickListener != null) {
- int resPos = position - getHeaderViewCount() * getNumColumnsCompatible();
- if (resPos >= 0) {
- mOnItemClickListener.onItemClick(parent, view, resPos, id);
- }
+ private ItemClickHandler getItemClickHandler() {
+ if (mItemClickHandler == null) {
+ mItemClickHandler = new ItemClickHandler();
}
+ return mItemClickHandler;
}
- @Override
- public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
- if (mOnItemLongClickListener != null) {
- int resPos = position - getHeaderViewCount() * getNumColumnsCompatible();
- if (resPos >= 0) {
- mOnItemLongClickListener.onItemLongClick(parent, view, resPos, id);
+ private class ItemClickHandler implements android.widget.AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener {
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ if (mOnItemClickListener != null) {
+ int resPos = position - getHeaderViewCount() * getNumColumnsCompatible();
+ if (resPos >= 0) {
+ mOnItemClickListener.onItemClick(parent, view, resPos, id);
+ }
}
}
- return true;
+
+ @Override
+ public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
+ if (mOnItemLongClickListener != null) {
+ int resPos = position - getHeaderViewCount() * getNumColumnsCompatible();
+ if (resPos >= 0) {
+ mOnItemLongClickListener.onItemLongClick(parent, view, resPos, id);
+ }
+ }
+ return true;
+ }
}
}
diff --git a/update-project.py b/update-project.py
index cf6b1e2..cafa395 100644
--- a/update-project.py
+++ b/update-project.py
@@ -1,6 +1,6 @@
import os
vars = {
- 'lib_version': '1.0.11'
+ 'lib_version': '1.0.12'
}
files = [