mirror of
https://github.com/nextcloud/android.git
synced 2024-12-20 16:02:01 +03:00
Fix an issue with pinch to zoom
This commit is contained in:
parent
423252d923
commit
f5c40a1cfa
2 changed files with 30 additions and 2 deletions
|
@ -31,7 +31,8 @@
|
|||
android:id="@+id/top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000000">
|
||||
android:background="#000000"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressWheel"
|
||||
|
@ -49,7 +50,8 @@
|
|||
android:layout_margin="@dimen/zero"
|
||||
android:layout_centerInParent="true"
|
||||
android:contentDescription="@string/preview_image_description"
|
||||
android:src="@drawable/image_fail" />
|
||||
android:src="@drawable/image_fail"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
|
|
|
@ -37,6 +37,7 @@ import android.view.View.OnClickListener;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.R;
|
||||
|
@ -75,6 +76,7 @@ public class PreviewImageFragment extends FileFragment {
|
|||
private TouchImageViewCustom mImageView;
|
||||
private TextView mMessageView;
|
||||
private ProgressBar mProgressWheel;
|
||||
private RelativeLayout mRelativeLayout;
|
||||
|
||||
public Bitmap mBitmap = null;
|
||||
|
||||
|
@ -84,6 +86,8 @@ public class PreviewImageFragment extends FileFragment {
|
|||
|
||||
private LoadBitmapTask mLoadBitmapTask = null;
|
||||
|
||||
private boolean weZoomedAlready;
|
||||
|
||||
|
||||
/**
|
||||
* Public factory method to create a new fragment that previews an image.
|
||||
|
@ -149,8 +153,30 @@ public class PreviewImageFragment extends FileFragment {
|
|||
super.onCreateView(inflater, container, savedInstanceState);
|
||||
View view = inflater.inflate(R.layout.preview_image_fragment, container, false);
|
||||
mImageView = (TouchImageViewCustom) view.findViewById(R.id.image);
|
||||
mRelativeLayout = (RelativeLayout) view.findViewById(R.id.top);
|
||||
mImageView.setVisibility(View.GONE);
|
||||
|
||||
mImageView.setOnTouchImageViewListener(new TouchImageViewCustom.OnTouchImageViewListener() {
|
||||
@Override
|
||||
public void onMove() {
|
||||
if (!weZoomedAlready && mImageView.isZoomed()) {
|
||||
weZoomedAlready = true;
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
|
||||
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
|
||||
mImageView.setLayoutParams(layoutParams);
|
||||
mRelativeLayout.invalidate();
|
||||
} else if (!mImageView.isZoomed()) {
|
||||
weZoomedAlready = false;
|
||||
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
|
||||
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
|
||||
mImageView.setLayoutParams(layoutParams);
|
||||
mRelativeLayout.invalidate();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
view.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
Loading…
Reference in a new issue