replace SubsamplingImageView with PhotoView

This commit is contained in:
tibbi 2016-06-23 11:12:51 +02:00
parent 63d2d8b30b
commit 28ab32a3ad
7 changed files with 50 additions and 28 deletions

View file

@ -32,8 +32,8 @@ dependencies {
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0' compile 'com.android.support:design:23.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.5.0'
compile 'com.jakewharton:butterknife:8.0.1' compile 'com.jakewharton:butterknife:8.0.1'
compile 'com.github.chrisbanes:PhotoView:1.2.6'
apt 'com.jakewharton:butterknife-compiler:8.0.1' apt 'com.jakewharton:butterknife-compiler:8.0.1'
} }

View file

@ -24,9 +24,9 @@ public class LicenseActivity extends AppCompatActivity {
openUrl(R.string.butterknife_url); openUrl(R.string.butterknife_url);
} }
@OnClick(R.id.license_subsampling_title) @OnClick(R.id.license_photoview_title)
public void subsamplingClicked() { public void photoViewClicked() {
openUrl(R.string.subsampling_url); openUrl(R.string.photoview_url);
} }
private void openUrl(int id) { private void openUrl(int id) {

View file

@ -1,17 +1,21 @@
package com.simplemobiletools.gallery.fragments; package com.simplemobiletools.gallery.fragments;
import android.animation.ObjectAnimator;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.davemorrissey.labs.subscaleview.ImageSource; import com.bumptech.glide.Glide;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.bumptech.glide.request.animation.ViewPropertyAnimation;
import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.Constants;
import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.R;
import com.simplemobiletools.gallery.models.Medium; import com.simplemobiletools.gallery.models.Medium;
public class PhotoFragment extends ViewPagerFragment implements View.OnClickListener { import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;
public class PhotoFragment extends ViewPagerFragment implements PhotoViewAttacher.OnPhotoTapListener {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -21,28 +25,28 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
if (medium == null) if (medium == null)
return view; return view;
final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view.findViewById(R.id.photo_view); final PhotoView photoView = (PhotoView) view.findViewById(R.id.photo_view);
imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF); Glide.with(getContext()).load(medium.getPath()).asBitmap().thumbnail(0.2f).animate(fadeInAnimator).into(photoView);
imageView.setImage(ImageSource.uri(medium.getPath())); new PhotoViewAttacher(photoView).setOnPhotoTapListener(this);
imageView.setMaxScale(5f);
imageView.setOnClickListener(this);
return view; return view;
} }
ViewPropertyAnimation.Animator fadeInAnimator = new ViewPropertyAnimation.Animator() {
@Override
public void animate(View view) {
view.setAlpha(0f);
ObjectAnimator fadeAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
fadeAnim.setDuration(250);
fadeAnim.start();
}
};
@Override @Override
public void onSaveInstanceState(Bundle outState) { public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
} }
@Override
public void onClick(View v) {
if (mListener == null)
mListener = (FragmentClickListener) getActivity();
mListener.fragmentClicked();
}
@Override @Override
public void itemDragged() { public void itemDragged() {
@ -52,4 +56,21 @@ public class PhotoFragment extends ViewPagerFragment implements View.OnClickList
public void systemUiVisibilityChanged(boolean toFullscreen) { public void systemUiVisibilityChanged(boolean toFullscreen) {
} }
@Override
public void onPhotoTap(View view, float v, float v1) {
photoClicked();
}
@Override
public void onOutsidePhotoTap() {
photoClicked();
}
private void photoClicked() {
if (mListener == null)
mListener = (FragmentClickListener) getActivity();
mListener.fragmentClicked();
}
} }

View file

@ -32,18 +32,18 @@
android:text="@string/butterknife_text"/> android:text="@string/butterknife_text"/>
<TextView <TextView
android:id="@+id/license_subsampling_title" android:id="@+id/license_photoview_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin" android:paddingTop="@dimen/activity_margin"
android:text="@string/subsampling_title" android:text="@string/photoview_title"
android:textColor="@color/colorPrimary"/> android:textColor="@color/colorPrimary"/>
<TextView <TextView
android:id="@+id/license_subsampling_text" android:id="@+id/license_photoview_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/subsampling_text"/> android:text="@string/photoview_text"/>
<TextView <TextView
android:id="@+id/license_glide_title" android:id="@+id/license_glide_title"

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView <uk.co.senab.photoview.PhotoView
android:id="@+id/photo_view" android:id="@+id/photo_view"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -46,9 +46,9 @@
<string name="butterknife_title"><u>Butter Knife (view injector)</u></string> <string name="butterknife_title"><u>Butter Knife (view injector)</u></string>
<string name="butterknife_text">Copyright 2013 Jake Wharton\n\nLicensed 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\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless 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.</string> <string name="butterknife_text">Copyright 2013 Jake Wharton\n\nLicensed 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\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless 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.</string>
<string name="butterknife_url">https://github.com/JakeWharton/butterknife</string> <string name="butterknife_url">https://github.com/JakeWharton/butterknife</string>
<string name="subsampling_title"><u>Subsampling Scale Image View (zoomable imageviews)</u></string> <string name="photoview_title"><u>PhotoView (zoomable imageviews)</u></string>
<string name="subsampling_text">Copyright 2016 davemorrissey\n\nLicensed 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\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless 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.</string> <string name="photoview_text">Copyright 2011,2012 Chris Banes\n\nLicensed 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\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless 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.</string>
<string name="subsampling_url">https://github.com/davemorrissey/subsampling-scale-image-view</string> <string name="photoview_url">https://github.com/chrisbanes/PhotoView</string>
<string name="glide_title"><u>Glide (image loading and caching)</u></string> <string name="glide_title"><u>Glide (image loading and caching)</u></string>
<string name="glide_text">Copyright 2014 Google, Inc. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</string> <string name="glide_text">Copyright 2014 Google, Inc. All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY GOOGLE, INC. ``AS IS\'\' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</string>
<string name="glide_url">https://github.com/bumptech/glide</string> <string name="glide_url">https://github.com/bumptech/glide</string>

View file

@ -16,6 +16,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
jcenter() jcenter()
maven { url "https://jitpack.io" }
} }
} }