|
@ -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() |
|
|
|
|
|
.error(R.drawable.ic_file_not_found) |
|
|
|
|
|
.listener(new RequestListener<Drawable>() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { |
|
|
|
|
|
photoView.setZoomable(false); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { |
|
|
|
|
|
photoView.setOnLongClickListener(v -> { |
|
|
|
|
|
ImageDownloadDialogBuilder imageDownloadDialogBuilder = new ImageDownloadDialogBuilder(context, imageURL); |
|
|
|
|
|
imageDownloadDialogBuilder.show(); |
|
|
|
|
|
return false; |
|
|
|
|
|
}); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
.into(photoView); |
|
|
.into(photoView); |
|
|
|
|
|
|
|
|
builder.addContentView(photoView, new ViewGroup.LayoutParams( |
|
|
builder.addContentView(photoView, new ViewGroup.LayoutParams( |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
ViewGroup.LayoutParams.MATCH_PARENT)); |
|
|
ViewGroup.LayoutParams.MATCH_PARENT)); |
|
|
builder.show(); |
|
|
builder.show(); |
|
|
|
|
|
|
|
|
photoView.setOnLongClickListener(v -> { |
|
|
|
|
|
ImageDownloadDialogBuilder imageDownloadDialogBuilder = new ImageDownloadDialogBuilder(context, imageURL); |
|
|
|
|
|
imageDownloadDialogBuilder.show(); |
|
|
|
|
|
return false; |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|