├── simple
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── 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
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ └── layout
│ │ │ │ ├── activity_list_view.xml
│ │ │ │ ├── activity_custom_list_view.xml
│ │ │ │ ├── activity_grid_view.xml
│ │ │ │ ├── activity_single_view.xml
│ │ │ │ ├── custom_list_item.xml
│ │ │ │ └── activity_main.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── arthur
│ │ │ │ └── simple
│ │ │ │ ├── custom
│ │ │ │ ├── CustomImageInfo.java
│ │ │ │ ├── CustomListViewActivity.java
│ │ │ │ └── CustomListAdapter.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── GridViewActivity.java
│ │ │ │ ├── ListViewActivity.java
│ │ │ │ └── SingleViewActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── arthur
│ │ │ └── simple
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── arthur
│ │ └── simple
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── library
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── colors.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
│ │ │ ├── anim
│ │ │ │ ├── activity_in.xml
│ │ │ │ └── activity_out.xml
│ │ │ └── layout
│ │ │ │ ├── rollout_grid_view.xml
│ │ │ │ ├── activity_rollout_preview.xml
│ │ │ │ └── rollout_list_view.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── arthur
│ │ │ │ └── rollout
│ │ │ │ ├── model
│ │ │ │ ├── RolloutBDInfo.java
│ │ │ │ └── RolloutInfo.java
│ │ │ │ ├── tools
│ │ │ │ ├── RGlideUtil.java
│ │ │ │ └── RCommonUtil.java
│ │ │ │ ├── view
│ │ │ │ ├── RSquareLayout.java
│ │ │ │ └── RolloutViewPager.java
│ │ │ │ ├── adapter
│ │ │ │ ├── RListViewAdapter.java
│ │ │ │ └── RGridViewAdapter.java
│ │ │ │ └── activity
│ │ │ │ ├── RolloutPreviewActivity.java
│ │ │ │ └── RolloutBaseActivity.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── arthur
│ │ │ └── rollout
│ │ │ └── rolloutanimview
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── arthur
│ │ └── rollout
│ │ └── rolloutanimview
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gif
├── rollout_1.gif
├── rollout_7.gif
└── rollout_10.gif
├── .idea
├── copyright
│ └── profiles_settings.xml
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── compiler.xml
├── gradle.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
└── gradlew
/simple/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/library/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | library.iml
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':library', ':simple'
2 |
--------------------------------------------------------------------------------
/gif/rollout_1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/gif/rollout_1.gif
--------------------------------------------------------------------------------
/gif/rollout_7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/gif/rollout_7.gif
--------------------------------------------------------------------------------
/gif/rollout_10.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/gif/rollout_10.gif
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/library/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RolloutAnimView
3 |
4 |
--------------------------------------------------------------------------------
/simple/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/simple/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/simple/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/simple/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/library/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/library/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/library/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/simple/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/simple/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/simple/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/simple/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/library/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/library/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/simple/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Arthurshen98/RolloutAnimView/HEAD/simple/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.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/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/simple/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/simple/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/simple/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Simple
3 | 单张图片
4 | ListView
5 | GridView
6 | 自定义listView的形式
7 |
8 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 44dp
7 | 18dp
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #191919
7 | #00000000
8 |
9 |
--------------------------------------------------------------------------------
/library/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/simple/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/model/RolloutBDInfo.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by arthur on 2017/3/13.
7 | * 可以继承它
8 | */
9 |
10 | public class RolloutBDInfo implements Serializable {
11 | //坐标
12 | public float x;
13 | public float y;
14 | //在容器中显示的image的宽 高
15 | public float width;
16 | public float height;
17 | }
18 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/custom/CustomImageInfo.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple.custom;
2 |
3 | import com.arthur.rollout.model.RolloutInfo;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * Created by arthur on 2017/3/14.
9 | * 重写info保留RolloutInfo里面的属性
10 | */
11 |
12 | public class CustomImageInfo extends RolloutInfo implements Serializable {
13 |
14 | public int id;
15 | public String text;
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/simple/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/model/RolloutInfo.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.model;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * Created by arthur on 2017/3/13.
7 | * 可以继承它改变属性
8 | */
9 |
10 | public class RolloutInfo implements Serializable {
11 | /**
12 | * 图片路径
13 | */
14 | public String url;
15 | /**
16 | * 图片本身的宽 和 高,(清晰显示前的宽高),可以自己设定可以根据屏幕设定,可以根据图片大小设定
17 | */
18 | public float width;
19 | public float height;
20 | }
21 |
--------------------------------------------------------------------------------
/simple/src/test/java/com/arthur/simple/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
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 | }
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/library/src/test/java/com/arthur/rollout/rolloutanimview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.rolloutanimview;
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 | }
--------------------------------------------------------------------------------
/library/src/main/res/anim/activity_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
14 |
17 |
--------------------------------------------------------------------------------
/library/src/main/res/anim/activity_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
14 |
18 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/library/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 E:\android studio\sdk\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 |
--------------------------------------------------------------------------------
/simple/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 E:\android studio\sdk\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 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/activity_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/rollout_grid_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
12 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/activity_custom_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/activity_rollout_preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/rollout_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/activity_grid_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/tools/RGlideUtil.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.tools;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 |
8 | /**
9 | * Created by arthur on 2017/3/13.
10 | * glide 工具
11 | */
12 |
13 | public class RGlideUtil {
14 | /**
15 | * 加载图片
16 | *
17 | * @param context 上下文
18 | * @param url 路径
19 | * @param imageView view
20 | */
21 | public static void setImage(Context context, String url, ImageView imageView) {
22 | Glide.with(context).load(url).centerCrop().into(imageView);
23 | }
24 |
25 | /**
26 | * 清楚内存缓存,必须在UI线程调用
27 | */
28 | public static void clearMemory(Context context) {
29 | Glide.get(context).clearMemory();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/simple/src/androidTest/java/com/arthur/simple/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
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.arthur.simple", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | minSdkVersion 14
8 | targetSdkVersion 25
9 | versionCode 1
10 | versionName "1.0"
11 | multiDexEnabled true
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile fileTree(dir: 'libs', include: ['*.jar'])
23 | testCompile 'junit:junit:4.12'
24 | compile 'com.android.support:appcompat-v7:25.1.1'
25 | compile 'com.github.chrisbanes.photoview:library:1.2.3'
26 | compile 'com.facebook.rebound:rebound:0.3.8'
27 | compile 'com.github.bumptech.glide:glide:3.7.0'
28 | compile 'com.nineoldandroids:library:2.4.0'
29 | }
30 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/arthur/rollout/rolloutanimview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.rolloutanimview;
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.arthur.rollout.rolloutanimview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/simple/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/simple/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.arthur.simple"
9 | minSdkVersion 14
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
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 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | exclude group: 'com.android.support', module: 'support-annotations'
29 | })
30 | compile 'com.android.support:appcompat-v7:25.1.1'
31 | testCompile 'junit:junit:4.12'
32 | compile project(':library')
33 | }
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Android RolloutAnimview
2 | ==
3 | Introduction
4 | --
5 | 这是一个图片浏览工具,点击图片开始位置开始平移动画到center展示动画,可回弹效果,可左滑右滑,双击放大。
6 |
7 | Demonstration
8 | --
9 | 单张图片的效果
10 |
11 | 
12 |
13 | ListView显示图片的效果
14 |
15 | 
16 |
17 | GridView显示图片的效果
18 |
19 | 
20 |
21 | Usage
22 | --
23 | simple里面有实现的方式,传递数据到指定的Activity即可。可分为单张显示,Listview显示,GridView显示等。数据处理大同小异。
24 |
25 | 没有gradle引用方式,你可以把library下载下来自己去更改代码,更改自己喜欢的风格。
26 |
27 | library里面已经引用了这几个库,无需再次添加。
28 |
29 | * compile 'com.github.chrisbanes.photoview:library:1.2.3' 图片放大缩小
30 |
31 | * compile 'com.facebook.rebound:rebound:0.3.8' //facebook的弹性动画
32 |
33 | * compile 'com.github.bumptech.glide:glide:3.7.0' //图片加载工具
34 |
35 | 可以自己定义listview的adapter进行图片数据的计算。在custom文件夹下就是自己定义item去显示。
36 |
37 | 如果觉得我加入的图片可以的欢迎star ^ .^
38 |
39 | 项目仅仅用于练手,可以看看内部源码设计,不太完善,没有更新了
40 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/activity_single_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
17 |
18 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/custom_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
18 |
28 |
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/tools/RCommonUtil.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.tools;
2 |
3 | import android.content.Context;
4 | import android.util.DisplayMetrics;
5 |
6 | /**
7 | * Created by arthur on 2017/3/13.
8 | * arthurShen
9 | */
10 |
11 | public class RCommonUtil {
12 |
13 | public static int dip2px(Context context, float dpValue) {
14 | final float scale = context.getResources().getDisplayMetrics().density;
15 | return (int) (dpValue * scale + 0.5f);
16 | }
17 |
18 | /**
19 | * 根据手机的分辨率从 px(像素) 的单位 转成为 dp
20 | */
21 | public static int px2dip(Context context, float pxValue) {
22 | final float scale = context.getResources().getDisplayMetrics().density;
23 | return (int) (pxValue / scale + 0.5f);
24 | }
25 |
26 | /**
27 | * 获取屏幕高度
28 | *
29 | * @param context 环境
30 | * @return 高度
31 | */
32 | public static float getScreenHeight(Context context) {
33 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
34 | if (dm.heightPixels > 0) {
35 | return dm.heightPixels;
36 | }else {
37 | return px2dip(context, 1920);
38 | }
39 | }
40 |
41 | public static float getScreenWidth(Context context) {
42 | DisplayMetrics dm = context.getResources().getDisplayMetrics();
43 | if (dm.widthPixels > 0) {
44 | return dm.widthPixels;
45 | }else {
46 | return px2dip(context, 1080);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/view/RSquareLayout.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.view;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.RelativeLayout;
6 |
7 | /**
8 | * Created by DavidWang on 15/9/6.
9 | */
10 | public class RSquareLayout extends RelativeLayout {
11 |
12 | public RSquareLayout(Context context, AttributeSet attrs, int defStyle) {
13 | super(context, attrs, defStyle);
14 | }
15 |
16 | public RSquareLayout(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public RSquareLayout(Context context) {
21 | super(context);
22 | }
23 |
24 | @SuppressWarnings("unused")
25 | @Override
26 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
27 | // For simple implementation, or internal size is always 0.
28 | // We depend on the container to specify the layout size of
29 | // our view. We can't really know what it is since we will be
30 | // adding and removing different arbitrary views and do not
31 | // want the layout to change as this happens.
32 | setMeasuredDimension(getDefaultSize(0, widthMeasureSpec), getDefaultSize(0, heightMeasureSpec));
33 |
34 | // Children are just made to fill our space.
35 | int childWidthSize = getMeasuredWidth();
36 | int childHeightSize = getMeasuredHeight();
37 | //高度和宽度一样
38 | heightMeasureSpec = widthMeasureSpec = MeasureSpec.makeMeasureSpec(childWidthSize, MeasureSpec.EXACTLY);
39 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import com.arthur.simple.custom.CustomListViewActivity;
9 |
10 | /**
11 | * 站在牛人的肩膀上
12 | * library里面已经引用的包有:
13 | * compile 'com.android.support:appcompat-v7:25.1.1' //可以换成v4或降低版本,等等
14 | * compile 'com.github.chrisbanes.photoview:library:1.2.3' 图片放大缩小
15 | * compile 'com.facebook.rebound:rebound:0.3.8' //facebook的弹性动画
16 | * compile 'com.github.bumptech.glide:glide:3.7.0' //图片加载工具
17 | * compile 'com.nineoldandroids:library:2.4.0' //大神JakeWharton的动画库
18 | */
19 | public class MainActivity extends AppCompatActivity implements View.OnClickListener {
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_main);
25 |
26 | findViewById(R.id.single_view).setOnClickListener(this);
27 | findViewById(R.id.list_view).setOnClickListener(this);
28 | findViewById(R.id.grid_view).setOnClickListener(this);
29 | findViewById(R.id.custom_listview).setOnClickListener(this);
30 | }
31 |
32 | @Override
33 | public void onClick(View v) {
34 | switch (v.getId()) {
35 | case R.id.single_view:
36 | startActivity(new Intent(this,SingleViewActivity.class));
37 | break;
38 | case R.id.list_view:
39 | startActivity(new Intent(this,ListViewActivity.class));
40 | break;
41 | case R.id.grid_view:
42 | startActivity(new Intent(this,GridViewActivity.class));
43 | break;
44 | case R.id.custom_listview:
45 | startActivity(new Intent(this, CustomListViewActivity.class));
46 | break;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/simple/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
28 |
29 |
39 |
40 |
49 |
50 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/view/RolloutViewPager.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.view;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | /**
9 | * Found at http://stackoverflow.com/questions/7814017/is-it-possible-to-disable-scrolling-on-a-viewpager.
10 | * Convenient way to temporarily disable ViewPager navigation while interacting with ImageView.
11 | *
12 | * Julia Zudikova
13 | */
14 |
15 | /**
16 | * Hacky fix for Issue #4 and
17 | * http://code.google.com/p/android/issues/detail?id=18990
18 | *
19 | * ScaleGestureDetector seems to mess up the touch events, which means that
20 | * ViewGroups which make use of onInterceptTouchEvent throw a lot of
21 | * IllegalArgumentException: pointerIndex out of range.
22 | *
23 | * There's not much I can do in my code for now, but we can mask the result by
24 | * just catching the problem and ignoring it.
25 | *
26 | * @author Chris Banes
27 | */
28 | public class RolloutViewPager extends ViewPager {
29 |
30 | private boolean isLocked;
31 |
32 | public RolloutViewPager(Context context) {
33 | super(context);
34 | isLocked = false;
35 | }
36 |
37 | public RolloutViewPager(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 | isLocked = false;
40 | }
41 |
42 | @Override
43 | public boolean onInterceptTouchEvent(MotionEvent ev) {
44 | if (!isLocked) {
45 | try {
46 | return super.onInterceptTouchEvent(ev);
47 | } catch (IllegalArgumentException e) {
48 | e.printStackTrace();
49 | return false;
50 | }
51 | }
52 | return false;
53 | }
54 |
55 | @Override
56 | public boolean onTouchEvent(MotionEvent event) {
57 | if (!isLocked) {
58 | return super.onTouchEvent(event);
59 | }
60 | return false;
61 | }
62 |
63 | public void toggleLock() {
64 | isLocked = !isLocked;
65 | }
66 |
67 | public void setLocked(boolean isLocked) {
68 | this.isLocked = isLocked;
69 | }
70 |
71 | public boolean isLocked() {
72 | return isLocked;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/GridViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
2 |
3 | import android.os.Bundle;
4 | import android.widget.GridView;
5 | import android.widget.ListView;
6 |
7 | import com.arthur.rollout.activity.RolloutBaseActivity;
8 | import com.arthur.rollout.adapter.RGridViewAdapter;
9 | import com.arthur.rollout.adapter.RListViewAdapter;
10 | import com.arthur.rollout.model.RolloutInfo;
11 |
12 | import java.util.ArrayList;
13 |
14 | public class GridViewActivity extends RolloutBaseActivity {
15 |
16 | public GridView gridView;
17 | private RGridViewAdapter adapter;
18 | private ArrayList data;
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_grid_view);
23 |
24 | init();
25 | listener();
26 | handler();
27 | }
28 |
29 | private void init() {
30 | gridView = (GridView)findViewById(R.id.gridview);
31 | }
32 | private void listener() {
33 | }
34 |
35 | private void handler() {
36 | data = new ArrayList();
37 | for (int i = 0 ; i < 5; i++) {
38 | RolloutInfo model = new RolloutInfo();
39 | model.url = "http://img4q.duitang.com/uploads/item/201408/11/20140811141753_iNtAF.jpeg";
40 | model.width = 1280;
41 | model.height = 720;
42 | data.add(model);
43 | RolloutInfo model1 = new RolloutInfo();
44 | model1.url = "http://imgsrc.baidu.com/forum/pic/item/8b82b9014a90f603fa18d50f3912b31bb151edca.jpg";
45 | model1.width = 1280;
46 | model1.height = 720;
47 | data.add(model1);
48 | RolloutInfo model2 = new RolloutInfo();
49 | model2.url = "http://imgsrc.baidu.com/forum/pic/item/8e230cf3d7ca7bcb3acde5a2be096b63f724a8b2.jpg";
50 | model2.width = 1280;
51 | model2.height = 720;
52 | data.add(model2);
53 | RolloutInfo model3 = new RolloutInfo();
54 | model3.url = "http://att.bbs.duowan.com/forum/201210/20/210446opy9p5pghu015p9u.jpg";
55 | model3.width = 1280;
56 | model3.height = 720;
57 | data.add(model3);
58 | RolloutInfo model4 = new RolloutInfo();
59 | model4.url = "http://img5.duitang.com/uploads/item/201404/11/20140411214939_XswXa.jpeg";
60 | model4.width = 1280;
61 | model4.height = 720;
62 | data.add(model4);
63 | }
64 | //要把listview传入
65 | adapter = new RGridViewAdapter(this,gridView,data);
66 | gridView.setAdapter(adapter);
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/ListViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
2 |
3 | import android.os.Bundle;
4 | import android.widget.ImageView;
5 | import android.widget.ListView;
6 |
7 | import com.arthur.rollout.activity.RolloutBaseActivity;
8 | import com.arthur.rollout.adapter.RListViewAdapter;
9 | import com.arthur.rollout.model.RolloutBDInfo;
10 | import com.arthur.rollout.model.RolloutInfo;
11 | import com.arthur.rollout.tools.RGlideUtil;
12 |
13 | import java.util.ArrayList;
14 |
15 | /**
16 | * listView的实例代码
17 | */
18 | public class ListViewActivity extends RolloutBaseActivity {
19 |
20 | public ListView listView;
21 | //继承library里的adapter
22 | private RListViewAdapter adapter;
23 | //library里RolloutInfo
24 | private ArrayList data;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_list_view);
30 |
31 | init();
32 | listener();
33 | handler();
34 | }
35 |
36 | private void init() {
37 | listView = (ListView)findViewById(R.id.list_view);
38 | }
39 | private void listener() {
40 | }
41 |
42 | private void handler() {
43 | data = new ArrayList();
44 | for (int i = 0 ; i < 5; i++) {
45 | RolloutInfo model = new RolloutInfo();
46 | model.url = "https://a-ssl.duitang.com/uploads/item/201408/31/20140831220442_RAeKU.thumb.700_0.jpeg";
47 | model.width = 1280;
48 | model.height = 720;
49 | data.add(model);
50 | RolloutInfo model1 = new RolloutInfo();
51 | model1.url = "http://v1.qzone.cc/pic/201603/18/17/18/56ebc7eb74384954.jpeg!600x600.jpg";
52 | model1.width = 1280;
53 | model1.height = 720;
54 | data.add(model1);
55 | RolloutInfo model2 = new RolloutInfo();
56 | model2.url = "http://imgsrc.baidu.com/forum/pic/item/8e230cf3d7ca7bcb3acde5a2be096b63f724a8b2.jpg";
57 | model2.width = 1280;
58 | model2.height = 720;
59 | data.add(model2);
60 | RolloutInfo model3 = new RolloutInfo();
61 | model3.url = "http://pic0.mofang.com/2014/0626/20140626052559887.jpg";
62 | model3.width = 1280;
63 | model3.height = 720;
64 | data.add(model3);
65 | RolloutInfo model4 = new RolloutInfo();
66 | model4.url = "http://img5.duitang.com/uploads/item/201404/11/20140411214939_XswXa.jpeg";
67 | model4.width = 1280;
68 | model4.height = 720;
69 | data.add(model4);
70 | }
71 | //要把listview传入
72 | adapter = new RListViewAdapter(this,listView,data);
73 | listView.setAdapter(adapter);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/SingleViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.arthur.rollout.activity.RolloutBaseActivity;
10 | import com.arthur.rollout.activity.RolloutPreviewActivity;
11 | import com.arthur.rollout.model.RolloutBDInfo;
12 | import com.arthur.rollout.model.RolloutInfo;
13 | import com.arthur.rollout.tools.RGlideUtil;
14 |
15 | import java.io.Serializable;
16 | import java.util.ArrayList;
17 |
18 | /**
19 | * 1,要继承库里面的Activity(因为某些限制,库里面包含activity)
20 | * 2,传数据到指定的activity
21 | */
22 | public class SingleViewActivity extends RolloutBaseActivity implements View.OnClickListener {
23 |
24 | private ImageView show_img;
25 | private ArrayList data;
26 |
27 | @Override
28 | protected void onCreate(Bundle savedInstanceState) {
29 | super.onCreate(savedInstanceState);
30 | setContentView(R.layout.activity_single_view);
31 |
32 | init();
33 | listener();
34 | handler();
35 | }
36 |
37 | private void init() {
38 | show_img = (ImageView) findViewById(R.id.show_img);
39 |
40 | }
41 | private void listener() {
42 | show_img.setOnClickListener(this);
43 | }
44 |
45 | private void handler() {
46 | data = new ArrayList();
47 | bdInfo = new RolloutBDInfo();
48 | imageInfo = new RolloutInfo();
49 | //图片的宽高可以自己去设定,也可以计算图片宽高
50 | imageInfo.width = 1280;
51 | imageInfo.height = 720;
52 | imageInfo.url = "https://timgsa.baidu.com/timg?image&quality=80&size=b10000_10000&sec=1489482821&di=43da5087a3013c51d60e1f08d0af9a1e&src=http://imgsrc.baidu.com/forum/pic/item/f2a72fbd06bcb4b7a344df77.jpg";
53 | data.add(imageInfo);
54 | //显示图片
55 | RGlideUtil.setImage(this, imageInfo.url, show_img);
56 | }
57 |
58 | @Override
59 | public void onClick(View v) {
60 | switch (v.getId()){
61 | case R.id.show_img:
62 | //获取相对位置,左边和顶部
63 | bdInfo.x = show_img.getLeft();
64 | bdInfo.y = show_img.getTop();
65 | //视图布局的宽高
66 | bdInfo.width = show_img.getLayoutParams().width;
67 | bdInfo.height = show_img.getLayoutParams().height;
68 | //跳转和传数据都必须要
69 | Intent intent = new Intent(this, RolloutPreviewActivity.class);
70 | intent.putExtra("data", (Serializable) data);
71 | intent.putExtra("bdinfo",bdInfo);
72 | intent.putExtra("type", 0);//单图传0
73 | intent.putExtra("index",0);
74 | startActivity(intent);
75 | break;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/.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 | 1.8
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/custom/CustomListViewActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple.custom;
2 |
3 | import android.os.Bundle;
4 | import android.widget.ListView;
5 |
6 | import com.arthur.rollout.activity.RolloutBaseActivity;
7 | import com.arthur.simple.R;
8 |
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * 这个是可以自定义的adapter,item布局和info去实现的listView,
13 | * 备注:gridview里面与RGridViewAdapter类似,看了源码可以改造
14 | */
15 | public class CustomListViewActivity extends RolloutBaseActivity {
16 |
17 | public ListView listView;
18 | private ArrayList data;
19 | private CustomListAdapter adapter;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_custom_list_view);
25 |
26 | init();
27 | listener();
28 | handler();
29 | }
30 |
31 | private void init() {
32 | listView = (ListView)findViewById(R.id.custom_list);
33 | }
34 | private void listener() {
35 | }
36 |
37 | private void handler() {
38 | data = new ArrayList();
39 | for (int i = 0 ; i < 5; i++) {
40 | CustomImageInfo model = new CustomImageInfo();
41 | model.url = "http://v1.qzone.cc/pic/201603/18/17/18/56ebc7eb74384954.jpeg!600x600.jpg";
42 | model.width = 1280;
43 | model.height = 720;
44 | model.text = "杀生丸";
45 | data.add(model);
46 | CustomImageInfo model1 = new CustomImageInfo();
47 | model1.url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1490086858&di=f8938d348ad720fb839c39068f7a915b&imgtype=jpg&er=1&src=http%3A%2F%2Fwww.zgqydx.cn%2Ftupian%2Fbd64135.jpg.jpg";
48 | model1.width = 1280;
49 | model1.height = 720;
50 | model1.text = "汉库克";
51 | data.add(model1);
52 | CustomImageInfo model2 = new CustomImageInfo();
53 | model2.url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489492371312&di=ddd981235ef8a164dec438b3c1b7d86e&imgtype=0&src=http%3A%2F%2Fb.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Ff9198618367adab4f3ad7d5289d4b31c8701e4a6.jpg";
54 | model2.width = 1280;
55 | model2.height = 720;
56 | model2.text = "罗宾";
57 | data.add(model2);
58 | CustomImageInfo model3 = new CustomImageInfo();
59 | model3.url = "https://a-ssl.duitang.com/uploads/item/201408/31/20140831220442_RAeKU.thumb.700_0.jpeg";
60 | model3.width = 1280;
61 | model3.height = 720;
62 | model3.text = "娜美";
63 | data.add(model3);
64 | CustomImageInfo model4 = new CustomImageInfo();
65 | model4.url = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1489492189656&di=9e3ad450917dc9652951e3c9a16106c3&imgtype=0&src=http%3A%2F%2Fimg4q.duitang.com%2Fuploads%2Fitem%2F201502%2F20%2F20150220100612_Yy4cn.png";
66 | model4.width = 1280;
67 | model4.height = 720;
68 | model4.text = "索隆";
69 | data.add(model4);
70 | }
71 | //要把listview传入
72 | adapter = new CustomListAdapter(this,listView,data);
73 | listView.setAdapter(adapter);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/adapter/RListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.ListView;
10 |
11 |
12 | import com.arthur.rollout.activity.RolloutPreviewActivity;
13 | import com.arthur.rollout.model.RolloutBDInfo;
14 | import com.arthur.rollout.model.RolloutInfo;
15 | import com.arthur.rollout.rolloutanimview.R;
16 | import com.arthur.rollout.tools.RCommonUtil;
17 | import com.arthur.rollout.tools.RGlideUtil;
18 |
19 | import java.io.Serializable;
20 | import java.util.ArrayList;
21 |
22 |
23 | /**
24 | * arthur list 适配器
25 | */
26 | public class RListViewAdapter extends BaseAdapter {
27 |
28 | private Context context;
29 | private ArrayList data;
30 | private RolloutBDInfo bdInfo;
31 | private ListView mListView;
32 |
33 | public RListViewAdapter(Context context, ListView listView, ArrayList data) {
34 | this.context = context;
35 | this.data = data;
36 | this.mListView = listView;
37 | bdInfo = new RolloutBDInfo();
38 | }
39 |
40 | @Override
41 | public int getCount() {
42 | return data.size();
43 | }
44 |
45 | @Override
46 | public Object getItem(int position) {
47 | return data == null ? null : data.get(position);
48 | }
49 |
50 | @Override
51 | public long getItemId(int position) {
52 | return position;
53 | }
54 |
55 | @Override
56 | public View getView(int position, View convertView, ViewGroup arg2) {
57 | RolloutInfo info = data.get(position);
58 | ViewHolder holder = null;
59 | if (convertView == null) {
60 | holder = new ViewHolder();
61 | convertView = View.inflate(context, R.layout.rollout_list_view, null);
62 | holder.list_img = (ImageView) convertView.findViewById(R.id.list_img);
63 |
64 | convertView.setTag(holder);
65 | } else {
66 | holder = (ViewHolder) convertView.getTag();
67 | }
68 |
69 | RGlideUtil.setImage(context, info.url, holder.list_img);
70 | holder.list_img.setOnClickListener(new ImageOnclick(position, holder.list_img));
71 |
72 | return convertView;
73 | }
74 |
75 | public class ViewHolder {
76 | ImageView list_img;
77 | }
78 |
79 | private class ImageOnclick implements View.OnClickListener {
80 |
81 | private int index;
82 | private ImageView imageView;
83 |
84 | public ImageOnclick(int index, ImageView imageView) {
85 | this.index = index;
86 | this.imageView = imageView;
87 | }
88 |
89 | @Override
90 | public void onClick(View v) {
91 | View c = mListView.getChildAt(0);
92 | //相对于其父视图的顶部位置
93 | int top = c.getTop();
94 | //返回适配器的数据集中显示在屏幕上的第一个项目的位置。
95 | int firstVisiblePosition = mListView.getFirstVisiblePosition();
96 | //Left position of this view relative to its parent.
97 | bdInfo.x = imageView.getLeft();
98 | bdInfo.y = RCommonUtil.dip2px(context, 7) + (index - firstVisiblePosition) * RCommonUtil.dip2px(context, 70) + top + mListView.getTop();
99 |
100 | //关于imageView想要有多宽
101 | bdInfo.width = imageView.getLayoutParams().width;
102 | bdInfo.height = imageView.getLayoutParams().height;
103 |
104 | Intent intent = new Intent(context, RolloutPreviewActivity.class);
105 | intent.putExtra("data", (Serializable) data);
106 | intent.putExtra("bdinfo", bdInfo);
107 | intent.putExtra("index", index);
108 | intent.putExtra("type", 1);
109 | context.startActivity(intent);
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/adapter/RGridViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.GridView;
9 | import android.widget.ImageView;
10 |
11 | import com.arthur.rollout.activity.RolloutPreviewActivity;
12 | import com.arthur.rollout.model.RolloutBDInfo;
13 | import com.arthur.rollout.model.RolloutInfo;
14 | import com.arthur.rollout.rolloutanimview.R;
15 | import com.arthur.rollout.tools.RCommonUtil;
16 | import com.arthur.rollout.tools.RGlideUtil;
17 |
18 | import java.io.Serializable;
19 | import java.util.ArrayList;
20 |
21 |
22 | /**
23 | * arthur GridView 适配器
24 | */
25 | public class RGridViewAdapter extends BaseAdapter {
26 |
27 | private Context context;
28 | private ArrayList data;
29 | private RolloutBDInfo bdInfo;
30 | private GridView mGridView;
31 |
32 | public RGridViewAdapter(Context context, GridView gridView, ArrayList data) {
33 | this.context = context;
34 | this.data = data;
35 | this.mGridView = gridView;
36 | bdInfo = new RolloutBDInfo();
37 | }
38 |
39 | @Override
40 | public int getCount() {
41 | return data.size();
42 | }
43 |
44 | @Override
45 | public Object getItem(int position) {
46 | return data == null ? null : data.get(position);
47 | }
48 |
49 | @Override
50 | public long getItemId(int position) {
51 | return position;
52 | }
53 |
54 | @Override
55 | public View getView(int position, View convertView, ViewGroup arg2) {
56 | RolloutInfo info = data.get(position);
57 | ViewHolder holder = null;
58 | if (convertView == null) {
59 | holder = new ViewHolder();
60 | convertView = View.inflate(context,
61 | R.layout.rollout_grid_view, null);
62 | holder.gridimage = (ImageView) convertView.findViewById(R.id.grid_image);
63 |
64 | convertView.setTag(holder);
65 | } else {
66 | holder = (ViewHolder) convertView.getTag();
67 | }
68 |
69 |
70 | RGlideUtil.setImage(context, info.url, holder.gridimage);
71 | holder.gridimage.setOnClickListener(new ImageOnclick(position, holder.gridimage));
72 |
73 | return convertView;
74 | }
75 |
76 | public class ViewHolder {
77 | ImageView gridimage;
78 | }
79 |
80 | private class ImageOnclick implements View.OnClickListener {
81 |
82 | private int index;
83 | private ImageView imageView;
84 |
85 | public ImageOnclick(int index, ImageView imageView) {
86 | this.index = index;
87 | this.imageView = imageView;
88 | }
89 |
90 | @Override
91 | public void onClick(View v) {
92 |
93 | View c = mGridView.getChildAt(0);
94 | int top = c.getTop();
95 | int firstVisiblePosition = mGridView.getFirstVisiblePosition() / 3;
96 |
97 | int a, b;
98 | //模拟行列划分3等分进行计算
99 | a = index / 3;
100 | b = index % 3;
101 |
102 | bdInfo.width = (RCommonUtil.getScreenWidth(context) - 3 * RCommonUtil.dip2px(context, 2)) / 3;
103 | bdInfo.height = bdInfo.width;
104 | //把屏幕划分成了行和列,采用行列估算方法,进行计算位置
105 | bdInfo.x = RCommonUtil.dip2px(context, 1) + b * bdInfo.width + b * RCommonUtil.dip2px(context, 2);
106 | bdInfo.y = RCommonUtil.dip2px(context, 1) + bdInfo.height * (a - firstVisiblePosition) + top + (a - firstVisiblePosition) * RCommonUtil.dip2px(context, 2) + mGridView.getTop() - RCommonUtil.dip2px(context, 1);
107 |
108 | Intent intent = new Intent(context, RolloutPreviewActivity.class);
109 | intent.putExtra("data", (Serializable) data);
110 | intent.putExtra("bdinfo", bdInfo);
111 | intent.putExtra("index", index);
112 | intent.putExtra("type", 2);
113 | context.startActivity(intent);
114 | }
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/simple/src/main/java/com/arthur/simple/custom/CustomListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.arthur.simple.custom;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.ImageView;
9 | import android.widget.ListView;
10 | import android.widget.TextView;
11 |
12 | import com.arthur.rollout.activity.RolloutPreviewActivity;
13 | import com.arthur.rollout.model.RolloutBDInfo;
14 | import com.arthur.rollout.tools.RCommonUtil;
15 | import com.arthur.rollout.tools.RGlideUtil;
16 | import com.arthur.simple.R;
17 |
18 | import java.io.Serializable;
19 | import java.util.ArrayList;
20 |
21 | /**
22 | * Created by arthur on 2017/3/14.
23 | * 可自己根据需要定义的adapter
24 | */
25 |
26 | public class CustomListAdapter extends BaseAdapter {
27 |
28 | private Context context;
29 | private ArrayList data;
30 | //改属性基本不改,保留
31 | private RolloutBDInfo bdInfo;
32 | private ListView mListView;
33 |
34 | public CustomListAdapter(Context context, ListView listView, ArrayList data) {
35 | this.context = context;
36 | this.data = data;
37 | this.mListView = listView;
38 | bdInfo = new RolloutBDInfo();
39 | }
40 |
41 | @Override
42 | public int getCount() {
43 | return data.size();
44 | }
45 |
46 | @Override
47 | public Object getItem(int position) {
48 | return data == null ? null : data.get(position);
49 | }
50 |
51 | @Override
52 | public long getItemId(int position) {
53 | return position;
54 | }
55 |
56 | @Override
57 | public View getView(int position, View convertView, ViewGroup parent) {
58 | CustomImageInfo info = data.get(position);
59 | ViewHolder holder = null;
60 | if (convertView == null) {
61 | holder = new ViewHolder();
62 | convertView = View.inflate(context,R.layout.custom_list_item, null);
63 | holder.list_img = (ImageView) convertView.findViewById(R.id.custom_list_img);
64 | holder.text = (TextView) convertView.findViewById(R.id.custom_text);
65 | convertView.setTag(holder);
66 | } else {
67 | holder = (ViewHolder) convertView.getTag();
68 | }
69 |
70 | RGlideUtil.setImage(context, info.url, holder.list_img);
71 | holder.list_img.setOnClickListener(new ImageOnclick(position, holder.list_img));
72 | holder.text.setText(info.text);
73 |
74 | return convertView;
75 | }
76 |
77 | public class ViewHolder {
78 | ImageView list_img;
79 | TextView text;
80 | }
81 |
82 |
83 | //上面基本都一样的,重点就是这里面要传的东西
84 | private class ImageOnclick implements View.OnClickListener {
85 |
86 | private int index;
87 | private ImageView imageView;
88 |
89 | public ImageOnclick(int index, ImageView imageView) {
90 | this.index = index;
91 | this.imageView = imageView;
92 | }
93 |
94 | @Override
95 | public void onClick(View v) {
96 | View c = mListView.getChildAt(0);
97 | //相对于其父视图的顶部位置
98 | int top = c.getTop();
99 | //返回适配器的数据集中显示在屏幕上的第一个项目的位置。
100 | int firstVisiblePosition = mListView.getFirstVisiblePosition();
101 | //Left position of this view relative to its parent.
102 | bdInfo.x = imageView.getLeft();
103 | bdInfo.y = RCommonUtil.dip2px(context, 7) + (index - firstVisiblePosition) * RCommonUtil.dip2px(context, 70) + top + mListView.getTop();
104 |
105 | //关于imageView想要有多宽
106 | bdInfo.width = imageView.getLayoutParams().width;
107 | bdInfo.height = imageView.getLayoutParams().height;
108 |
109 | Intent intent = new Intent(context, RolloutPreviewActivity.class);
110 | intent.putExtra("data", (Serializable) data);
111 | intent.putExtra("bdinfo", bdInfo);
112 | intent.putExtra("index", index);
113 | intent.putExtra("type", 1);//list传1
114 | context.startActivity(intent);
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/activity/RolloutPreviewActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.activity;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.support.v4.view.ViewPager;
6 | import android.util.Log;
7 | import android.view.KeyEvent;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.Window;
11 | import android.view.WindowManager;
12 | import android.widget.RelativeLayout;
13 |
14 | import com.arthur.rollout.model.RolloutBDInfo;
15 | import com.arthur.rollout.model.RolloutInfo;
16 | import com.arthur.rollout.rolloutanimview.R;
17 | import com.arthur.rollout.tools.RCommonUtil;
18 | import com.arthur.rollout.tools.RGlideUtil;
19 | import com.arthur.rollout.view.RolloutViewPager;
20 | import com.bumptech.glide.Glide;
21 |
22 | import java.util.ArrayList;
23 |
24 | import uk.co.senab.photoview.PhotoView;
25 | import uk.co.senab.photoview.PhotoViewAttacher;
26 |
27 | public class RolloutPreviewActivity extends RolloutBaseActivity implements ViewPager.OnPageChangeListener {
28 |
29 | private int index = 0;
30 | private int selectIndex = -1;
31 |
32 | private RelativeLayout main_show_view;
33 |
34 | private ViewPager viewpager;
35 | private SamplePagerAdapter pagerAdapter;
36 |
37 | private ArrayList ImgList;
38 |
39 | private float moveheight;
40 | private int type;
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);// 全屏
46 | requestWindowFeature(Window.FEATURE_NO_TITLE);
47 | setContentView(R.layout.activity_rollout_preview);
48 | findID();
49 | Listener();
50 | InData();
51 | getValue();
52 | }
53 |
54 | @Override
55 | public void findID() {
56 | super.findID();
57 | viewpager = (RolloutViewPager) findViewById(R.id.bi_viewpager);
58 | main_show_view = (RelativeLayout) findViewById(R.id.main_show_view);
59 | }
60 |
61 | @Override
62 | public void Listener() {
63 | super.Listener();
64 | viewpager.setOnPageChangeListener(this);
65 | }
66 |
67 | @Override
68 | public void InData() {
69 | super.InData();
70 |
71 | index = getIntent().getIntExtra("index", 0);
72 | type = getIntent().getIntExtra("type", 0);
73 | ImgList = (ArrayList) getIntent().getSerializableExtra("data");
74 |
75 | Log.e("1", ImgList.size() + "数量");
76 |
77 | imageInfo = ImgList.get(index);
78 | bdInfo = (RolloutBDInfo) getIntent().getSerializableExtra("bdinfo");
79 |
80 | pagerAdapter = new SamplePagerAdapter();
81 | viewpager.setAdapter(pagerAdapter);
82 | viewpager.setCurrentItem(index);
83 |
84 | if (type == 1) {
85 | moveheight = RCommonUtil.dip2px(this, 70);
86 | } else if (type == 2) {
87 | moveheight = (Width - 3 * RCommonUtil.dip2px(this, 2)) / 3;
88 | } else if (type == 3) {
89 | moveheight = (Width - RCommonUtil.dip2px(this, 80) - RCommonUtil.dip2px(this, 2)) / 3;
90 | }
91 | }
92 |
93 |
94 | @Override
95 | public void onPageScrollStateChanged(int arg0) {
96 |
97 | }
98 |
99 | @Override
100 | public void onPageScrolled(int arg0, float arg1, int arg2) {
101 |
102 | }
103 |
104 | @Override
105 | public void onPageSelected(int arg0) {
106 | if (showimg == null) {
107 | return;
108 | }
109 | RolloutInfo info = ImgList.get(arg0);
110 | //单张
111 | if (type == 0) {
112 | RGlideUtil.setImage(RolloutPreviewActivity.this, info.url, showimg);
113 | } else if (type == 1) {//listview
114 | selectIndex = arg0;
115 | int move_index = arg0 - index;
116 | to_y = move_index * moveheight;
117 | } else if (type == 2) {//gridview,计算图片原始的位置,某行某列
118 | selectIndex = arg0;
119 | int a = index / 3;
120 | int b = index % 3;
121 | int a1 = arg0 / 3;
122 | int b1 = arg0 % 3;
123 | to_y = (a1 - a) * moveheight + (a1 - a) * RCommonUtil.dip2px(this, 2);
124 | to_x = (b1 - b) * moveheight + (b1 - b) * RCommonUtil.dip2px(this, 2);
125 | } else if (type == 3) {//类似与朋友圈
126 | selectIndex = arg0;
127 | int a = index / 3;
128 | int b = index % 3;
129 | int a1 = arg0 / 3;
130 | int b1 = arg0 % 3;
131 | to_y = (a1 - a) * moveheight + (a1 - a) * RCommonUtil.dip2px(this, 1);
132 | to_x = (b1 - b) * moveheight + (b1 - b) * RCommonUtil.dip2px(this, 1);
133 | }
134 | }
135 |
136 | class SamplePagerAdapter extends PagerAdapter {
137 |
138 | @Override
139 | public int getCount() {
140 | return ImgList.size();
141 | }
142 |
143 | @Override
144 | public View instantiateItem(ViewGroup container, int position) {
145 | PhotoView photoView = new PhotoView(container.getContext());
146 | String path = ImgList.get(position).url;
147 | Glide.with(RolloutPreviewActivity.this).load(path).into(photoView);
148 | // Now just add PhotoView to ViewPager and return it
149 | photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
150 |
151 | @Override
152 | public void onViewTap(View arg0, float arg1, float arg2) {
153 | viewpager.setVisibility(View.GONE);
154 | showimg.setVisibility(View.VISIBLE);
155 | if (selectIndex != -1) {
156 | RGlideUtil.setImage(RolloutPreviewActivity.this, ImgList.get(selectIndex).url, showimg);
157 | }
158 | setShowimage();
159 | }
160 | });
161 | container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT,
162 | ViewGroup.LayoutParams.MATCH_PARENT);
163 |
164 | return photoView;
165 | }
166 |
167 | @Override
168 | public void destroyItem(ViewGroup container, int position, Object object) {
169 | container.removeView((View) object);
170 | }
171 |
172 | @Override
173 | public boolean isViewFromObject(View view, Object object) {
174 | return view == object;
175 | }
176 | }
177 |
178 | @Override
179 | public boolean onKeyDown(int keyCode, KeyEvent event) {
180 | if (keyCode == KeyEvent.KEYCODE_BACK) {
181 | viewpager.setVisibility(View.GONE);
182 | showimg.setVisibility(View.VISIBLE);
183 | setShowimage();
184 | }
185 | return true;
186 | }
187 |
188 | @Override
189 | protected void EndSoring() {
190 | super.EndSoring();
191 | viewpager.setVisibility(View.VISIBLE);
192 | showimg.setVisibility(View.GONE);
193 | }
194 |
195 | @Override
196 | protected void EndMove() {
197 | super.EndMove();
198 | finish();
199 | }
200 |
201 | @Override
202 | protected void onDestroy() {
203 | super.onDestroy();
204 | if (selectIndex != -1) {
205 | selectIndex = -1;
206 | }
207 | RGlideUtil.clearMemory(this);
208 | }
209 | }
210 |
--------------------------------------------------------------------------------
/library/src/main/java/com/arthur/rollout/activity/RolloutBaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.arthur.rollout.activity;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 | import android.widget.RelativeLayout;
10 |
11 | import com.arthur.rollout.model.RolloutBDInfo;
12 | import com.arthur.rollout.model.RolloutInfo;
13 | import com.arthur.rollout.rolloutanimview.R;
14 | import com.arthur.rollout.tools.RCommonUtil;
15 | import com.arthur.rollout.tools.RGlideUtil;
16 | import com.facebook.rebound.Spring;
17 | import com.facebook.rebound.SpringConfig;
18 | import com.facebook.rebound.SpringListener;
19 | import com.facebook.rebound.SpringSystem;
20 | import com.facebook.rebound.SpringUtil;
21 | import com.nineoldandroids.animation.Animator;
22 | import com.nineoldandroids.animation.AnimatorSet;
23 | import com.nineoldandroids.animation.ObjectAnimator;
24 |
25 | /**
26 | * 站在牛人的肩膀上
27 | * 引用的包:
28 | * compile 'com.android.support:appcompat-v7:25.1.1' //可以换成v4或降低版本
29 | * compile 'com.github.chrisbanes.photoview:library:1.2.3' 图片放大缩小
30 | * compile 'com.facebook.rebound:rebound:0.3.8' //facebook的弹性动画
31 | * compile 'com.github.bumptech.glide:glide:3.7.0' //图片加载工具
32 | * compile 'com.nineoldandroids:library:2.4.0' //大神JakeWharton的动画库
33 | */
34 | public class RolloutBaseActivity extends Activity {
35 |
36 | // 屏幕宽度
37 | public float Width;
38 | // 屏幕高度
39 | public float Height;
40 | //整个动画过程显示的图片
41 | protected ImageView showimg;
42 | //弹性库:拉力,摩擦力
43 | private final Spring mSpring = SpringSystem
44 | .create()
45 | .createSpring()
46 | .addListener(new ExampleSpringListener());
47 |
48 | private RelativeLayout MainView;
49 |
50 | protected RolloutBDInfo bdInfo;
51 | protected RolloutInfo imageInfo;
52 | //用于动画的数值
53 | private float size, size_h;
54 |
55 | //关于imageView想要有多宽
56 | private float img_w;
57 | private float img_h;
58 |
59 | //原图高
60 | private float y_img_h;
61 | //退出时候图片飞向的坐标xy
62 | protected float to_x = 0;
63 | protected float to_y = 0;
64 | //打开时图片的坐标
65 | private float tx;
66 | private float ty;
67 |
68 | @Override
69 | protected void onCreate(Bundle savedInstanceState) {
70 | super.onCreate(savedInstanceState);
71 | Width = RCommonUtil.getScreenWidth(this);
72 | Height = RCommonUtil.getScreenHeight(this);
73 | }
74 |
75 |
76 | /**
77 | * 获取资源
78 | */
79 | protected void findID() {
80 | MainView = (RelativeLayout) findViewById(R.id.main_show_view);
81 | }
82 |
83 | /**
84 | * 监听
85 | */
86 | protected void Listener() {
87 | }
88 |
89 | /**
90 | * 初始
91 | */
92 | public void InData() {
93 | }
94 |
95 |
96 | protected void EndSoring() {
97 |
98 | }
99 |
100 | protected void EndMove() {
101 |
102 | }
103 |
104 | /**
105 | * 获取相应的数据
106 | */
107 | protected void getValue() {
108 | showimg = new ImageView(this);
109 | showimg.setScaleType(ImageView.ScaleType.CENTER_CROP);
110 |
111 | RGlideUtil.setImage(this, imageInfo.url, showimg);
112 | //关于imageView想要有多宽
113 | img_w = bdInfo.width;
114 | img_h = bdInfo.height;
115 | //动画变化值
116 | size = Width / img_w;
117 | y_img_h = imageInfo.height * Width / imageInfo.width;
118 | size_h = y_img_h / img_h;
119 |
120 | RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams((int) bdInfo.width, (int) bdInfo.height);
121 | showimg.setLayoutParams(p);
122 | p.setMargins((int) bdInfo.x, (int) bdInfo.y, (int) (Width - (bdInfo.x + bdInfo.width)), (int) (Height - (bdInfo.y + bdInfo.height)));
123 |
124 | MainView.addView(showimg);
125 |
126 | showimg.setVisibility(View.VISIBLE);
127 | new Handler().postDelayed(new Runnable() {
128 | public void run() {
129 | setShowimage();
130 | }
131 | }, 300);
132 | }
133 |
134 | /**
135 | * 根据数据设置展示图
136 | */
137 | protected void setShowimage() {
138 | if (mSpring.getEndValue() == 0) {
139 | mSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(170, 5));
140 | tx = Width / 2 - (bdInfo.x + img_w / 2);
141 | ty = Height / 2 - (bdInfo.y + img_h / 2);
142 | MoveView();
143 | return;
144 | }
145 | mSpring.setSpringConfig(SpringConfig.fromOrigamiTensionAndFriction(1, 5));
146 | mSpring.setEndValue(0);
147 | new Handler().postDelayed(new Runnable() {
148 | public void run() {
149 | //execute the task
150 | MoveBackView();
151 | }
152 | }, 300);
153 |
154 | }
155 |
156 | private class ExampleSpringListener implements SpringListener {
157 |
158 | @Override
159 | public void onSpringUpdate(Spring spring) {
160 | double CurrentValue = spring.getCurrentValue();
161 | float mappedValue = (float) SpringUtil.mapValueFromRangeToRange(CurrentValue, 0, 1, 1, size);
162 | float mapy = (float) SpringUtil.mapValueFromRangeToRange(CurrentValue, 0, 1, 1, size_h);
163 | showimg.setScaleX(mappedValue);
164 | showimg.setScaleY(mapy);
165 | if (CurrentValue == 1) {
166 | EndSoring();
167 | }
168 | }
169 |
170 | @Override
171 | public void onSpringAtRest(Spring spring) {
172 |
173 | }
174 |
175 | @Override
176 | public void onSpringActivate(Spring spring) {
177 |
178 | }
179 |
180 | @Override
181 | public void onSpringEndStateChange(Spring spring) {
182 |
183 | }
184 | }
185 |
186 | /**
187 | * 图片展示前动画
188 | */
189 | private void MoveView() {
190 | //属性动画
191 | ObjectAnimator.ofFloat(MainView, "alpha", 0.8f).setDuration(0).start();
192 | MainView.setVisibility(View.VISIBLE);
193 | //属性动画集合
194 | AnimatorSet set = new AnimatorSet();
195 | set.playTogether(
196 | ObjectAnimator.ofFloat(showimg, "translationX", tx).setDuration(200),
197 | ObjectAnimator.ofFloat(showimg, "translationY", ty).setDuration(200),
198 | ObjectAnimator.ofFloat(MainView, "alpha", 1).setDuration(200)
199 |
200 | );
201 | set.addListener(new Animator.AnimatorListener() {
202 | @Override
203 | public void onAnimationStart(Animator animator) {
204 |
205 | }
206 |
207 | @Override
208 | public void onAnimationEnd(Animator animator) {
209 | showimg.setScaleType(ImageView.ScaleType.FIT_XY);
210 | mSpring.setEndValue(1);
211 | MainView.setBackgroundResource(R.color.rollout_preview_bg);
212 | }
213 |
214 | @Override
215 | public void onAnimationCancel(Animator animator) {
216 |
217 | }
218 |
219 | @Override
220 | public void onAnimationRepeat(Animator animator) {
221 |
222 | }
223 | });
224 | set.start();
225 |
226 | }
227 | /**
228 | * 图片退出动画
229 | */
230 | private void MoveBackView() {
231 | AnimatorSet set = new AnimatorSet();
232 | set.playTogether(
233 | ObjectAnimator.ofFloat(showimg, "translationX", to_x).setDuration(200),
234 | ObjectAnimator.ofFloat(showimg, "translationY", to_y).setDuration(200)
235 | );
236 | set.addListener(new Animator.AnimatorListener() {
237 | @Override
238 | public void onAnimationStart(Animator animator) {
239 | showimg.setScaleType(ImageView.ScaleType.CENTER_CROP);
240 | }
241 |
242 | @Override
243 | public void onAnimationEnd(Animator animator) {
244 | EndMove();
245 | }
246 |
247 | @Override
248 | public void onAnimationCancel(Animator animator) {
249 |
250 | }
251 |
252 | @Override
253 | public void onAnimationRepeat(Animator animator) {
254 |
255 | }
256 | });
257 | set.start();
258 | }
259 |
260 | /**
261 | * 对跳转的动画可以重新自己定义
262 | *
263 | * @param intent
264 | */
265 | @Override
266 | public void startActivity(Intent intent) {
267 | super.startActivity(intent);
268 | overridePendingTransition(R.anim.activity_in, 0);
269 | }
270 |
271 | @Override
272 | public void onBackPressed() {
273 | super.onBackPressed();
274 | overridePendingTransition(0, R.anim.activity_out);
275 | }
276 |
277 | @Override
278 | public void finish() {
279 | super.finish();
280 | overridePendingTransition(0, R.anim.activity_out);
281 | }
282 |
283 | @Override
284 | protected void onDestroy() {
285 | super.onDestroy();
286 | RGlideUtil.clearMemory(this);
287 | }
288 | }
289 |
--------------------------------------------------------------------------------