diff --git a/Sample_zhy_StickyNavLayout_Listview/.classpath b/Sample_zhy_StickyNavLayout_Listview/.classpath deleted file mode 100755 index 26bdfa6..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/.project b/Sample_zhy_StickyNavLayout_Listview/.project deleted file mode 100644 index b375665..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - Sample_zhy_StickyNavLayout02 - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/Sample_zhy_StickyNavLayout_Listview/.settings/org.eclipse.jdt.core.prefs b/Sample_zhy_StickyNavLayout_Listview/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b080d2d..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/Sample_zhy_StickyNavLayout_Listview/AndroidManifest.xml b/Sample_zhy_StickyNavLayout_Listview/AndroidManifest.xml deleted file mode 100755 index 2bcc3ec..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/ic_launcher-web.png b/Sample_zhy_StickyNavLayout_Listview/ic_launcher-web.png deleted file mode 100755 index a18cbb4..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/ic_launcher-web.png and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/libs/android-support-v4.jar b/Sample_zhy_StickyNavLayout_Listview/libs/android-support-v4.jar deleted file mode 100755 index 9056828..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/libs/android-support-v4.jar and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/project.properties b/Sample_zhy_StickyNavLayout_Listview/project.properties deleted file mode 100755 index e1534f8..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=../library_zhy_StickyNavLayout02 diff --git a/Sample_zhy_StickyNavLayout_Listview/res/drawable-hdpi/ic_launcher.png b/Sample_zhy_StickyNavLayout_Listview/res/drawable-hdpi/ic_launcher.png deleted file mode 100755 index 288b665..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/res/drawable-mdpi/ic_launcher.png b/Sample_zhy_StickyNavLayout_Listview/res/drawable-mdpi/ic_launcher.png deleted file mode 100755 index 6ae570b..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/res/drawable-xhdpi/ic_launcher.png b/Sample_zhy_StickyNavLayout_Listview/res/drawable-xhdpi/ic_launcher.png deleted file mode 100755 index d4fb7cd..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/res/drawable-xxhdpi/ic_launcher.png b/Sample_zhy_StickyNavLayout_Listview/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100755 index 85a6081..0000000 Binary files a/Sample_zhy_StickyNavLayout_Listview/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/Sample_zhy_StickyNavLayout_Listview/res/layout/activity_main.xml b/Sample_zhy_StickyNavLayout_Listview/res/layout/activity_main.xml deleted file mode 100755 index c84333a..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/layout/activity_main.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Sample_zhy_StickyNavLayout_Listview/res/layout/fragment_tab.xml b/Sample_zhy_StickyNavLayout_Listview/res/layout/fragment_tab.xml deleted file mode 100755 index 342f352..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/layout/fragment_tab.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - \ No newline at end of file diff --git a/Sample_zhy_StickyNavLayout_Listview/res/layout/item.xml b/Sample_zhy_StickyNavLayout_Listview/res/layout/item.xml deleted file mode 100644 index c7e637c..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/layout/item.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/layout/test.xml b/Sample_zhy_StickyNavLayout_Listview/res/layout/test.xml deleted file mode 100644 index 77845ad..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/layout/test.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Sample_zhy_StickyNavLayout_Listview/res/menu/main.xml b/Sample_zhy_StickyNavLayout_Listview/res/menu/main.xml deleted file mode 100755 index d122a4b..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/menu/main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values-sw600dp/dimens.xml b/Sample_zhy_StickyNavLayout_Listview/res/values-sw600dp/dimens.xml deleted file mode 100755 index c876987..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values-sw720dp-land/dimens.xml b/Sample_zhy_StickyNavLayout_Listview/res/values-sw720dp-land/dimens.xml deleted file mode 100755 index 0df3067..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 128dp - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values-v11/styles.xml b/Sample_zhy_StickyNavLayout_Listview/res/values-v11/styles.xml deleted file mode 100755 index e3ef53d..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values-v14/styles.xml b/Sample_zhy_StickyNavLayout_Listview/res/values-v14/styles.xml deleted file mode 100755 index 94dd245..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values/dimens.xml b/Sample_zhy_StickyNavLayout_Listview/res/values/dimens.xml deleted file mode 100755 index 2e0e2ae..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values/dimens.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - 16dp - 16dp - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values/strings.xml b/Sample_zhy_StickyNavLayout_Listview/res/values/strings.xml deleted file mode 100755 index f9e0e4a..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values/strings.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - sample_StickyNavLayout - Settings - Hello world! - - diff --git a/Sample_zhy_StickyNavLayout_Listview/res/values/styles.xml b/Sample_zhy_StickyNavLayout_Listview/res/values/styles.xml deleted file mode 100755 index 4ea9326..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/TabFragment.java b/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/TabFragment.java deleted file mode 100755 index 4a6669d..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/TabFragment.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.zhy.sample.StickyNavLayout; - -import java.util.ArrayList; -import java.util.List; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ListView; -import android.widget.TextView; - -public class TabFragment extends Fragment -{ - public static final String TITLE = "title"; - private String mTitle = "Defaut Value"; - private ListView mListView; - // private TextView mTextView; - private List mDatas = new ArrayList(); - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - if (getArguments() != null) - { - mTitle = getArguments().getString(TITLE); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) - { - View view = inflater.inflate(R.layout.fragment_tab, container, false); - mListView = (ListView) view - .findViewById(R.id.id_stickynavlayout_innerscrollview); - // mTextView = (TextView) view.findViewById(R.id.id_info); - // mTextView.setText(mTitle); - for (int i = 0; i < 50; i++) - { - mDatas.add(mTitle+" -> " + i); - } - mListView.setAdapter(new ArrayAdapter(getActivity(), - R.layout.item, R.id.id_info, mDatas) - { - @Override - public View getView(int position, View convertView, ViewGroup parent) - { - //Log.e("tag", "convertView = " + convertView); - return super.getView(position, convertView, parent); - } - }); - return view; - - } - - public static TabFragment newInstance(String title) - { - TabFragment tabFragment = new TabFragment(); - Bundle bundle = new Bundle(); - bundle.putString(TITLE, title); - tabFragment.setArguments(bundle); - return tabFragment; - } - -} diff --git a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/view/SimpleViewPagerIndicator.java b/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/view/SimpleViewPagerIndicator.java deleted file mode 100755 index de8df54..0000000 --- a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/view/SimpleViewPagerIndicator.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.zhy.view; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.widget.LinearLayout; -import android.widget.ScrollView; -import android.widget.TextView; - -public class SimpleViewPagerIndicator extends LinearLayout -{ - - private static final int COLOR_TEXT_NORMAL = 0xFF000000; - private static final int COLOR_INDICATOR_COLOR = Color.GREEN; - - private String[] mTitles; - private int mTabCount; - private int mIndicatorColor = COLOR_INDICATOR_COLOR; - private float mTranslationX; - private Paint mPaint = new Paint(); - private int mTabWidth; - - public SimpleViewPagerIndicator(Context context) - { - this(context, null); - } - - public SimpleViewPagerIndicator(Context context, AttributeSet attrs) - { - super(context, attrs); - mPaint.setColor(mIndicatorColor); - mPaint.setStrokeWidth(9.0F); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) - { - super.onSizeChanged(w, h, oldw, oldh); - mTabWidth = w / mTabCount; - } - - public void setTitles(String[] titles) - { - mTitles = titles; - mTabCount = titles.length; - generateTitleView(); - - } - - public void setIndicatorColor(int indicatorColor) - { - this.mIndicatorColor = indicatorColor; - } - - @Override - protected void dispatchDraw(Canvas canvas) - { - super.dispatchDraw(canvas); - canvas.save(); - canvas.translate(mTranslationX, getHeight() - 2); - canvas.drawLine(0, 0, mTabWidth, 0, mPaint); - canvas.restore(); - } - - public void scroll(int position, float offset) - { - /** - *
-		 *  0-1:position=0 ;1-0:postion=0;
-		 * 
- */ - mTranslationX = getWidth() / mTabCount * (position + offset); - invalidate(); - } - - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) - { - return super.dispatchTouchEvent(ev); - } - - private void generateTitleView() - { - if (getChildCount() > 0) - this.removeAllViews(); - int count = mTitles.length; - - setWeightSum(count); - for (int i = 0; i < count; i++) - { - TextView tv = new TextView(getContext()); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, - LayoutParams.MATCH_PARENT); - lp.weight = 1; - tv.setGravity(Gravity.CENTER); - tv.setTextColor(COLOR_TEXT_NORMAL); - tv.setText(mTitles[i]); - tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); - tv.setLayoutParams(lp); - tv.setOnClickListener(new OnClickListener() - { - @Override - public void onClick(View v) - { - - } - }); - addView(tv); - } - } - -} diff --git a/StickyNavLayout.iml b/StickyNavLayout.iml new file mode 100644 index 0000000..71c8493 --- /dev/null +++ b/StickyNavLayout.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/.idea/libraries/animated_vector_drawable_25_3_1.xml b/app/.idea/libraries/animated_vector_drawable_25_3_1.xml new file mode 100644 index 0000000..cb6762a --- /dev/null +++ b/app/.idea/libraries/animated_vector_drawable_25_3_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/appcompat_v7_25_3_1.xml b/app/.idea/libraries/appcompat_v7_25_3_1.xml new file mode 100644 index 0000000..275a83a --- /dev/null +++ b/app/.idea/libraries/appcompat_v7_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/base_adapter_2_0_0.xml b/app/.idea/libraries/base_adapter_2_0_0.xml new file mode 100644 index 0000000..d539a43 --- /dev/null +++ b/app/.idea/libraries/base_adapter_2_0_0.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/hamcrest_core_1_3.xml b/app/.idea/libraries/hamcrest_core_1_3.xml new file mode 100644 index 0000000..157e3f3 --- /dev/null +++ b/app/.idea/libraries/hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/junit_4_12.xml b/app/.idea/libraries/junit_4_12.xml new file mode 100644 index 0000000..305df30 --- /dev/null +++ b/app/.idea/libraries/junit_4_12.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/recyclerview_v7_25_3_1.xml b/app/.idea/libraries/recyclerview_v7_25_3_1.xml new file mode 100644 index 0000000..014c30d --- /dev/null +++ b/app/.idea/libraries/recyclerview_v7_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_annotations_25_3_1.xml b/app/.idea/libraries/support_annotations_25_3_1.xml new file mode 100644 index 0000000..42adfc6 --- /dev/null +++ b/app/.idea/libraries/support_annotations_25_3_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_compat_25_3_1.xml b/app/.idea/libraries/support_compat_25_3_1.xml new file mode 100644 index 0000000..3e7ff7e --- /dev/null +++ b/app/.idea/libraries/support_compat_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_core_ui_25_3_1.xml b/app/.idea/libraries/support_core_ui_25_3_1.xml new file mode 100644 index 0000000..f4a4cb7 --- /dev/null +++ b/app/.idea/libraries/support_core_ui_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_core_utils_25_3_1.xml b/app/.idea/libraries/support_core_utils_25_3_1.xml new file mode 100644 index 0000000..53299bf --- /dev/null +++ b/app/.idea/libraries/support_core_utils_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_fragment_25_3_1.xml b/app/.idea/libraries/support_fragment_25_3_1.xml new file mode 100644 index 0000000..418132a --- /dev/null +++ b/app/.idea/libraries/support_fragment_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_media_compat_25_3_1.xml b/app/.idea/libraries/support_media_compat_25_3_1.xml new file mode 100644 index 0000000..8449cb7 --- /dev/null +++ b/app/.idea/libraries/support_media_compat_25_3_1.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_v4_25_3_1.xml b/app/.idea/libraries/support_v4_25_3_1.xml new file mode 100644 index 0000000..3fd512d --- /dev/null +++ b/app/.idea/libraries/support_v4_25_3_1.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/libraries/support_vector_drawable_25_3_1.xml b/app/.idea/libraries/support_vector_drawable_25_3_1.xml new file mode 100644 index 0000000..1dacf7d --- /dev/null +++ b/app/.idea/libraries/support_vector_drawable_25_3_1.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/modules.xml b/app/.idea/modules.xml new file mode 100644 index 0000000..a10838d --- /dev/null +++ b/app/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/.idea/runConfigurations.xml b/app/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/app/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/.idea/vcs.xml b/app/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/app/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/app.iml b/app/app.iml new file mode 100644 index 0000000..475c810 --- /dev/null +++ b/app/app.iml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..4219754 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,28 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + + defaultConfig { + applicationId "com.zhy.stickynavlayout" + minSdkVersion 11 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + testCompile 'junit:junit:4.12' + compile 'com.android.support:appcompat-v7:25+' + compile 'com.zhy:base-adapter:2.0.0' + compile 'com.android.support:recyclerview-v7:25+' +} diff --git a/Sample_zhy_StickyNavLayout_Listview/proguard-project.txt b/app/proguard-rules.pro old mode 100755 new mode 100644 similarity index 62% rename from Sample_zhy_StickyNavLayout_Listview/proguard-project.txt rename to app/proguard-rules.pro index f2fe155..1c6c033 --- a/Sample_zhy_StickyNavLayout_Listview/proguard-project.txt +++ b/app/proguard-rules.pro @@ -1,11 +1,8 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. +# in /Users/zhy/android/sdk/android-sdk-macosx/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/app/src/androidTest/java/com/zhy/stickynavlayout/ApplicationTest.java b/app/src/androidTest/java/com/zhy/stickynavlayout/ApplicationTest.java new file mode 100644 index 0000000..bb05494 --- /dev/null +++ b/app/src/androidTest/java/com/zhy/stickynavlayout/ApplicationTest.java @@ -0,0 +1,15 @@ +package com.zhy.stickynavlayout; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase +{ + public ApplicationTest() + { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4eba46c --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/MainActivity.java b/app/src/main/java/com/zhy/stickynavlayout/MainActivity.java similarity index 89% rename from Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/MainActivity.java rename to app/src/main/java/com/zhy/stickynavlayout/MainActivity.java index 0b600ad..91e39e0 100755 --- a/Sample_zhy_StickyNavLayout_Listview/src/com/zhy/sample/StickyNavLayout/MainActivity.java +++ b/app/src/main/java/com/zhy/stickynavlayout/MainActivity.java @@ -1,4 +1,4 @@ -package com.zhy.sample.StickyNavLayout; +package com.zhy.stickynavlayout; import android.os.Bundle; import android.support.v4.app.Fragment; @@ -6,10 +6,9 @@ import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.widget.RelativeLayout; -import android.widget.TextView; -import com.zhy.view.SimpleViewPagerIndicator; +import com.zhy.stickynavlayout.view.SimpleViewPagerIndicator; + public class MainActivity extends FragmentActivity { @@ -99,4 +98,5 @@ private void initViews() */ } + } diff --git a/app/src/main/java/com/zhy/stickynavlayout/TabFragment.java b/app/src/main/java/com/zhy/stickynavlayout/TabFragment.java new file mode 100755 index 0000000..31117d8 --- /dev/null +++ b/app/src/main/java/com/zhy/stickynavlayout/TabFragment.java @@ -0,0 +1,71 @@ +package com.zhy.stickynavlayout; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.zhy.base.adapter.ViewHolder; +import com.zhy.base.adapter.recyclerview.CommonAdapter; + +import java.util.ArrayList; +import java.util.List; + +public class TabFragment extends Fragment +{ + public static final String TITLE = "title"; + private String mTitle = "Defaut Value"; + private RecyclerView mRecyclerView; + // private TextView mTextView; + private List mDatas = new ArrayList(); + + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); + if (getArguments() != null) + { + mTitle = getArguments().getString(TITLE); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) + { + View view = inflater.inflate(R.layout.fragment_tab, container, false); + mRecyclerView = (RecyclerView) view + .findViewById(R.id.id_stickynavlayout_innerscrollview); + mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); + // mTextView = (TextView) view.findViewById(R.id.id_info); + // mTextView.setText(mTitle); + for (int i = 0; i < 50; i++) + { + mDatas.add(mTitle + " -> " + i); + } + mRecyclerView.setAdapter(new CommonAdapter(getActivity(), R.layout.item, mDatas) + { + @Override + public void convert(ViewHolder holder, String o) + { + holder.setText(R.id.id_info, o); + } + }); + + return view; + + } + + public static TabFragment newInstance(String title) + { + TabFragment tabFragment = new TabFragment(); + Bundle bundle = new Bundle(); + bundle.putString(TITLE, title); + tabFragment.setArguments(bundle); + return tabFragment; + } + +} diff --git a/sample_zhy_StickyNavLayout/src/com/zhy/view/SimpleViewPagerIndicator.java b/app/src/main/java/com/zhy/stickynavlayout/view/SimpleViewPagerIndicator.java old mode 100644 new mode 100755 similarity index 92% rename from sample_zhy_StickyNavLayout/src/com/zhy/view/SimpleViewPagerIndicator.java rename to app/src/main/java/com/zhy/stickynavlayout/view/SimpleViewPagerIndicator.java index 6353cc9..9917e6c --- a/sample_zhy_StickyNavLayout/src/com/zhy/view/SimpleViewPagerIndicator.java +++ b/app/src/main/java/com/zhy/stickynavlayout/view/SimpleViewPagerIndicator.java @@ -1,119 +1,118 @@ -package com.zhy.view; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.util.AttributeSet; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.MotionEvent; -import android.view.View; -import android.widget.LinearLayout; -import android.widget.ScrollView; -import android.widget.TextView; - -public class SimpleViewPagerIndicator extends LinearLayout -{ - - private static final int COLOR_TEXT_NORMAL = 0xFF000000; - private static final int COLOR_INDICATOR_COLOR = Color.GREEN; - - private String[] mTitles; - private int mTabCount; - private int mIndicatorColor = COLOR_INDICATOR_COLOR; - private float mTranslationX; - private Paint mPaint = new Paint(); - private int mTabWidth; - - public SimpleViewPagerIndicator(Context context) - { - this(context, null); - } - - public SimpleViewPagerIndicator(Context context, AttributeSet attrs) - { - super(context, attrs); - mPaint.setColor(mIndicatorColor); - mPaint.setStrokeWidth(9.0F); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) - { - super.onSizeChanged(w, h, oldw, oldh); - mTabWidth = w / mTabCount; - } - - public void setTitles(String[] titles) - { - mTitles = titles; - mTabCount = titles.length; - generateTitleView(); - - } - - public void setIndicatorColor(int indicatorColor) - { - this.mIndicatorColor = indicatorColor; - } - - @Override - protected void dispatchDraw(Canvas canvas) - { - super.dispatchDraw(canvas); - canvas.save(); - canvas.translate(mTranslationX, getHeight() - 2); - canvas.drawLine(0, 0, mTabWidth, 0, mPaint); - canvas.restore(); - } - - public void scroll(int position, float offset) - { - /** - *
-		 *  0-1:position=0 ;1-0:postion=0;
-		 * 
- */ - mTranslationX = getWidth() / mTabCount * (position + offset); - invalidate(); - } - - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) - { - return super.dispatchTouchEvent(ev); - } - - private void generateTitleView() - { - if (getChildCount() > 0) - this.removeAllViews(); - int count = mTitles.length; - - setWeightSum(count); - for (int i = 0; i < count; i++) - { - TextView tv = new TextView(getContext()); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, - LayoutParams.MATCH_PARENT); - lp.weight = 1; - tv.setGravity(Gravity.CENTER); - tv.setTextColor(COLOR_TEXT_NORMAL); - tv.setText(mTitles[i]); - tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); - tv.setLayoutParams(lp); - tv.setOnClickListener(new OnClickListener() - { - @Override - public void onClick(View v) - { - - } - }); - addView(tv); - } - } - -} +package com.zhy.stickynavlayout.view; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.util.AttributeSet; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.MotionEvent; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +public class SimpleViewPagerIndicator extends LinearLayout +{ + + private static final int COLOR_TEXT_NORMAL = 0xFF000000; + private static final int COLOR_INDICATOR_COLOR = Color.GREEN; + + private String[] mTitles; + private int mTabCount; + private int mIndicatorColor = COLOR_INDICATOR_COLOR; + private float mTranslationX; + private Paint mPaint = new Paint(); + private int mTabWidth; + + public SimpleViewPagerIndicator(Context context) + { + this(context, null); + } + + public SimpleViewPagerIndicator(Context context, AttributeSet attrs) + { + super(context, attrs); + mPaint.setColor(mIndicatorColor); + mPaint.setStrokeWidth(9.0F); + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) + { + super.onSizeChanged(w, h, oldw, oldh); + mTabWidth = w / mTabCount; + } + + public void setTitles(String[] titles) + { + mTitles = titles; + mTabCount = titles.length; + generateTitleView(); + + } + + public void setIndicatorColor(int indicatorColor) + { + this.mIndicatorColor = indicatorColor; + } + + @Override + protected void dispatchDraw(Canvas canvas) + { + super.dispatchDraw(canvas); + canvas.save(); + canvas.translate(mTranslationX, getHeight() - 2); + canvas.drawLine(0, 0, mTabWidth, 0, mPaint); + canvas.restore(); + } + + public void scroll(int position, float offset) + { + /** + *
+		 *  0-1:position=0 ;1-0:postion=0;
+		 * 
+ */ + mTranslationX = getWidth() / mTabCount * (position + offset); + invalidate(); + } + + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) + { + return super.dispatchTouchEvent(ev); + } + + private void generateTitleView() + { + if (getChildCount() > 0) + this.removeAllViews(); + int count = mTitles.length; + + setWeightSum(count); + for (int i = 0; i < count; i++) + { + TextView tv = new TextView(getContext()); + LayoutParams lp = new LayoutParams(0, + LayoutParams.MATCH_PARENT); + lp.weight = 1; + tv.setGravity(Gravity.CENTER); + tv.setTextColor(COLOR_TEXT_NORMAL); + tv.setText(mTitles[i]); + tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); + tv.setLayoutParams(lp); + tv.setOnClickListener(new OnClickListener() + { + @Override + public void onClick(View v) + { + + } + }); + addView(tv); + } + } + +} diff --git a/app/src/main/java/com/zhy/stickynavlayout/view/StickyNavLayout.java b/app/src/main/java/com/zhy/stickynavlayout/view/StickyNavLayout.java new file mode 100755 index 0000000..4044c6c --- /dev/null +++ b/app/src/main/java/com/zhy/stickynavlayout/view/StickyNavLayout.java @@ -0,0 +1,329 @@ +package com.zhy.stickynavlayout.view; + +import android.animation.ValueAnimator; +import android.content.Context; +import android.support.v4.view.NestedScrollingParent; +import android.support.v4.view.ViewCompat; +import android.support.v4.view.ViewPager; +import android.support.v7.widget.RecyclerView; +import android.util.AttributeSet; +import android.util.Log; +import android.view.VelocityTracker; +import android.view.View; +import android.view.ViewConfiguration; +import android.view.ViewGroup; +import android.view.animation.Interpolator; +import android.widget.LinearLayout; +import android.widget.OverScroller; + +import com.zhy.stickynavlayout.R; + + +public class StickyNavLayout extends LinearLayout implements NestedScrollingParent +{ + private static final String TAG = "StickyNavLayout"; + + @Override + public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) + { + Log.e(TAG, "onStartNestedScroll"); + return true; + } + + @Override + public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes) + { + Log.e(TAG, "onNestedScrollAccepted"); + } + + @Override + public void onStopNestedScroll(View target) + { + Log.e(TAG, "onStopNestedScroll"); + } + + @Override + public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) + { + Log.e(TAG, "onNestedScroll"); + } + + @Override + public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) + { + Log.e(TAG, "onNestedPreScroll"); + boolean hiddenTop = dy > 0 && getScrollY() < mTopViewHeight; + boolean showTop = dy < 0 && getScrollY() >= 0 && !ViewCompat.canScrollVertically(target, -1); + + if (hiddenTop || showTop) + { + scrollBy(0, dy); + consumed[1] = dy; + } + } + + private int TOP_CHILD_FLING_THRESHOLD = 3; + @Override + public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) + { + //如果是recyclerView 根据判断第一个元素是哪个位置可以判断是否消耗 + //这里判断如果第一个元素的位置是大于TOP_CHILD_FLING_THRESHOLD的 + //认为已经被消耗,在animateScroll里不会对velocityY<0时做处理 + if (target instanceof RecyclerView && velocityY < 0) { + final RecyclerView recyclerView = (RecyclerView) target; + final View firstChild = recyclerView.getChildAt(0); + final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild); + consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD; + } + if (!consumed) { + animateScroll(velocityY, computeDuration(0),consumed); + } else { + animateScroll(velocityY, computeDuration(velocityY),consumed); + } + return true; + } + + @Override + public boolean onNestedPreFling(View target, float velocityX, float velocityY) + { + //不做拦截 可以传递给子View + return false; + } + + @Override + public int getNestedScrollAxes() + { + Log.e(TAG, "getNestedScrollAxes"); + return 0; + } + + /** + * 根据速度计算滚动动画持续时间 + * @param velocityY + * @return + */ + private int computeDuration(float velocityY) { + final int distance; + if (velocityY > 0) { + distance = Math.abs(mTop.getHeight() - getScrollY()); + } else { + distance = Math.abs(mTop.getHeight() - (mTop.getHeight() - getScrollY())); + } + + + final int duration; + velocityY = Math.abs(velocityY); + if (velocityY > 0) { + duration = 3 * Math.round(1000 * (distance / velocityY)); + } else { + final float distanceRatio = (float) distance / getHeight(); + duration = (int) ((distanceRatio + 1) * 150); + } + + return duration; + + } + + private void animateScroll(float velocityY, final int duration,boolean consumed) { + final int currentOffset = getScrollY(); + final int topHeight = mTop.getHeight(); + if (mOffsetAnimator == null) { + mOffsetAnimator = new ValueAnimator(); + mOffsetAnimator.setInterpolator(mInterpolator); + mOffsetAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + if (animation.getAnimatedValue() instanceof Integer) { + scrollTo(0, (Integer) animation.getAnimatedValue()); + } + } + }); + } else { + mOffsetAnimator.cancel(); + } + mOffsetAnimator.setDuration(Math.min(duration, 600)); + + if (velocityY >= 0) { + mOffsetAnimator.setIntValues(currentOffset, topHeight); + mOffsetAnimator.start(); + }else { + //如果子View没有消耗down事件 那么就让自身滑倒0位置 + if(!consumed){ + mOffsetAnimator.setIntValues(currentOffset, 0); + mOffsetAnimator.start(); + } + + } + } + + private View mTop; + private View mNav; + private ViewPager mViewPager; + + private int mTopViewHeight; + + private OverScroller mScroller; + private VelocityTracker mVelocityTracker; + private ValueAnimator mOffsetAnimator; + private Interpolator mInterpolator; + private int mTouchSlop; + private int mMaximumVelocity, mMinimumVelocity; + + private float mLastY; + private boolean mDragging; + + public StickyNavLayout(Context context, AttributeSet attrs) + { + super(context, attrs); + setOrientation(LinearLayout.VERTICAL); + + mScroller = new OverScroller(context); + mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); + mMaximumVelocity = ViewConfiguration.get(context) + .getScaledMaximumFlingVelocity(); + mMinimumVelocity = ViewConfiguration.get(context) + .getScaledMinimumFlingVelocity(); + + } + + private void initVelocityTrackerIfNotExists() + { + if (mVelocityTracker == null) + { + mVelocityTracker = VelocityTracker.obtain(); + } + } + + private void recycleVelocityTracker() + { + if (mVelocityTracker != null) + { + mVelocityTracker.recycle(); + mVelocityTracker = null; + } + } + + +// @Override +// public boolean onTouchEvent(MotionEvent event) +// { +// initVelocityTrackerIfNotExists(); +// mVelocityTracker.addMovement(event); +// int action = event.getAction(); +// float y = event.getY(); +// +// switch (action) +// { +// case MotionEvent.ACTION_DOWN: +// if (!mScroller.isFinished()) +// mScroller.abortAnimation(); +// mLastY = y; +// return true; +// case MotionEvent.ACTION_MOVE: +// float dy = y - mLastY; +// +// if (!mDragging && Math.abs(dy) > mTouchSlop) +// { +// mDragging = true; +// } +// if (mDragging) +// { +// scrollBy(0, (int) -dy); +// } +// +// mLastY = y; +// break; +// case MotionEvent.ACTION_CANCEL: +// mDragging = false; +// recycleVelocityTracker(); +// if (!mScroller.isFinished()) +// { +// mScroller.abortAnimation(); +// } +// break; +// case MotionEvent.ACTION_UP: +// mDragging = false; +// mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); +// int velocityY = (int) mVelocityTracker.getYVelocity(); +// if (Math.abs(velocityY) > mMinimumVelocity) +// { +// fling(-velocityY); +// } +// recycleVelocityTracker(); +// break; +// } +// +// return super.onTouchEvent(event); +// } + + + @Override + protected void onFinishInflate() + { + super.onFinishInflate(); + mTop = findViewById(R.id.id_stickynavlayout_topview); + mNav = findViewById(R.id.id_stickynavlayout_indicator); + View view = findViewById(R.id.id_stickynavlayout_viewpager); + if (!(view instanceof ViewPager)) + { + throw new RuntimeException( + "id_stickynavlayout_viewpager show used by ViewPager !"); + } + mViewPager = (ViewPager) view; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) + { + //不限制顶部的高度 + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + getChildAt(0).measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); + ViewGroup.LayoutParams params = mViewPager.getLayoutParams(); + params.height = getMeasuredHeight() - mNav.getMeasuredHeight(); + setMeasuredDimension(getMeasuredWidth(), mTop.getMeasuredHeight() + mNav.getMeasuredHeight() + mViewPager.getMeasuredHeight()); + + } + + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) + { + super.onSizeChanged(w, h, oldw, oldh); + mTopViewHeight = mTop.getMeasuredHeight(); + } + + + public void fling(int velocityY) + { + mScroller.fling(0, getScrollY(), 0, velocityY, 0, 0, 0, mTopViewHeight); + invalidate(); + } + + @Override + public void scrollTo(int x, int y) + { + if (y < 0) + { + y = 0; + } + if (y > mTopViewHeight) + { + y = mTopViewHeight; + } + if (y != getScrollY()) + { + super.scrollTo(x, y); + } + } + + @Override + public void computeScroll() + { + if (mScroller.computeScrollOffset()) + { + scrollTo(0, mScroller.getCurrY()); + invalidate(); + } + } + + +} diff --git a/sample_zhy_StickyNavLayout/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml old mode 100644 new mode 100755 similarity index 74% rename from sample_zhy_StickyNavLayout/res/layout/activity_main.xml rename to app/src/main/res/layout/activity_main.xml index cb59d80..a8efb2d --- a/sample_zhy_StickyNavLayout/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,36 +1,34 @@ - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_tab.xml b/app/src/main/res/layout/fragment_tab.xml new file mode 100755 index 0000000..6b37f34 --- /dev/null +++ b/app/src/main/res/layout/fragment_tab.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item.xml b/app/src/main/res/layout/item.xml new file mode 100644 index 0000000..65d5b6b --- /dev/null +++ b/app/src/main/res/layout/item.xml @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/sample_zhy_StickyNavLayout/res/values/dimens.xml b/app/src/main/res/values/dimens.xml similarity index 99% rename from sample_zhy_StickyNavLayout/res/values/dimens.xml rename to app/src/main/res/values/dimens.xml index 55c1e59..47c8224 100644 --- a/sample_zhy_StickyNavLayout/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,7 +1,5 @@ - 16dp 16dp - diff --git a/library_zhy_StickyNavLayout/res/values/ids_sticky_nav_layout.xml b/app/src/main/res/values/ids_sticky_nav_layout.xml similarity index 100% rename from library_zhy_StickyNavLayout/res/values/ids_sticky_nav_layout.xml rename to app/src/main/res/values/ids_sticky_nav_layout.xml diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..52116d4 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + StickyNavLayout + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/com/zhy/stickynavlayout/ExampleUnitTest.java b/app/src/test/java/com/zhy/stickynavlayout/ExampleUnitTest.java new file mode 100644 index 0000000..9c0f594 --- /dev/null +++ b/app/src/test/java/com/zhy/stickynavlayout/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.zhy.stickynavlayout; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * To work on unit tests, switch the Test Artifact in the Build Variants view. + */ +public class ExampleUnitTest +{ + @Test + public void addition_isCorrect() throws Exception + { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..03bced9 --- /dev/null +++ b/build.gradle @@ -0,0 +1,23 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.1.0' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..1d3591c --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +# Default value: -Xmx10248m -XX:MaxPermSize=256m +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..122a0dc --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 28 10:00:20 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/library_zhy_StickyNavLayout/.classpath b/library_zhy_StickyNavLayout/.classpath deleted file mode 100644 index 7bc01d9..0000000 --- a/library_zhy_StickyNavLayout/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/library_zhy_StickyNavLayout/.project b/library_zhy_StickyNavLayout/.project deleted file mode 100644 index d668604..0000000 --- a/library_zhy_StickyNavLayout/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - library_zhy_StickyNavLayout - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/library_zhy_StickyNavLayout/AndroidManifest.xml b/library_zhy_StickyNavLayout/AndroidManifest.xml deleted file mode 100644 index f2e8c52..0000000 --- a/library_zhy_StickyNavLayout/AndroidManifest.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/library_zhy_StickyNavLayout/ic_launcher-web.png b/library_zhy_StickyNavLayout/ic_launcher-web.png deleted file mode 100644 index a18cbb4..0000000 Binary files a/library_zhy_StickyNavLayout/ic_launcher-web.png and /dev/null differ diff --git a/library_zhy_StickyNavLayout/libs/android-support-v4.jar b/library_zhy_StickyNavLayout/libs/android-support-v4.jar deleted file mode 100644 index 9056828..0000000 Binary files a/library_zhy_StickyNavLayout/libs/android-support-v4.jar and /dev/null differ diff --git a/library_zhy_StickyNavLayout/proguard-project.txt b/library_zhy_StickyNavLayout/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/library_zhy_StickyNavLayout/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/library_zhy_StickyNavLayout/project.properties b/library_zhy_StickyNavLayout/project.properties deleted file mode 100644 index 91d2b02..0000000 --- a/library_zhy_StickyNavLayout/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library=true diff --git a/library_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png b/library_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 288b665..0000000 Binary files a/library_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/library_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png b/library_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 6ae570b..0000000 Binary files a/library_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/library_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png b/library_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index d4fb7cd..0000000 Binary files a/library_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/library_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png b/library_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 85a6081..0000000 Binary files a/library_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/library_zhy_StickyNavLayout/res/menu/main.xml b/library_zhy_StickyNavLayout/res/menu/main.xml deleted file mode 100644 index c002028..0000000 --- a/library_zhy_StickyNavLayout/res/menu/main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/library_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml b/library_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml deleted file mode 100644 index 44f01db..0000000 --- a/library_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/library_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml b/library_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml deleted file mode 100644 index 61e3fa8..0000000 --- a/library_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 128dp - - diff --git a/library_zhy_StickyNavLayout/res/values-v11/styles.xml b/library_zhy_StickyNavLayout/res/values-v11/styles.xml deleted file mode 100644 index 3c02242..0000000 --- a/library_zhy_StickyNavLayout/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/library_zhy_StickyNavLayout/res/values-v14/styles.xml b/library_zhy_StickyNavLayout/res/values-v14/styles.xml deleted file mode 100644 index a91fd03..0000000 --- a/library_zhy_StickyNavLayout/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/library_zhy_StickyNavLayout/res/values/dimens.xml b/library_zhy_StickyNavLayout/res/values/dimens.xml deleted file mode 100644 index 55c1e59..0000000 --- a/library_zhy_StickyNavLayout/res/values/dimens.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - 16dp - 16dp - - diff --git a/library_zhy_StickyNavLayout/res/values/strings.xml b/library_zhy_StickyNavLayout/res/values/strings.xml deleted file mode 100644 index c529061..0000000 --- a/library_zhy_StickyNavLayout/res/values/strings.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - lib_StickyNavLayout - Settings - Hello world! - - diff --git a/library_zhy_StickyNavLayout/res/values/styles.xml b/library_zhy_StickyNavLayout/res/values/styles.xml deleted file mode 100644 index 6ce89c7..0000000 --- a/library_zhy_StickyNavLayout/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/library_zhy_StickyNavLayout/src/com/zhy/view/StickyNavLayout.java b/library_zhy_StickyNavLayout/src/com/zhy/view/StickyNavLayout.java deleted file mode 100755 index cb9c6bf..0000000 --- a/library_zhy_StickyNavLayout/src/com/zhy/view/StickyNavLayout.java +++ /dev/null @@ -1,320 +0,0 @@ -package com.zhy.view; - -import android.content.Context; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.util.Log; -import android.view.MotionEvent; -import android.view.VelocityTracker; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.OverScroller; -import android.widget.ScrollView; - -public class StickyNavLayout extends LinearLayout { - - private View mTop; - private View mNav; - private ViewPager mViewPager; - - private int mTopViewHeight; - private ViewGroup mInnerScrollView; - private boolean isTopHidden = false; - - private OverScroller mScroller; - private VelocityTracker mVelocityTracker; - private int mTouchSlop; - private int mMaximumVelocity, mMinimumVelocity; - - private float mLastY; - private boolean mDragging; - - private boolean isInControl = false; - - public StickyNavLayout(Context context, AttributeSet attrs) { - super(context, attrs); - setOrientation(LinearLayout.VERTICAL); - - mScroller = new OverScroller(context); - mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); - mMaximumVelocity = ViewConfiguration.get(context) - .getScaledMaximumFlingVelocity(); - mMinimumVelocity = ViewConfiguration.get(context) - .getScaledMinimumFlingVelocity(); - - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mTop = findViewById(R.id.id_stickynavlayout_topview); - mNav = findViewById(R.id.id_stickynavlayout_indicator); - View view = findViewById(R.id.id_stickynavlayout_viewpager); - if (!(view instanceof ViewPager)) { - throw new RuntimeException( - "id_stickynavlayout_viewpager show used by ViewPager !"); - } - mViewPager = (ViewPager) view; - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - ViewGroup.LayoutParams params = mViewPager.getLayoutParams(); - params.height = getMeasuredHeight() - mNav.getMeasuredHeight(); - - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - super.onSizeChanged(w, h, oldw, oldh); - mTopViewHeight = mTop.getMeasuredHeight(); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - int action = ev.getAction(); - float y = ev.getY(); - - switch (action) { - case MotionEvent.ACTION_DOWN: - mLastY = y; - break; - case MotionEvent.ACTION_MOVE: - float dy = y - mLastY; - getCurrentScrollView(); - - if (mInnerScrollView instanceof ScrollView) { - if (mInnerScrollView.getScrollY() == 0 && isTopHidden && dy > 0 - && !isInControl) { - isInControl = true; - ev.setAction(MotionEvent.ACTION_CANCEL); - MotionEvent ev2 = MotionEvent.obtain(ev); - dispatchTouchEvent(ev); - ev2.setAction(MotionEvent.ACTION_DOWN); - return dispatchTouchEvent(ev2); - } - } else if (mInnerScrollView instanceof ListView) { - - ListView lv = (ListView) mInnerScrollView; - View c = lv.getChildAt(lv.getFirstVisiblePosition()); - - if (!isInControl && c != null && c.getTop() == 0 && isTopHidden - && dy > 0) { - isInControl = true; - ev.setAction(MotionEvent.ACTION_CANCEL); - MotionEvent ev2 = MotionEvent.obtain(ev); - dispatchTouchEvent(ev); - ev2.setAction(MotionEvent.ACTION_DOWN); - return dispatchTouchEvent(ev2); - } - }else if (mInnerScrollView instanceof RecyclerView) { - - RecyclerView rv = (RecyclerView) mInnerScrollView; - - if (!isInControl && android.support.v4.view.ViewCompat.canScrollVertically(rv, -1) && isTopHidden - && dy > 0) { - isInControl = true; - ev.setAction(MotionEvent.ACTION_CANCEL); - MotionEvent ev2 = MotionEvent.obtain(ev); - dispatchTouchEvent(ev); - ev2.setAction(MotionEvent.ACTION_DOWN); - return dispatchTouchEvent(ev2); - } - } - break; - } - return super.dispatchTouchEvent(ev); - } - - /** - * - */ - @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { - final int action = ev.getAction(); - float y = ev.getY(); - switch (action) { - case MotionEvent.ACTION_DOWN: - mLastY = y; - break; - case MotionEvent.ACTION_MOVE: - float dy = y - mLastY; - getCurrentScrollView(); - if (Math.abs(dy) > mTouchSlop) { - mDragging = true; - if (mInnerScrollView instanceof ScrollView) { - // 如果topView没有隐藏 - // 或sc的scrollY = 0 && topView隐藏 && 下拉,则拦截 - if (!isTopHidden - || (mInnerScrollView.getScrollY() == 0 - && isTopHidden && dy > 0)) { - - initVelocityTrackerIfNotExists(); - mVelocityTracker.addMovement(ev); - mLastY = y; - return true; - } - } else if (mInnerScrollView instanceof ListView) { - - ListView lv = (ListView) mInnerScrollView; - View c = lv.getChildAt(lv.getFirstVisiblePosition()); - // 如果topView没有隐藏 - // 或sc的listView在顶部 && topView隐藏 && 下拉,则拦截 - - if (!isTopHidden || // - (c != null // - && c.getTop() == 0// - && isTopHidden && dy > 0)) { - - initVelocityTrackerIfNotExists(); - mVelocityTracker.addMovement(ev); - mLastY = y; - return true; - } - }else if (mInnerScrollView instanceof RecyclerView) { - RecyclerView rv = (RecyclerView) mInnerScrollView; - if (!isTopHidden || (!android.support.v4.view.ViewCompat.canScrollVertically(rv, -1) && isTopHidden && dy > 0)) { - initVelocityTrackerIfNotExists(); - mVelocityTracker.addMovement(ev); - mLastY = y; - return true; - } - } - - } - break; - case MotionEvent.ACTION_CANCEL: - case MotionEvent.ACTION_UP: - mDragging = false; - recycleVelocityTracker(); - break; - } - return super.onInterceptTouchEvent(ev); - } - - private void getCurrentScrollView() { - - int currentItem = mViewPager.getCurrentItem(); - PagerAdapter a = mViewPager.getAdapter(); - if (a instanceof FragmentPagerAdapter) { - FragmentPagerAdapter fadapter = (FragmentPagerAdapter) a; - Fragment item = (Fragment) fadapter.instantiateItem(mViewPager, - currentItem); - mInnerScrollView = (ViewGroup) (item.getView() - .findViewById(R.id.id_stickynavlayout_innerscrollview)); - } else if (a instanceof FragmentStatePagerAdapter) { - FragmentStatePagerAdapter fsAdapter = (FragmentStatePagerAdapter) a; - Fragment item = (Fragment) fsAdapter.instantiateItem(mViewPager, - currentItem); - mInnerScrollView = (ViewGroup) (item.getView() - .findViewById(R.id.id_stickynavlayout_innerscrollview)); - } - - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - initVelocityTrackerIfNotExists(); - mVelocityTracker.addMovement(event); - int action = event.getAction(); - float y = event.getY(); - - switch (action) { - case MotionEvent.ACTION_DOWN: - if (!mScroller.isFinished()) - mScroller.abortAnimation(); - mLastY = y; - return true; - case MotionEvent.ACTION_MOVE: - float dy = y - mLastY; - - Log.e("TAG", "dy = " + dy + " , y = " + y + " , mLastY = " + mLastY); - - if (!mDragging && Math.abs(dy) > mTouchSlop) { - mDragging = true; - } - if (mDragging) { - scrollBy(0, (int) -dy); - - // 如果topView隐藏,且上滑动时,则改变当前事件为ACTION_DOWN - if (getScrollY() == mTopViewHeight && dy < 0) { - event.setAction(MotionEvent.ACTION_DOWN); - dispatchTouchEvent(event); - isInControl = false; - } - } - - mLastY = y; - break; - case MotionEvent.ACTION_CANCEL: - mDragging = false; - recycleVelocityTracker(); - if (!mScroller.isFinished()) { - mScroller.abortAnimation(); - } - break; - case MotionEvent.ACTION_UP: - mDragging = false; - mVelocityTracker.computeCurrentVelocity(1000, mMaximumVelocity); - int velocityY = (int) mVelocityTracker.getYVelocity(); - if (Math.abs(velocityY) > mMinimumVelocity) { - fling(-velocityY); - } - recycleVelocityTracker(); - break; - } - - return super.onTouchEvent(event); - } - - public void fling(int velocityY) { - mScroller.fling(0, getScrollY(), 0, velocityY, 0, 0, 0, mTopViewHeight); - invalidate(); - } - - @Override - public void scrollTo(int x, int y) { - if (y < 0) { - y = 0; - } - if (y > mTopViewHeight) { - y = mTopViewHeight; - } - if (y != getScrollY()) { - super.scrollTo(x, y); - } - - isTopHidden = getScrollY() == mTopViewHeight; - - } - - @Override - public void computeScroll() { - if (mScroller.computeScrollOffset()) { - scrollTo(0, mScroller.getCurrY()); - invalidate(); - } - } - - private void initVelocityTrackerIfNotExists() { - if (mVelocityTracker == null) { - mVelocityTracker = VelocityTracker.obtain(); - } - } - - private void recycleVelocityTracker() { - if (mVelocityTracker != null) { - mVelocityTracker.recycle(); - mVelocityTracker = null; - } - } - -} diff --git a/sample_zhy_StickyNavLayout/.classpath b/sample_zhy_StickyNavLayout/.classpath deleted file mode 100644 index 7bc01d9..0000000 --- a/sample_zhy_StickyNavLayout/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/sample_zhy_StickyNavLayout/.project b/sample_zhy_StickyNavLayout/.project deleted file mode 100644 index ab98deb..0000000 --- a/sample_zhy_StickyNavLayout/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - sample_zhy_StickyNavLayout - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/sample_zhy_StickyNavLayout/AndroidManifest.xml b/sample_zhy_StickyNavLayout/AndroidManifest.xml deleted file mode 100644 index 1e2eb81..0000000 --- a/sample_zhy_StickyNavLayout/AndroidManifest.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/sample_zhy_StickyNavLayout/ic_launcher-web.png b/sample_zhy_StickyNavLayout/ic_launcher-web.png deleted file mode 100644 index a18cbb4..0000000 Binary files a/sample_zhy_StickyNavLayout/ic_launcher-web.png and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/libs/android-support-v4.jar b/sample_zhy_StickyNavLayout/libs/android-support-v4.jar deleted file mode 100644 index 9056828..0000000 Binary files a/sample_zhy_StickyNavLayout/libs/android-support-v4.jar and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/proguard-project.txt b/sample_zhy_StickyNavLayout/proguard-project.txt deleted file mode 100644 index f2fe155..0000000 --- a/sample_zhy_StickyNavLayout/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# To enable ProGuard in your project, edit project.properties -# to define the proguard.config property as described in that file. -# -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in ${sdk.dir}/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the ProGuard -# include property in project.properties. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/sample_zhy_StickyNavLayout/project.properties b/sample_zhy_StickyNavLayout/project.properties deleted file mode 100644 index 073b5a8..0000000 --- a/sample_zhy_StickyNavLayout/project.properties +++ /dev/null @@ -1,15 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system edit -# "ant.properties", and override values to adapt the script to your -# project structure. -# -# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): -#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt - -# Project target. -target=android-19 -android.library.reference.1=../library_zhy_StickyNavLayout diff --git a/sample_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png b/sample_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 288b665..0000000 Binary files a/sample_zhy_StickyNavLayout/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png b/sample_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 6ae570b..0000000 Binary files a/sample_zhy_StickyNavLayout/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png b/sample_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index d4fb7cd..0000000 Binary files a/sample_zhy_StickyNavLayout/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png b/sample_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png deleted file mode 100644 index 85a6081..0000000 Binary files a/sample_zhy_StickyNavLayout/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/sample_zhy_StickyNavLayout/res/layout/fragment_tab.xml b/sample_zhy_StickyNavLayout/res/layout/fragment_tab.xml deleted file mode 100644 index ba8628a..0000000 --- a/sample_zhy_StickyNavLayout/res/layout/fragment_tab.xml +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sample_zhy_StickyNavLayout/res/menu/main.xml b/sample_zhy_StickyNavLayout/res/menu/main.xml deleted file mode 100644 index c002028..0000000 --- a/sample_zhy_StickyNavLayout/res/menu/main.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/sample_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml b/sample_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml deleted file mode 100644 index 44f01db..0000000 --- a/sample_zhy_StickyNavLayout/res/values-sw600dp/dimens.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - diff --git a/sample_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml b/sample_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml deleted file mode 100644 index 61e3fa8..0000000 --- a/sample_zhy_StickyNavLayout/res/values-sw720dp-land/dimens.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - 128dp - - diff --git a/sample_zhy_StickyNavLayout/res/values-v11/styles.xml b/sample_zhy_StickyNavLayout/res/values-v11/styles.xml deleted file mode 100644 index 3c02242..0000000 --- a/sample_zhy_StickyNavLayout/res/values-v11/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/sample_zhy_StickyNavLayout/res/values-v14/styles.xml b/sample_zhy_StickyNavLayout/res/values-v14/styles.xml deleted file mode 100644 index a91fd03..0000000 --- a/sample_zhy_StickyNavLayout/res/values-v14/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - diff --git a/sample_zhy_StickyNavLayout/res/values/strings.xml b/sample_zhy_StickyNavLayout/res/values/strings.xml deleted file mode 100644 index d8f705c..0000000 --- a/sample_zhy_StickyNavLayout/res/values/strings.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - sample_StickyNavLayout - Settings - Hello world! - - diff --git a/sample_zhy_StickyNavLayout/res/values/styles.xml b/sample_zhy_StickyNavLayout/res/values/styles.xml deleted file mode 100644 index 6ce89c7..0000000 --- a/sample_zhy_StickyNavLayout/res/values/styles.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/MainActivity.java b/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/MainActivity.java deleted file mode 100644 index fa1db1b..0000000 --- a/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/MainActivity.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.zhy.sample.StickyNavLayout; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v4.view.ViewPager.OnPageChangeListener; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import com.zhy.view.SimpleViewPagerIndicator; - -public class MainActivity extends FragmentActivity { - private String[] mTitles = new String[] { "简介", "评价", "相关" }; - private SimpleViewPagerIndicator mIndicator; - private ViewPager mViewPager; - private FragmentPagerAdapter mAdapter; - private TabFragment[] mFragments = new TabFragment[mTitles.length]; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - - initViews(); - initDatas(); - initEvents(); - } - - private void initEvents() { - mViewPager.setOnPageChangeListener(new OnPageChangeListener() { - @Override - public void onPageSelected(int position) { - } - - @Override - public void onPageScrolled(int position, float positionOffset, - int positionOffsetPixels) { - mIndicator.scroll(position, positionOffset); - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - }); - - } - - private void initDatas() { - mIndicator.setTitles(mTitles); - - for (int i = 0; i < mTitles.length; i++) { - mFragments[i] = (TabFragment) TabFragment.newInstance(mTitles[i]); - } - - mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { - @Override - public int getCount() { - return mTitles.length; - } - - @Override - public Fragment getItem(int position) { - return mFragments[position]; - } - - }; - - mViewPager.setAdapter(mAdapter); - mViewPager.setCurrentItem(0); - } - - private void initViews() { - mIndicator = (SimpleViewPagerIndicator) findViewById(R.id.id_stickynavlayout_indicator); - mViewPager = (ViewPager) findViewById(R.id.id_stickynavlayout_viewpager); - - } - -} diff --git a/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/TabFragment.java b/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/TabFragment.java deleted file mode 100644 index 1e09cd4..0000000 --- a/sample_zhy_StickyNavLayout/src/com/zhy/sample/StickyNavLayout/TabFragment.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.zhy.sample.StickyNavLayout; - -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -public class TabFragment extends Fragment -{ - public static final String TITLE = "title"; - private String mTitle = "Defaut Value"; - private TextView mTextView; - - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); - if (getArguments() != null) - { - mTitle = getArguments().getString(TITLE); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) - { - View view = inflater.inflate(R.layout.fragment_tab, container, false); - mTextView = (TextView) view.findViewById(R.id.id_info); - mTextView.setText(mTitle); - return view; - - } - - public static TabFragment newInstance(String title) - { - TabFragment tabFragment = new TabFragment(); - Bundle bundle = new Bundle(); - bundle.putString(TITLE, title); - tabFragment.setArguments(bundle); - return tabFragment; - } - -} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e7b4def --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app'