├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── caik.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── kcode
│ │ └── autoviewpager
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── image
│ │ │ ├── 1.jpg
│ │ │ ├── 2.jpg
│ │ │ └── 3.jpg
│ ├── java
│ │ └── com
│ │ │ └── kcode
│ │ │ └── autoviewpager
│ │ │ ├── App.java
│ │ │ ├── MainActivity.java
│ │ │ └── bean
│ │ │ └── Picture.java
│ └── res
│ │ ├── drawable
│ │ ├── point_checked.xml
│ │ └── point_normal.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── imageview.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
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── kcode
│ └── autoviewpager
│ └── ExampleUnitTest.java
├── autoScrollViewPager
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── kcode
│ │ └── autoscrollviewpager
│ │ └── view
│ │ ├── AutoScrollViewPager.java
│ │ ├── AutoViewPager.java
│ │ └── BaseViewPagerAdapter.java
│ └── res
│ ├── drawable
│ ├── point_checked.xml
│ └── point_normal.xml
│ ├── layout
│ ├── imageview.xml
│ ├── point_center_text.xml
│ └── point_right_text.xml
│ └── values
│ ├── attr.xml
│ ├── colors.xml
│ └── strings.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/caik.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | 1.8
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 1.8
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## AutoViewPager
2 | 
3 |
4 | ## Download
5 |
6 | Gradle:
7 |
8 | in module's build.gradle,use:
9 |
10 | ```
11 | repositories {
12 | jcenter()
13 | maven { url "https://jitpack.io" }
14 | }
15 | ```
16 |
17 | replace:
18 |
19 | ```
20 | repositories {
21 | jcenter()
22 | }
23 | ```
24 |
25 | in app's build.gradle,add:
26 |
27 | ```
28 | compile 'com.github.fccaikai:AutoScrollViewPager:1.0.1'
29 | ```
30 |
31 | ## Usage
32 | * in layout
33 |
34 | ```
35 |
39 |
40 |
41 | ```
42 |
43 |
44 | * in activity:
45 |
46 | ```
47 |
48 | public class MainActivity extends AppCompatActivity {
49 |
50 | private AutoScrollViewPager mViewPager;
51 |
52 | private String[] paths = {"https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=c493b482b47eca800d053ee7a1229712/8cb1cb1349540923abd671df9658d109b2de49d7.jpg",
53 | "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=45fbfa5555da81cb51e684cd6267d0a4/2f738bd4b31c8701491ea047237f9e2f0608ffe3.jpg",
54 | "https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ae0e95c0fc1986185e47e8847aec2e69/0b46f21fbe096b63eb314ef108338744ebf8ac62.jpg",
55 | "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=1fad2b46952397ddc9799f046983b216/dc54564e9258d109c94bbb13d558ccbf6d814de2.jpg",
56 | "https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ff0999f6d4160924c325a51be406359b/86d6277f9e2f070861ccd4a0ed24b899a801f241.jpg"};
57 |
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.activity_main);
62 |
63 | mViewPager = (AutoScrollViewPager) findViewById(R.id.viewPager);
64 |
65 | BaseViewPagerAdapter adapter = new BaseViewPagerAdapter(this,listener) {
66 | @Override
67 | public void loadImage(ImageView view, int position, String url) {
68 | Picasso.with(MainActivity.this).load(url).into(view);
69 | }
70 |
71 | @Override
72 | public void setSubTitle(TextView textView, int position, String s) {
73 | textView.setText(s);
74 | }
75 | };
76 | mViewPager.setAdapter(adapter);
77 |
78 | adapter.add(initData());
79 |
80 |
81 | }
82 |
83 | private List initData() {
84 | List data = new ArrayList<>();
85 | Picture picture ;
86 | for (int i = 0 ; i < paths.length ;i++){
87 | data.add(paths[i]);
88 | }
89 | return data;
90 | }
91 |
92 | @Override
93 | protected void onDestroy() {
94 | super.onDestroy();
95 | mViewPager.onDestroy();
96 | }
97 |
98 | private BaseViewPagerAdapter.OnAutoViewPagerItemClickListener listener = new BaseViewPagerAdapter.OnAutoViewPagerItemClickListener() {
99 |
100 | @Override
101 | public void onItemClick(int position, String url) {
102 | Toast.makeText(getApplicationContext(),
103 | url, Toast.LENGTH_SHORT).show();
104 | }
105 | };
106 | }
107 | ```
108 |
109 | Override```public void loadImage(ImageView view, int position, String url)``` to load image to ImageView.
110 |
111 | Override```public void setSubTitle(TextView textView, int position, String s)``` to set text to subTitle.
112 |
113 |
114 | * OnClick
115 |
116 |
117 | ```
118 | private BaseViewPagerAdapter.OnAutoViewPagerItemClickListener listener = new BaseViewPagerAdapter.OnAutoViewPagerItemClickListener() {
119 |
120 | @Override
121 | public void onItemClick(int position, String url) {
122 | Toast.makeText(getApplicationContext(),
123 |
124 | url, Toast.LENGTH_SHORT).show();
125 | }
126 | };
127 | ```
128 |
129 | init OnClickListener
130 |
131 | ```
132 | public BaseViewPagerAdapter(Context context, List data,OnAutoViewPagerItemClickListener listener)
133 |
134 | ```
135 |
136 | * PointLayout
137 | add ```xmlns:app="http://schemas.android.com/apk/res-auto"``` to layout file. And ,
138 | user ```app:point_layout="right|center"```.
139 |
140 | sample:[AutoViewPager](https://github.com/fccaikai/AutoScrollViewPager/tree/master/app)
141 |
142 |
143 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 | defaultConfig {
7 | applicationId "com.kcode.autoviewpager"
8 | minSdkVersion 14
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
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(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:24.2.0'
28 | testCompile 'junit:junit:4.12'
29 | // compile 'com.github.fccaikai:AutoScrollViewPager:0.8.0', {
30 | // exclude group: 'com.android.support', module: 'appcompat-v7'
31 | // }
32 | compile project(':autoScrollViewPager')
33 | compile 'com.squareup.picasso:picasso:2.3.2'
34 | }
35 |
--------------------------------------------------------------------------------
/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/caik/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/androidTest/java/com/kcode/autoviewpager/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoviewpager;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.kcode.autoviewpager", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/assets/image/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/assets/image/1.jpg
--------------------------------------------------------------------------------
/app/src/main/assets/image/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/assets/image/2.jpg
--------------------------------------------------------------------------------
/app/src/main/assets/image/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/assets/image/3.jpg
--------------------------------------------------------------------------------
/app/src/main/java/com/kcode/autoviewpager/App.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoviewpager;
2 |
3 | import android.app.Application;
4 | import android.os.StrictMode;
5 |
6 | /**
7 | * Created by caik on 2017/1/3.
8 | */
9 |
10 | public class App extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
16 | StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
17 |
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kcode/autoviewpager/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoviewpager;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | import com.kcode.autoscrollviewpager.view.AutoScrollViewPager;
11 | import com.kcode.autoscrollviewpager.view.BaseViewPagerAdapter;
12 | import com.kcode.autoviewpager.bean.Picture;
13 | import com.squareup.picasso.Picasso;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | public class MainActivity extends AppCompatActivity {
19 |
20 | private BaseViewPagerAdapter mBaseViewPagerAdapter;
21 |
22 | private AutoScrollViewPager mViewPager;
23 |
24 | private String[] paths = {"https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=c493b482b47eca800d053ee7a1229712/8cb1cb1349540923abd671df9658d109b2de49d7.jpg",
25 | "https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ff0999f6d4160924c325a51be406359b/86d6277f9e2f070861ccd4a0ed24b899a801f241.jpg"};
26 |
27 | // private String[] paths = {"https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=c493b482b47eca800d053ee7a1229712/8cb1cb1349540923abd671df9658d109b2de49d7.jpg",
28 | // "https://ss0.baidu.com/94o3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=45fbfa5555da81cb51e684cd6267d0a4/2f738bd4b31c8701491ea047237f9e2f0608ffe3.jpg",
29 | // "https://ss2.baidu.com/-vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ae0e95c0fc1986185e47e8847aec2e69/0b46f21fbe096b63eb314ef108338744ebf8ac62.jpg",
30 | // "https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=1fad2b46952397ddc9799f046983b216/dc54564e9258d109c94bbb13d558ccbf6d814de2.jpg",
31 | // "https://ss1.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/image/h%3D200/sign=ff0999f6d4160924c325a51be406359b/86d6277f9e2f070861ccd4a0ed24b899a801f241.jpg"};
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_main);
37 |
38 | mViewPager = (AutoScrollViewPager) findViewById(R.id.viewPager);
39 |
40 | mBaseViewPagerAdapter = new BaseViewPagerAdapter(this,listener) {
41 | @Override
42 | public void loadImage(ImageView view, int position, String url) {
43 | Picasso.with(MainActivity.this).load(url).into(view);
44 | }
45 |
46 | @Override
47 | public void setSubTitle(TextView textView, int position, String s) {
48 | textView.setText(s);
49 | }
50 | };
51 | mViewPager.setAdapter(mBaseViewPagerAdapter);
52 |
53 | mBaseViewPagerAdapter.add(initData());
54 |
55 |
56 | }
57 |
58 | private List initData() {
59 | List data = new ArrayList<>();
60 | Picture picture ;
61 | for (int i = 0 ; i < paths.length ;i++){
62 | data.add(paths[i]);
63 | }
64 | return data;
65 | }
66 |
67 | @Override
68 | protected void onDestroy() {
69 | super.onDestroy();
70 | mViewPager.onDestroy();
71 | }
72 |
73 | public void add(View view) {
74 | mBaseViewPagerAdapter.add("http://img3.imgtn.bdimg.com/it/u=214931719,1608091472&fm=21&gp=0.jpg");
75 | }
76 |
77 | private BaseViewPagerAdapter.OnAutoViewPagerItemClickListener listener = new BaseViewPagerAdapter.OnAutoViewPagerItemClickListener() {
78 |
79 | @Override
80 | public void onItemClick(int position, String url) {
81 | Toast.makeText(getApplicationContext(),
82 | position + " ========= "+ url, Toast.LENGTH_SHORT).show();
83 | }
84 | };
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/kcode/autoviewpager/bean/Picture.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoviewpager.bean;
2 |
3 | /**
4 | * Created by caik on 2016/10/19.
5 | */
6 |
7 | public class Picture {
8 | private String path;
9 | private String name;
10 |
11 | public Picture(String path, String name) {
12 | this.path = path;
13 | this.name = name;
14 | }
15 |
16 | public String getPath() {
17 | return path;
18 | }
19 |
20 | public void setPath(String path) {
21 | this.path = path;
22 | }
23 |
24 | public String getName() {
25 | return name;
26 | }
27 |
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/point_checked.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/point_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
18 |
19 |
20 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AutoViewPager
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/kcode/autoviewpager/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoviewpager;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/autoScrollViewPager/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/autoScrollViewPager/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.1"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 |
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 'com.android.support:appcompat-v7:24.2.0'
24 | }
--------------------------------------------------------------------------------
/autoScrollViewPager/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/caik/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 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoScrollViewPager.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoscrollviewpager.view;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.LinearLayout;
11 | import android.widget.RelativeLayout;
12 | import android.widget.TextView;
13 |
14 | import com.kcode.autoscrollviewpager.R;
15 |
16 | import static com.kcode.autoscrollviewpager.R.id.pointLayout;
17 |
18 | /**
19 | * Created by caik on 2016/10/17.
20 | */
21 |
22 | public class AutoScrollViewPager extends RelativeLayout {
23 |
24 | private final static String RIGHT_POINT = "right";
25 | private final static String CENTER_POINT = "center";
26 |
27 | private final static int RIGHT_INT = 0;
28 | private final static int CENTER_INT = 1;
29 |
30 | private AutoViewPager mViewPager;
31 |
32 | private Context mContext;
33 |
34 | private LinearLayout layout;
35 | private View view;//底部文字和小圆点
36 | private TextView mSubTitle;//标题文字
37 |
38 | public TextView getSubTitle() {
39 | return mSubTitle;
40 | }
41 |
42 | public AutoViewPager getViewPager() {
43 | return mViewPager;
44 | }
45 |
46 | public AutoScrollViewPager(Context context) {
47 | this(context,null);
48 | }
49 |
50 | public AutoScrollViewPager(Context context, AttributeSet attrs) {
51 | this(context,attrs,0);
52 | }
53 |
54 | public AutoScrollViewPager(Context context, AttributeSet attrs, int defStyleAttr) {
55 | super(context, attrs, defStyleAttr);
56 |
57 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AutoScrollViewPager, defStyleAttr, 0);
58 | String pointLayoutStr = typedArray.getString(R.styleable.AutoScrollViewPager_point_layout);
59 | switch (pointLayoutStr) {
60 | case RIGHT_POINT:
61 | view = LayoutInflater.from(context).inflate(R.layout.point_right_text,null);
62 | break;
63 | case CENTER_POINT:
64 | view = LayoutInflater.from(context).inflate(R.layout.point_center_text,null);
65 | break;
66 | default:
67 | view = LayoutInflater.from(context).inflate(R.layout.point_center_text,null);
68 | break;
69 | }
70 |
71 | typedArray.recycle();
72 |
73 | init(context);
74 |
75 | }
76 |
77 | private void init(Context context) {
78 | mContext = context;
79 | mViewPager = new AutoViewPager(context);
80 | addView(mViewPager);
81 |
82 | if (view != null) {
83 | mSubTitle = (TextView) view.findViewById(R.id.subTitle);
84 | layout = (LinearLayout) view.findViewById(pointLayout);
85 | LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
86 | params.addRule(ALIGN_PARENT_BOTTOM);
87 | view.setLayoutParams(params);
88 | addView(view);
89 | }
90 |
91 | }
92 |
93 | public void setAdapter(BaseViewPagerAdapter adapter) {
94 | if (mViewPager != null) {
95 | mViewPager.init(mViewPager, adapter);
96 | }
97 | }
98 |
99 | public void initPointView(int size) {
100 | initPointView(size,0);
101 | }
102 |
103 | public void initPointView(int size,int currentPoint) {
104 |
105 | layout.removeAllViews();
106 | for (int i = 0; i < size; i++) {
107 | ImageView imageView = new ImageView(mContext);
108 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20, 20);
109 | params.leftMargin = 8;
110 | imageView.setLayoutParams(params);
111 | if (i == currentPoint) {
112 | imageView.setBackgroundResource(R.drawable.point_checked);
113 | } else {
114 | imageView.setBackgroundResource(R.drawable.point_normal);
115 | }
116 |
117 | layout.addView(imageView);
118 | }
119 | }
120 |
121 |
122 | public void updatePointView(int position) {
123 | int size = layout.getChildCount();
124 | for (int i = 0; i < size; i++) {
125 | ImageView imageView = (ImageView) layout.getChildAt(i);
126 | if (i == position) {
127 | imageView.setBackgroundResource(R.drawable.point_checked);
128 | } else {
129 | imageView.setBackgroundResource(R.drawable.point_normal);
130 | }
131 |
132 | }
133 | }
134 |
135 | public void onDestroy() {
136 | if (mViewPager != null) {
137 | mViewPager.onDestroy();
138 | }
139 | }
140 |
141 | public void onResume(){
142 | if (mViewPager != null && !mViewPager.isStart()) {
143 | mViewPager.start();
144 | }
145 | }
146 |
147 | public void onPause(){
148 | if (mViewPager != null) {
149 | mViewPager.onStop();
150 | }
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/AutoViewPager.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoscrollviewpager.view;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.util.Log;
7 | import android.view.MotionEvent;
8 | import android.widget.TextView;
9 |
10 | import java.util.Timer;
11 | import java.util.TimerTask;
12 |
13 | /**
14 | * Created by caik on 2016/10/10.
15 | */
16 |
17 | public class AutoViewPager extends ViewPager {
18 |
19 | private static final String TAG = "AutoViewPager";
20 | private static final int TIME = 3000;
21 |
22 | private Timer mTimer;
23 | private AutoTask mTask;
24 | private boolean isStart;
25 | private int currentItem;
26 |
27 | public boolean isStart() {
28 | return isStart;
29 | }
30 |
31 | public AutoViewPager(Context context) {
32 | this(context,null);
33 | }
34 |
35 | public AutoViewPager(Context context, AttributeSet attrs) {
36 | super(context, attrs);
37 | }
38 |
39 | public void init(AutoViewPager viewPager,BaseViewPagerAdapter adapter){
40 | adapter.init(viewPager,adapter);
41 | }
42 |
43 | public void start(){
44 |
45 | if (((BaseViewPagerAdapter)getAdapter()).getRealCount() == 0) {
46 | return;
47 | }
48 | //先停止
49 | onStop();
50 | doStart();
51 |
52 | }
53 |
54 | private void doStart() {
55 | isStart = true;
56 | if (mTimer == null) {
57 | mTimer = new Timer();
58 | }
59 | mTimer.schedule(new AutoTask(),TIME,TIME);
60 | }
61 |
62 | private Runnable runnable = new Runnable() {
63 | @Override
64 | public void run() {
65 | changePageView();
66 | }
67 | };
68 |
69 | private void changePageView() {
70 | currentItem = getCurrentItem();
71 | if(currentItem == getAdapter().getCount() - 1){
72 | currentItem = 0 ;
73 | }else {
74 | currentItem++ ;
75 | }
76 | setCurrentItem(currentItem);
77 | //更新小圆点状态
78 | int nextItem = (currentItem % ((BaseViewPagerAdapter)getAdapter()).getRealCount());
79 | onPageSelected(nextItem);
80 | }
81 |
82 | private AutoHandler mHandler = new AutoHandler();
83 |
84 | public void updatePointView(int size) {
85 | updatePointView(size,0);
86 | }
87 |
88 | public void updatePointView(int size,int currentItem) {
89 | if (getParent() instanceof AutoScrollViewPager){
90 | AutoScrollViewPager pager = (AutoScrollViewPager) getParent();
91 | pager.initPointView(size,currentItem);
92 | }else {
93 | Log.e(TAG,"parent view not be AutoScrollViewPager");
94 | }
95 | }
96 |
97 | public void onPageSelected(int position) {
98 | if (getParent() == null) {
99 | return;
100 | }
101 |
102 | if (getParent() instanceof AutoScrollViewPager) {
103 | AutoScrollViewPager pager = (AutoScrollViewPager) getParent();
104 | pager.updatePointView(position);
105 | }
106 | }
107 |
108 | public void onStop(){
109 | isStart = false;
110 | //先取消定时器
111 | if (mTimer != null) {
112 | mTimer.cancel();
113 | mTimer = null;
114 | }
115 | }
116 |
117 | public void onDestroy(){
118 | onStop();
119 | }
120 |
121 | public void onResume(){
122 | start();
123 | }
124 |
125 | @Override
126 | public boolean onTouchEvent(MotionEvent ev) {
127 | switch (ev.getAction()){
128 | case MotionEvent.ACTION_UP:
129 | onResume();
130 | break;
131 | }
132 | return super.onTouchEvent(ev);
133 | }
134 |
135 | @Override
136 | public boolean onInterceptTouchEvent(MotionEvent ev) {
137 | switch (ev.getAction()){
138 | case MotionEvent.ACTION_DOWN:
139 | //onTouchEvent中无法拦截到ACTION_DOWN的动作
140 | onStop();
141 | break;
142 | }
143 | return super.onInterceptTouchEvent(ev);
144 | }
145 |
146 | public TextView getSubTitle() {
147 | if (getParent() instanceof AutoScrollViewPager){
148 | AutoScrollViewPager pager = (AutoScrollViewPager) getParent();
149 | return pager.getSubTitle();
150 | }
151 |
152 | return null;
153 | }
154 |
155 | private class AutoTask extends TimerTask{
156 | @Override
157 | public void run() {
158 | mHandler.post(runnable);
159 | }
160 | }
161 |
162 | private final static class AutoHandler extends android.os.Handler{}
163 |
164 | }
165 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/java/com/kcode/autoscrollviewpager/view/BaseViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.kcode.autoscrollviewpager.view;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.kcode.autoscrollviewpager.R;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 |
18 | /**
19 | * Created by caik on 2016/10/11.
20 | */
21 |
22 | public abstract class BaseViewPagerAdapter extends PagerAdapter implements ViewPager.OnPageChangeListener{
23 |
24 | private static final String TAG = "BaseViewPagerAdapter";
25 |
26 | private List data = new ArrayList<>();
27 |
28 | private Context mContext;
29 | private AutoViewPager mView;
30 |
31 | private OnAutoViewPagerItemClickListener listener;
32 |
33 | public BaseViewPagerAdapter(List t) {
34 | this.data = t;
35 | }
36 |
37 | public BaseViewPagerAdapter(Context context) {
38 | this.mContext = context;
39 | }
40 |
41 |
42 | public BaseViewPagerAdapter(Context context, OnAutoViewPagerItemClickListener listener) {
43 | this.mContext = context;
44 | this.listener = listener;
45 | }
46 |
47 | public BaseViewPagerAdapter(Context context, List data) {
48 | this.mContext = context;
49 | this.data = data;
50 | }
51 |
52 | public BaseViewPagerAdapter(Context context, List data,OnAutoViewPagerItemClickListener listener) {
53 | this.mContext = context;
54 | this.data = data;
55 | this.listener = listener;
56 | }
57 |
58 | public void init(AutoViewPager viewPager,BaseViewPagerAdapter adapter){
59 | mView = viewPager;
60 | mView.setAdapter(this);
61 | mView.addOnPageChangeListener(this);
62 |
63 | if (data == null || data.size() == 0){
64 | return;
65 | }
66 | //设置初始为中间,这样一开始就能够往左滑动了
67 | int position = Integer.MAX_VALUE/2 - (Integer.MAX_VALUE/2) % getRealCount();
68 | mView.setCurrentItem(position);
69 |
70 | if (!mView.isStart()) {
71 | mView.start();
72 | mView.updatePointView(getRealCount());
73 | }
74 |
75 | }
76 |
77 | public void setListener(OnAutoViewPagerItemClickListener listener) {
78 | this.listener = listener;
79 | }
80 |
81 | public void add(T t){
82 |
83 | if (mView.getAdapter() == null) {
84 | throw new RuntimeException("必须先设置Adapter");
85 | }
86 |
87 | if (data == null) {
88 | data = new ArrayList<>();
89 | }
90 | int currentItem = mView.getCurrentItem() % getRealCount();
91 | data.add(t);
92 | //先停止自动滚动
93 | mView.onStop();
94 | Log.d(TAG, "当前显示第" + currentItem + "/" + mView.getCurrentItem());
95 | // notifyDataSetChanged();
96 | mView.updatePointView(getRealCount(),currentItem);
97 | //重新开始自动滚动
98 | mView.onResume();
99 |
100 | }
101 |
102 | public void add(List list){
103 | if (data == null) {
104 | data = new ArrayList<>();
105 | }
106 |
107 | data.addAll(list);
108 |
109 | notifyDataSetChanged();
110 |
111 | mView.start();
112 | mView.updatePointView(getRealCount());
113 |
114 | }
115 |
116 | public void init(List list){
117 | if (data == null) {
118 | data = new ArrayList<>();
119 | }
120 |
121 | data.clear();
122 | data.addAll(list);
123 |
124 | notifyDataSetChanged();
125 |
126 | if (!mView.isStart()) {
127 | mView.start();
128 | mView.updatePointView(getRealCount());
129 | }
130 |
131 |
132 | }
133 |
134 | @Override
135 | public int getCount() {
136 | return (data == null || data.size() == 0 ) ? 0 : Integer.MAX_VALUE;
137 | }
138 |
139 | public int getRealCount(){
140 | return data == null ? 0 : data.size();
141 | }
142 |
143 | @Override
144 | public void destroyItem(ViewGroup container, int position, Object object) {
145 | ImageView view = (ImageView) object;
146 | container.removeView(view);
147 | view = null;
148 | }
149 |
150 | @Override
151 | public Object instantiateItem(ViewGroup container, final int position) {
152 | ImageView view = (ImageView) LayoutInflater.from(mContext)
153 | .inflate(R.layout.imageview,container,false);
154 | loadImage(view,position, data.get(position % getRealCount()));
155 | container.addView(view);
156 |
157 | //设置标题(不知道为什么标题跟图片对不上,所以做了如下处理,有大神看到帮忙看看。。。)
158 | if (mView.getSubTitle() != null){
159 | if (position == 0){
160 | setSubTitle(mView.getSubTitle(),position,data.get((getRealCount() - 1)));
161 | }else {
162 | setSubTitle(mView.getSubTitle(),position,data.get((position - 1) % getRealCount()));
163 | }
164 |
165 | }
166 |
167 | view.setOnClickListener(new View.OnClickListener() {
168 | @Override
169 | public void onClick(View view) {
170 |
171 | mView.onStop();
172 | if (listener != null) {
173 | listener.onItemClick(position % getRealCount(),data.get(position % getRealCount()));
174 | }
175 | mView.onResume();
176 | }
177 | });
178 |
179 | return view;
180 | }
181 |
182 | public abstract void loadImage(ImageView view,int position,T t);
183 | public abstract void setSubTitle(TextView textView,int position,T t);
184 |
185 | @Override
186 | public boolean isViewFromObject(View view, Object object) {
187 | return view == object;
188 | }
189 |
190 | @Override
191 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
192 |
193 | }
194 |
195 | @Override
196 | public void onPageSelected(int position) {
197 | // mView.onPageSelected(position % getRealCount());
198 | }
199 |
200 | @Override
201 | public void onPageScrollStateChanged(int state) {
202 |
203 | }
204 |
205 | public interface OnAutoViewPagerItemClickListener {
206 | void onItemClick(int position,T t);
207 | }
208 | }
209 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/drawable/point_checked.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/drawable/point_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/layout/imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/layout/point_center_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/layout/point_right_text.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
18 |
19 |
20 |
31 |
32 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/autoScrollViewPager/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AutoScrollViewPager
3 |
4 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.0'
9 | // NOTE: Do not place your application dependencies here; they belong
10 | // in the individual module build.gradle files
11 | }
12 |
13 |
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | maven { url "https://jitpack.io" }
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/caikaidev/AutoScrollViewPager/77457e7ddef6073ad47c12a62c016d80c550dd5d/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 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.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':autoScrollViewPager'
2 |
--------------------------------------------------------------------------------