├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── layout
│ │ │ │ ├── fragment_fragment4.xml
│ │ │ │ ├── view_toolbar.xml
│ │ │ │ ├── list_test_item.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── fragment_fragment1.xml
│ │ │ │ ├── fragment_fragment3.xml
│ │ │ │ └── fragment_fragment2.xml
│ │ │ └── values-w820dp
│ │ │ │ └── dimens.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── loopeer
│ │ │ └── android
│ │ │ └── librarys
│ │ │ └── pullswitcher
│ │ │ ├── TestPagerAdapter.java
│ │ │ ├── MainActivity.java
│ │ │ ├── TestSwitcherAdapter.java
│ │ │ ├── TestCustomFooterView.java
│ │ │ ├── TestFragment2Scroll.java
│ │ │ ├── TestRecyclerAdapter.java
│ │ │ ├── TestFragment3ViewPager.java
│ │ │ ├── TestFragment4.java
│ │ │ ├── TestFragment1Recycler.java
│ │ │ └── DividerItemDecoration.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── loopeer
│ │ │ └── android
│ │ │ └── librarys
│ │ │ └── pullswitcher
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── pullswitcher
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── pullswitcherview
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── integers.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── anim
│ │ │ │ ├── in_from_top.xml
│ │ │ │ ├── in_from_bottom.xml
│ │ │ │ ├── out_to_top.xml
│ │ │ │ └── out_to_bottom.xml
│ │ │ └── values-zh
│ │ │ │ └── strings.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── loopeer
│ │ │ │ └── android
│ │ │ │ └── librarys
│ │ │ │ ├── Footer.java
│ │ │ │ ├── Header.java
│ │ │ │ ├── SwitchListener.java
│ │ │ │ ├── SwitcherHolder.java
│ │ │ │ ├── HeaderFooter.java
│ │ │ │ ├── SwitcherAdapter.java
│ │ │ │ ├── DefaultHeader.java
│ │ │ │ ├── DefaultFooter.java
│ │ │ │ ├── SwitcherHolderImpl.java
│ │ │ │ ├── SwitchFragmentAdapter.java
│ │ │ │ ├── PullIndicator.java
│ │ │ │ └── PullSwitchView.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── loopeer
│ │ │ └── android
│ │ │ └── librarys
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── loopeer
│ │ └── android
│ │ └── librarys
│ │ └── ApplicationTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── screenshot
└── screenshot.gif
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradlew.bat
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/pullswitcherview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':pullswitcherview'
2 |
--------------------------------------------------------------------------------
/screenshot/screenshot.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/screenshot/screenshot.gif
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PullSwitcher
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loopeer/PullSwitcher/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 300
5 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/Footer.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | public interface Footer extends HeaderFooter {
4 |
5 |
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/Header.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | public interface Header extends HeaderFooter {
4 |
5 |
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #B8B8B8
5 |
6 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/SwitchListener.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | public interface SwitchListener {
4 |
5 | void onPagePause();
6 | void onPageResume();
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Oct 29 22:30:14 CST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/SwitcherHolder.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | public interface SwitcherHolder {
4 |
5 | void onNextPage();
6 | void onPrePage();
7 | boolean isLastPage();
8 | boolean isFirstPage();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 12dp
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #777777
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_fragment4.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/HeaderFooter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | public interface HeaderFooter {
4 |
5 | void onMoveStart(int currentPosY, int startSwitchOffset, CharSequence string);
6 |
7 | void onCanStartSwitch(int currentPosY, int startSwitchOffset, CharSequence string);
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/anim/in_from_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/view_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/anim/in_from_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/anim/out_to_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/anim/out_to_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/pullswitcherview/src/test/java/com/loopeer/android/librarys/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/list_test_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/test/java/com/loopeer/android/librarys/pullswitcher/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/values-zh/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 继续下拉返回上一页
4 | 松手返回上一页
5 | 继续上拉进入下一页
6 | 松手进入下一页
7 | 已经是第一页了
8 | 没有更多页面了
9 |
10 |
11 |
--------------------------------------------------------------------------------
/pullswitcherview/src/androidTest/java/com/loopeer/android/librarys/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/loopeer/android/librarys/pullswitcher/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/pullswitcherview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | keep pull down to go back
4 | Let go back
5 | keep pull up to go next page
6 | Let go to next page
7 | Already first one
8 | No more
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/SwitcherAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.view.ViewGroup;
4 |
5 | public abstract class SwitcherAdapter {
6 |
7 | private SwitcherHolder switcherHolder;
8 |
9 | public abstract void replaceItem(ViewGroup container, int prePosition, int newPosition);
10 |
11 | public abstract int getCount();
12 |
13 | public void setOnPageChangeListener(SwitcherHolder holder) {
14 | this.switcherHolder = holder;
15 | }
16 |
17 | public SwitcherHolder getSwitcherHolder() {
18 | return switcherHolder;
19 | }
20 |
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/pullswitcherview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/todou/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | public class TestPagerAdapter extends FragmentPagerAdapter {
8 |
9 | public TestPagerAdapter(FragmentManager fm) {
10 | super(fm);
11 | }
12 |
13 | @Override
14 | public Fragment getItem(int position) {
15 | return TestFragment4.newInstance();
16 | }
17 |
18 | @Override
19 | public int getCount() {
20 | return 4;
21 | }
22 |
23 | @Override
24 | public CharSequence getPageTitle(int position) {
25 | return "Tab: " + (position + 1);
26 | }
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_fragment1.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.loopeer.android.librarys.pullswitcher"
9 | minSdkVersion 15
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | compile 'com.android.support:appcompat-v7:23.1.0'
26 | compile 'com.android.support:design:23.1.0'
27 | compile 'com.android.support:recyclerview-v7:23.1.0'
28 | compile project(':pullswitcherview')
29 | // compile 'com.loopeer.library:pullswitcherview:1.0.6'
30 | }
31 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Specific files to exclude
2 | dist
3 | com_crashlytics_export_strings.xml
4 | keys.xml
5 | #*.keystore
6 |
7 | ### Android
8 | ###########
9 | # built application files
10 | *.apk
11 | *.ap_
12 |
13 | # files for the dex VM
14 | *.dex
15 |
16 | # Java class files
17 | *.class
18 |
19 | # generated files
20 | bin/
21 | gen/
22 |
23 | # Local configuration file (sdk path, etc)
24 | local.properties
25 | gradle.properties
26 | keystore.properties
27 |
28 | ### Mac
29 | .DS_store
30 |
31 | ### Linux
32 | #########
33 | !.gitignore
34 | *~
35 |
36 | ### Windows
37 | ############
38 | # Windows image file caches
39 | Thumbs.db
40 | ehthumbs.db
41 |
42 | # Folder config file
43 | Desktop.ini
44 |
45 | # Recycle Bin used on file shares
46 | $RECYCLE.BIN/
47 |
48 | ### IntelliJ
49 | *.iml
50 | *.ipr
51 | *.iws
52 | .idea/
53 |
54 | ### Gradle
55 | .gradle/
56 | build/
57 | out/
58 |
59 | #Maven
60 | target
61 | release.properties
62 | pom.xml.*
63 |
64 | ### AppEngine
65 | google_generated/
66 | datanucleus.log
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_fragment3.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.widget.FrameLayout;
6 |
7 | import com.loopeer.android.librarys.SwitcherAdapter;
8 | import com.loopeer.android.librarys.SwitcherHolderImpl;
9 |
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | private FrameLayout containerLayout;
14 | private SwitcherAdapter adapter;
15 | private SwitcherHolderImpl mSwitchHolder;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 |
22 | containerLayout = (FrameLayout) findViewById(R.id.container);
23 |
24 | mSwitchHolder = new SwitcherHolderImpl(containerLayout);
25 | adapter = new TestSwitcherAdapter(getSupportFragmentManager());
26 | mSwitchHolder.setAdapter(adapter);
27 | }
28 |
29 | @Override
30 | public void onBackPressed() {
31 | mSwitchHolder.doBack();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestSwitcherAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 |
6 | import com.loopeer.android.librarys.SwitchFragmentAdapter;
7 |
8 | public class TestSwitcherAdapter extends SwitchFragmentAdapter {
9 |
10 | public TestSwitcherAdapter(FragmentManager fm) {
11 | super(fm);
12 | }
13 |
14 | @Override
15 | public Fragment getItem(int position) {
16 | Fragment fragment;
17 | switch (position) {
18 | case 0:
19 | fragment = TestFragment1Recycler.newInstance(getSwitcherHolder());
20 | break;
21 | case 1:
22 | fragment = TestFragment2Scroll.newInstance(getSwitcherHolder());
23 | break;
24 | case 2:
25 | fragment = TestFragment3ViewPager.newInstance(getSwitcherHolder());
26 | break;
27 | default:
28 | fragment = null;
29 | }
30 | return fragment;
31 | }
32 |
33 | @Override
34 | public int getCount() {
35 | return 3;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestCustomFooterView.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.Gravity;
6 | import android.widget.TextView;
7 |
8 | import com.loopeer.android.librarys.Footer;
9 |
10 | public class TestCustomFooterView extends TextView implements Footer{
11 |
12 | public TestCustomFooterView(Context context) {
13 | this(context, null);
14 | }
15 |
16 | public TestCustomFooterView(Context context, AttributeSet attrs) {
17 | this(context, attrs, 0);
18 | }
19 |
20 | public TestCustomFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 | setPadding(20, 20, 20, 20);
23 | setGravity(Gravity.CENTER);
24 | }
25 |
26 | @Override
27 | public void onMoveStart(int currentPosY, int startSwitchOffset, CharSequence string) {
28 | setText("Test custom footer text onMoveStart");
29 | }
30 |
31 | @Override
32 | public void onCanStartSwitch(int currentPosY, int startSwitchOffset, CharSequence string) {
33 | setText("Test custom footer text onCanStartSwitch");
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestFragment2Scroll.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 |
10 | import com.loopeer.android.librarys.PullSwitchView;
11 | import com.loopeer.android.librarys.SwitcherHolder;
12 |
13 | public class TestFragment2Scroll extends Fragment {
14 |
15 | private SwitcherHolder switcherHolder;
16 |
17 | public static TestFragment2Scroll newInstance(SwitcherHolder switcherHolder) {
18 | TestFragment2Scroll testFragment = new TestFragment2Scroll();
19 | testFragment.switcherHolder = switcherHolder;
20 | return testFragment;
21 | }
22 |
23 | @Nullable
24 | @Override
25 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
26 | return inflater.inflate(R.layout.fragment_fragment2, container, false);
27 | }
28 |
29 | @Override
30 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
31 | super.onViewCreated(view, savedInstanceState);
32 |
33 | PullSwitchView pullSwitchView = (PullSwitchView) view.findViewById(R.id.switcher);
34 | pullSwitchView.setSwitcherHolder(switcherHolder);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/DefaultHeader.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.content.Context;
4 | import android.support.v4.content.ContextCompat;
5 | import android.util.AttributeSet;
6 | import android.view.Gravity;
7 | import android.widget.TextView;
8 |
9 | public class DefaultHeader extends TextView implements Header {
10 |
11 | public DefaultHeader(Context context) {
12 | this(context, null);
13 | }
14 |
15 | public DefaultHeader(Context context, AttributeSet attrs) {
16 | this(context, attrs, 0);
17 | }
18 |
19 | public DefaultHeader(Context context, AttributeSet attrs, int defStyleAttr) {
20 | super(context, attrs, defStyleAttr);
21 |
22 | init(context, attrs, defStyleAttr);
23 | }
24 |
25 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
26 | setGravity(Gravity.CENTER);
27 | int padding = getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
28 | setPadding(padding, padding, padding, padding);
29 | setTextColor(ContextCompat.getColor(context, R.color.switcher_color_hint));
30 | }
31 |
32 |
33 | @Override
34 | public void onMoveStart(int currentPosY, int startSwitchOffset, CharSequence string) {
35 | setText(string);
36 | }
37 |
38 | @Override
39 | public void onCanStartSwitch(int currentPosY, int startSwitchOffset, CharSequence string) {
40 | setText(string);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.TextView;
8 |
9 | public class TestRecyclerAdapter extends RecyclerView.Adapter {
10 | private String[] mDataset;
11 |
12 |
13 | public static class ViewHolder extends RecyclerView.ViewHolder {
14 | public TextView mTextView;
15 |
16 | public ViewHolder(View v) {
17 | super(v);
18 | mTextView = (TextView) v;
19 | }
20 | }
21 |
22 | public TestRecyclerAdapter(String[] myDataset) {
23 | mDataset = myDataset;
24 | }
25 |
26 | // Create new views (invoked by the layout manager)
27 | @Override
28 | public TestRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
29 | int viewType) {
30 | // create a new view
31 | View v = LayoutInflater.from(parent.getContext())
32 | .inflate(R.layout.list_test_item, parent, false);
33 |
34 | ViewHolder vh = new ViewHolder(v);
35 | return vh;
36 | }
37 |
38 | @Override
39 | public void onBindViewHolder(ViewHolder holder, int position) {
40 | holder.mTextView.setText(mDataset[position]);
41 |
42 | }
43 |
44 | @Override
45 | public int getItemCount() {
46 | return mDataset.length;
47 | }
48 | }
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/DefaultFooter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.content.Context;
4 | import android.support.v4.content.ContextCompat;
5 | import android.util.AttributeSet;
6 | import android.view.Gravity;
7 | import android.widget.TextView;
8 |
9 | public class DefaultFooter extends TextView implements Footer {
10 | private static final String TAG = "DefaultFooter";
11 |
12 | public DefaultFooter(Context context) {
13 | this(context, null);
14 | }
15 |
16 | public DefaultFooter(Context context, AttributeSet attrs) {
17 | this(context, attrs, 0);
18 | }
19 |
20 | public DefaultFooter(Context context, AttributeSet attrs, int defStyleAttr) {
21 | super(context, attrs, defStyleAttr);
22 |
23 | init(context, attrs, defStyleAttr);
24 | }
25 |
26 | private void init(Context context, AttributeSet attrs, int defStyleAttr) {
27 | setGravity(Gravity.CENTER);
28 | int padding = getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
29 | setPadding(padding, padding, padding, padding);
30 | setTextColor(ContextCompat.getColor(context, R.color.switcher_color_hint));
31 | }
32 |
33 | @Override
34 | public void onMoveStart(int currentPosY, int startSwitchOffset, final CharSequence string) {
35 | setText(string.toString());
36 | }
37 |
38 | @Override
39 | public void onCanStartSwitch(int currentPosY, int startSwitchOffset, final CharSequence string) {
40 | setText(string.toString());
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestFragment3ViewPager.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.design.widget.TabLayout;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.view.ViewPager;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | import com.loopeer.android.librarys.PullSwitchView;
13 | import com.loopeer.android.librarys.SwitcherHolder;
14 |
15 | public class TestFragment3ViewPager extends Fragment {
16 |
17 | private SwitcherHolder switcherHolder;
18 | private PullSwitchView pullSwitchView;
19 |
20 | private TestPagerAdapter mAdapter;
21 | private ViewPager mViewpager;
22 | private TabLayout mTabs;
23 |
24 | public static TestFragment3ViewPager newInstance(SwitcherHolder switcherHolder) {
25 | TestFragment3ViewPager testFragment = new TestFragment3ViewPager();
26 | testFragment.switcherHolder = switcherHolder;
27 | return testFragment;
28 | }
29 |
30 | @Nullable
31 | @Override
32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
33 | return inflater.inflate(R.layout.fragment_fragment3, container, false);
34 | }
35 |
36 | @Override
37 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
38 | super.onViewCreated(view, savedInstanceState);
39 |
40 | initSwitchView(view);
41 | initPagerTabs(view);
42 | }
43 |
44 | private void initPagerTabs(View view) {
45 | mViewpager = (ViewPager) view.findViewById(R.id.viewpager);
46 | mTabs = (TabLayout) view.findViewById(R.id.tabs);
47 | mAdapter = new TestPagerAdapter(getChildFragmentManager());
48 | mViewpager.setAdapter(mAdapter);
49 | mTabs.setupWithViewPager(mViewpager);
50 | }
51 |
52 | private void initSwitchView(View view) {
53 | pullSwitchView = (PullSwitchView) view.findViewById(R.id.switcher);
54 | pullSwitchView.setSwitcherHolder(switcherHolder);
55 | pullSwitchView.disableWhenHorizontalMove(true);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/SwitcherHolderImpl.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.app.Activity;
4 | import android.view.ViewGroup;
5 |
6 |
7 | public class SwitcherHolderImpl implements SwitcherHolder {
8 |
9 | private ViewGroup mContainer;
10 | private SwitcherAdapter mAdapter;
11 | private int mPreCurrentItem;
12 | private int mCurItem; // Index of currently displayed page.
13 |
14 | public SwitcherHolderImpl(ViewGroup mContainer) {
15 | this.mContainer = mContainer;
16 | }
17 |
18 | public void setAdapter(SwitcherAdapter adapter) {
19 | mAdapter = adapter;
20 | mPreCurrentItem = 0;
21 | adapter.setOnPageChangeListener(this);
22 | setCurrentItem(0);
23 | }
24 |
25 | public void setCurrentItem(int i) {
26 | mCurItem = i;
27 | if (mCurItem == mPreCurrentItem && mCurItem != 0) return;
28 | mAdapter.replaceItem(mContainer, mPreCurrentItem, mCurItem);
29 | mAdapter.setOnPageChangeListener(this);
30 | mPreCurrentItem = i;
31 | }
32 |
33 | public int getCurrentPosition() {
34 | return mCurItem;
35 | }
36 |
37 | public void nextPage() {
38 | if (mCurItem == mAdapter.getCount() - 1) return;
39 | mPreCurrentItem = mCurItem++;
40 | nextPage(mCurItem);
41 | }
42 |
43 | public void nextPage(int position) {
44 | setCurrentItem(position);
45 | }
46 |
47 | public void prePage() {
48 | if (mCurItem == 0) return;
49 | mPreCurrentItem = mCurItem --;
50 | prePage(mCurItem);
51 | }
52 |
53 | private void prePage(int position) {
54 | setCurrentItem(position);
55 | }
56 |
57 | @Override
58 | public void onNextPage() {
59 | nextPage();
60 | }
61 |
62 | @Override
63 | public void onPrePage() {
64 | prePage();
65 | }
66 |
67 | @Override
68 | public boolean isLastPage() {
69 | return mCurItem == mAdapter.getCount() - 1;
70 | }
71 |
72 | @Override
73 | public boolean isFirstPage() {
74 | return mCurItem == 0;
75 | }
76 |
77 | public void doBack() {
78 | if (mCurItem == 0) {
79 | ((Activity) mContainer.getContext()).finish();
80 | } else {
81 | onPrePage();
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_fragment2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
20 |
21 |
25 |
26 |
30 |
31 |
36 |
37 |
38 |
39 |
44 |
45 |
49 |
50 |
55 |
56 |
57 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestFragment4.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | public class TestFragment4 extends Fragment {
13 |
14 | private RecyclerView mRecyclerView;
15 | private RecyclerView.Adapter mAdapter;
16 | private RecyclerView.LayoutManager mLayoutManager;
17 |
18 | public static TestFragment4 newInstance() {
19 | TestFragment4 testFragment = new TestFragment4();
20 | return testFragment;
21 | }
22 |
23 | @Nullable
24 | @Override
25 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
26 | return inflater.inflate(R.layout.fragment_fragment4, container, false);
27 | }
28 |
29 | @Override
30 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
31 | super.onViewCreated(view, savedInstanceState);
32 |
33 | initTestRecyclerView(view);
34 | }
35 |
36 | private void initTestRecyclerView(View view) {
37 | mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
38 | mRecyclerView.setHasFixedSize(true);
39 | mLayoutManager = new LinearLayoutManager(getContext());
40 | mRecyclerView.setLayoutManager(mLayoutManager);
41 | mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
42 |
43 | mAdapter = new TestRecyclerAdapter(new String[]{
44 | "We've partnered with Udacity to laun",
45 | "ch a new online course - Google Cast and Android TV Development. This course ",
46 | "teaches you how to extend your existing Android app to work with these technologies. It’s packed with practical advice,",
47 | " code snippets, and deep dives into sample code." ,
48 | "You can take advantage of ",
49 | "both, without",
50 | " having to rewrite your app.",
51 | " Android TV is just ",
52 | "Android on a new form factor, and the Leanback library makes it easy to add a big screen ",
53 | "and cinematic UI to your app. Google Cast comes with great samples and guides to help you get started. Google also provides the Cast Companion Library",
54 | " which makes it faster and easier to add cast to your Android app.",
55 | });
56 | mRecyclerView.setAdapter(mAdapter);
57 | }
58 | }
59 |
60 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/pullswitcherview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: 'com.jfrog.bintray'
4 |
5 | version = "1.0.6"
6 |
7 | android {
8 | compileSdkVersion 23
9 | buildToolsVersion "23.0.1"
10 |
11 | defaultConfig {
12 | minSdkVersion 15
13 | targetSdkVersion 23
14 | versionCode 1
15 | versionName "1.0"
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | testCompile 'junit:junit:4.12'
28 | compile 'com.android.support:appcompat-v7:23.1.0'
29 | }
30 |
31 | def siteUrl = 'https://github.com/loopeer/PullSwitcher' // 项目的主页
32 | def gitUrl = 'https://github.com/loopeer/PullSwitcher.git' // Git仓库的url
33 | group = "com.loopeer.library"
34 | install {
35 | repositories.mavenInstaller {
36 | // This generates POM.xml with proper parameters
37 | pom {
38 | project {
39 | packaging 'aar'
40 | // Add your description here
41 | name 'Pull switcher help to switch fragment easier ' //项目描述
42 | url siteUrl
43 | // Set your license
44 | licenses {
45 | license {
46 | name 'The Apache Software License, Version 2.0'
47 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
48 | }
49 | }
50 | developers {
51 | developer {
52 | id 'ToDou' //填写开发者基本信息
53 | name 'ToDou'
54 | email 'yytodou123@gmail.com'
55 | }
56 | }
57 | scm {
58 | connection gitUrl
59 | developerConnection gitUrl
60 | url siteUrl
61 | }
62 | }
63 | }
64 | }
65 | }
66 | task sourcesJar(type: Jar) {
67 | from android.sourceSets.main.java.srcDirs
68 | classifier = 'sources'
69 | }
70 | task javadoc(type: Javadoc) {
71 | source = android.sourceSets.main.java.srcDirs
72 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
73 | }
74 | task javadocJar(type: Jar, dependsOn: javadoc) {
75 | classifier = 'javadoc'
76 | from javadoc.destinationDir
77 | }
78 | artifacts {
79 | archives javadocJar
80 | archives sourcesJar
81 | }
82 | Properties properties = new Properties()
83 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
84 | bintray {
85 | user = properties.getProperty("bintray.user")
86 | key = properties.getProperty("bintray.apikey")
87 | configurations = ['archives']
88 | pkg {
89 | repo = "maven" //发布到Bintray的那个仓库里,默认账户有四个库,我们这里上传到maven库
90 | name = "pullswitcherview" //发布到Bintray上的项目名字
91 | websiteUrl = siteUrl
92 | vcsUrl = gitUrl
93 | licenses = ["Apache-2.0"]
94 | publish = true
95 | }
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/app/src/main/java/com/loopeer/android/librarys/pullswitcher/TestFragment1Recycler.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys.pullswitcher;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Toast;
12 |
13 | import com.loopeer.android.librarys.PullSwitchView;
14 | import com.loopeer.android.librarys.SwitchListener;
15 | import com.loopeer.android.librarys.SwitcherHolder;
16 |
17 | public class TestFragment1Recycler extends Fragment implements SwitchListener {
18 |
19 | private SwitcherHolder switcherHolder;
20 | private PullSwitchView pullSwitchView;
21 |
22 | private RecyclerView mRecyclerView;
23 | private RecyclerView.Adapter mAdapter;
24 | private RecyclerView.LayoutManager mLayoutManager;
25 |
26 | public static TestFragment1Recycler newInstance(SwitcherHolder switcherHolder) {
27 | TestFragment1Recycler testFragment = new TestFragment1Recycler();
28 | testFragment.switcherHolder = switcherHolder;
29 | return testFragment;
30 | }
31 |
32 | @Nullable
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
35 | return inflater.inflate(R.layout.fragment_fragment1, container, false);
36 | }
37 |
38 | @Override
39 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
40 | super.onViewCreated(view, savedInstanceState);
41 |
42 | initSwitchView(view);
43 | initTestRecyclerView(view);
44 | }
45 |
46 | private void initSwitchView(View view) {
47 | pullSwitchView = (PullSwitchView) view.findViewById(R.id.switcher);
48 | pullSwitchView.setSwitcherHolder(switcherHolder);
49 | pullSwitchView.setFooterView(new TestCustomFooterView(getActivity()));
50 | }
51 |
52 | private void initTestRecyclerView(View view) {
53 | mRecyclerView = (RecyclerView) view.findViewById(R.id.my_recycler_view);
54 | mRecyclerView.setHasFixedSize(true);
55 | mLayoutManager = new LinearLayoutManager(getContext());
56 | mRecyclerView.setLayoutManager(mLayoutManager);
57 | mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext()));
58 |
59 | mAdapter = new TestRecyclerAdapter(new String[]{
60 | "We've partnered with Udacity to laun",
61 | "ch a new online course - Google Cast and Android TV Development. This course ",
62 | "teaches you how to extend your existing Android app to work with these technologies. It’s packed with practical advice,",
63 | " code snippets, and deep dives into sample code." ,
64 | "You can take advantage of ",
65 | "both, without",
66 | " having to rewrite your app.",
67 | " Android TV is just ",
68 | "Android on a new form factor, and the Leanback library makes it easy to add a big screen ",
69 | "and cinematic UI to your app. Google Cast comes with great samples and guides to help you get started. Google also provides the Cast Companion Library",
70 | " which makes it faster and easier to add cast to your Android app.",
71 | });
72 | mRecyclerView.setAdapter(mAdapter);
73 | }
74 |
75 | @Override
76 | public void onPagePause() {
77 | Toast.makeText(getActivity(), "test recycler pause", Toast.LENGTH_SHORT).show();
78 | }
79 |
80 | @Override
81 | public void onPageResume() {
82 | Toast.makeText(getActivity(), "test recycler resume", Toast.LENGTH_SHORT).show();
83 | }
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/SwitchFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentTransaction;
6 | import android.view.ViewGroup;
7 |
8 | public abstract class SwitchFragmentAdapter extends SwitcherAdapter {
9 | private static final String TAG = "FragmentPagerAdapter";
10 |
11 | private final FragmentManager mFragmentManager;
12 |
13 | public SwitchFragmentAdapter(FragmentManager fm) {
14 | mFragmentManager = fm;
15 | }
16 |
17 | /**
18 | * Return the Fragment associated with a specified position.
19 | */
20 | public abstract Fragment getItem(int position);
21 |
22 | @Override
23 | public void replaceItem(ViewGroup container, int prePosition, int newPosition) {
24 | FragmentTransaction mCurTransaction = mFragmentManager.beginTransaction();
25 |
26 | if (prePosition == newPosition) {
27 | Fragment fragment = createFragment(container, newPosition);
28 | mCurTransaction.add(container.getId(), fragment, makeFragmentName(container.getId(), newPosition)).commit(); // 隐藏当前的fragment,add下一个到Activity中
29 | return;
30 | }
31 | Fragment preFragment = createFragment(container, prePosition);
32 | Fragment newFragment = createFragment(container, newPosition);
33 | switchContent(container, preFragment, newFragment, prePosition, newPosition);
34 | }
35 |
36 | private Fragment createFragment(ViewGroup container, int newPosition) {
37 | Fragment fragment = retrieveFromCache(container, newPosition);
38 | if (null == fragment) {
39 | try {
40 | return getItem(newPosition);
41 | } catch (Exception e) {
42 | return null;
43 | }
44 | }
45 | return fragment;
46 | }
47 |
48 | public void switchContent(ViewGroup content, Fragment from, Fragment to, int prePosition, int newPosition) {
49 | FragmentTransaction transaction = mFragmentManager.beginTransaction();
50 | if (newPosition >= prePosition) {
51 | transaction.setCustomAnimations(R.anim.in_from_bottom, R.anim.out_to_top,
52 | R.anim.in_from_top, R.anim.out_to_bottom);
53 | } else {
54 | transaction.setCustomAnimations(R.anim.in_from_top, R.anim.out_to_bottom,
55 | R.anim.in_from_top, R.anim.out_to_bottom);
56 | }
57 | if (!to.isAdded()) {
58 | transaction.hide(from).add(content.getId(), to, makeFragmentName(content.getId(), newPosition)).commit();
59 | } else {
60 | transaction.hide(from).show(to).commit();
61 | }
62 | checkAndDispatchSwitchListener(from, to);
63 |
64 | }
65 |
66 | private void checkAndDispatchSwitchListener(Fragment from, Fragment to) {
67 | if (from instanceof SwitchListener) {
68 | ((SwitchListener) from).onPagePause();
69 | }
70 |
71 | if (to instanceof SwitchListener) {
72 | ((SwitchListener) to).onPageResume();
73 | }
74 | }
75 |
76 | private Fragment retrieveFromCache(ViewGroup view, int menuItem) {
77 | if (mFragmentManager.getFragments() == null) return null;
78 | for (Fragment backFragment : mFragmentManager.getFragments()) {
79 | String name = makeFragmentName(view.getId(), menuItem);
80 | if (null != backFragment
81 | && name.equals(backFragment.getTag())) {
82 | return backFragment;
83 | }
84 | }
85 | return null;
86 | }
87 |
88 | public long getItemId(int position) {
89 | return position;
90 | }
91 |
92 | private static String makeFragmentName(int viewId, int id) {
93 | return "android:switcher:" + viewId + ":" + id;
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/pullswitcherview/src/main/java/com/loopeer/android/librarys/PullIndicator.java:
--------------------------------------------------------------------------------
1 | package com.loopeer.android.librarys;
2 |
3 | import android.graphics.PointF;
4 |
5 | public class PullIndicator {
6 | public final static String TAG = "PullIndicator";
7 |
8 | public final static int POS_START = 0;
9 | private boolean mIsUnderTouch = false;
10 | private PointF mPtLastMove = new PointF();
11 | private float mOffsetX;
12 | private float mOffsetY;
13 | private int mCurrentPosY = 0;
14 | private int mLastPos = 0;
15 | private int mHeaderHeight;
16 | private int mFooterHeight;
17 | private int mStartSwitchOffset = 200;
18 | private Header mHeaderImpl;
19 | private Footer mFooterImpl;
20 | private ShowText mShowText;
21 | private SwitcherHolder mSwitchHolderImpl;
22 |
23 | public int getContentHeight() {
24 | return mContentHeight;
25 | }
26 |
27 | public void setContentHeight(int contentHeight) {
28 | this.mContentHeight = contentHeight;
29 | }
30 |
31 | private int mContentHeight;
32 | private int mPressedPos = 0;
33 | private float mResistance = 1.7f;
34 |
35 | public int getHeaderHeight() {
36 | return mHeaderHeight;
37 | }
38 |
39 | public void setHeaderHeight(int headerHeight) {
40 | this.mHeaderHeight = headerHeight;
41 | }
42 |
43 | public int getFooterHeight() {
44 | return mFooterHeight;
45 | }
46 |
47 | public void setFooterHeight(int footerHeight) {
48 | this.mFooterHeight = footerHeight;
49 | }
50 |
51 | public int getCurrentPosY() {
52 | return mCurrentPosY;
53 | }
54 |
55 | public void onRelease() {
56 | mIsUnderTouch = false;
57 | }
58 |
59 | public void onPressDown(float x, float y) {
60 | mIsUnderTouch = true;
61 | mPressedPos = mCurrentPosY;
62 | mPtLastMove.set(x, y);
63 | }
64 |
65 | public final void onMove(float x, float y) {
66 | float offsetX = x - mPtLastMove.x;
67 | float offsetY = (y - mPtLastMove.y);
68 | processOnMove(x, y, offsetX, offsetY);
69 | mPtLastMove.set(x, y);
70 | }
71 |
72 | protected void processOnMove(float currentX, float currentY, float offsetX, float offsetY) {
73 | setOffset(offsetX, offsetY / mResistance);
74 | }
75 |
76 | protected void setOffset(float x, float y) {
77 | mOffsetX = x;
78 | mOffsetY = y;
79 | }
80 |
81 | public final void setCurrentPos(int current) {
82 | mLastPos = mCurrentPosY;
83 | mCurrentPosY = current;
84 | }
85 |
86 | public boolean hasMovedAfterPressedDown() {
87 | return mCurrentPosY != mPressedPos;
88 | }
89 |
90 | public boolean hasLeftStartPosition() {
91 | return mCurrentPosY != POS_START;
92 | }
93 |
94 | public boolean hasOverStartPosition() {
95 | return mCurrentPosY <= POS_START;
96 | }
97 |
98 | public boolean hasBelowStartPosition() {
99 | return mCurrentPosY >= POS_START;
100 | }
101 |
102 | public int getLastPosY() {
103 | return mLastPos;
104 | }
105 |
106 | public boolean isInStartPosition() {
107 | return mCurrentPosY == POS_START;
108 | }
109 |
110 | public boolean willOverTop(int to) {
111 | return to < POS_START;
112 | }
113 |
114 | public float getOffsetX() {
115 | return mOffsetX;
116 | }
117 |
118 | public float getOffsetY() {
119 | return mOffsetY;
120 | }
121 |
122 | public float getResistance() {
123 | return mResistance;
124 | }
125 |
126 | public void setResistance(float resistance) {
127 | mResistance = resistance;
128 | }
129 |
130 | public boolean isUnderTouch() {
131 | return mIsUnderTouch;
132 | }
133 |
134 | public boolean isAlreadyHere(int to) {
135 | return mCurrentPosY == to;
136 | }
137 |
138 | public int getStartSwitchOffset() {
139 | return mStartSwitchOffset;
140 | }
141 |
142 | public void setStartSwitchOffset(int startSwitchOffset) {
143 | this.mStartSwitchOffset = startSwitchOffset;
144 | }
145 |
146 | public void applyMoveStatus() {
147 | if (isInStartPosition()) return;
148 | if (getCurrentPosY() > getStartSwitchOffset()) {
149 | mHeaderImpl.onCanStartSwitch(getCurrentPosY(), getStartSwitchOffset(), mShowText.headerSwitchTiptext);
150 | } else if (getCurrentPosY() > 0){
151 | mHeaderImpl.onMoveStart(getCurrentPosY(), getStartSwitchOffset(), mShowText.headerStarttext);
152 | } else if (getCurrentPosY() < - getStartSwitchOffset()){
153 | mFooterImpl.onCanStartSwitch(getCurrentPosY(), getStartSwitchOffset(), mShowText.footerSwitchTiptext);
154 | } else if (getCurrentPosY() < 0){
155 | mFooterImpl.onMoveStart(getCurrentPosY(), getStartSwitchOffset(), mShowText.footerStarttext);
156 | }
157 | }
158 |
159 | public boolean hasArrivedTheSwitchOffset() {
160 | return Math.abs(getCurrentPosY()) >= getStartSwitchOffset();
161 | }
162 |
163 | public Footer getFooterImpl() {
164 | return mFooterImpl;
165 | }
166 |
167 | public void setFooterImpl(Footer footerImpl) {
168 | this.mFooterImpl = footerImpl;
169 | }
170 |
171 | public Header getHeaderImpl() {
172 | return mHeaderImpl;
173 | }
174 |
175 | public void setHeaderImpl(Header headerImpl) {
176 | this.mHeaderImpl = headerImpl;
177 | }
178 |
179 | public void setShowText(ShowText showText) {
180 | mShowText = showText;
181 | }
182 |
183 | public void setSwitchHolderImpl(SwitcherHolder switchHolderImpl) {
184 | mSwitchHolderImpl = switchHolderImpl;
185 | }
186 |
187 | public static class ShowText {
188 | String headerStarttext;
189 | String headerSwitchTiptext;
190 | String footerStarttext;
191 | String footerSwitchTiptext;
192 |
193 | public ShowText(String headerStarttext, String headerSwitchTiptext,
194 | String footerStarttext, String footerSwitchTiptext) {
195 | this.headerStarttext = headerStarttext;
196 | this.headerSwitchTiptext = headerSwitchTiptext;
197 | this.footerStarttext = footerStarttext;
198 | this.footerSwitchTiptext = footerSwitchTiptext;
199 | }
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PullSwitcher
2 |
3 | This library is learn from [liaohuqiu/android-Ultra-Pull-To-Refresh](https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh) and learn the
4 | pull to next layout effect from [zzz40500/Android-PullToNextLayout](https://github.com/zzz40500/Android-PullToNextLayout), this fragments adapter make the fragment hide or show in the activity. So, you can keep data in those.
5 |
6 | The child of the pushswitcherview in the fragment must be **NestedScrollingChild**, such as a RecyclerView, NestedScrollView and viewpager wrap pre-view
7 |
8 | Screeshot
9 | ====
10 | 
11 |
12 | Installation
13 | ====
14 | ```groovy
15 | dependencies {
16 | compile 'com.loopeer.library:pullswitcherview:1.0.6'
17 | }
18 | ```
19 |
20 | Usage
21 | ====
22 | ###1. Add adapter and holder in activity
23 |
24 | ```java
25 | private SwitcherAdapter adapter;
26 | private SwitcherHolder mSwitchHolder;
27 |
28 | ...{
29 | mSwitchHolder = new SwitcherHolder(containerLayout);
30 | adapter = new TestSwitcherAdapter(getSupportFragmentManager());
31 | mSwitchHolder.setAdapter(adapter);
32 | }
33 |
34 | ```
35 | Then, create your custom switcher adapter.
36 | ```java
37 | public class TestSwitcherAdapter extends SwitchFragmentAdapter {
38 |
39 | public TestSwitcherAdapter(FragmentManager fm) {
40 | super(fm);
41 | }
42 |
43 | @Override
44 | public Fragment getItem(int position) {
45 | Fragment fragment;
46 | switch (position) {
47 | case 0:
48 | fragment = TestFragment1Recycler.newInstance(getSwitcherHolder());
49 | break;
50 | case 1:
51 | fragment = TestFragment2Scroll.newInstance(getSwitcherHolder());
52 | break;
53 | case 2:
54 | fragment = TestFragment3ViewPager.newInstance(getSwitcherHolder());
55 | break;
56 | default:
57 | fragment = null;
58 | }
59 | return fragment;
60 | }
61 |
62 | @Override
63 | public int getCount() {
64 | return 3;
65 | }
66 | }
67 | ```
68 | ###2. Create cutom fragment
69 |
70 | You can create the single fragment or view by the **PullSwitchView**, add the layout. set the **PullSwitchView** as your layou which layout you want to move. PullSwitchView can host only one direct child. And the footer and header must implements FooterImpl or HeaderImpl. The pullSwitchView will add header and footer for you by default. But you can set your custom view which must implements the Impl.
71 | ```xml
72 |
73 |
78 |
79 |
84 |
85 |
90 |
91 |
92 |
93 |
94 | ```
95 | init your pullswitchview
96 | ```java
97 | private void initSwitchView(View view) {
98 | pullSwitchView = (PullSwitchView) view.findViewById(R.id.switcher);
99 | pullSwitchView.setSwitcherHolder(switcherHolder);
100 | }
101 | ```
102 |
103 | If you want go back by press the back key, you should add this in activity:
104 | ```java
105 | @Override
106 | public void onBackPressed() {
107 | mSwitchHolder.doBack();
108 | }
109 | ```
110 |
111 | ####You can add switcher listener
112 | ```java
113 |
114 | public class TestFragment1Recycler extends Fragment implements PullHandler, SwitchListener {
115 | ...
116 |
117 | @Override
118 | public void onPagePause() {
119 | Toast.makeText(getActivity(), "test recycler pause", Toast.LENGTH_SHORT).show();
120 | }
121 |
122 | @Override
123 | public void onPageResume() {
124 | Toast.makeText(getActivity(), "test recycler resume", Toast.LENGTH_SHORT).show();
125 | }
126 | }
127 | ```
128 |
129 | ####You can add your custom footer and header view
130 | create your custom view and implements the footer
131 | ```java
132 | pullSwitchView.setFooterView(new TestCustomFooterView(getActivity()));
133 |
134 | ```
135 | and the custom footer can set your pull tips
136 | ```java
137 | public class TestCustomFooterView extends TextView implements Footer{
138 |
139 | public TestCustomFooterView(Context context) {
140 | this(context, null);
141 | }
142 |
143 | public TestCustomFooterView(Context context, AttributeSet attrs) {
144 | this(context, attrs, 0);
145 | }
146 |
147 | public TestCustomFooterView(Context context, AttributeSet attrs, int defStyleAttr) {
148 | super(context, attrs, defStyleAttr);
149 | setPadding(20, 20, 20, 20);
150 | setGravity(Gravity.CENTER);
151 | }
152 |
153 | @Override
154 | public void onMoveStart(int currentPosY, int startSwitchOffset, CharSequence string) {
155 | setText("Test custom footer text onMoveStart");
156 | }
157 |
158 | @Override
159 | public void onCanStartSwitch(int currentPosY, int startSwitchOffset, CharSequence string) {
160 | setText("Test custom footer text onCanStartSwitch");
161 |
162 | }
163 | }
164 | ```
165 |
166 | License
167 | ====
168 |
169 | Copyright 2015 Loopeer
170 |
171 | Licensed under the Apache License, Version 2.0 (the "License");
172 | you may not use this file except in compliance with the License.
173 | You may obtain a copy of the License at
174 |
175 | http://www.apache.org/licenses/LICENSE-2.0
176 |
177 | Unless required by applicable law or agreed to in writing, software
178 | distributed under the License is distributed on an "AS IS" BASIS,
179 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
180 | See the License for the specific language governing permissions and
181 | limitations under the License.
182 |