Add normal preview support
This commit is contained in:
1 parent
6659fefc21
commit
2c4daa447e
15 files changed
+380
-158
No files matched your search
@@ -34,6 +34,7 @@ import com.hippo.conaco.ConacoTask;
|
||||
import com.hippo.conaco.DataContainer;
|
||||
import com.hippo.conaco.Unikery;
|
||||
import com.hippo.conaco.ValueHolder;
|
||||
import com.hippo.drawable.PreciselyClipDrawable;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
@@ -49,6 +50,11 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
private DataContainer mContainer;
|
||||
private boolean mUseNetwork;
|
||||
|
||||
private int mOffsetX = Integer.MIN_VALUE;
|
||||
private int mOffsetY = Integer.MIN_VALUE;
|
||||
private int mClipWidth = Integer.MIN_VALUE;
|
||||
private int mClipHeight = Integer.MIN_VALUE;
|
||||
|
||||
private ValueHolder<Bitmap> mHolder;
|
||||
|
||||
private boolean mFailed;
|
||||
@@ -152,6 +158,20 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
load(key, url, null, true);
|
||||
}
|
||||
|
||||
public void setClip(int offsetX, int offsetY, int clipWidth, int clipHeight) {
|
||||
mOffsetX = offsetX;
|
||||
mOffsetY = offsetY;
|
||||
mClipWidth = clipWidth;
|
||||
mClipHeight = clipHeight;
|
||||
}
|
||||
|
||||
public void resetClip() {
|
||||
mOffsetX = Integer.MIN_VALUE;
|
||||
mOffsetY = Integer.MIN_VALUE;
|
||||
mClipWidth = Integer.MIN_VALUE;
|
||||
mClipHeight = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
public void load(String key, String url, boolean useNetwork) {
|
||||
load(key, url, null, useNetwork);
|
||||
}
|
||||
@@ -252,6 +272,10 @@ public class LoadImageView extends FixedAspectImageView implements Unikery<Bitma
|
||||
Bitmap bitmap = holder.getValue();
|
||||
Drawable drawable = new BitmapDrawable(getResources(), bitmap);
|
||||
|
||||
if (Integer.MIN_VALUE != mOffsetX) {
|
||||
drawable = new PreciselyClipDrawable(drawable, mOffsetX, mOffsetY, mClipWidth, mClipHeight);
|
||||
}
|
||||
|
||||
if ((source == Conaco.Source.DISK || source == Conaco.Source.NETWORK)) {
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = new ColorDrawable(Color.TRANSPARENT);
|
||||
|
||||
Reference in new issue
Block a user