-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用旧版本Glide,增加流畅度 改用另一个图片查看器库,增加流畅度 更新地图
- Loading branch information
Showing
40 changed files
with
3,241 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdk 34 | ||
|
||
namespace 'com.SuperKotlin.pictureviewer' | ||
defaultConfig { | ||
minSdkVersion 18 | ||
targetSdkVersion 21 | ||
versionCode 1 | ||
versionName "2.0.1" | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
//implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.github.bumptech.glide:glide:3.7.0' | ||
implementation 'com.android.support:support-v4:28.0.0' | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\Users\zhuyong\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
|
||
> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true"> | ||
|
||
<activity android:name=".ImagePagerActivity" /> | ||
|
||
</application> | ||
|
||
</manifest> |
59 changes: 59 additions & 0 deletions
59
PictureViewer/src/main/java/com/SuperKotlin/pictureviewer/Compat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright 2011, 2012 Chris Banes. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package com.SuperKotlin.pictureviewer; | ||
|
||
import android.annotation.TargetApi; | ||
import android.os.Build.VERSION; | ||
import android.os.Build.VERSION_CODES; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
|
||
public class Compat { | ||
|
||
private static final int SIXTY_FPS_INTERVAL = 1000 / 60; | ||
|
||
public static void postOnAnimation(View view, Runnable runnable) { | ||
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) { | ||
postOnAnimationJellyBean(view, runnable); | ||
} else { | ||
view.postDelayed(runnable, SIXTY_FPS_INTERVAL); | ||
} | ||
} | ||
|
||
@TargetApi(16) | ||
private static void postOnAnimationJellyBean(View view, Runnable runnable) { | ||
view.postOnAnimation(runnable); | ||
} | ||
|
||
public static int getPointerIndex(int action) { | ||
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) | ||
return getPointerIndexHoneyComb(action); | ||
else | ||
return getPointerIndexEclair(action); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@TargetApi(VERSION_CODES.ECLAIR) | ||
private static int getPointerIndexEclair(int action) { | ||
return (action & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT; | ||
} | ||
|
||
@TargetApi(VERSION_CODES.HONEYCOMB) | ||
private static int getPointerIndexHoneyComb(int action) { | ||
return (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; | ||
} | ||
|
||
} |
142 changes: 142 additions & 0 deletions
142
PictureViewer/src/main/java/com/SuperKotlin/pictureviewer/CupcakeGestureDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/******************************************************************************* | ||
* Copyright 2011, 2012 Chris Banes. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*******************************************************************************/ | ||
package com.SuperKotlin.pictureviewer; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
import android.view.MotionEvent; | ||
import android.view.VelocityTracker; | ||
import android.view.ViewConfiguration; | ||
|
||
public class CupcakeGestureDetector implements GestureDetector { | ||
|
||
protected OnGestureListener mListener; | ||
private static final String LOG_TAG = "CupcakeGestureDetector"; | ||
float mLastTouchX; | ||
float mLastTouchY; | ||
final float mTouchSlop; | ||
final float mMinimumVelocity; | ||
|
||
@Override | ||
public void setOnGestureListener(OnGestureListener listener) { | ||
this.mListener = listener; | ||
} | ||
|
||
public CupcakeGestureDetector(Context context) { | ||
final ViewConfiguration configuration = ViewConfiguration | ||
.get(context); | ||
mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); | ||
mTouchSlop = configuration.getScaledTouchSlop(); | ||
} | ||
|
||
private VelocityTracker mVelocityTracker; | ||
private boolean mIsDragging; | ||
|
||
float getActiveX(MotionEvent ev) { | ||
return ev.getX(); | ||
} | ||
|
||
float getActiveY(MotionEvent ev) { | ||
return ev.getY(); | ||
} | ||
|
||
public boolean isScaling() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(MotionEvent ev) { | ||
switch (ev.getAction()) { | ||
case MotionEvent.ACTION_DOWN: { | ||
mVelocityTracker = VelocityTracker.obtain(); | ||
if (null != mVelocityTracker) { | ||
mVelocityTracker.addMovement(ev); | ||
} else { | ||
Log.i(LOG_TAG, "Velocity tracker is null"); | ||
} | ||
|
||
mLastTouchX = getActiveX(ev); | ||
mLastTouchY = getActiveY(ev); | ||
mIsDragging = false; | ||
break; | ||
} | ||
|
||
case MotionEvent.ACTION_MOVE: { | ||
final float x = getActiveX(ev); | ||
final float y = getActiveY(ev); | ||
final float dx = x - mLastTouchX, dy = y - mLastTouchY; | ||
|
||
if (!mIsDragging) { | ||
// Use Pythagoras to see if drag length is larger than | ||
// touch slop | ||
mIsDragging = Math.sqrt((dx * dx) + (dy * dy)) >= mTouchSlop; | ||
} | ||
|
||
if (mIsDragging) { | ||
mListener.onDrag(dx, dy); | ||
mLastTouchX = x; | ||
mLastTouchY = y; | ||
|
||
if (null != mVelocityTracker) { | ||
mVelocityTracker.addMovement(ev); | ||
} | ||
} | ||
break; | ||
} | ||
|
||
case MotionEvent.ACTION_CANCEL: { | ||
// Recycle Velocity Tracker | ||
if (null != mVelocityTracker) { | ||
mVelocityTracker.recycle(); | ||
mVelocityTracker = null; | ||
} | ||
break; | ||
} | ||
|
||
case MotionEvent.ACTION_UP: { | ||
if (mIsDragging) { | ||
if (null != mVelocityTracker) { | ||
mLastTouchX = getActiveX(ev); | ||
mLastTouchY = getActiveY(ev); | ||
|
||
// Compute velocity within the last 1000ms | ||
mVelocityTracker.addMovement(ev); | ||
mVelocityTracker.computeCurrentVelocity(1000); | ||
|
||
final float vX = mVelocityTracker.getXVelocity(), vY = mVelocityTracker | ||
.getYVelocity(); | ||
|
||
// If the velocity is greater than minVelocity, call | ||
// listener | ||
if (Math.max(Math.abs(vX), Math.abs(vY)) >= mMinimumVelocity) { | ||
mListener.onFling(mLastTouchX, mLastTouchY, -vX, | ||
-vY); | ||
} | ||
} | ||
} | ||
|
||
// Recycle Velocity Tracker | ||
if (null != mVelocityTracker) { | ||
mVelocityTracker.recycle(); | ||
mVelocityTracker = null; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
PictureViewer/src/main/java/com/SuperKotlin/pictureviewer/DefaultOnDoubleTapListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.SuperKotlin.pictureviewer; | ||
|
||
import android.graphics.RectF; | ||
import android.view.GestureDetector; | ||
import android.view.MotionEvent; | ||
import android.widget.ImageView; | ||
|
||
/** | ||
* Provided default implementation of GestureDetector.OnDoubleTapListener, to be overriden with custom behavior, if needed | ||
* <p> </p> | ||
* To be used via {@link uk.co.senab.photoview.PhotoViewAttacher#setOnDoubleTapListener(GestureDetector.OnDoubleTapListener)} | ||
*/ | ||
public class DefaultOnDoubleTapListener implements GestureDetector.OnDoubleTapListener { | ||
|
||
private PhotoViewAttacher photoViewAttacher; | ||
|
||
/** | ||
* Default constructor | ||
* | ||
* @param photoViewAttacher PhotoViewAttacher to bind to | ||
*/ | ||
public DefaultOnDoubleTapListener(PhotoViewAttacher photoViewAttacher) { | ||
setPhotoViewAttacher(photoViewAttacher); | ||
} | ||
|
||
/** | ||
* Allows to change PhotoViewAttacher within range of single instance | ||
* | ||
* @param newPhotoViewAttacher PhotoViewAttacher to bind to | ||
*/ | ||
public void setPhotoViewAttacher(PhotoViewAttacher newPhotoViewAttacher) { | ||
this.photoViewAttacher = newPhotoViewAttacher; | ||
} | ||
|
||
@Override | ||
public boolean onSingleTapConfirmed(MotionEvent e) { | ||
if (this.photoViewAttacher == null) | ||
return false; | ||
|
||
ImageView imageView = photoViewAttacher.getImageView(); | ||
|
||
if (null != photoViewAttacher.getOnPhotoTapListener()) { | ||
final RectF displayRect = photoViewAttacher.getDisplayRect(); | ||
|
||
if (null != displayRect) { | ||
final float x = e.getX(), y = e.getY(); | ||
|
||
// Check to see if the user tapped on the photo | ||
if (displayRect.contains(x, y)) { | ||
|
||
float xResult = (x - displayRect.left) | ||
/ displayRect.width(); | ||
float yResult = (y - displayRect.top) | ||
/ displayRect.height(); | ||
|
||
photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult); | ||
return true; | ||
} | ||
} | ||
} | ||
if (null != photoViewAttacher.getOnViewTapListener()) { | ||
photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY()); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public boolean onDoubleTap(MotionEvent ev) { | ||
if (photoViewAttacher == null) | ||
return false; | ||
|
||
try { | ||
float scale = photoViewAttacher.getScale(); | ||
float x = ev.getX(); | ||
float y = ev.getY(); | ||
|
||
if (scale < photoViewAttacher.getMediumScale()) { | ||
photoViewAttacher.setScale(photoViewAttacher.getMediumScale(), x, y, true); | ||
} else if (scale >= photoViewAttacher.getMediumScale() && scale < photoViewAttacher.getMaximumScale()) { | ||
photoViewAttacher.setScale(photoViewAttacher.getMaximumScale(), x, y, true); | ||
} else { | ||
photoViewAttacher.setScale(photoViewAttacher.getMinimumScale(), x, y, true); | ||
} | ||
} catch (ArrayIndexOutOfBoundsException e) { | ||
// Can sometimes happen when getX() and getY() is called | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onDoubleTapEvent(MotionEvent e) { | ||
// Wait for the confirmed onDoubleTap() instead | ||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.