|
@ -3,12 +3,20 @@ package gr.thmmy.mthmmy.utils.ui; |
|
|
import android.app.Dialog; |
|
|
import android.app.Dialog; |
|
|
import android.content.Context; |
|
|
import android.content.Context; |
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
|
|
|
import android.graphics.drawable.Drawable; |
|
|
import android.view.ViewGroup; |
|
|
import android.view.ViewGroup; |
|
|
import android.view.Window; |
|
|
import android.view.Window; |
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
|
|
|
|
import com.bumptech.glide.Glide; |
|
|
import com.bumptech.glide.Glide; |
|
|
|
|
|
import com.bumptech.glide.load.DataSource; |
|
|
|
|
|
import com.bumptech.glide.load.engine.GlideException; |
|
|
|
|
|
import com.bumptech.glide.request.RequestListener; |
|
|
|
|
|
import com.bumptech.glide.request.target.Target; |
|
|
import com.github.chrisbanes.photoview.PhotoView; |
|
|
import com.github.chrisbanes.photoview.PhotoView; |
|
|
|
|
|
|
|
|
|
|
|
import gr.thmmy.mthmmy.R; |
|
|
import gr.thmmy.mthmmy.base.BaseApplication; |
|
|
import gr.thmmy.mthmmy.base.BaseApplication; |
|
|
|
|
|
|
|
|
public class PhotoViewUtils { |
|
|
public class PhotoViewUtils { |
|
@ -24,21 +32,32 @@ public class PhotoViewUtils { |
|
|
|
|
|
|
|
|
PhotoView photoView = new PhotoView(context); |
|
|
PhotoView photoView = new PhotoView(context); |
|
|
photoView.setLayoutParams(new ViewGroup.LayoutParams(screenWidth, screenHeight)); |
|
|
photoView.setLayoutParams(new ViewGroup.LayoutParams(screenWidth, screenHeight)); |
|
|
|
|
|
|
|
|
Glide.with(context) |
|
|
Glide.with(context) |
|
|
.load(imageURL) |
|
|
.load(imageURL) |
|
|
.fitCenter() |
|
|
.fitCenter() |
|
|
.into(photoView); |
|
|
.error(R.drawable.ic_file_not_found) |
|
|
|
|
|
.listener(new RequestListener<Drawable>() { |
|
|
builder.addContentView(photoView, new ViewGroup.LayoutParams( |
|
|
@Override |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { |
|
|
ViewGroup.LayoutParams.MATCH_PARENT)); |
|
|
photoView.setZoomable(false); |
|
|
builder.show(); |
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { |
|
|
photoView.setOnLongClickListener(v -> { |
|
|
photoView.setOnLongClickListener(v -> { |
|
|
ImageDownloadDialogBuilder imageDownloadDialogBuilder = new ImageDownloadDialogBuilder(context, imageURL); |
|
|
ImageDownloadDialogBuilder imageDownloadDialogBuilder = new ImageDownloadDialogBuilder(context, imageURL); |
|
|
imageDownloadDialogBuilder.show(); |
|
|
imageDownloadDialogBuilder.show(); |
|
|
return false; |
|
|
return false; |
|
|
}); |
|
|
}); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.into(photoView); |
|
|
|
|
|
|
|
|
|
|
|
builder.addContentView(photoView, new ViewGroup.LayoutParams( |
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT)); |
|
|
|
|
|
builder.show(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|