工作空间 v3.7.4.6版本的 MD5 值为:94c1c0052e9f2e949ae1349e6caf437b
以下内容为反编译后的 NSViewPageAdapter.java 源代码,内容仅作参考
package imageshow;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Base64;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.RequiresApi;
import androidx.viewpager.widget.PagerAdapter;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.q;
import com.bumptech.glide.request.g;
import com.uusafe.im.base.popwindow.PopItemAction;
import com.uusafe.im.base.popwindow.PopWindow;
import com.uusafe.mbs.imageselector.R;
import com.xiaomi.mipush.sdk.Constants;
import java.io.File;
import java.lang.ref.SoftReference;
import java.util.List;
import photoview.NSPhotoView;
public class NSViewPageAdapter extends PagerAdapter {
static g f7670a = new g().skipMemoryCache(true).override(Integer.MIN_VALUE, Integer.MIN_VALUE).diskCacheStrategy(q.f2606d);
private Context f7671b;
private b f7672c;
private List<String> f7673d;
private SparseArray<SoftReference<View>> f7674e;
private a f;
public interface a {
void a(String str);
}
public NSViewPageAdapter(Context context, b bVar) {
this.f7671b = context;
this.f7672c = bVar;
this.f7673d = bVar.c();
this.f7674e = new SparseArray<>(this.f7673d.size());
}
@Override
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
viewGroup.removeView((View) obj);
}
@Override
public int getCount() {
return this.f7673d.size();
}
@Override
public Object instantiateItem(ViewGroup viewGroup, int i) {
g gVar = null;
View view = this.f7674e.get(i) != null ? this.f7674e.get(i).get() : null;
if (view == null) {
view = LayoutInflater.from(this.f7671b).inflate(R.layout.imagesshow_photoview, viewGroup, false);
view.setTag(Integer.valueOf(i));
NSPhotoView nSPhotoView = (NSPhotoView) view.findViewById(R.id.ns_sdk_imagesshow_photoview);
String str = this.f7673d.get(i);
boolean a2 = a(str);
if (this.f7672c.b() == 0) {
gVar = new g().skipMemoryCache(true).override(Integer.MIN_VALUE, Integer.MIN_VALUE).encodeFormat(Bitmap.CompressFormat.PNG).encodeQuality(100).diskCacheStrategy(q.f2604b).format(DecodeFormat.PREFER_RGB_565).disallowHardwareConfig();
} else if (this.f7672c.b() == 1) {
gVar = new g().override(Integer.MIN_VALUE, Integer.MIN_VALUE).encodeFormat(Bitmap.CompressFormat.PNG).diskCacheStrategy(q.f2604b).encodeQuality(100).format(DecodeFormat.PREFER_RGB_565).disallowHardwareConfig();
}
if (a2) {
str = str.split(Constants.ACCEPT_TIME_SEPARATOR_SP)[1];
byte[] decode = Base64.decode(str, 0);
if (gVar != null) {
com.bumptech.glide.c.c(this.f7671b).mo27load(decode).apply((com.bumptech.glide.request.a<?>) gVar).into(nSPhotoView);
}
} else if (gVar != null) {
com.bumptech.glide.c.c(this.f7671b).mo25load(str).apply((com.bumptech.glide.request.a<?>) gVar).into(nSPhotoView);
}
nSPhotoView.setOnClickListener(new c(this));
nSPhotoView.setOnLongClickListener(new d(this, i, str, a2));
this.f7674e.put(i, new SoftReference<>(view));
}
viewGroup.addView(view);
return view;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
public void setOnImageLongClickListener(a aVar) {
this.f = aVar;
}
public static boolean a(String str) {
return !TextUtils.isEmpty(str) && str.startsWith("data:image");
}
public void b(String str, boolean z) {
new PopWindow.Builder((Activity) this.f7671b).setStyle(PopWindow.PopWindowStyle.PopUp).addItemAction(new PopItemAction("保存", PopItemAction.PopItemStyle.Normal, new e(this, str, z))).addItemAction(new PopItemAction("取消", PopItemAction.PopItemStyle.Cancel)).create().show();
}
@RequiresApi(api = 24)
public void a(String str, boolean z) {
String str2 = this.f7671b.getPackageName() + ".fileprovider";
if (z) {
byte[] decode = Base64.decode(str, 0);
com.donkingliang.imageselector.c.d.a(this.f7671b, BitmapFactory.decodeByteArray(decode, 0, decode.length), str2);
} else if (new File(str).exists()) {
try {
com.donkingliang.imageselector.c.d.a(this.f7671b, BitmapFactory.decodeFile(str), str2);
} catch (Exception e2) {
e2.printStackTrace();
}
} else {
new Thread(new f(this, str, str2)).start();
}
}
}