CAG v5.7.4版本的 MD5 值为:bc57ead76a7a30559f0708e9d60d749f
以下内容为反编译后的 MZBannerView.java 源代码,内容仅作参考
package com.zhouwei.mzbanner;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Handler;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Scroller;
import android.widget.TextView;
import androidx.viewpager.widget.ViewPager;
import d.c.a.j.v;
import d.c.a.j.z;
import d.c.f.d0.j;
import i.c.a.c.n0;
import i.c.a.c.y;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import n.e;
import n.i.a.l;
import n.i.b.h;
import org.godfootsteps.arch.R$dimen;
import org.godfootsteps.arch.R$fraction;
import org.godfootsteps.arch.R$styleable;
import org.godfootsteps.arch.api.AppClient;
import org.godfootsteps.arch.api.model.HomeNormalModel;
import org.godfootsteps.arch.customSystemViews.CustomThumbnailView;
import org.godfootsteps.arch.videoApi.VideoClient;
import org.godfootsteps.home.R$drawable;
import org.godfootsteps.home.R$id;
import org.godfootsteps.home.R$layout;
import org.godfootsteps.home.viewholder.MZBannerVH;
public class MZBannerView<T> extends RelativeLayout {
public ViewPager.j A;
public b B;
public Handler C;
public boolean D;
public final Runnable E;
public CustomViewPager f4281i;
public MZPagerAdapter f4282j;
public List<T> f4283k;
public boolean f4284l;
public int f4285m;
public int f4286n;
public c f4287o;
public boolean f4288p;
public boolean f4289q;
public LinearLayout f4290r;
public ArrayList<ImageView> f4291s;
public int[] f4292t;
public int f4293u;
public int f4294v;
public int f4295w;
public int x;
public int y;
public int z;
public enum IndicatorAlign {
LEFT,
CENTER,
RIGHT
}
public static class MZPagerAdapter<T> extends e.g0.a.a {
public List<T> a;
public j b;
public ViewPager c;
public boolean f4297d;
public b f4298e;
public MZPagerAdapter(List<T> list, j jVar, boolean z) {
if (this.a == null) {
this.a = new ArrayList();
}
for (T t2 : list) {
this.a.add(t2);
}
this.b = jVar;
this.f4297d = z;
}
public final int a() {
List<T> list = this.a;
if (list == null) {
return 0;
}
return list.size();
}
@Override
public void destroyItem(ViewGroup viewGroup, int i2, Object obj) {
viewGroup.removeView((View) obj);
}
@Override
public void finishUpdate(ViewGroup viewGroup) {
if (this.f4297d && this.c.getCurrentItem() == getCount() - 1) {
try {
this.c.setCurrentItem(0, false);
} catch (IllegalStateException e2) {
e2.printStackTrace();
}
}
}
@Override
public int getCount() {
return this.f4297d ? a() * 500 : a();
}
@Override
public Object instantiateItem(ViewGroup viewGroup, int i2) {
int a = i2 % a();
MZBannerVH mZBannerVH = this.b.a;
int i3 = MZBannerVH.f15894m;
h.e(mZBannerVH, "this$0");
final MZBannerVH.a aVar = new MZBannerVH.a(mZBannerVH);
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R$layout.item_banner, (ViewGroup) null);
aVar.a = (CustomThumbnailView) inflate.findViewById(R$id.banner_image);
aVar.b = (TextView) inflate.findViewById(R$id.tv_banner_date);
aVar.c = (TextView) inflate.findViewById(R$id.tv_banner_title);
aVar.f15897d = (TextView) inflate.findViewById(R$id.tv_banner_tag);
h.d(inflate, "view");
List<T> list = this.a;
if (list != null && list.size() > 0) {
Context context = viewGroup.getContext();
List<T> list2 = this.a;
HomeNormalModel.ListBean listBean = list2 != null ? (HomeNormalModel.ListBean) list2.get(a) : null;
h.c(context);
boolean z = true;
final float fraction = context.getResources().getFraction(R$fraction.news_banner_width_percent, 1, 1) * y.f0();
if (listBean != null) {
MZBannerVH mZBannerVH2 = aVar.f15898e;
if (h.a(listBean.getType(), "video")) {
VideoClient.a.a(listBean.getVideoId(), new l<String, e>() {
{
super(1);
}
@Override
public e invoke(String str) {
invoke2(str);
return e.a;
}
public final void invoke2(String str) {
h.e(str, "url");
CustomThumbnailView customThumbnailView = MZBannerVH.a.this.a;
if (customThumbnailView == null) {
return;
}
int i4 = R$drawable.ic_video_default;
float f2 = fraction;
customThumbnailView.e(str, i4, (r14 & 4) != 0 ? -1 : (int) f2, (r14 & 8) != 0 ? -1 : (int) ((f2 * 9) / 16), (r14 & 16) != 0 ? false : false);
}
}, true);
} else {
CustomThumbnailView customThumbnailView = aVar.a;
if (customThumbnailView != null) {
StringBuilder sb = new StringBuilder();
Objects.requireNonNull(AppClient.a);
sb.append("https://appservercn.kingdomsalvation.org");
sb.append(mZBannerVH2.f15895k);
sb.append("hd/");
sb.append(listBean.getImage());
customThumbnailView.e(sb.toString(), R$drawable.ic_placeholder_16_9, (int) fraction, (int) ((fraction * 9) / 16), true);
}
}
TextView textView = aVar.f15897d;
if (textView != null) {
textView.setText(listBean.getTag());
}
String tag = listBean.getTag();
if (tag != null && tag.length() != 0) {
z = false;
}
if (z) {
TextView textView2 = aVar.f15897d;
if (textView2 != null) {
n0.q(textView2, 0);
n0.b(textView2, false);
}
TextView textView3 = aVar.b;
if (textView3 != null) {
n0.m(textView3, y.E(0.0f));
}
} else {
TextView textView4 = aVar.f15897d;
if (textView4 != null) {
n0.q(textView4, y.E(8.0f));
n0.t(textView4);
}
TextView textView5 = aVar.b;
if (textView5 != null) {
n0.m(textView5, y.E(8.0f));
}
}
TextView textView6 = aVar.b;
if (textView6 != null) {
textView6.setText(z.b(listBean.getDate()));
}
TextView textView7 = aVar.c;
if (textView7 != null) {
textView7.setText(listBean.getTitle());
}
}
}
inflate.setOnClickListener(new i.a0.a.b(this, a));
viewGroup.addView(inflate);
return inflate;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
}
public class a implements Runnable {
public a() {
}
@Override
public void run() {
MZBannerView mZBannerView = MZBannerView.this;
if (mZBannerView.f4284l) {
mZBannerView.f4285m = mZBannerView.f4281i.getCurrentItem();
MZBannerView mZBannerView2 = MZBannerView.this;
int i2 = mZBannerView2.f4285m + 1;
mZBannerView2.f4285m = i2;
if (i2 == mZBannerView2.f4282j.getCount() - 1) {
MZBannerView mZBannerView3 = MZBannerView.this;
mZBannerView3.f4285m = 0;
mZBannerView3.f4281i.setCurrentItem(0, false);
MZBannerView mZBannerView4 = MZBannerView.this;
mZBannerView4.C.postDelayed(this, mZBannerView4.f4286n);
return;
}
MZBannerView mZBannerView5 = MZBannerView.this;
mZBannerView5.f4281i.setCurrentItem(mZBannerView5.f4285m);
MZBannerView mZBannerView6 = MZBannerView.this;
mZBannerView6.C.postDelayed(this, mZBannerView6.f4286n);
}
}
}
public interface b {
}
public static class c extends Scroller {
public int a;
public boolean b;
public c(Context context) {
super(context);
this.a = 800;
this.b = false;
}
@Override
public void startScroll(int i2, int i3, int i4, int i5) {
super.startScroll(i2, i3, i4, i5, this.a);
}
@Override
public void startScroll(int i2, int i3, int i4, int i5, int i6) {
if (!this.b) {
i6 = this.a;
}
super.startScroll(i2, i3, i4, i5, i6);
}
}
public MZBannerView(Context context) {
super(context);
this.f4284l = true;
this.f4285m = 0;
this.f4286n = 4000;
this.f4288p = true;
this.f4289q = true;
this.f4291s = new ArrayList<>();
this.f4292t = new int[]{org.godfootsteps.arch.R$drawable.indicator_normal, org.godfootsteps.arch.R$drawable.indicator_selected};
this.f4293u = 0;
this.f4294v = 0;
this.f4295w = 0;
this.x = 0;
this.y = 0;
this.z = 1;
this.C = new Handler();
this.D = true;
this.E = new a();
b();
}
public static int a(int i2) {
return (int) TypedValue.applyDimension(1, i2, Resources.getSystem().getDisplayMetrics());
}
public void addPageChangeLisnter(ViewPager.j jVar) {
this.A = jVar;
}
public final void b() {
View inflate;
int a2;
if (this.f4288p) {
inflate = LayoutInflater.from(getContext()).inflate(org.godfootsteps.arch.R$layout.mz_banner_effect_layout, (ViewGroup) this, true);
} else {
inflate = LayoutInflater.from(getContext()).inflate(org.godfootsteps.arch.R$layout.mz_banner_normal_layout, (ViewGroup) this, true);
}
this.f4290r = (LinearLayout) inflate.findViewById(org.godfootsteps.arch.R$id.banner_indicator_container);
CustomViewPager customViewPager = (CustomViewPager) inflate.findViewById(org.godfootsteps.arch.R$id.mzbanner_vp);
this.f4281i = customViewPager;
customViewPager.setClipToPadding(false);
d();
if (v.i()) {
a2 = y.z0() ? a(16) : a(24);
} else {
a2 = a(8);
}
this.f4281i.setPageMargin(a2);
this.y = a(30);
try {
Field declaredField = ViewPager.class.getDeclaredField("mScroller");
declaredField.setAccessible(true);
c cVar = new c(this.f4281i.getContext());
this.f4287o = cVar;
declaredField.set(this.f4281i, cVar);
} catch (IllegalAccessException e2) {
e2.printStackTrace();
} catch (IllegalArgumentException e3) {
e3.printStackTrace();
} catch (NoSuchFieldException e4) {
e4.printStackTrace();
}
int i2 = this.z;
if (i2 == 0) {
setIndicatorAlign(IndicatorAlign.LEFT);
} else if (i2 == 1) {
setIndicatorAlign(IndicatorAlign.CENTER);
} else {
setIndicatorAlign(IndicatorAlign.RIGHT);
}
setClickable(true);
}
public final void c(Context context, AttributeSet attributeSet) {
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.MZBannerView);
this.f4288p = obtainStyledAttributes.getBoolean(R$styleable.MZBannerView_open_mz_mode, true);
this.D = obtainStyledAttributes.getBoolean(R$styleable.MZBannerView_middle_page_cover, true);
this.f4289q = obtainStyledAttributes.getBoolean(R$styleable.MZBannerView_canLoop, true);
this.z = obtainStyledAttributes.getInt(R$styleable.MZBannerView_indicatorAlign, 1);
this.f4293u = obtainStyledAttributes.getDimensionPixelSize(R$styleable.MZBannerView_indicatorPaddingLeft, 0);
this.f4294v = obtainStyledAttributes.getDimensionPixelSize(R$styleable.MZBannerView_indicatorPaddingRight, 0);
this.f4295w = obtainStyledAttributes.getDimensionPixelSize(R$styleable.MZBannerView_indicatorPaddingTop, 0);
this.x = obtainStyledAttributes.getDimensionPixelSize(R$styleable.MZBannerView_indicatorPaddingBottom, 8);
obtainStyledAttributes.recycle();
}
public void d() {
int L = ((y.L() - ((int) (getContext().getResources().getFraction(R$fraction.news_banner_width_percent, 1, 1) * y.L()))) - (((int) getContext().getResources().getDimension(R$dimen.dp0_32_x)) * 2)) / 2;
a(8);
this.f4281i.setPadding(L, 0, L, 0);
this.f4290r.setPadding(L, 0, L, 0);
}
@Override
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
if (!this.f4289q) {
return super.dispatchTouchEvent(motionEvent);
}
int action = motionEvent.getAction();
if (action != 0) {
if (action != 1) {
if (action != 2) {
if (action != 3) {
}
}
}
this.C.removeCallbacks(this.E);
this.C.postDelayed(this.E, this.f4286n);
return super.dispatchTouchEvent(motionEvent);
}
this.C.removeCallbacks(this.E);
return super.dispatchTouchEvent(motionEvent);
}
public int getDuration() {
return this.f4287o.a;
}
public ViewPager getViewPager() {
return this.f4281i;
}
public void setBannerPageClickListener(b bVar) {
this.B = bVar;
}
public void setDelayedTime(int i2) {
this.f4286n = i2;
}
public void setDuration(int i2) {
this.f4287o.a = i2;
}
public void setIndicatorAlign(IndicatorAlign indicatorAlign) {
this.z = indicatorAlign.ordinal();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.f4290r.getLayoutParams();
if (indicatorAlign == IndicatorAlign.LEFT) {
layoutParams.addRule(9);
} else if (indicatorAlign == IndicatorAlign.RIGHT) {
layoutParams.addRule(11);
} else {
layoutParams.addRule(14);
}
layoutParams.setMargins(0, this.f4295w, 0, this.x);
this.f4290r.setLayoutParams(layoutParams);
}
public void setIndicatorVisible(boolean z) {
if (z) {
this.f4290r.setVisibility(0);
} else {
this.f4290r.setVisibility(8);
}
}
public void setUseDefaultDuration(boolean z) {
this.f4287o.b = z;
}
public MZBannerView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.f4284l = true;
this.f4285m = 0;
this.f4286n = 4000;
this.f4288p = true;
this.f4289q = true;
this.f4291s = new ArrayList<>();
this.f4292t = new int[]{org.godfootsteps.arch.R$drawable.indicator_normal, org.godfootsteps.arch.R$drawable.indicator_selected};
this.f4293u = 0;
this.f4294v = 0;
this.f4295w = 0;
this.x = 0;
this.y = 0;
this.z = 1;
this.C = new Handler();
this.D = true;
this.E = new a();
c(context, attributeSet);
b();
}
public MZBannerView(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
this.f4284l = true;
this.f4285m = 0;
this.f4286n = 4000;
this.f4288p = true;
this.f4289q = true;
this.f4291s = new ArrayList<>();
this.f4292t = new int[]{org.godfootsteps.arch.R$drawable.indicator_normal, org.godfootsteps.arch.R$drawable.indicator_selected};
this.f4293u = 0;
this.f4294v = 0;
this.f4295w = 0;
this.x = 0;
this.y = 0;
this.z = 1;
this.C = new Handler();
this.D = true;
this.E = new a();
c(context, attributeSet);
b();
}
}