diff --git a/.gitignore b/.gitignore
index 48fbd02..ebfc7a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ local.properties
# Proguard folder generated by Eclipse
proguard/
/PullToZoomView/.idea
+*.iml
diff --git a/PullToZoomView/PullToZoomView.iml b/PullToZoomView/PullToZoomView.iml
deleted file mode 100644
index 0bb6048..0000000
--- a/PullToZoomView/PullToZoomView.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PullToZoomView/app/app.iml b/PullToZoomView/app/app.iml
deleted file mode 100644
index f3cf23a..0000000
--- a/PullToZoomView/app/app.iml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PullToZoomView/app/build.gradle b/PullToZoomView/app/build.gradle
index 734d5ca..3fdf409 100644
--- a/PullToZoomView/app/build.gradle
+++ b/PullToZoomView/app/build.gradle
@@ -1,19 +1,19 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 20
+ compileSdkVersion 23
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.ecloud.pulltozoomview.demo"
- minSdkVersion 11
- targetSdkVersion 20
+ minSdkVersion 14
+ targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
- runProguard false
+ minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -21,6 +21,8 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:20.0.0'
+ compile 'com.android.support:appcompat-v7:23.0.1'
+ compile 'com.android.support:recyclerview-v7:23.0.1'
compile project(':library')
+// compile 'com.github.frank-zhu:pullzoomview:1.0.0'
}
diff --git a/PullToZoomView/app/src/main/AndroidManifest.xml b/PullToZoomView/app/src/main/AndroidManifest.xml
index e623720..97d9de9 100644
--- a/PullToZoomView/app/src/main/AndroidManifest.xml
+++ b/PullToZoomView/app/src/main/AndroidManifest.xml
@@ -24,6 +24,9 @@
+
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/MainActivity.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/MainActivity.java
index ab1efe3..aa73389 100644
--- a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/MainActivity.java
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/MainActivity.java
@@ -7,6 +7,8 @@
import android.view.MenuItem;
import android.view.View;
+import com.ecloud.pulltozoomview.demo.recyclerview.PullToZoomRecyclerActivity;
+
public class MainActivity extends ActionBarActivity {
@@ -28,6 +30,13 @@ public void onClick(View v) {
startActivity(new Intent(MainActivity.this, PullToZoomScrollActivity.class));
}
});
+
+ findViewById(R.id.btn_recycler_view).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ startActivity(new Intent(MainActivity.this, PullToZoomRecyclerActivity.class));
+ }
+ });
}
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomListActivity.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomListActivity.java
index 29defd8..bb08e81 100644
--- a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomListActivity.java
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomListActivity.java
@@ -7,11 +7,9 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
-import android.widget.LinearLayout;
import com.ecloud.pulltozoomview.PullToZoomListViewEx;
@@ -44,12 +42,12 @@ protected void onCreate(Bundle savedInstanceState) {
"BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
listView.setAdapter(new ArrayAdapter(PullToZoomListActivity.this, android.R.layout.simple_list_item_1, adapterData));
-// listView.getRootView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
-// @Override
-// public void onItemClick(AdapterView> parent, View view, int position, long id) {
-// Log.e("zhuwenwu", "position = " + position);
-// }
-// });
+ listView.getPullRootView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ Log.e("zhuwenwu", "position = " + position);
+ }
+ });
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomRecyclerViewEx.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomRecyclerViewEx.java
new file mode 100644
index 0000000..442f975
--- /dev/null
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomRecyclerViewEx.java
@@ -0,0 +1,392 @@
+package com.ecloud.pulltozoomview.demo;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.os.SystemClock;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.animation.Interpolator;
+import android.widget.AbsListView;
+import android.widget.AdapterView;
+import android.widget.FrameLayout;
+
+import com.ecloud.pulltozoomview.PullToZoomBase;
+import com.ecloud.pulltozoomview.demo.recyclerview.RecyclerViewHeaderAdapter;
+
+/**
+ * Author: ZhuWenWu
+ * Version V1.0
+ * Date: 2014/11/7 18:01.
+ * Description:
+ * Modification History:
+ * Date Author Version Description
+ * -----------------------------------------------------------------------------------
+ * 2014/11/7 ZhuWenWu 1.0 1.0
+ * Why & What is modified:
+ */
+public class PullToZoomRecyclerViewEx extends PullToZoomBase implements AbsListView.OnScrollListener {
+ private static final String TAG = PullToZoomRecyclerViewEx.class.getSimpleName();
+ private FrameLayout mHeaderContainer;
+ private int mHeaderHeight;
+ private ScalingRunnable mScalingRunnable;
+
+ private static final Interpolator sInterpolator = new Interpolator() {
+ public float getInterpolation(float paramAnonymousFloat) {
+ float f = paramAnonymousFloat - 1.0F;
+ return 1.0F + f * (f * (f * (f * f)));
+ }
+ };
+
+ public PullToZoomRecyclerViewEx(Context context) {
+ this(context, null);
+ }
+
+ public PullToZoomRecyclerViewEx(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mRootView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+
+
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ super.onScrolled(recyclerView, dx, dy);
+
+ if (mZoomView != null && !isHideHeader() && isPullToZoomEnabled()) {
+ float f = mHeaderHeight - mHeaderContainer.getBottom();
+ Log.d(TAG, "onScroll --> f = " + f);
+ if (isParallax()) {
+ if ((f > 0.0F) && (f < mHeaderHeight)) {
+ int i = (int) (0.65D * f);
+ mHeaderContainer.scrollTo(0, -i);
+ } else if (mHeaderContainer.getScrollY() != 0) {
+ mHeaderContainer.scrollTo(0, 0);
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+
+
+ }
+ });
+ mScalingRunnable = new ScalingRunnable();
+ }
+
+ /**
+ * 是否显示headerView
+ *
+ * @param isHideHeader true: show false: hide
+ */
+ @Override
+ public void setHideHeader(boolean isHideHeader) {
+ if (isHideHeader != isHideHeader()) {
+ super.setHideHeader(isHideHeader);
+ if (isHideHeader) {
+ removeHeaderView();
+ } else {
+ updateHeaderView();
+ }
+ }
+ }
+
+ @Override
+ public void setHeaderView(View headerView) {
+ if (headerView != null) {
+ this.mHeaderView = headerView;
+ updateHeaderView();
+ }
+ }
+
+ @Override
+ public void setZoomView(View zoomView) {
+ if (zoomView != null) {
+ this.mZoomView = zoomView;
+ updateHeaderView();
+ }
+ }
+
+ /**
+ * 移除HeaderView
+ * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
+ */
+ private void removeHeaderView() {
+ if (mHeaderContainer != null) {
+ if (mRootView != null && mRootView.getAdapter() != null) {
+
+ RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
+
+ if (mAdapter != null) {
+
+ if (mAdapter.getHeader(0) != null)
+ mAdapter.removeHeaderView(mAdapter.getHeader(0));
+ }
+
+ }
+ }
+ }
+
+ /**
+ * 更新HeaderView 先移除-->再添加zoomView、HeaderView -->然后添加到listView的head
+ * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
+ */
+ private void updateHeaderView() {
+ if (mHeaderContainer != null) {
+
+ if (mRootView != null && mRootView.getAdapter() != null) {
+
+ RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
+
+ if (mAdapter != null) {
+
+ if (mAdapter.getHeader(0) != null)
+ mAdapter.removeHeaderView(mAdapter.getHeader(0));
+
+ mHeaderContainer.removeAllViews();
+
+ if (mZoomView != null) {
+ mHeaderContainer.addView(mZoomView);
+ }
+
+ if (mHeaderView != null) {
+ mHeaderContainer.addView(mHeaderView);
+ }
+
+ mHeaderHeight = mHeaderContainer.getHeight();
+
+ RecyclerViewHeaderAdapter.ExtraItem mExtraItem = new RecyclerViewHeaderAdapter.ExtraItem(RecyclerViewHeaderAdapter.INT_TYPE_HEADER, new RecyclerView.ViewHolder(mHeaderContainer) {
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+ });
+
+ mAdapter.addHeaderView(mExtraItem);
+ }
+ }
+ }
+ }
+
+ public void setAdapterAndLayoutManager(RecyclerView.Adapter adapter, GridLayoutManager mLayoutManager) {
+ mRootView.setLayoutManager(mLayoutManager);
+ mRootView.setAdapter(adapter);
+ updateHeaderView();
+ }
+
+ public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
+// mRootView.setOnItemClickListener(listener);
+ }
+
+ /**
+ * 创建listView 如果要兼容API9,需要修改此处
+ *
+ * @param context 上下文
+ * @param attrs AttributeSet
+ * @return ListView
+ */
+ @Override
+ protected RecyclerView createRootView(Context context, AttributeSet attrs) {
+ RecyclerView rv = new RecyclerView(context, attrs);
+ // Set it to this so it can be used in ListActivity/ListFragment
+
+// rv.setId(android.R.id.list);
+ return rv;
+ }
+
+ /**
+ * 重置动画,自动滑动到顶部
+ */
+ @Override
+ protected void smoothScrollToTop() {
+ Log.d(TAG, "smoothScrollToTop --> ");
+ mScalingRunnable.startAnimation(200L);
+ }
+
+ /**
+ * zoomView动画逻辑
+ *
+ * @param newScrollValue 手指Y轴移动距离值
+ */
+ @Override
+ protected void pullHeaderToZoom(int newScrollValue) {
+ Log.d(TAG, "pullHeaderToZoom --> newScrollValue = " + newScrollValue);
+ Log.d(TAG, "pullHeaderToZoom --> mHeaderHeight = " + mHeaderHeight);
+ if (mScalingRunnable != null && !mScalingRunnable.isFinished()) {
+ mScalingRunnable.abortAnimation();
+ }
+
+ ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
+ localLayoutParams.height = Math.abs(newScrollValue) + mHeaderHeight;
+ mHeaderContainer.setLayoutParams(localLayoutParams);
+ }
+
+ @Override
+ protected boolean isReadyForPullStart() {
+ return isFirstItemVisible();
+ }
+
+ private boolean isFirstItemVisible() {
+ if (mRootView != null) {
+ final RecyclerView.Adapter adapter = mRootView.getAdapter();
+ final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager();
+
+
+ if (null == adapter || adapter.getItemCount() == 0) {
+ return true;
+ } else {
+ /**
+ * This check should really just be:
+ * mRootView.getFirstVisiblePosition() == 0, but PtRListView
+ * internally use a HeaderView which messes the positions up. For
+ * now we'll just add one to account for it and rely on the inner
+ * condition which checks getTop().
+ */
+
+ int[] into = {0,0};
+ if (mLayoutmanager != null)
+ into[0] = mLayoutmanager.findFirstVisibleItemPosition();
+ if (into.length > 0 && into.length > 0 && into[0] <= 1) {
+ final View firstVisibleChild = mRootView.getChildAt(0);
+ if (firstVisibleChild != null) {
+ return firstVisibleChild.getTop() >= mRootView.getTop();
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public void handleStyledAttributes(TypedArray a) {
+ mHeaderContainer = new FrameLayout(getContext());
+ if (mZoomView != null) {
+ mHeaderContainer.addView(mZoomView);
+ }
+ if (mHeaderView != null) {
+ mHeaderContainer.addView(mHeaderView);
+ }
+ RecyclerViewHeaderAdapter mAdapter = (RecyclerViewHeaderAdapter) mRootView.getAdapter();
+ if (mAdapter != null) {
+ RecyclerViewHeaderAdapter.ExtraItem mExtraItem = new RecyclerViewHeaderAdapter.ExtraItem(RecyclerViewHeaderAdapter.INT_TYPE_HEADER, new RecyclerView.ViewHolder(mHeaderContainer) {
+ @Override
+ public String toString() {
+ return super.toString();
+ }
+ });
+
+ mAdapter.addHeaderView(mExtraItem);
+ }
+ }
+
+ /**
+ * 设置HeaderView高度
+ *
+ * @param width 宽
+ * @param height 高
+ */
+ public void setHeaderViewSize(int width, int height) {
+ if (mHeaderContainer != null) {
+ Object localObject = mHeaderContainer.getLayoutParams();
+ if (localObject == null) {
+ localObject = new AbsListView.LayoutParams(width, height);
+ }
+ ((ViewGroup.LayoutParams) localObject).width = width;
+ ((ViewGroup.LayoutParams) localObject).height = height;
+ mHeaderContainer.setLayoutParams((ViewGroup.LayoutParams) localObject);
+ mHeaderHeight = height;
+ }
+ }
+
+ public void setHeaderLayoutParams(AbsListView.LayoutParams layoutParams) {
+ if (mHeaderContainer != null) {
+ mHeaderContainer.setLayoutParams(layoutParams);
+ mHeaderHeight = layoutParams.height;
+ }
+ }
+
+ protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2,
+ int paramInt3, int paramInt4) {
+ super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
+ Log.d(TAG, "onLayout --> ");
+ if (mHeaderHeight == 0 && mHeaderContainer != null) {
+ mHeaderHeight = mHeaderContainer.getHeight();
+ }
+ }
+
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ Log.d(TAG, "onScrollStateChanged --> ");
+ }
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ if (mZoomView != null && !isHideHeader() && isPullToZoomEnabled()) {
+ float f = mHeaderHeight - mHeaderContainer.getBottom();
+ Log.d(TAG, "onScroll --> f = " + f);
+ if (isParallax()) {
+ if ((f > 0.0F) && (f < mHeaderHeight)) {
+ int i = (int) (0.65D * f);
+ mHeaderContainer.scrollTo(0, -i);
+ } else if (mHeaderContainer.getScrollY() != 0) {
+ mHeaderContainer.scrollTo(0, 0);
+ }
+ }
+ }
+ }
+
+
+ class ScalingRunnable implements Runnable {
+ protected long mDuration;
+ protected boolean mIsFinished = true;
+ protected float mScale;
+ protected long mStartTime;
+
+ ScalingRunnable() {
+ }
+
+ public void abortAnimation() {
+ mIsFinished = true;
+ }
+
+ public boolean isFinished() {
+ return mIsFinished;
+ }
+
+ public void run() {
+ if (mZoomView != null) {
+ float f2;
+ ViewGroup.LayoutParams localLayoutParams;
+ if ((!mIsFinished) && (mScale > 1.0D)) {
+ float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
+ f2 = mScale - (mScale - 1.0F) * PullToZoomRecyclerViewEx.sInterpolator.getInterpolation(f1);
+ localLayoutParams = mHeaderContainer.getLayoutParams();
+ Log.d(TAG, "ScalingRunnable --> f2 = " + f2);
+ if (f2 > 1.0F) {
+ localLayoutParams.height = ((int) (f2 * mHeaderHeight));
+ mHeaderContainer.setLayoutParams(localLayoutParams);
+ post(this);
+ return;
+ }
+ mIsFinished = true;
+ }
+ }
+ }
+
+ public void startAnimation(long paramLong) {
+ if (mZoomView != null) {
+ mStartTime = SystemClock.currentThreadTimeMillis();
+ mDuration = paramLong;
+ mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
+ mIsFinished = false;
+ post(this);
+ }
+ }
+ }
+}
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomScrollActivity.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomScrollActivity.java
index 4a1d0ea..cedcd7a 100644
--- a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomScrollActivity.java
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/PullToZoomScrollActivity.java
@@ -1,6 +1,5 @@
package com.ecloud.pulltozoomview.demo;
-import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.DisplayMetrics;
@@ -9,10 +8,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.LinearLayout;
-import com.ecloud.pulltozoomview.PullToZoomScrollView;
import com.ecloud.pulltozoomview.PullToZoomScrollViewEx;
/**
@@ -35,8 +32,23 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pull_to_zoom_scroll_view);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ loadViewForCode();
scrollView = (PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
- scrollView.getRootView().findViewById(R.id.tv_test1).setOnClickListener(new View.OnClickListener() {
+ scrollView.getPullRootView().findViewById(R.id.tv_test1).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.e("zhuwenwu", "onClick -->");
+ }
+ });
+
+ scrollView.getPullRootView().findViewById(R.id.tv_test2).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Log.e("zhuwenwu", "onClick -->");
+ }
+ });
+
+ scrollView.getPullRootView().findViewById(R.id.tv_test3).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("zhuwenwu", "onClick -->");
@@ -78,7 +90,7 @@ else if (id == R.id.action_normal) {
scrollView.setHideHeader(false);
return true;
} else if (id == R.id.action_hide_head) {
-// scrollView.hideHeaderView();
+// scrollView.hideHeaderVie˛w();
scrollView.setHideHeader(true);
return true;
} else if (id == R.id.action_disable_zoom) {
@@ -94,12 +106,12 @@ else if (id == R.id.action_normal) {
}
private void loadViewForCode() {
- PullToZoomScrollView scrollView = (PullToZoomScrollView) findViewById(R.id.scroll_view);
+ PullToZoomScrollViewEx scrollView = (PullToZoomScrollViewEx) findViewById(R.id.scroll_view);
View headView = LayoutInflater.from(this).inflate(R.layout.profile_head_view, null, false);
View zoomView = LayoutInflater.from(this).inflate(R.layout.profile_zoom_view, null, false);
View contentView = LayoutInflater.from(this).inflate(R.layout.profile_content_view, null, false);
- scrollView.setHeaderContainer(headView);
+ scrollView.setHeaderView(headView);
scrollView.setZoomView(zoomView);
- scrollView.setContentContainerView(contentView);
+ scrollView.setScrollContentView(contentView);
}
}
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/PullToZoomRecyclerActivity.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/PullToZoomRecyclerActivity.java
new file mode 100644
index 0000000..744928a
--- /dev/null
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/PullToZoomRecyclerActivity.java
@@ -0,0 +1,150 @@
+package com.ecloud.pulltozoomview.demo.recyclerview;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.DisplayMetrics;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.TextView;
+
+import com.ecloud.pulltozoomview.demo.PullToZoomRecyclerViewEx;
+import com.ecloud.pulltozoomview.demo.R;
+
+/**
+ * Created by manishdeora on 13/05/15.
+ */
+public class PullToZoomRecyclerActivity extends ActionBarActivity {
+ private PullToZoomRecyclerViewEx listView;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+ setContentView(R.layout.activity_pull_to_zoom_recycler_view);
+
+ listView = (PullToZoomRecyclerViewEx) findViewById(R.id.recyclerview);
+
+
+ final RecyclerViewHeaderAdapter mAdapter = new RecyclerAdapterCustom(this);
+
+ final GridLayoutManager manager = new GridLayoutManager(this, 2);
+ manager.setOrientation(GridLayoutManager.VERTICAL);
+ manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
+ @Override
+ public int getSpanSize(int position) {
+ return mAdapter.getItemViewType(position) == RecyclerViewHeaderAdapter.INT_TYPE_HEADER ? 2 : 1;
+ }
+ });
+ listView.setAdapterAndLayoutManager(mAdapter, manager);
+
+
+ DisplayMetrics localDisplayMetrics = new DisplayMetrics();
+ getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
+ int mScreenHeight = localDisplayMetrics.heightPixels;
+ int mScreenWidth = localDisplayMetrics.widthPixels;
+ AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
+ listView.setHeaderLayoutParams(localObject);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.list_view, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+ if (id == android.R.id.home) {
+ finish();
+ return true;
+ } else if (id == R.id.action_normal) {
+ listView.setParallax(false);
+ return true;
+ } else if (id == R.id.action_parallax) {
+ listView.setParallax(true);
+ return true;
+ } else if (id == R.id.action_show_head) {
+ listView.setHideHeader(false);
+ return true;
+ } else if (id == R.id.action_hide_head) {
+ listView.setHideHeader(true);
+ return true;
+ } else if (id == R.id.action_disable_zoom) {
+ listView.setZoomEnabled(false);
+ return true;
+ } else if (id == R.id.action_enable_zoom) {
+ listView.setZoomEnabled(true);
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ public class RecyclerAdapterCustom extends RecyclerViewHeaderAdapter {
+ final String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
+ "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
+ "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
+ "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
+ "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
+ "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
+ "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};
+
+ public RecyclerAdapterCustom(Context context) {
+ super(context);
+ }
+
+ @Override
+ public int getCount() {
+ return adapterData.length;
+ }
+
+ @Override
+ public ViewHolderRecyclerPullToZoom onCreateContentView(ViewGroup parent, int viewType) {
+ return new ViewHolderRecyclerPullToZoom(new TextView(getContext()));
+ }
+
+ @Override
+ public void onBindView(ViewHolderRecyclerPullToZoom view, int position) {
+
+ view.mtextview.setText(adapterData[position]);
+
+// final StaggeredGridLayoutManager.LayoutParams lp =
+// (StaggeredGridLayoutManager.LayoutParams) view.mtextview.getLayoutParams();
+////
+// lp.span = span;
+// lp.height = size;
+// itemView.setLayoutParams(lp);
+
+
+ }
+ }
+
+ public static class ViewHolderRecyclerPullToZoom extends RecyclerView.ViewHolder {
+
+ TextView mtextview;
+
+ public ViewHolderRecyclerPullToZoom(View itemView) {
+ super(itemView);
+
+ mtextview = (TextView) itemView;
+ }
+ }
+}
\ No newline at end of file
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/RecyclerViewHeaderAdapter.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/RecyclerViewHeaderAdapter.java
new file mode 100644
index 0000000..828dd6e
--- /dev/null
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/RecyclerViewHeaderAdapter.java
@@ -0,0 +1,195 @@
+/*
+ * Created by Krishan Patel.
+ * Copyright (c) 2014. Rocko Labs Ltd. All Rights Reserved.
+ */
+
+package com.ecloud.pulltozoomview.demo.recyclerview;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.support.v7.widget.StaggeredGridLayoutManager;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class RecyclerViewHeaderAdapter extends RecyclerView.Adapter {
+ public static final int INT_TYPE_HEADER = 0;
+ public static final int INT_TYPE_FOOTER = 1;
+
+ public static class ExtraItem {
+ public final int type;
+ public final V view;
+
+ public ExtraItem(int type, V view) {
+ this.type = type;
+ this.view = view;
+ }
+
+ }
+
+ private View emptyView;
+
+ private final Context context;
+ private final List headers;
+ private final List footers;
+
+ public RecyclerViewHeaderAdapter(Context context) {
+ this.context = context;
+ this.headers = new ArrayList();
+ this.footers = new ArrayList();
+ }
+
+ public Context getContext() {
+ return context;
+ }
+
+ public void setEmptyView(View emptyView) {
+ this.emptyView = emptyView;
+ emptyView.setVisibility(getCount() == 0 ? View.VISIBLE : View.GONE);
+ }
+
+ public abstract int getCount();
+
+ @Override
+ public final int getItemCount() {
+ int count = headers.size();
+ count += getCount();
+ count += footers.size();
+
+ if (emptyView != null)
+ emptyView.setVisibility(getCount() == 0 ? View.VISIBLE : View.GONE);
+
+ return count;
+ }
+
+ public ExtraItem addHeaderView(int type, V headerView) {
+ ExtraItem item = new ExtraItem(type, headerView);
+ addHeaderView(item);
+ return item;
+ }
+
+ public void addHeaderView(ExtraItem headerView) {
+ headers.add(headerView);
+ notifyItemInserted(headers.size());
+ }
+
+ public void removeHeaderView(int type) {
+ List indexesToRemove = new ArrayList();
+ for (int i = 0; i < headers.size(); i++) {
+ ExtraItem item = headers.get(i);
+ if (item.type == type)
+ indexesToRemove.add(item);
+ }
+
+ for (ExtraItem item : indexesToRemove) {
+ int index = headers.indexOf(item);
+ headers.remove(item);
+ notifyItemRemoved(index);
+ }
+ }
+
+ public void removeHeaderView(ExtraItem headerView) {
+ int indexToRemove = headers.indexOf(headerView);
+ if (indexToRemove >= 0) {
+ headers.remove(indexToRemove);
+ notifyItemRemoved(indexToRemove);
+ }
+ }
+
+ public ExtraItem addFooterView(int type, V footerView) {
+ ExtraItem item = new ExtraItem(type, footerView);
+ addFooterView(item);
+ return item;
+ }
+
+ public void addFooterView(ExtraItem footerView) {
+ footers.add(footerView);
+ notifyItemInserted(getItemCount());
+ }
+
+ public void removeFooterView(int type) {
+ List indexesToRemove = new ArrayList();
+ for (int i = 0; i < footers.size(); i++) {
+ ExtraItem item = footers.get(i);
+ if (item.type == type)
+ indexesToRemove.add(item);
+ }
+
+ for (ExtraItem item : indexesToRemove) {
+ int index = footers.indexOf(item);
+ footers.remove(item);
+ notifyItemRemoved(headers.size() + getCount() + index);
+ }
+ }
+
+ public void removeFooterView(ExtraItem footerView) {
+ int indexToRemove = footers.indexOf(footerView);
+ if (indexToRemove >= 0) {
+ footers.remove(indexToRemove);
+ notifyItemRemoved(headers.size() + getCount() + indexToRemove);
+ }
+ }
+
+ public int getViewType(int position) {
+ return super.getItemViewType(position);
+ }
+
+
+ public ExtraItem getHeader(int mIntArgHeaderPos) {
+
+ if (headers != null && headers.size() > mIntArgHeaderPos) {
+ return headers.get(mIntArgHeaderPos);
+ }
+ return null;
+ }
+
+ @Override
+ public final int getItemViewType(int position) {
+ if (position < headers.size())
+ return INT_TYPE_HEADER;
+ else
+ return INT_TYPE_FOOTER;
+// return getViewType(position - headers.size());
+ }
+
+ @Override
+ public final V onCreateViewHolder(ViewGroup parent, int viewType) {
+ for (ExtraItem item : headers)
+ if (viewType == item.type)
+ return item.view;
+
+ for (ExtraItem item : footers)
+ if (viewType == item.type)
+ return item.view;
+
+ return onCreateContentView(parent, viewType);
+ }
+
+ public abstract V onCreateContentView(ViewGroup parent, int viewType);
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ if (position >= headers.size() && (position - headers.size()) < getCount()) {
+ //noinspection unchecked
+ onBindView((V) holder, position - headers.size());
+ } else {
+
+ try {
+ final StaggeredGridLayoutManager.LayoutParams lp =
+ (StaggeredGridLayoutManager.LayoutParams) holder.itemView.getLayoutParams();
+//
+ lp.setFullSpan(true);
+ ;
+
+ holder.itemView.setLayoutParams(lp);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public abstract void onBindView(V view, int position);
+
+}
\ No newline at end of file
diff --git a/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/SpannableStaggeredGridLayoutManager.java b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/SpannableStaggeredGridLayoutManager.java
new file mode 100644
index 0000000..7943981
--- /dev/null
+++ b/PullToZoomView/app/src/main/java/com/ecloud/pulltozoomview/demo/recyclerview/SpannableStaggeredGridLayoutManager.java
@@ -0,0 +1,15 @@
+package com.ecloud.pulltozoomview.demo.recyclerview;
+
+import android.support.v7.widget.RecyclerView;
+
+/**
+ * Created by manishdeora on 14/05/15.
+ */
+public class SpannableStaggeredGridLayoutManager extends RecyclerView.LayoutManager{
+
+
+ @Override
+ public RecyclerView.LayoutParams generateDefaultLayoutParams() {
+ return null;
+ }
+}
diff --git a/PullToZoomView/app/src/main/res/layout/activity_main.xml b/PullToZoomView/app/src/main/res/layout/activity_main.xml
index 6696eb3..9e23686 100644
--- a/PullToZoomView/app/src/main/res/layout/activity_main.xml
+++ b/PullToZoomView/app/src/main/res/layout/activity_main.xml
@@ -1,33 +1,48 @@
-
+ android:layout_marginTop="142dp"
+ android:text="Zoom List View"
+ android:textSize="22sp" />
-
+ android:layout_marginTop="83dp"
+ android:text="Zoom Scroll View"
+ android:textSize="22sp" />
+
+
+
+
+
+
diff --git a/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_recycler_view.xml b/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_recycler_view.xml
new file mode 100644
index 0000000..1c6eef2
--- /dev/null
+++ b/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_recycler_view.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_scroll_view.xml b/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_scroll_view.xml
index 4c275cf..446db56 100644
--- a/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_scroll_view.xml
+++ b/PullToZoomView/app/src/main/res/layout/activity_pull_to_zoom_scroll_view.xml
@@ -9,8 +9,5 @@
+ android:layout_height="match_parent"/>
\ No newline at end of file
diff --git a/PullToZoomView/app/src/main/res/layout/profile_content_view.xml b/PullToZoomView/app/src/main/res/layout/profile_content_view.xml
index db4b187..331537d 100644
--- a/PullToZoomView/app/src/main/res/layout/profile_content_view.xml
+++ b/PullToZoomView/app/src/main/res/layout/profile_content_view.xml
@@ -1,5 +1,4 @@
-
+ android:padding="20dp"
+ android:text="test1"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test1"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test1"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test1"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test2"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test2"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test2"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test2"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test3"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test3"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test3"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test3"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test4"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test4"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test4"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test4"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test5"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test5"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test5"
+ android:textSize="20sp" />
+ android:padding="20dp"
+ android:text="test5"
+ android:textSize="20sp" />
\ No newline at end of file
diff --git a/PullToZoomView/app/src/main/res/layout/profile_head_view.xml b/PullToZoomView/app/src/main/res/layout/profile_head_view.xml
index 80f91f3..142795d 100644
--- a/PullToZoomView/app/src/main/res/layout/profile_head_view.xml
+++ b/PullToZoomView/app/src/main/res/layout/profile_head_view.xml
@@ -22,7 +22,7 @@
android:layout_marginTop="8dp"
android:layout_below="@id/iv_user_head"
android:layout_centerHorizontal="true"
- android:text=""
+ android:text="qawdqwdqwdqwdwqd"
android:textColor="#ffffff" />
Code
ZoomListView
ZoomScrollView
+ ZoomRecyclerView
Normal
Parallax
Show Head
diff --git a/PullToZoomView/build.gradle b/PullToZoomView/build.gradle
index 9b8abe4..9405f3f 100644
--- a/PullToZoomView/build.gradle
+++ b/PullToZoomView/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.12.2'
+ classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/PullToZoomView/gradle.properties b/PullToZoomView/gradle.properties
index 7346ce7..ac3ea1d 100644
--- a/PullToZoomView/gradle.properties
+++ b/PullToZoomView/gradle.properties
@@ -18,16 +18,21 @@
# org.gradle.parallel=true
VERSION_NAME=1.0.0
-VERSION_CODE=1
-GROUP=com.ecloud
+VERSION_CODE=100
+GROUP=com.github.frank-zhu
+
+ANDROID_BUILD_MIN_SDK_VERSION=14
+ANDROID_BUILD_TARGET_SDK_VERSION=23
+ANDROID_BUILD_SDK_VERSION=23
+ANDROID_BUILD_TOOLS_VERSION=23.0.0
POM_DESCRIPTION=An Android custom ListView and ScrollView with pull to zoom-in.
POM_URL=https://github.com/Frank-Zhu/PullZoomView/tree/master/PullToZoomView
POM_SCM_URL=https://github.com/Frank-Zhu/PullZoomView/tree/master/PullToZoomView
-POM_SCM_CONNECTION=scm:https://github.com/Frank-Zhu/PullZoomView.git
-POM_SCM_DEV_CONNECTION=scm:https://github.com/Frank-Zhu/PullZoomView.git
+POM_SCM_CONNECTION=scm:git@github.com:Frank-Zhu/PullZoomView.git
+POM_SCM_DEV_CONNECTION=scm:git@github.com:Frank-Zhu/PullZoomView.git
POM_LICENCE_NAME=apache
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0
POM_LICENCE_DIST=repo
-POM_DEVELOPER_ID=frank
+POM_DEVELOPER_ID=frank-zhu
POM_DEVELOPER_NAME=Frank Zhu
\ No newline at end of file
diff --git a/PullToZoomView/gradle/wrapper/gradle-wrapper.properties b/PullToZoomView/gradle/wrapper/gradle-wrapper.properties
index 1e61d1f..ea63eec 100644
--- a/PullToZoomView/gradle/wrapper/gradle-wrapper.properties
+++ b/PullToZoomView/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Apr 10 15:27:10 PDT 2013
+#Fri Feb 06 15:14:21 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/PullToZoomView/library/build.gradle b/PullToZoomView/library/build.gradle
index 6df2855..d2c75b9 100644
--- a/PullToZoomView/library/build.gradle
+++ b/PullToZoomView/library/build.gradle
@@ -2,19 +2,18 @@ apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
- compileSdkVersion 19
- buildToolsVersion "20.0.0"
+ compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
+ buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
- applicationId "com.ecloud.pulltozoomview"
- minSdkVersion 11
- targetSdkVersion 19
- versionCode 1
- versionName "1.0"
+ minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
+ targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
+ versionName project.VERSION_NAME
+ versionCode Integer.parseInt(project.VERSION_CODE)
}
buildTypes {
release {
- runProguard false
+ minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -22,7 +21,7 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:20.0.0'
+ compile 'com.android.support:appcompat-v7:23.0.1'
}
-apply from: './gradle-mvn-push.gradle'
+apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
diff --git a/PullToZoomView/library/gradle-mvn-push.gradle b/PullToZoomView/library/gradle-mvn-push.gradle
deleted file mode 100644
index 7e76374..0000000
--- a/PullToZoomView/library/gradle-mvn-push.gradle
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2013 Chris Banes
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-apply plugin: 'maven'
-apply plugin: 'signing'
-
-def isReleaseBuild() {
- return VERSION_NAME.contains("SNAPSHOT") == false
-}
-
-def getReleaseRepositoryUrl() {
- return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
- : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
-}
-
-def getSnapshotRepositoryUrl() {
- return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
- : "https://oss.sonatype.org/content/repositories/snapshots/"
-}
-
-def getRepositoryUsername() {
- return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
-}
-
-def getRepositoryPassword() {
- return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
-}
-
-afterEvaluate { project ->
- uploadArchives {
- repositories {
- mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- pom.groupId = GROUP
- pom.artifactId = POM_ARTIFACT_ID
- pom.version = VERSION_NAME
-
- repository(url: getReleaseRepositoryUrl()) {
- authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
- }
- snapshotRepository(url: getSnapshotRepositoryUrl()) {
- authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
- }
-
- pom.project {
- name POM_NAME
- packaging POM_PACKAGING
- description POM_DESCRIPTION
- url POM_URL
-
- scm {
- url POM_SCM_URL
- connection POM_SCM_CONNECTION
- developerConnection POM_SCM_DEV_CONNECTION
- }
-
- licenses {
- license {
- name POM_LICENCE_NAME
- url POM_LICENCE_URL
- distribution POM_LICENCE_DIST
- }
- }
-
- developers {
- developer {
- id POM_DEVELOPER_ID
- name POM_DEVELOPER_NAME
- }
- }
- }
- }
- }
- }
-
- signing {
- required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
- sign configurations.archives
- }
-
- task apklib(type: Zip) {
- appendix = extension = 'apklib'
-
- from 'AndroidManifest.xml'
- into('res') {
- from 'res'
- }
- into('src') {
- from 'src'
- }
- }
-
- task jar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- }
-
- task androidJavadocs(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
- }
-
- task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
- classifier = 'javadoc'
- from androidJavadocs.destinationDir
- }
-
- task androidSourcesJar(type: Jar) {
- classifier = 'sources'
- from android.sourceSets.main.java.srcDirs
- }
-
- artifacts {
- archives androidSourcesJar
- archives apklib
- archives jar
- }
-}
\ No newline at end of file
diff --git a/PullToZoomView/library/gradle.properties b/PullToZoomView/library/gradle.properties
index 5ef5283..8b2f41c 100644
--- a/PullToZoomView/library/gradle.properties
+++ b/PullToZoomView/library/gradle.properties
@@ -18,5 +18,5 @@
# org.gradle.parallel=true
POM_NAME=PullToZoomView Library
-POM_ARTIFACT_ID=pull-to-zoom-view
+POM_ARTIFACT_ID=pullzoomview
POM_PACKAGING=aar
\ No newline at end of file
diff --git a/PullToZoomView/library/library.iml b/PullToZoomView/library/library.iml
deleted file mode 100644
index 7148de7..0000000
--- a/PullToZoomView/library/library.iml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/IPullToZoom.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/IPullToZoom.java
index 5834a31..b2dbe7a 100644
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/IPullToZoom.java
+++ b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/IPullToZoom.java
@@ -31,7 +31,7 @@ public interface IPullToZoom {
*
* @return The View which is currently wrapped
*/
- public T getRootView();
+ public T getPullRootView();
/**
* Whether Pull-to-Refresh is enabled
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomBase.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomBase.java
index a344f37..a14fd32 100644
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomBase.java
+++ b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomBase.java
@@ -87,7 +87,7 @@ private void init(Context context, AttributeSet attrs) {
mHeaderView = mLayoutInflater.inflate(headerViewResId, null, false);
}
- isParallax = a.getBoolean(R.styleable.PullToZoomListView_isHeadParallax, true);
+ isParallax = a.getBoolean(R.styleable.PullToZoomView_isHeaderParallax, true);
// Let the derivative classes have a go at handling attributes, then
// recycle them...
@@ -102,7 +102,7 @@ public void setOnPullZoomListener(OnPullZoomListener onPullZoomListener) {
}
@Override
- public T getRootView() {
+ public T getPullRootView() {
return mRootView;
}
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListView.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListView.java
deleted file mode 100644
index 7e5d619..0000000
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListView.java
+++ /dev/null
@@ -1,338 +0,0 @@
-package com.ecloud.pulltozoomview;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Interpolator;
-import android.widget.AbsListView;
-import android.widget.FrameLayout;
-import android.widget.ListView;
-
-/**
- * Author: ZhuWenWu
- * Version V1.0
- * Date: 2014/9/1 10:50.
- * Description:
- * Modification History:
- * Date Author Version Description
- * -----------------------------------------------------------------------------------
- * 2014/9/1 ZhuWenWu 1.0 1.0
- * Why & What is modified:
- */
-
-public class PullToZoomListView extends ListView implements AbsListView.OnScrollListener {
- private static final int INVALID_VALUE = -1;
- private static final String TAG = PullToZoomListView.class.getSimpleName();
-
- private static final Interpolator sInterpolator = new Interpolator() {
- public float getInterpolation(float paramAnonymousFloat) {
- float f = paramAnonymousFloat - 1.0F;
- return 1.0F + f * (f * (f * (f * f)));
- }
- };
-
- private FrameLayout mHeaderContainer;
- private View mHeaderView;
-
- private OnScrollListener mOnScrollListener;
- private ScalingRunnable mScalingRunnable;
-
- private int mScreenHeight;
- private int mScreenWidth;
- private int mHeaderHeight;
- private int mActivePointerId = -1;
- private float mLastMotionY = -1.0F;
- private float mLastScale = -1.0F;
- private float mMaxScale = -1.0F;
- private boolean isParallax = true;
- private boolean isHideHeader = false;
- private boolean isEnableZoom = true;
-
- public PullToZoomListView(Context paramContext) {
- this(paramContext, null);
- }
-
- public PullToZoomListView(Context paramContext, AttributeSet paramAttributeSet) {
- this(paramContext, paramAttributeSet, 0);
- }
-
- public PullToZoomListView(Context paramContext, AttributeSet attrs, int paramInt) {
- super(paramContext, attrs, paramInt);
- init(attrs);
- }
-
- private void endScaling() {
- if (mHeaderContainer.getBottom() >= mHeaderHeight)
- Log.d(TAG, "endScaling");
- mScalingRunnable.startAnimation(200L);
- }
-
- private void init(AttributeSet attrs) {
- mHeaderContainer = new FrameLayout(getContext());
- if (attrs != null) {
- LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
- //初始化状态View
- TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PullToZoomListView);
-
- int headViewResId = a.getResourceId(R.styleable.PullToZoomListView_listHeadView, 0);
- if (headViewResId > 0) {
- mHeaderView = mLayoutInflater.inflate(headViewResId, null, false);
- mHeaderContainer.addView(mHeaderView);
- isHideHeader = false;
- } else {
- isHideHeader = true;
- }
-
- isParallax = a.getBoolean(R.styleable.PullToZoomListView_isHeadParallax, true);
-
- a.recycle();
- }
-
- DisplayMetrics localDisplayMetrics = new DisplayMetrics();
- ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
- mScreenHeight = localDisplayMetrics.heightPixels;
- mScreenWidth = localDisplayMetrics.widthPixels;
- if (mHeaderView != null) {
- setHeaderViewSize(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
- addHeaderView(mHeaderContainer);
- }
- mScalingRunnable = new ScalingRunnable();
- super.setOnScrollListener(this);
- }
-
- public void setParallax(boolean isParallax) {
- this.isParallax = isParallax;
- }
-
- public void setEnableZoom(boolean isEnableZoom) {
- this.isEnableZoom = isEnableZoom;
- }
-
- public void setHeaderView(View headerView) {
- if (mHeaderView != null) {
- removeHeaderView(mHeaderContainer);
- }
- this.mHeaderView = headerView;
- updateHeaderView(headerView);
- }
-
- private void updateHeaderView(View headerView) {
- if (headerView != null) {
- mHeaderContainer.removeAllViews();
- mHeaderContainer.addView(mHeaderView);
- setHeaderViewSize(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
- mHeaderHeight = mHeaderContainer.getHeight();
- addHeaderView(mHeaderContainer);
- }
- }
-
- public View getHeaderView() {
- return mHeaderView;
- }
-
- public boolean isHideHeader() {
- return isHideHeader;
- }
-
- public void showHeadView() {
- if (mHeaderView != null && isHideHeader) {
- isHideHeader = false;
- updateHeaderView(mHeaderView);
- }
- }
-
- public void hideHeadView() {
- if (mHeaderView != null && !isHideHeader) {
- isHideHeader = true;
- removeHeaderView(mHeaderContainer);
- }
- }
-
- private void onSecondaryPointerUp(MotionEvent paramMotionEvent) {
- int i = (paramMotionEvent.getAction()) >> 8;
- if (paramMotionEvent.getPointerId(i) == mActivePointerId)
- if (i != 0) {
- mLastMotionY = paramMotionEvent.getY(0);
- mActivePointerId = paramMotionEvent.getPointerId(0);
- }
- }
-
- private void reset() {
- mActivePointerId = -1;
- mLastMotionY = -1.0F;
- mMaxScale = -1.0F;
- mLastScale = -1.0F;
- }
-
- public boolean onInterceptTouchEvent(MotionEvent paramMotionEvent) {
- return super.onInterceptTouchEvent(paramMotionEvent);
- }
-
- protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2,
- int paramInt3, int paramInt4) {
- super.onLayout(paramBoolean, paramInt1, paramInt2, paramInt3, paramInt4);
- if (mHeaderHeight == 0 && mHeaderView != null) {
- mHeaderHeight = mHeaderContainer.getHeight();
- }
- }
-
- @Override
- public void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3) {
- Log.d(TAG, "onScroll");
- if (mHeaderView != null && !isHideHeader && isEnableZoom) {
- float f = mHeaderHeight - mHeaderContainer.getBottom();
- Log.d(TAG, "f = " + f);
- if (isParallax) {
- if ((f > 0.0F) && (f < mHeaderHeight)) {
- int i = (int) (0.65D * f);
- mHeaderContainer.scrollTo(0, -i);
- } else if (mHeaderContainer.getScrollY() != 0) {
- mHeaderContainer.scrollTo(0, 0);
- }
- }
- }
-
- if (mOnScrollListener != null) {
- mOnScrollListener.onScroll(paramAbsListView, paramInt1, paramInt2, paramInt3);
- }
- }
-
- public void onScrollStateChanged(AbsListView paramAbsListView, int paramInt) {
- if (mOnScrollListener != null) {
- mOnScrollListener.onScrollStateChanged(paramAbsListView, paramInt);
- }
- }
-
- public boolean onTouchEvent(MotionEvent paramMotionEvent) {
- Log.d(TAG, "action = " + (0xFF & paramMotionEvent.getAction()));
- if (mHeaderView != null && !isHideHeader && isEnableZoom) {
- switch (0xFF & paramMotionEvent.getAction()) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_OUTSIDE:
- if (!mScalingRunnable.isFinished()) {
- mScalingRunnable.abortAnimation();
- }
- mLastMotionY = paramMotionEvent.getY();
- mActivePointerId = paramMotionEvent.getPointerId(0);
- mMaxScale = (mScreenHeight / mHeaderHeight);
- mLastScale = (mHeaderContainer.getBottom() / mHeaderHeight);
- break;
- case MotionEvent.ACTION_MOVE:
- Log.d(TAG, "mActivePointerId" + mActivePointerId);
- int j = paramMotionEvent.findPointerIndex(mActivePointerId);
- if (j == INVALID_VALUE) {
- Log.e("PullToZoomListView", "Invalid pointerId=" + mActivePointerId + " in onTouchEvent");
- } else {
- if (mLastMotionY == -1.0F) {
- mLastMotionY = paramMotionEvent.getY(j);
- }
- if (mHeaderContainer.getBottom() >= mHeaderHeight) {
- ViewGroup.LayoutParams localLayoutParams = mHeaderContainer.getLayoutParams();
- float f = ((paramMotionEvent.getY(j) - mLastMotionY + mHeaderContainer.getBottom()) / mHeaderHeight - mLastScale) / 2.0F + mLastScale;
- if ((mLastScale <= 1.0D) && (f < mLastScale)) {
- localLayoutParams.height = mHeaderHeight;
- mHeaderContainer.setLayoutParams(localLayoutParams);
- return super.onTouchEvent(paramMotionEvent);
- }
- mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
- localLayoutParams.height = ((int) (mHeaderHeight * mLastScale));
- if (localLayoutParams.height < mScreenHeight) {
- mHeaderContainer.setLayoutParams(localLayoutParams);
- }
- mLastMotionY = paramMotionEvent.getY(j);
- return true;
- }
- mLastMotionY = paramMotionEvent.getY(j);
- }
- break;
- case MotionEvent.ACTION_UP:
- reset();
- endScaling();
- break;
- case MotionEvent.ACTION_CANCEL:
- int i = paramMotionEvent.getActionIndex();
- mLastMotionY = paramMotionEvent.getY(i);
- mActivePointerId = paramMotionEvent.getPointerId(i);
- break;
- case MotionEvent.ACTION_POINTER_DOWN:
- onSecondaryPointerUp(paramMotionEvent);
- mLastMotionY = paramMotionEvent.getY(paramMotionEvent.findPointerIndex(mActivePointerId));
- break;
- }
- }
- return super.onTouchEvent(paramMotionEvent);
- }
-
- public void setHeaderViewSize(int paramInt1, int paramInt2) {
- if (mHeaderView != null) {
- Object localObject = mHeaderContainer.getLayoutParams();
- if (localObject == null) {
- localObject = new LayoutParams(paramInt1, paramInt2);
- }
- ((ViewGroup.LayoutParams) localObject).width = paramInt1;
- ((ViewGroup.LayoutParams) localObject).height = paramInt2;
- mHeaderContainer.setLayoutParams((ViewGroup.LayoutParams) localObject);
- mHeaderHeight = paramInt2;
- }
- }
-
- public void setOnScrollListener(OnScrollListener paramOnScrollListener) {
- mOnScrollListener = paramOnScrollListener;
- }
-
- class ScalingRunnable implements Runnable {
- protected long mDuration;
- protected boolean mIsFinished = true;
- protected float mScale;
- protected long mStartTime;
-
- ScalingRunnable() {
- }
-
- public void abortAnimation() {
- mIsFinished = true;
- }
-
- public boolean isFinished() {
- return mIsFinished;
- }
-
- public void run() {
- if (mHeaderView != null) {
- float f2;
- ViewGroup.LayoutParams localLayoutParams;
- if ((!mIsFinished) && (mScale > 1.0D)) {
- float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
- f2 = mScale - (mScale - 1.0F) * PullToZoomListView.sInterpolator.getInterpolation(f1);
- localLayoutParams = mHeaderContainer.getLayoutParams();
- if (f2 > 1.0F) {
- Log.d(TAG, "f2>1.0");
- localLayoutParams.height = ((int) (f2 * mHeaderHeight));
- mHeaderContainer.setLayoutParams(localLayoutParams);
- post(this);
- return;
- }
- mIsFinished = true;
- }
- }
- }
-
- public void startAnimation(long paramLong) {
- if (mHeaderView != null) {
- mStartTime = SystemClock.currentThreadTimeMillis();
- mDuration = paramLong;
- mScale = ((float) (mHeaderContainer.getBottom()) / mHeaderHeight);
- mIsFinished = false;
- post(this);
- }
- }
- }
-}
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListViewEx.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListViewEx.java
index 7c06923..dacce0e 100644
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListViewEx.java
+++ b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomListViewEx.java
@@ -82,20 +82,12 @@ public void setZoomView(View zoomView) {
}
}
- /**
- * 移除HeaderView
- * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
- */
private void removeHeaderView() {
if (mHeaderContainer != null) {
mRootView.removeHeaderView(mHeaderContainer);
}
}
- /**
- * 更新HeaderView 先移除-->再添加zoomView、HeaderView -->然后添加到listView的head
- * 如果要兼容API 9,需要修改此处逻辑,API 11以下不支持动态添加header
- */
private void updateHeaderView() {
if (mHeaderContainer != null) {
mRootView.removeHeaderView(mHeaderContainer);
@@ -123,16 +115,12 @@ public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
mRootView.setOnItemClickListener(listener);
}
- /**
- * 创建listView 如果要兼容API9,需要修改此处
- *
- * @param context 上下文
- * @param attrs AttributeSet
- * @return ListView
- */
@Override
protected ListView createRootView(Context context, AttributeSet attrs) {
- return new ListView(context, attrs);
+ ListView lv = new ListView(context, attrs);
+ // Set it to this so it can be used in ListActivity/ListFragment
+ lv.setId(android.R.id.list);
+ return lv;
}
/**
@@ -144,11 +132,6 @@ protected void smoothScrollToTop() {
mScalingRunnable.startAnimation(200L);
}
- /**
- * zoomView动画逻辑
- *
- * @param newScrollValue 手指Y轴移动距离值
- */
@Override
protected void pullHeaderToZoom(int newScrollValue) {
Log.d(TAG, "pullHeaderToZoom --> newScrollValue = " + newScrollValue);
@@ -207,8 +190,8 @@ public void handleStyledAttributes(TypedArray a) {
/**
* 设置HeaderView高度
*
- * @param width 宽
- * @param height 高
+ * @param width
+ * @param height
*/
public void setHeaderViewSize(int width, int height) {
if (mHeaderContainer != null) {
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollView.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollView.java
deleted file mode 100644
index 57fe358..0000000
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollView.java
+++ /dev/null
@@ -1,422 +0,0 @@
-package com.ecloud.pulltozoomview;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.SystemClock;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.util.Log;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Interpolator;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import android.widget.ScrollView;
-
-/**
- * Author: ZhuWenWu
- * Version V1.0
- * Date: 2014/9/1 10:50.
- * Description:
- * Modification History:
- * Date Author Version Description
- * -----------------------------------------------------------------------------------
- * 2014/9/1 ZhuWenWu 1.0 1.0
- * Why & What is modified:
- */
-public class PullToZoomScrollView extends ScrollView {
- private static final String TAG = PullToZoomScrollView.class.getSimpleName();
-
- private static final Interpolator sInterpolator = new Interpolator() {
- public float getInterpolation(float paramAnonymousFloat) {
- float f = paramAnonymousFloat - 1.0F;
- return 1.0F + f * (f * (f * (f * f)));
- }
- };
-
- private View mContentView;//中间View
- private View mHeadView;//头部View
- private View mZoomView;//缩放拉伸View
-
- private FrameLayout mContentContainer;
- private FrameLayout mHeaderContainer;
- private FrameLayout mZoomContainer;
- private LinearLayout mRootContainer;
-
- private OnScrollViewChangedListener mOnScrollListener;
- private OnScrollViewZoomListener onScrollViewZoomListener;
- private ScalingRunnable mScalingRunnable;
-
- private int mScreenHeight;
- private int mZoomHeight;
- private int mZoomWidth;
-
- private int mActivePointerId = -1;
- private float mLastMotionY = -1.0F;
- private float mLastScale = -1.0F;
- private float mMaxScale = -1.0F;
- private boolean isHeaderTop = true;
- private boolean isEnableZoom = true;
- private boolean isParallax = false;
-
- public PullToZoomScrollView(Context context) {
- this(context, null);
- }
-
- public PullToZoomScrollView(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
- }
-
- public PullToZoomScrollView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(attrs);
- }
-
- private void init(AttributeSet attrs) {
- mHeaderContainer = new FrameLayout(getContext());
- mZoomContainer = new FrameLayout(getContext());
- mContentContainer = new FrameLayout(getContext());
-
- mRootContainer = new LinearLayout(getContext());
- mRootContainer.setOrientation(LinearLayout.VERTICAL);
-
- if (attrs != null) {
- LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
- //初始化状态View
- TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PullToZoomScrollView);
-
- int zoomViewResId = a.getResourceId(R.styleable.PullToZoomScrollView_scrollZoomView, 0);
- if (zoomViewResId > 0) {
- mZoomView = mLayoutInflater.inflate(zoomViewResId, null, false);
- mZoomContainer.addView(mZoomView);
- mHeaderContainer.addView(mZoomContainer);
- }
-
- int headViewResId = a.getResourceId(R.styleable.PullToZoomScrollView_scrollHeadView, 0);
- if (headViewResId > 0) {
- mHeadView = mLayoutInflater.inflate(headViewResId, null, false);
- mHeaderContainer.addView(mHeadView);
- }
- int contentViewResId = a.getResourceId(R.styleable.PullToZoomScrollView_scrollContentView, 0);
- if (contentViewResId > 0) {
- mContentView = mLayoutInflater.inflate(contentViewResId, null, false);
- mContentContainer.addView(mContentView);
- }
-
- a.recycle();
- }
-
- DisplayMetrics localDisplayMetrics = new DisplayMetrics();
- ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
- mScreenHeight = localDisplayMetrics.heightPixels;
- mZoomWidth = localDisplayMetrics.widthPixels;
- mScalingRunnable = new ScalingRunnable();
-
- mRootContainer.addView(mHeaderContainer);
- mRootContainer.addView(mContentContainer);
-
- mRootContainer.setClipChildren(false);
- mHeaderContainer.setClipChildren(false);
-
- addView(mRootContainer);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
- }
-
- public void setEnableZoom(boolean isEnableZoom) {
- this.isEnableZoom = isEnableZoom;
- }
-
- public void setParallax(boolean isParallax) {
- this.isParallax = isParallax;
- }
-
- public void setOnScrollListener(OnScrollViewChangedListener mOnScrollListener) {
- this.mOnScrollListener = mOnScrollListener;
- }
-
- public void setOnScrollViewZoomListener(OnScrollViewZoomListener onScrollViewZoomListener) {
- this.onScrollViewZoomListener = onScrollViewZoomListener;
- }
-
- public void setContentContainerView(View view) {
- if (mContentContainer != null) {
- mContentContainer.removeAllViews();
- mContentView = view;
- mContentContainer.addView(view);
- }
- }
-
- public void setHeaderContainer(View view) {
- if (mHeaderContainer != null && view != null) {
- mHeaderContainer.removeAllViews();
- mHeadView = view;
- if (mZoomView != null && mZoomContainer != null) {
- mZoomContainer.removeAllViews();
- mZoomContainer.addView(mZoomView);
- mHeaderContainer.addView(mZoomContainer);
- }
- mHeaderContainer.addView(mHeadView);
- }
- }
-
- public void setZoomView(View view) {
- if (mZoomContainer != null && view != null) {
- this.mZoomView = view;
- mZoomContainer.removeAllViews();
- mZoomContainer.addView(mZoomView);
- if (mHeaderContainer != null) {
- mHeaderContainer.removeAllViews();
- mHeaderContainer.addView(mZoomContainer);
- if (mHeadView != null) {
- mHeaderContainer.addView(mHeadView);
- }
- }
- }
- }
-
- public void showHeaderView() {
- if (mZoomView != null || mHeadView != null) {
- mHeaderContainer.setVisibility(VISIBLE);
- }
- }
-
- public void hideHeaderView() {
- if (mZoomView != null || mHeadView != null) {
- mHeaderContainer.setVisibility(GONE);
- }
- }
-
- public FrameLayout getZoomContainer() {
- return mZoomContainer;
- }
-
- public FrameLayout getHeaderContainer() {
- return mHeaderContainer;
- }
-
- public View getZoomView() {
- return mZoomView;
- }
-
- public View getContentView() {
- return mContentView;
- }
-
- public View getHeadView() {
- return mHeadView;
- }
-
- public void setZoomHeight(int mZoomHeight) {
- this.mZoomHeight = mZoomHeight;
- }
-
- public LinearLayout getRootContainer() {
- return mRootContainer;
- }
-
- private void endScaling() {
- if (mZoomContainer.getBottom() >= mZoomHeight) {
- Log.d(TAG, "endScaling");
- }
- mScalingRunnable.startAnimation(200L);
- }
-
- public boolean onInterceptTouchEvent(MotionEvent event) {
- return super.onInterceptTouchEvent(event);
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- if (mZoomHeight == 0) {
- if (mZoomContainer != null) {
- mZoomHeight = mZoomContainer.getHeight();
- mZoomWidth = mZoomContainer.getWidth();
- }
- }
- }
-
- @Override
- protected void onScrollChanged(int left, int top, int oldLeft, int oldTop) {
- super.onScrollChanged(left, top, oldLeft, oldTop);
- if (isEnableZoom) {
- isHeaderTop = getScrollY() <= 0;
-
- Log.d(TAG, "onScrollChanged --> ");
- if (isParallax) {
- float f = mZoomHeight - mZoomContainer.getBottom() + getScrollY();
- Log.d(TAG, "f = " + f);
- if ((f > 0.0F) && (f < mZoomHeight)) {
- int i = (int) (0.65D * f);
- mHeaderContainer.scrollTo(0, -i);
- } else if (mHeaderContainer.getScrollY() != 0) {
- mHeaderContainer.scrollTo(0, 0);
- }
- }
- }
- if (mOnScrollListener != null) {
- mOnScrollListener.onScrollChanged(left, top, oldLeft, oldTop);
- }
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent ev) {
- Log.d(TAG, "onTouchEvent --> action = " + (0xFF & ev.getAction()));
- if (isHeaderTop && isEnableZoom) {
- switch (0xFF & ev.getAction()) {
- case MotionEvent.ACTION_DOWN:
- case MotionEvent.ACTION_OUTSIDE:
- if (!mScalingRunnable.isFinished()) {
- mScalingRunnable.abortAnimation();
- }
- mLastMotionY = ev.getY();
- mActivePointerId = ev.getPointerId(0);
- mMaxScale = (mScreenHeight / mZoomHeight);
- mLastScale = (mZoomContainer.getBottom() / mZoomHeight);
- if (onScrollViewZoomListener != null) {
- onScrollViewZoomListener.onStart();
- }
- break;
- case MotionEvent.ACTION_MOVE:
- Log.d(TAG, "mActivePointerId = " + mActivePointerId);
- int j = ev.findPointerIndex(this.mActivePointerId);
- if (j == -1) {
- Log.e(TAG, "Invalid pointerId = " + mActivePointerId + " in onTouchEvent");
- } else {
- if (mLastMotionY == -1.0F) {
- mLastMotionY = ev.getY(j);
- }
- if (mZoomContainer.getBottom() >= mZoomHeight) {
- FrameLayout.LayoutParams localLayoutParams = (FrameLayout.LayoutParams) mZoomContainer.getLayoutParams();
- ViewGroup.LayoutParams headLayoutParams = mHeaderContainer.getLayoutParams();
- float f = ((ev.getY(j) - mLastMotionY + mZoomContainer.getBottom()) / mZoomHeight - mLastScale) / 2.0F + mLastScale;
- if ((mLastScale <= 1.0D) && (f < mLastScale)) {
- localLayoutParams.height = mZoomHeight;
- localLayoutParams.width = mZoomWidth;
- localLayoutParams.gravity = Gravity.CENTER;
- headLayoutParams.height = mZoomHeight;
- mZoomContainer.setLayoutParams(localLayoutParams);
- mHeaderContainer.setLayoutParams(headLayoutParams);
- return super.onTouchEvent(ev);
- }
- mLastScale = Math.min(Math.max(f, 1.0F), mMaxScale);
- localLayoutParams.height = ((int) (mZoomHeight * mLastScale));
- localLayoutParams.width = ((int) (mZoomWidth * mLastScale));
- localLayoutParams.gravity = Gravity.CENTER;
- headLayoutParams.height = ((int) (mZoomHeight * mLastScale));
- if (localLayoutParams.height < mScreenHeight) {
- mZoomContainer.setLayoutParams(localLayoutParams);
- mHeaderContainer.setLayoutParams(headLayoutParams);
- }
- mLastMotionY = ev.getY(j);
- return true;
- }
- this.mLastMotionY = ev.getY(j);
- }
- break;
- case MotionEvent.ACTION_UP:
- reset();
- endScaling();
- if (onScrollViewZoomListener != null) {
- onScrollViewZoomListener.onFinish();
- }
- break;
- case MotionEvent.ACTION_CANCEL:
- int i = ev.getActionIndex();
- mLastMotionY = ev.getY(i);
- mActivePointerId = ev.getPointerId(i);
- break;
- case MotionEvent.ACTION_POINTER_DOWN:
- onSecondaryPointerUp(ev);
- mLastMotionY = ev.getY(ev.findPointerIndex(mActivePointerId));
- break;
- }
- }
- return super.onTouchEvent(ev);
- }
-
- private void onSecondaryPointerUp(MotionEvent paramMotionEvent) {
- int i = (paramMotionEvent.getAction()) >> 8;
- if (paramMotionEvent.getPointerId(i) == mActivePointerId)
- if (i != 0) {
- mLastMotionY = paramMotionEvent.getY(0);
- mActivePointerId = paramMotionEvent.getPointerId(0);
- }
- }
-
- private void reset() {
- this.mActivePointerId = -1;
- this.mLastMotionY = -1.0F;
- this.mMaxScale = -1.0F;
- this.mLastScale = -1.0F;
- }
-
-
- class ScalingRunnable implements Runnable {
- long mDuration;
- boolean mIsFinished = true;
- float mScale;
- long mStartTime;
-
- ScalingRunnable() {
- }
-
- public void abortAnimation() {
- mIsFinished = true;
- }
-
- public boolean isFinished() {
- return mIsFinished;
- }
-
- public void run() {
- float f2;
- FrameLayout.LayoutParams localLayoutParams;
- ViewGroup.LayoutParams headLayoutParams;
- if ((!mIsFinished) && (mScale > 1.0D)) {
- float f1 = ((float) SystemClock.currentThreadTimeMillis() - (float) mStartTime) / (float) mDuration;
- f2 = mScale - (mScale - 1.0F) * sInterpolator.getInterpolation(f1);
- localLayoutParams = (FrameLayout.LayoutParams) mZoomContainer.getLayoutParams();
- headLayoutParams = mHeaderContainer.getLayoutParams();
- if (f2 > 1.0F) {
- Log.d(TAG, "f2 > 1.0");
- localLayoutParams.height = ((int) (f2 * mZoomHeight));
- localLayoutParams.width = ((int) (f2 * mZoomWidth));
- localLayoutParams.gravity = Gravity.CENTER;
- mZoomContainer.setLayoutParams(localLayoutParams);
- headLayoutParams.height = ((int) (f2 * mZoomHeight));
- mHeaderContainer.setLayoutParams(headLayoutParams);
- post(this);
- return;
- }
- mIsFinished = true;
- }
- }
-
- public void startAnimation(long paramLong) {
- mStartTime = SystemClock.currentThreadTimeMillis();
- mDuration = paramLong;
- mScale = ((float) (mZoomContainer.getBottom()) / mZoomHeight);
- mIsFinished = false;
- post(this);
- }
- }
-
- public interface OnScrollViewChangedListener {
- public void onScrollChanged(int left, int top, int oldLeft, int oldTop);
- }
-
- public interface OnScrollViewZoomListener {
- public void onStart();
-
- public void onFinish();
- }
-}
diff --git a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollViewEx.java b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollViewEx.java
index 3861d3c..1e5fcc0 100644
--- a/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollViewEx.java
+++ b/PullToZoomView/library/src/main/java/com/ecloud/pulltozoomview/PullToZoomScrollViewEx.java
@@ -26,7 +26,7 @@
*/
public class PullToZoomScrollViewEx extends PullToZoomBase {
private static final String TAG = PullToZoomScrollViewEx.class.getSimpleName();
- private boolean isCustomHeaderHeight = false;//自定义header高度之后可能导致zoomView拉伸不正确
+ private boolean isCustomHeaderHeight = false;
private FrameLayout mHeaderContainer;
private LinearLayout mRootContainer;
private View mContentView;
@@ -103,30 +103,49 @@ public void setHideHeader(boolean isHideHeader) {
@Override
public void setHeaderView(View headerView) {
- if (mHeaderContainer != null && headerView != null) {
- mHeaderContainer.removeAllViews();
+ if (headerView != null) {
mHeaderView = headerView;
- if (mZoomView != null) {
- mHeaderContainer.addView(mZoomView);
- }
- mHeaderContainer.addView(mHeaderView);
+ updateHeaderView();
}
}
@Override
public void setZoomView(View zoomView) {
- if (mHeaderContainer != null && zoomView != null) {
+ if (zoomView != null) {
+ mZoomView = zoomView;
+ updateHeaderView();
+ }
+ }
+
+ private void updateHeaderView() {
+ if (mHeaderContainer != null) {
mHeaderContainer.removeAllViews();
- mHeaderContainer.addView(mZoomView);
+
+ if (mZoomView != null) {
+ mHeaderContainer.addView(mZoomView);
+ }
+
if (mHeaderView != null) {
mHeaderContainer.addView(mHeaderView);
}
}
}
+ public void setScrollContentView(View contentView) {
+ if (contentView != null) {
+ if (mContentView != null) {
+ mRootContainer.removeView(mContentView);
+ }
+ mContentView = contentView;
+ mRootContainer.addView(mContentView);
+ }
+ }
+
@Override
protected ScrollView createRootView(Context context, AttributeSet attrs) {
- return new InternalScrollView(context, attrs);
+ ScrollView scrollView = new InternalScrollView(context, attrs);
+ scrollView.setId(R.id.scrollview);
+ return scrollView;
}
@Override
@@ -152,7 +171,7 @@ public void handleStyledAttributes(TypedArray a) {
if (mHeaderView != null) {
mHeaderContainer.addView(mHeaderView);
}
- int contentViewResId = a.getResourceId(R.styleable.PullToZoomScrollView_scrollContentView, 0);
+ int contentViewResId = a.getResourceId(R.styleable.PullToZoomView_contentView, 0);
if (contentViewResId > 0) {
LayoutInflater mLayoutInflater = LayoutInflater.from(getContext());
mContentView = mLayoutInflater.inflate(contentViewResId, null, false);
@@ -172,8 +191,8 @@ public void handleStyledAttributes(TypedArray a) {
/**
* 设置HeaderView高度
*
- * @param width 宽
- * @param height 高
+ * @param width
+ * @param height
*/
public void setHeaderViewSize(int width, int height) {
if (mHeaderContainer != null) {
diff --git a/PullToZoomView/library/src/main/res/values/attrs.xml b/PullToZoomView/library/src/main/res/values/attrs.xml
index ec5f7f5..4b19714 100644
--- a/PullToZoomView/library/src/main/res/values/attrs.xml
+++ b/PullToZoomView/library/src/main/res/values/attrs.xml
@@ -1,16 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/PullToZoomView/library/src/main/res/values/ids.xml b/PullToZoomView/library/src/main/res/values/ids.xml
new file mode 100644
index 0000000..8716efb
--- /dev/null
+++ b/PullToZoomView/library/src/main/res/values/ids.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 90586cf..30ee952 100644
--- a/README.md
+++ b/README.md
@@ -14,16 +14,24 @@ Features
Usage
============
-### 1. Add PullZoomView to your project
-####Maven
-####Eclipse
-1. Download ZIP then extract the PullZoomView project
-1. From Eclipse menu: New > Android Project from Existing Code > PullZoomView project > Finish
-1. Right click on your project
-1. Android > Library: Add > PullZoomView
+In your `build.gradle`:
-### 2.Reference the sample app
+```gradle
+ dependencies {
+ compile 'com.github.frank-zhu:pullzoomview:1.0.0'
+ }
+```
+or Maven:
+
+```xml
+
+ com.github.frank-zhu
+ pullzoomview
+ 1.0.0
+ aar
+
+```
Using this library?
============
@@ -42,7 +50,7 @@ Developers @matrixxun
About me
============
-[Click Me](http://frank-zhu.github.io/about.html)
+[Click Me](http://frank-zhu.github.io/about/)
License
============