├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── razerdp
│ │ └── com
│ │ └── zoomviewactivity
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── razerdp
│ │ │ └── com
│ │ │ └── zoomviewactivity
│ │ │ ├── BaseScaleElementAnimaActivity.java
│ │ │ ├── GalleryActivity.java
│ │ │ ├── ImageRect.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ ├── activity_gallery.xml
│ │ ├── activity_main.xml
│ │ └── item_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
│ │ ├── ids.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── razerdp
│ └── com
│ └── zoomviewactivity
│ └── ExampleUnitTest.java
├── art
└── preview.gif
├── 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
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Zoom a view when start a new activity
2 | # 仿微信等图片浏览时的缩放过渡BaseActivity
3 |
4 | ####preview:
5 | 
6 |
7 | ###实现原理:
8 | 【上篇】[一起撸个微信图片浏览的BaseActivity吧(上)——初步思考与基础结构](http://www.jianshu.com/p/a593acec1470)
9 |
10 | 【下篇】[一起撸个微信图片浏览的BaseActivity吧(下)——过渡动画的实现](http://www.jianshu.com/p/2716c08e78b4)
11 |
12 | ##LICENSE:
13 | ***
14 | The MIT License (MIT)
15 |
16 | Copyright (c) [2016] [razerdp]
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
21 |
22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "23.0.3"
6 | defaultConfig {
7 | applicationId "razerdp.com.zoomviewactivity"
8 | minSdkVersion 15
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(dir: 'libs', include: ['*.jar'])
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.1.1'
28 | testCompile 'junit:junit:4.12'
29 | compile 'com.github.bumptech.glide:glide:3.7.0'
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/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 D:\AndroidSDK/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/razerdp/com/zoomviewactivity/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
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("razerdp.com.zoomviewactivity", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/razerdp/com/zoomviewactivity/BaseScaleElementAnimaActivity.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorSet;
5 | import android.animation.ObjectAnimator;
6 | import android.app.Activity;
7 | import android.content.Intent;
8 | import android.graphics.Point;
9 | import android.graphics.Rect;
10 | import android.graphics.RectF;
11 | import android.os.Bundle;
12 | import android.support.annotation.LayoutRes;
13 | import android.support.annotation.Nullable;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.text.TextUtils;
16 | import android.util.Log;
17 | import android.view.View;
18 | import android.view.ViewTreeObserver;
19 | import android.view.animation.DecelerateInterpolator;
20 | import android.widget.ImageView;
21 | import com.bumptech.glide.load.resource.bitmap.GlideBitmapDrawable;
22 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
23 | import com.bumptech.glide.request.animation.GlideAnimation;
24 | import com.bumptech.glide.request.target.SimpleTarget;
25 |
26 | /**
27 | * Created by 大灯泡 on 2016/9/2.
28 | *
29 | * 包含放大缩小过渡动画的activity
30 | */
31 |
32 | public abstract class BaseScaleElementAnimaActivity extends AppCompatActivity {
33 |
34 | protected V targetScaleAnimaedImageView;
35 | private String picUrl;
36 | private boolean needAnima;
37 | private AnimatorSet currentAnimator;
38 | private Point globalOffset;
39 |
40 | private Rect startRect;
41 | private Rect endRect;
42 |
43 | @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | initData();
46 | }
47 |
48 | @Override public void setContentView(@LayoutRes int layoutResID) {
49 | super.setContentView(layoutResID);
50 | initImageView();
51 | }
52 |
53 | private void initData() {
54 | picUrl = getIntent().getStringExtra("url");
55 | startRect = getIntent().getParcelableExtra("fromRect");
56 | needAnima = startRect != null && !TextUtils.isEmpty(picUrl);
57 | if (needAnima) {
58 | endRect = new Rect();
59 | globalOffset = new Point();
60 | }
61 | }
62 |
63 | private void initImageView() {
64 | targetScaleAnimaedImageView = getAnimaedImageView();
65 | needAnima = (needAnima && targetScaleAnimaedImageView != null);
66 | if (needAnima) {
67 | targetScaleAnimaedImageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
68 | @Override public boolean onPreDraw() {
69 | //此时目标已经有了宽高信息
70 | targetScaleAnimaedImageView.getGlobalVisibleRect(endRect, globalOffset);
71 | playEnterAnima();
72 | targetScaleAnimaedImageView.getViewTreeObserver().removeOnPreDrawListener(this);
73 | return true;
74 | }
75 | });
76 | targetScaleAnimaedImageView.setOnClickListener(new View.OnClickListener() {
77 | @Override public void onClick(View v) {
78 | playExitAnima();
79 | }
80 | });
81 | }
82 | }
83 |
84 | @Override protected void onResume() {
85 | super.onResume();
86 | }
87 |
88 | private void playEnterAnima() {
89 | if (currentAnimator != null) {
90 | currentAnimator.cancel();
91 | }
92 | onLoadingPicture(imageViewTarget, picUrl);
93 |
94 | startRect.offset(-globalOffset.x, -globalOffset.y);
95 | endRect.offset(-globalOffset.x, -globalOffset.y);
96 |
97 | float[] ratios = calculateRatios(startRect, endRect);
98 |
99 | targetScaleAnimaedImageView.setPivotX(0.5f);
100 | targetScaleAnimaedImageView.setPivotY(0.5f);
101 | final AnimatorSet enter = new AnimatorSet();
102 | enter.play(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.X, startRect.left, endRect.left))
103 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.Y, startRect.top, endRect.top))
104 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.SCALE_X, ratios[0], 1f))
105 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.SCALE_Y, ratios[1], 1f));
106 |
107 | enter.setDuration(400);
108 | enter.setInterpolator(new DecelerateInterpolator());
109 | enter.addListener(new Animator.AnimatorListener() {
110 | @Override
111 | public void onAnimationStart(Animator animation) {
112 | currentAnimator = enter;
113 | }
114 |
115 | @Override
116 | public void onAnimationEnd(Animator animation) {
117 | currentAnimator = null;
118 | }
119 |
120 | @Override
121 | public void onAnimationCancel(Animator animation) {
122 | currentAnimator = null;
123 | }
124 |
125 | @Override
126 | public void onAnimationRepeat(Animator animation) {
127 |
128 | }
129 | });
130 | enter.start();
131 | }
132 |
133 | private void playExitAnima() {
134 | if (currentAnimator != null) {
135 | currentAnimator.cancel();
136 | }
137 |
138 | float[] ratios = calculateRatios(startRect, endRect);
139 |
140 | Log.i("startRect", "exit after offset: >>> " + startRect.toString());
141 | Log.d("endtRect", "exit after offset: >>> " + endRect.toString());
142 | int deltaHeight = (int) (endRect.top * ratios[1]);
143 | int deltaWidth = (int) (endRect.left * ratios[0]);
144 |
145 | targetScaleAnimaedImageView.setPivotX(0.5f);
146 | targetScaleAnimaedImageView.setPivotY(0.5f);
147 | final AnimatorSet exit = new AnimatorSet();
148 |
149 | exit.play(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.X, startRect.left - deltaWidth))
150 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.Y, startRect.top - deltaHeight))
151 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.SCALE_X, ratios[0]))
152 | .with(ObjectAnimator.ofFloat(targetScaleAnimaedImageView, View.SCALE_Y, ratios[1]));
153 |
154 | exit.setDuration(400);
155 | exit.setInterpolator(new DecelerateInterpolator());
156 | exit.addListener(new Animator.AnimatorListener() {
157 | @Override
158 | public void onAnimationStart(Animator animation) {
159 | currentAnimator = exit;
160 | }
161 |
162 | @Override
163 | public void onAnimationEnd(Animator animation) {
164 | currentAnimator = null;
165 | finish();
166 | }
167 |
168 | @Override
169 | public void onAnimationCancel(Animator animation) {
170 | currentAnimator = null;
171 | }
172 |
173 | @Override
174 | public void onAnimationRepeat(Animator animation) {
175 |
176 | }
177 | });
178 | exit.start();
179 | }
180 |
181 | @Override public void finish() {
182 | super.finish();
183 | overridePendingTransition(0, android.R.anim.fade_out);
184 | }
185 |
186 | private SimpleTarget imageViewTarget = new SimpleTarget() {
187 | @Override public void onResourceReady(GlideDrawable resource, GlideAnimation super GlideDrawable> glideAnimation) {
188 | if (resource instanceof GlideBitmapDrawable) {
189 | targetScaleAnimaedImageView.setImageBitmap(((GlideBitmapDrawable) resource).getBitmap());
190 | ImageRect imageRect = new ImageRect(targetScaleAnimaedImageView);
191 | RectF rect = imageRect.getImageRect();
192 | endRect.set((int) rect.left, (int) rect.top, (int) rect.right, (int) rect.bottom);
193 |
194 | Log.d("imgrect", rect.toShortString());
195 | }
196 | }
197 | };
198 |
199 | protected abstract V getAnimaedImageView();
200 |
201 | protected abstract void onLoadingPicture(SimpleTarget targetImageView, String url);
202 |
203 | private float[] calculateRatios(Rect startBounds, Rect finalBounds) {
204 | float[] result = new float[2];
205 | float widthRatio = startBounds.width() * 1.0f / finalBounds.width() * 1.0f;
206 | float heightRatio = startBounds.height() * 1.0f / finalBounds.height() * 1.0f;
207 | result[0] = widthRatio;
208 | result[1] = heightRatio;
209 | return result;
210 | }
211 |
212 | public static void startWithScaleElementActivity(Activity from,
213 | @Nullable String picUrl,
214 | @Nullable Rect fromRect,
215 | Class extends BaseScaleElementAnimaActivity> clazz) {
216 | Intent intent = new Intent(from, clazz);
217 | intent.putExtra("url", picUrl);
218 | intent.putExtra("fromRect", fromRect);
219 | from.startActivity(intent);
220 | //禁用过渡动画
221 | from.overridePendingTransition(0, 0);
222 | }
223 | }
224 |
225 |
--------------------------------------------------------------------------------
/app/src/main/java/razerdp/com/zoomviewactivity/GalleryActivity.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
2 |
3 | import android.os.Bundle;
4 | import android.widget.ImageView;
5 | import com.bumptech.glide.Glide;
6 | import com.bumptech.glide.request.target.SimpleTarget;
7 |
8 | /**
9 | * Created by 大灯泡 on 2016/9/2.
10 | */
11 |
12 | public class GalleryActivity extends BaseScaleElementAnimaActivity{
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_gallery);
18 | }
19 |
20 | @Override protected ImageView getAnimaedImageView() {
21 | return (ImageView) findViewById(R.id.large_imageview);
22 | }
23 |
24 | @Override protected void onLoadingPicture(SimpleTarget targetImageView, String url) {
25 | Glide.with(this).load(url).into(targetImageView);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/java/razerdp/com/zoomviewactivity/ImageRect.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
2 |
3 | import android.graphics.Matrix;
4 | import android.graphics.Rect;
5 | import android.graphics.RectF;
6 | import android.widget.ImageView;
7 |
8 | /**
9 | * Created by 大灯泡 on 2016/9/2.
10 | */
11 |
12 | public class ImageRect {
13 | private RectF rect;
14 |
15 | public ImageRect(ImageView imageview) {
16 | rect = new RectF();
17 | if (imageview != null) {
18 | Rect drawableRect = imageview.getDrawable().getBounds();
19 | Matrix imgMatrix = imageview.getImageMatrix();
20 | float[] matrixValues = new float[9];
21 | imgMatrix.getValues(matrixValues);
22 | rect.left = matrixValues[2];
23 | rect.top = matrixValues[5];
24 | rect.right = rect.left + drawableRect.width() * matrixValues[0];
25 | rect.bottom = rect.top + drawableRect.height() * matrixValues[0];
26 | }
27 | }
28 |
29 | public RectF getImageRect() {
30 | return rect;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/java/razerdp/com/zoomviewactivity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
2 |
3 | import android.graphics.Rect;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.BaseAdapter;
10 | import android.widget.ImageView;
11 | import android.widget.LinearLayout;
12 | import android.widget.ListView;
13 | import android.widget.TextView;
14 | import com.bumptech.glide.Glide;
15 |
16 | public class MainActivity extends AppCompatActivity {
17 | public final static String[] imageThumbUrls = new String[] {
18 | "http://img0.imgtn.bdimg.com/it/u=174933758,4215677132&fm=21&gp=0.jpg",
19 | "http://img3.imgtn.bdimg.com/it/u=2489272570,1320005951&fm=21&gp=0.jpg",
20 | "http://img4.imgtn.bdimg.com/it/u=886577445,4037697725&fm=21&gp=0.jpg",
21 | "http://img1.imgtn.bdimg.com/it/u=223451437,1717713198&fm=21&gp=0.jpg",
22 | "http://img1.imgtn.bdimg.com/it/u=1291991673,1011525160&fm=21&gp=0.jpg",
23 | "http://img5.imgtn.bdimg.com/it/u=3109169726,2912642473&fm=21&gp=0.jpg",
24 | "http://img0.imgtn.bdimg.com/it/u=1570388022,3818490538&fm=21&gp=0.jpg",
25 | "http://img3.imgtn.bdimg.com/it/u=995253922,519230807&fm=21&gp=0.jpg",
26 | "http://img1.imgtn.bdimg.com/it/u=2196321947,3072185274&fm=21&gp=0.jpg",
27 | "http://img1.imgtn.bdimg.com/it/u=3241888575,3721340726&fm=21&gp=0.jpg",
28 | "http://img4.imgtn.bdimg.com/it/u=3989728472,2285970198&fm=21&gp=0.jpg",
29 | "http://img3.imgtn.bdimg.com/it/u=3345569329,251003876&fm=21&gp=0.jpg",
30 | "http://img1.imgtn.bdimg.com/it/u=1693679285,1236253130&fm=21&gp=0.jpg",
31 | "http://img4.imgtn.bdimg.com/it/u=548380399,1633182297&fm=21&gp=0.jpg",
32 | "http://img3.imgtn.bdimg.com/it/u=4048514484,4278139063&fm=21&gp=0.jpg",
33 | "http://img3.imgtn.bdimg.com/it/u=1671943955,3320345726&fm=21&gp=0.jpg",
34 | "http://img5.imgtn.bdimg.com/it/u=1209254764,1138673101&fm=21&gp=0.jpg",
35 | "http://img3.imgtn.bdimg.com/it/u=1675837036,1868624213&fm=21&gp=0.jpg",
36 | "http://img2.imgtn.bdimg.com/it/u=1155180725,1896054369&fm=21&gp=0.jpg",
37 | "http://img3.imgtn.bdimg.com/it/u=2273157982,216262949&fm=21&gp=0.jpg",
38 | "http://img0.imgtn.bdimg.com/it/u=3765951855,4291926133&fm=21&gp=0.jpg",
39 | "http://img1.imgtn.bdimg.com/it/u=3024454297,685457010&fm=21&gp=0.jpg",
40 | "http://img5.imgtn.bdimg.com/it/u=1490459227,3201555812&fm=21&gp=0.jpg",
41 | "http://img4.imgtn.bdimg.com/it/u=2333591480,3865559244&fm=21&gp=0.jpg",
42 | "http://img3.imgtn.bdimg.com/it/u=1928647624,2441315433&fm=21&gp=0.jpg",
43 | "http://img1.imgtn.bdimg.com/it/u=3548933321,1229645136&fm=21&gp=0.jpg",
44 | "http://img0.imgtn.bdimg.com/it/u=1977596414,2408269982&fm=21&gp=0.jpg",
45 | "http://img2.imgtn.bdimg.com/it/u=3595906845,2921183295&fm=21&gp=0.jpg",
46 | "http://img2.imgtn.bdimg.com/it/u=2723778700,4131168062&fm=21&gp=0.jpg",
47 | "http://img5.imgtn.bdimg.com/it/u=2397618454,1789270489&fm=21&gp=0.jpg",
48 | "http://img3.imgtn.bdimg.com/it/u=491049708,1747659465&fm=21&gp=0.jpg",
49 | "http://img1.imgtn.bdimg.com/it/u=630621970,2875108731&fm=21&gp=0.jpg",
50 | "http://img0.imgtn.bdimg.com/it/u=2284368585,3465236287&fm=21&gp=0.jpg",
51 | "http://img3.imgtn.bdimg.com/it/u=164449162,2080920875&fm=21&gp=0.jpg",
52 | "http://img5.imgtn.bdimg.com/it/u=3734366599,2068439888&fm=21&gp=0.jpg"
53 | };
54 | private ListView listview;
55 |
56 | @Override
57 | protected void onCreate(Bundle savedInstanceState) {
58 | super.onCreate(savedInstanceState);
59 | setContentView(R.layout.activity_main);
60 | initView();
61 | }
62 |
63 | private void initView() {
64 | listview = (ListView) findViewById(R.id.list_view);
65 | listview.setAdapter(new InnerAdapter());
66 | }
67 |
68 | class InnerAdapter extends BaseAdapter {
69 |
70 | @Override public int getCount() {
71 | return imageThumbUrls.length;
72 | }
73 |
74 | @Override public String getItem(int position) {
75 | return imageThumbUrls[position];
76 | }
77 |
78 | @Override public long getItemId(int position) {
79 | return position;
80 | }
81 |
82 | @Override public View getView(final int position, View convertView, ViewGroup parent) {
83 | ViewHolder vh = null;
84 | if (convertView == null) {
85 | convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.item_imageview, parent, false);
86 | TextView title = (TextView) convertView.findViewById(R.id.position);
87 | ImageView img = (ImageView) convertView.findViewById(R.id.img);
88 | vh = new ViewHolder(title, img);
89 | convertView.setTag(R.id.vh, vh);
90 | } else {
91 | vh = (ViewHolder) convertView.getTag(R.id.vh);
92 | }
93 | vh.title.setText(String.valueOf(position));
94 | Glide.with(MainActivity.this).load(getItem(position)).into(vh.img);
95 | final ViewHolder finalVh = vh;
96 | convertView.setOnClickListener(new View.OnClickListener() {
97 | @Override public void onClick(View v) {
98 | Rect rect = new Rect();
99 | finalVh.img.getGlobalVisibleRect(rect);
100 | BaseScaleElementAnimaActivity.startWithScaleElementActivity(
101 | MainActivity.this,
102 | imageThumbUrls[position],
103 | rect,
104 | GalleryActivity.class
105 | );
106 | }
107 | });
108 | return convertView;
109 | }
110 |
111 | class ViewHolder {
112 | public TextView title;
113 | public ImageView img;
114 |
115 | public ViewHolder(TextView title, ImageView img) {
116 | this.title = title;
117 | this.img = img;
118 | LinearLayout.LayoutParams params= (LinearLayout.LayoutParams) img.getLayoutParams();
119 | params.width= (int) (params.width+(Math.random()*150));
120 | params.height= (int) (params.height+(Math.random()*250));
121 | img.setLayoutParams(params);
122 |
123 | }
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_imageview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/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/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ZoomViewActivity
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/razerdp/com/zoomviewactivity/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package razerdp.com.zoomviewactivity;
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 | }
--------------------------------------------------------------------------------
/art/preview.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/art/preview.gif
--------------------------------------------------------------------------------
/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-rc1'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/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/razerdp/ZoomViewActivity/95fe213216548ccfe501920042870f30a28bd7d1/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'
2 |
--------------------------------------------------------------------------------