diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..3161f50e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: Baseflow +custom: https://baseflow.com/contact diff --git a/.github/ISSUE_TEMPLATE/a-regression.md b/.github/ISSUE_TEMPLATE/a-regression.md new file mode 100644 index 00000000..7dbeaebe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/a-regression.md @@ -0,0 +1,21 @@ +--- + +name: 🔙 Regression +about: Report unexpected behavior that worked previously +--- + +## 🔙 Regression + + + +### Old (and correct) behavior + +### Current behavior + +### Reproduction steps + +### Configuration + +**Version:** 1.x + +**Platform:** :robot: Android 9.x \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/b-bug-report.md b/.github/ISSUE_TEMPLATE/b-bug-report.md new file mode 100644 index 00000000..e6b06759 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/b-bug-report.md @@ -0,0 +1,19 @@ +--- + +name: 🐛 Bug Report +about: Create a report to help us fix bugs and make improvements +--- + +## 🐛 Bug Report + + + +### Expected behavior + +### Reproduction steps + +### Configuration + +**Version:** 1.x + +**Platform:** :robot: Android 9.x \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/c-feature-request.md b/.github/ISSUE_TEMPLATE/c-feature-request.md new file mode 100644 index 00000000..bd90365d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/c-feature-request.md @@ -0,0 +1,16 @@ +--- + +name: 🚀 Feature Request +about: Want to see something new included in the Framework? Submit it! +--- + +## 🚀 Feature Requests + + + +### Contextualize the feature + + +### Describe the feature + + diff --git a/.github/ISSUE_TEMPLATE/d-enhancement-proposal.md b/.github/ISSUE_TEMPLATE/d-enhancement-proposal.md new file mode 100644 index 00000000..e90e5e48 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/d-enhancement-proposal.md @@ -0,0 +1,13 @@ +--- + +name: 🏗 Enhancement Proposal +about: Proposals for code cleanup, refactor and improvements in general +--- + +## 🏗 Enhancement Proposal + + + +### Pitch + + diff --git a/.github/ISSUE_TEMPLATE/e-question.md b/.github/ISSUE_TEMPLATE/e-question.md new file mode 100644 index 00000000..03a4d36f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/e-question.md @@ -0,0 +1,11 @@ +--- + +name: 💬 Questions and Help +about: If you have questions, please use this for support +--- + +## 💬 Questions and Help + +For questions or help we recommend checking: + +- [Stack Overflow](https://stackoverflow.com/) \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..b001d7cc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +### :sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...) + + +### :arrow_heading_down: What is the current behavior? + + +### :new: What is the new behavior (if this is a feature change)? + + +### :boom: Does this PR introduce a breaking change? + + +### :bug: Recommendations for testing + + +### :memo: Links to relevant issues/docs + + +### :thinking: Checklist before submitting + +- [ ] All projects build +- [ ] Follows style guide lines +- [ ] Relevant documentation was updated +- [ ] Rebased onto current develop diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..4b2cf925 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [mvvmcross@gmail.com](mailto:mvvmcross@gmail). All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..4cf4c8fb --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing to PhotoView + +## Finding an issue to work on + +If you'd like to work on something that isn't in a current issue, especially if it would be a big change, please open a new issue for discussion! diff --git a/README.md b/README.md index 0289daf3..b1cfa0ed 100755 --- a/README.md +++ b/README.md @@ -3,16 +3,24 @@ PhotoView aims to help produce an easily usable implementation of a zooming Andr [![](https://jitpack.io/v/chrisbanes/PhotoView.svg)](https://jitpack.io/#chrisbanes/PhotoView) +[![](https://user-images.githubusercontent.com/12352397/85141529-94648e80-b24f-11ea-9a14-a845fb43b181.gif) + ## Dependency Add this in your root `build.gradle` file (**not** your module `build.gradle` file): ```gradle allprojects { - repositories { - maven { url "https://jitpack.io" } + repositories { + maven { url "https://www.jitpack.io" } } } + +buildscript { + repositories { + maven { url "https://www.jitpack.io" } + } +} ``` Then, add the library to your module `build.gradle` diff --git a/build.gradle b/build.gradle index e567eceb..9483085c 100755 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,14 @@ buildscript { + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:4.1.2' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -18,5 +20,6 @@ allprojects { } ext { - sdkVersion = 28 -} \ No newline at end of file + sdkVersion = 29 + minSdkVersion = 16 +} diff --git a/gradle.properties b/gradle.properties index b363d16f..d015431a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,2 @@ -VERSION_NAME=1.2.4 -VERSION_CODE=124 -GROUP=com.github.chrisbanes.photoview - -POM_DESCRIPTION=A simple ImageView that support zooming, both by Multi-touch gestures and double-tap. -POM_URL=https://github.com/chrisbanes/PhotoView -POM_SCM_URL=https://github.com/chrisbanes/PhotoView -POM_SCM_CONNECTION=scm:git@github.com/chrisbanes/PhotoView.git -POM_SCM_DEV_CONNECTION=scm:git@github.com/chrisbanes/PhotoView.git -POM_LICENCE_NAME=The Apache Software License, Version 2.0 -POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt -POM_LICENCE_DIST=repo -POM_DEVELOPER_ID=chrisbanes -POM_DEVELOPER_NAME=Chris Banes +android.useAndroidX=true +android.enableJetifier=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 146e8e42..490fda85 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fd1548a3..da9702f9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Sun Sep 30 16:42:21 CDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/gradlew b/gradlew index 4453ccea..2fe81a7d 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# 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 +# +# https://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. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,16 +44,16 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" -warn ( ) { +warn () { echo "$*" } -die ( ) { +die () { echo echo "$*" echo @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,35 +154,30 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args -save ( ) { +save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index e95643d6..9109989e 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/photoview/build.gradle b/photoview/build.gradle index 177d8e87..d500b0ef 100644 --- a/photoview/build.gradle +++ b/photoview/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' +apply plugin: 'maven-publish' android { compileSdkVersion rootProject.ext.sdkVersion defaultConfig { - minSdkVersion 14 + minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.sdkVersion versionCode 1 versionName "1.0" @@ -13,7 +13,67 @@ android { } dependencies { - implementation "androidx.appcompat:appcompat:1.0.0" + implementation "androidx.appcompat:appcompat:1.1.0" } -apply from: 'https://raw.githubusercontent.com/Commit451/gradle-android-javadocs/1.0.0/gradle-android-javadocs.gradle' +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + from components.release + + group = 'com.github.chrisbanes' + artifactId = 'PhotoView' + version = '2.3.0' + + // Adds javadocs and sources as separate jars. + artifact androidJavadocsJar + artifact(sourceJar) + + pom { + name = 'PhotoView' + description = 'A simple ImageView that support zooming, both by Multi-touch gestures and double-tap.' + url = 'https://github.com/Baseflow/PhotoView' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + developers { + developer { + id = 'chrisbanes' + name = 'Chris Banes' + } + } + scm { + connection = 'scm:git@github.com/chrisbanes/PhotoView.git' + developerConnection = 'scm:git@github.com/chrisbanes/PhotoView.git' + url = 'https://github.com/chrisbanes/PhotoView' + } + } + } + } + } +} + +task androidJavadocs(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + android.libraryVariants.all { variant -> + if (variant.name == 'release') { + owner.classpath += variant.javaCompileProvider.get().classpath + } + } + exclude '**/R.html', '**/R.*.html', '**/index.html' +} + +task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { + archiveClassifier.set('javadoc') + from androidJavadocs.destinationDir +} + +task sourceJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier "sources" +} \ No newline at end of file diff --git a/photoview/src/main/java/com/github/chrisbanes/photoview/CustomGestureDetector.java b/photoview/src/main/java/com/github/chrisbanes/photoview/CustomGestureDetector.java index 822754ff..aea97a7b 100755 --- a/photoview/src/main/java/com/github/chrisbanes/photoview/CustomGestureDetector.java +++ b/photoview/src/main/java/com/github/chrisbanes/photoview/CustomGestureDetector.java @@ -48,6 +48,7 @@ class CustomGestureDetector { mListener = listener; ScaleGestureDetector.OnScaleGestureListener mScaleListener = new ScaleGestureDetector.OnScaleGestureListener() { + private float lastFocusX, lastFocusY = 0; @Override public boolean onScale(ScaleGestureDetector detector) { @@ -58,13 +59,21 @@ public boolean onScale(ScaleGestureDetector detector) { if (scaleFactor >= 0) { mListener.onScale(scaleFactor, - detector.getFocusX(), detector.getFocusY()); + detector.getFocusX(), + detector.getFocusY(), + detector.getFocusX() - lastFocusX, + detector.getFocusY() - lastFocusY + ); + lastFocusX = detector.getFocusX(); + lastFocusY = detector.getFocusY(); } return true; } @Override public boolean onScaleBegin(ScaleGestureDetector detector) { + lastFocusX = detector.getFocusX(); + lastFocusY = detector.getFocusY(); return true; } diff --git a/photoview/src/main/java/com/github/chrisbanes/photoview/OnGestureListener.java b/photoview/src/main/java/com/github/chrisbanes/photoview/OnGestureListener.java index f7722af2..37caf68f 100644 --- a/photoview/src/main/java/com/github/chrisbanes/photoview/OnGestureListener.java +++ b/photoview/src/main/java/com/github/chrisbanes/photoview/OnGestureListener.java @@ -24,4 +24,5 @@ void onFling(float startX, float startY, float velocityX, void onScale(float scaleFactor, float focusX, float focusY); + void onScale(float scaleFactor, float focusX, float focusY, float dx, float dy); } \ No newline at end of file diff --git a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java index f8494d41..55965b81 100644 --- a/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java +++ b/photoview/src/main/java/com/github/chrisbanes/photoview/PhotoViewAttacher.java @@ -144,11 +144,17 @@ public void onFling(float startX, float startY, float velocityX, float velocityY @Override public void onScale(float scaleFactor, float focusX, float focusY) { + onScale(scaleFactor, focusX, focusY, 0, 0); + } + + @Override + public void onScale(float scaleFactor, float focusX, float focusY, float dx, float dy) { if (getScale() < mMaxScale || scaleFactor < 1f) { if (mScaleChangeListener != null) { mScaleChangeListener.onScaleChange(scaleFactor, focusX, focusY); } mSuppMatrix.postScale(scaleFactor, scaleFactor, focusX, focusY); + mSuppMatrix.postTranslate(dx, dy); checkAndDisplayMatrix(); } } diff --git a/sample/build.gradle b/sample/build.gradle index a55f874f..312566d9 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -1,27 +1,43 @@ -apply plugin: 'com.android.application' +apply plugin: "com.android.application" + +apply plugin: "kotlin-android" android { compileSdkVersion rootProject.ext.sdkVersion defaultConfig { applicationId "uk.co.senab.photoview.sample" - minSdkVersion 14 + minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.sdkVersion versionCode 100 versionName "1.0" } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + lintOptions { abortOnError false } } +tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions { + jvmTarget = "1.8" + } +} + dependencies { - implementation "androidx.appcompat:appcompat:1.0.0" - implementation "androidx.recyclerview:recyclerview:1.0.0" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "androidx.appcompat:appcompat:1.1.0" + implementation "androidx.recyclerview:recyclerview:1.1.0" - implementation "com.google.android.material:material:1.0.0" + implementation "com.google.android.material:material:1.1.0" - implementation 'com.squareup.picasso:picasso:2.5.2' + implementation "com.squareup.picasso:picasso:2.5.2" + implementation("io.coil-kt:coil:0.9.1") - implementation project(':photoview') + implementation project(":photoview") } diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index bd813a3f..3d1b9431 100755 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -1,4 +1,5 @@ @@ -8,7 +9,8 @@ android:fullBackupContent="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> @@ -26,6 +28,8 @@ + + diff --git a/sample/src/main/java/com/github/chrisbanes/photoview/sample/CoilSampleActivity.kt b/sample/src/main/java/com/github/chrisbanes/photoview/sample/CoilSampleActivity.kt new file mode 100644 index 00000000..8af2f3f8 --- /dev/null +++ b/sample/src/main/java/com/github/chrisbanes/photoview/sample/CoilSampleActivity.kt @@ -0,0 +1,19 @@ +package com.github.chrisbanes.photoview.sample + +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import coil.api.load +import com.github.chrisbanes.photoview.PhotoView + +class CoilSampleActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_simple) + + val photoView = findViewById(R.id.iv_photo) + photoView.load("https://images.unsplash.com/photo-1577643816920-65b43ba99fba?ixlib=rb-1.2.1&auto=format&fit=crop&w=3300&q=80") { + crossfade(true) + } + } +} diff --git a/sample/src/main/java/com/github/chrisbanes/photoview/sample/LauncherActivity.java b/sample/src/main/java/com/github/chrisbanes/photoview/sample/LauncherActivity.java index 73e7a9a8..b987c881 100755 --- a/sample/src/main/java/com/github/chrisbanes/photoview/sample/LauncherActivity.java +++ b/sample/src/main/java/com/github/chrisbanes/photoview/sample/LauncherActivity.java @@ -35,6 +35,7 @@ public class LauncherActivity extends AppCompatActivity { "ViewPager Sample", "Rotation Sample", "Picasso Sample", + "Coil Sample", "Activity Transition Sample", "Immersive Sample" }; @@ -55,35 +56,35 @@ private static class ItemAdapter extends RecyclerView.Adapter { @Override public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final ItemViewHolder holder = ItemViewHolder.newInstance(parent); - holder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - Class clazz; - - switch (holder.getAdapterPosition()) { - default: - case 0: - clazz = SimpleSampleActivity.class; - break; - case 1: - clazz = ViewPagerActivity.class; - break; - case 2: - clazz = RotationSampleActivity.class; - break; - case 3: - clazz = PicassoSampleActivity.class; - break; - case 4: - clazz = ActivityTransitionActivity.class; - break; - case 5: - clazz = ImmersiveActivity.class; - } - - Context context = holder.itemView.getContext(); - context.startActivity(new Intent(context, clazz)); + holder.itemView.setOnClickListener(v -> { + Class clazz; + + switch (holder.getAdapterPosition()) { + default: + case 0: + clazz = SimpleSampleActivity.class; + break; + case 1: + clazz = ViewPagerActivity.class; + break; + case 2: + clazz = RotationSampleActivity.class; + break; + case 3: + clazz = PicassoSampleActivity.class; + break; + case 4: + clazz = CoilSampleActivity.class; + break; + case 5: + clazz = ActivityTransitionActivity.class; + break; + case 6: + clazz = ImmersiveActivity.class; } + + Context context = holder.itemView.getContext(); + context.startActivity(new Intent(context, clazz)); }); return holder; } diff --git a/sample/src/main/java/com/github/chrisbanes/photoview/sample/PicassoSampleActivity.java b/sample/src/main/java/com/github/chrisbanes/photoview/sample/PicassoSampleActivity.java index 32e29e30..66a78e47 100644 --- a/sample/src/main/java/com/github/chrisbanes/photoview/sample/PicassoSampleActivity.java +++ b/sample/src/main/java/com/github/chrisbanes/photoview/sample/PicassoSampleActivity.java @@ -17,7 +17,7 @@ protected void onCreate(Bundle savedInstanceState) { final PhotoView photoView = findViewById(R.id.iv_photo); Picasso.with(this) - .load("http://pbs.twimg.com/media/Bist9mvIYAAeAyQ.jpg") + .load("https://images.unsplash.com/photo-1577643816920-65b43ba99fba?ixlib=rb-1.2.1&auto=format&fit=crop&w=3300&q=80") .into(photoView); } }