Initial commit
This commit is contained in:
563
sources/com/youth/banner/Banner.java
Normal file
563
sources/com/youth/banner/Banner.java
Normal file
@@ -0,0 +1,563 @@
|
||||
package com.youth.banner;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import com.youth.banner.listener.OnBannerClickListener;
|
||||
import com.youth.banner.listener.OnBannerListener;
|
||||
import com.youth.banner.loader.ImageLoaderInterface;
|
||||
import com.youth.banner.view.BannerViewPager;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class Banner extends FrameLayout implements ViewPager.OnPageChangeListener {
|
||||
private List<View> A;
|
||||
private List<ImageView> B;
|
||||
private Context C;
|
||||
private BannerViewPager D;
|
||||
private TextView E;
|
||||
private TextView F;
|
||||
private TextView G;
|
||||
private LinearLayout H;
|
||||
private LinearLayout I;
|
||||
private LinearLayout J;
|
||||
private ImageView K;
|
||||
private ImageLoaderInterface L;
|
||||
private BannerPagerAdapter M;
|
||||
private ViewPager.OnPageChangeListener N;
|
||||
private BannerScroller O;
|
||||
private OnBannerClickListener P;
|
||||
private OnBannerListener Q;
|
||||
private DisplayMetrics R;
|
||||
private WeakHandler S;
|
||||
private final Runnable T;
|
||||
public String a;
|
||||
private int b;
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
private int f;
|
||||
private int g;
|
||||
private int h;
|
||||
private int i;
|
||||
private boolean j;
|
||||
private boolean k;
|
||||
private int l;
|
||||
private int m;
|
||||
private int n;
|
||||
private int o;
|
||||
private int p;
|
||||
private int q;
|
||||
private int r;
|
||||
private int s;
|
||||
private int t;
|
||||
private int u;
|
||||
private int v;
|
||||
private int x;
|
||||
private List<String> y;
|
||||
private List z;
|
||||
|
||||
class BannerPagerAdapter extends PagerAdapter {
|
||||
BannerPagerAdapter() {
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
|
||||
viewGroup.removeView((View) obj);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public int getCount() {
|
||||
return Banner.this.A.size();
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public Object instantiateItem(ViewGroup viewGroup, final int i) {
|
||||
viewGroup.addView((View) Banner.this.A.get(i));
|
||||
View view = (View) Banner.this.A.get(i);
|
||||
if (Banner.this.P != null) {
|
||||
view.setOnClickListener(new View.OnClickListener() { // from class: com.youth.banner.Banner.BannerPagerAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view2) {
|
||||
Log.e(Banner.this.a, "你正在使用旧版点击事件接口,下标是从1开始,为了体验请更换为setOnBannerListener,下标从0开始计算");
|
||||
Banner.this.P.OnBannerClick(i);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Banner.this.Q != null) {
|
||||
view.setOnClickListener(new View.OnClickListener() { // from class: com.youth.banner.Banner.BannerPagerAdapter.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view2) {
|
||||
Banner.this.Q.OnBannerClick(Banner.this.c(i));
|
||||
}
|
||||
});
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object obj) {
|
||||
return view == obj;
|
||||
}
|
||||
}
|
||||
|
||||
public Banner(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
private void setImageList(List<?> list) {
|
||||
if (list == null || list.size() <= 0) {
|
||||
this.K.setVisibility(0);
|
||||
Log.e(this.a, "The image data set is empty.");
|
||||
return;
|
||||
}
|
||||
this.K.setVisibility(8);
|
||||
e();
|
||||
int i = 0;
|
||||
while (i <= this.s + 1) {
|
||||
ImageLoaderInterface imageLoaderInterface = this.L;
|
||||
View createImageView = imageLoaderInterface != null ? imageLoaderInterface.createImageView(this.C) : null;
|
||||
if (createImageView == null) {
|
||||
createImageView = new ImageView(this.C);
|
||||
}
|
||||
setScaleType(createImageView);
|
||||
Object obj = i == 0 ? list.get(this.s - 1) : i == this.s + 1 ? list.get(0) : list.get(i - 1);
|
||||
this.A.add(createImageView);
|
||||
ImageLoaderInterface imageLoaderInterface2 = this.L;
|
||||
if (imageLoaderInterface2 != null) {
|
||||
imageLoaderInterface2.displayImage(this.C, obj, createImageView);
|
||||
} else {
|
||||
Log.e(this.a, "Please set images loader.");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private void setScaleType(View view) {
|
||||
if (view instanceof ImageView) {
|
||||
ImageView imageView = (ImageView) view;
|
||||
switch (this.x) {
|
||||
case 0:
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
break;
|
||||
case 1:
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
break;
|
||||
case 2:
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
break;
|
||||
case 3:
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
break;
|
||||
case 4:
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_END);
|
||||
break;
|
||||
case 5:
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_START);
|
||||
break;
|
||||
case 6:
|
||||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
break;
|
||||
case 7:
|
||||
imageView.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewGroup, android.view.View
|
||||
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
|
||||
if (this.j) {
|
||||
int action = motionEvent.getAction();
|
||||
if (action == 1 || action == 3 || action == 4) {
|
||||
b();
|
||||
} else if (action == 0) {
|
||||
c();
|
||||
}
|
||||
}
|
||||
return super.dispatchTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
ViewPager.OnPageChangeListener onPageChangeListener = this.N;
|
||||
if (onPageChangeListener != null) {
|
||||
onPageChangeListener.onPageScrollStateChanged(i);
|
||||
}
|
||||
if (i == 0) {
|
||||
int i2 = this.t;
|
||||
if (i2 == 0) {
|
||||
this.D.a(this.s, false);
|
||||
return;
|
||||
} else {
|
||||
if (i2 == this.s + 1) {
|
||||
this.D.a(1, false);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (i != 1) {
|
||||
return;
|
||||
}
|
||||
int i3 = this.t;
|
||||
int i4 = this.s;
|
||||
if (i3 == i4 + 1) {
|
||||
this.D.a(1, false);
|
||||
} else if (i3 == 0) {
|
||||
this.D.a(i4, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrolled(int i, float f, int i2) {
|
||||
ViewPager.OnPageChangeListener onPageChangeListener = this.N;
|
||||
if (onPageChangeListener != null) {
|
||||
onPageChangeListener.onPageScrolled(c(i), f, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageSelected(int i) {
|
||||
this.t = i;
|
||||
ViewPager.OnPageChangeListener onPageChangeListener = this.N;
|
||||
if (onPageChangeListener != null) {
|
||||
onPageChangeListener.onPageSelected(c(i));
|
||||
}
|
||||
int i2 = this.g;
|
||||
if (i2 == 1 || i2 == 4 || i2 == 5) {
|
||||
List<ImageView> list = this.B;
|
||||
int i3 = this.v - 1;
|
||||
int i4 = this.s;
|
||||
list.get((i3 + i4) % i4).setImageResource(this.m);
|
||||
List<ImageView> list2 = this.B;
|
||||
int i5 = this.s;
|
||||
list2.get(((i - 1) + i5) % i5).setImageResource(this.l);
|
||||
this.v = i;
|
||||
}
|
||||
if (i == 0) {
|
||||
i = this.s;
|
||||
}
|
||||
if (i > this.s) {
|
||||
i = 1;
|
||||
}
|
||||
int i6 = this.g;
|
||||
if (i6 != 1) {
|
||||
if (i6 == 2) {
|
||||
this.G.setText(i + "/" + this.s);
|
||||
return;
|
||||
}
|
||||
if (i6 != 3) {
|
||||
if (i6 == 4) {
|
||||
this.E.setText(this.y.get(i - 1));
|
||||
return;
|
||||
} else {
|
||||
if (i6 != 5) {
|
||||
return;
|
||||
}
|
||||
this.E.setText(this.y.get(i - 1));
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.F.setText(i + "/" + this.s);
|
||||
this.E.setText(this.y.get(i - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnPageChangeListener(ViewPager.OnPageChangeListener onPageChangeListener) {
|
||||
this.N = onPageChangeListener;
|
||||
}
|
||||
|
||||
public Banner(Context context, AttributeSet attributeSet) {
|
||||
this(context, attributeSet, 0);
|
||||
}
|
||||
|
||||
private void b(Context context, AttributeSet attributeSet) {
|
||||
this.A.clear();
|
||||
a(context, attributeSet);
|
||||
View inflate = LayoutInflater.from(context).inflate(this.n, (ViewGroup) this, true);
|
||||
this.K = (ImageView) inflate.findViewById(R$id.bannerDefaultImage);
|
||||
this.D = (BannerViewPager) inflate.findViewById(R$id.bannerViewPager);
|
||||
this.J = (LinearLayout) inflate.findViewById(R$id.titleView);
|
||||
this.H = (LinearLayout) inflate.findViewById(R$id.circleIndicator);
|
||||
this.I = (LinearLayout) inflate.findViewById(R$id.indicatorInside);
|
||||
this.E = (TextView) inflate.findViewById(R$id.bannerTitle);
|
||||
this.G = (TextView) inflate.findViewById(R$id.numIndicator);
|
||||
this.F = (TextView) inflate.findViewById(R$id.numIndicatorInside);
|
||||
this.K.setImageResource(this.f);
|
||||
f();
|
||||
}
|
||||
|
||||
private void d() {
|
||||
this.B.clear();
|
||||
this.H.removeAllViews();
|
||||
this.I.removeAllViews();
|
||||
for (int i = 0; i < this.s; i++) {
|
||||
ImageView imageView = new ImageView(this.C);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(this.c, this.d);
|
||||
int i2 = this.b;
|
||||
layoutParams.leftMargin = i2;
|
||||
layoutParams.rightMargin = i2;
|
||||
if (i == 0) {
|
||||
imageView.setImageResource(this.l);
|
||||
} else {
|
||||
imageView.setImageResource(this.m);
|
||||
}
|
||||
this.B.add(imageView);
|
||||
int i3 = this.g;
|
||||
if (i3 == 1 || i3 == 4) {
|
||||
this.H.addView(imageView, layoutParams);
|
||||
} else if (i3 == 5) {
|
||||
this.I.addView(imageView, layoutParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void e() {
|
||||
this.A.clear();
|
||||
int i = this.g;
|
||||
if (i == 1 || i == 4 || i == 5) {
|
||||
d();
|
||||
return;
|
||||
}
|
||||
if (i == 3) {
|
||||
this.F.setText("1/" + this.s);
|
||||
return;
|
||||
}
|
||||
if (i == 2) {
|
||||
this.G.setText("1/" + this.s);
|
||||
}
|
||||
}
|
||||
|
||||
private void f() {
|
||||
try {
|
||||
Field declaredField = ViewPager.class.getDeclaredField("j");
|
||||
declaredField.setAccessible(true);
|
||||
this.O = new BannerScroller(this.D.getContext());
|
||||
this.O.a(this.i);
|
||||
declaredField.set(this.D, this.O);
|
||||
} catch (Exception e) {
|
||||
Log.e(this.a, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void g() {
|
||||
int i = this.s > 1 ? 0 : 8;
|
||||
int i2 = this.g;
|
||||
if (i2 == 1) {
|
||||
this.H.setVisibility(i);
|
||||
return;
|
||||
}
|
||||
if (i2 == 2) {
|
||||
this.G.setVisibility(i);
|
||||
return;
|
||||
}
|
||||
if (i2 == 3) {
|
||||
this.F.setVisibility(i);
|
||||
i();
|
||||
} else if (i2 == 4) {
|
||||
this.H.setVisibility(i);
|
||||
i();
|
||||
} else {
|
||||
if (i2 != 5) {
|
||||
return;
|
||||
}
|
||||
this.I.setVisibility(i);
|
||||
i();
|
||||
}
|
||||
}
|
||||
|
||||
private void h() {
|
||||
this.t = 1;
|
||||
if (this.M == null) {
|
||||
this.M = new BannerPagerAdapter();
|
||||
this.D.a((ViewPager.OnPageChangeListener) this);
|
||||
}
|
||||
this.D.setAdapter(this.M);
|
||||
this.D.setFocusable(true);
|
||||
this.D.setCurrentItem(1);
|
||||
int i = this.u;
|
||||
if (i != -1) {
|
||||
this.H.setGravity(i);
|
||||
}
|
||||
if (!this.k || this.s <= 1) {
|
||||
this.D.setScrollable(false);
|
||||
} else {
|
||||
this.D.setScrollable(true);
|
||||
}
|
||||
if (this.j) {
|
||||
b();
|
||||
}
|
||||
}
|
||||
|
||||
private void i() {
|
||||
if (this.y.size() != this.z.size()) {
|
||||
throw new RuntimeException("[Banner] --> The number of titles and images is different");
|
||||
}
|
||||
int i = this.p;
|
||||
if (i != -1) {
|
||||
this.J.setBackgroundColor(i);
|
||||
}
|
||||
int i2 = this.o;
|
||||
if (i2 != -1) {
|
||||
this.J.setLayoutParams(new RelativeLayout.LayoutParams(-1, i2));
|
||||
}
|
||||
int i3 = this.q;
|
||||
if (i3 != -1) {
|
||||
this.E.setTextColor(i3);
|
||||
}
|
||||
int i4 = this.r;
|
||||
if (i4 != -1) {
|
||||
this.E.setTextSize(0, i4);
|
||||
}
|
||||
List<String> list = this.y;
|
||||
if (list == null || list.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.E.setText(this.y.get(0));
|
||||
this.E.setVisibility(0);
|
||||
this.J.setVisibility(0);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
this.S.b(this.T);
|
||||
}
|
||||
|
||||
public Banner(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.a = "banner";
|
||||
this.b = 5;
|
||||
this.g = 1;
|
||||
this.h = 2000;
|
||||
this.i = 800;
|
||||
this.j = true;
|
||||
this.k = true;
|
||||
this.l = R$drawable.gray_radius;
|
||||
this.m = R$drawable.white_radius;
|
||||
this.n = R$layout.banner;
|
||||
this.s = 0;
|
||||
this.u = -1;
|
||||
this.v = 1;
|
||||
this.x = 1;
|
||||
this.S = new WeakHandler();
|
||||
this.T = new Runnable() { // from class: com.youth.banner.Banner.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (Banner.this.s <= 1 || !Banner.this.j) {
|
||||
return;
|
||||
}
|
||||
Banner banner = Banner.this;
|
||||
banner.t = (banner.t % (Banner.this.s + 1)) + 1;
|
||||
if (Banner.this.t == 1) {
|
||||
Banner.this.D.a(Banner.this.t, false);
|
||||
Banner.this.S.a(Banner.this.T);
|
||||
} else {
|
||||
Banner.this.D.setCurrentItem(Banner.this.t);
|
||||
Banner.this.S.a(Banner.this.T, Banner.this.h);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.C = context;
|
||||
this.y = new ArrayList();
|
||||
this.z = new ArrayList();
|
||||
this.A = new ArrayList();
|
||||
this.B = new ArrayList();
|
||||
this.R = context.getResources().getDisplayMetrics();
|
||||
this.e = this.R.widthPixels / 80;
|
||||
b(context, attributeSet);
|
||||
}
|
||||
|
||||
private void a(Context context, AttributeSet attributeSet) {
|
||||
if (attributeSet == null) {
|
||||
return;
|
||||
}
|
||||
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R$styleable.Banner);
|
||||
this.c = obtainStyledAttributes.getDimensionPixelSize(R$styleable.Banner_indicator_width, this.e);
|
||||
this.d = obtainStyledAttributes.getDimensionPixelSize(R$styleable.Banner_indicator_height, this.e);
|
||||
this.b = obtainStyledAttributes.getDimensionPixelSize(R$styleable.Banner_indicator_margin, 5);
|
||||
this.l = obtainStyledAttributes.getResourceId(R$styleable.Banner_indicator_drawable_selected, R$drawable.gray_radius);
|
||||
this.m = obtainStyledAttributes.getResourceId(R$styleable.Banner_indicator_drawable_unselected, R$drawable.white_radius);
|
||||
this.x = obtainStyledAttributes.getInt(R$styleable.Banner_image_scale_type, this.x);
|
||||
this.h = obtainStyledAttributes.getInt(R$styleable.Banner_delay_time, 2000);
|
||||
this.i = obtainStyledAttributes.getInt(R$styleable.Banner_scroll_time, 800);
|
||||
this.j = obtainStyledAttributes.getBoolean(R$styleable.Banner_is_auto_play, true);
|
||||
this.p = obtainStyledAttributes.getColor(R$styleable.Banner_title_background, -1);
|
||||
this.o = obtainStyledAttributes.getDimensionPixelSize(R$styleable.Banner_title_height, -1);
|
||||
this.q = obtainStyledAttributes.getColor(R$styleable.Banner_title_textcolor, -1);
|
||||
this.r = obtainStyledAttributes.getDimensionPixelSize(R$styleable.Banner_title_textsize, -1);
|
||||
this.n = obtainStyledAttributes.getResourceId(R$styleable.Banner_banner_layout, this.n);
|
||||
this.f = obtainStyledAttributes.getResourceId(R$styleable.Banner_banner_default_image, R$drawable.no_banner);
|
||||
obtainStyledAttributes.recycle();
|
||||
}
|
||||
|
||||
public int c(int i) {
|
||||
int i2 = this.s;
|
||||
int i3 = (i - 1) % i2;
|
||||
return i3 < 0 ? i3 + i2 : i3;
|
||||
}
|
||||
|
||||
public Banner b(int i) {
|
||||
if (i == 5) {
|
||||
this.u = 19;
|
||||
} else if (i == 6) {
|
||||
this.u = 17;
|
||||
} else if (i == 7) {
|
||||
this.u = 21;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banner b(List<?> list) {
|
||||
this.z = list;
|
||||
this.s = list.size();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banner a(ImageLoaderInterface imageLoaderInterface) {
|
||||
this.L = imageLoaderInterface;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.S.b(this.T);
|
||||
this.S.a(this.T, this.h);
|
||||
}
|
||||
|
||||
public Banner a(List<String> list) {
|
||||
this.y = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banner a(int i) {
|
||||
this.g = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banner a() {
|
||||
g();
|
||||
setImageList(this.z);
|
||||
h();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Banner a(OnBannerListener onBannerListener) {
|
||||
this.Q = onBannerListener;
|
||||
return this;
|
||||
}
|
||||
}
|
28
sources/com/youth/banner/BannerScroller.java
Normal file
28
sources/com/youth/banner/BannerScroller.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package com.youth.banner;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.Scroller;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BannerScroller extends Scroller {
|
||||
private int a;
|
||||
|
||||
public BannerScroller(Context context) {
|
||||
super(context);
|
||||
this.a = 800;
|
||||
}
|
||||
|
||||
public void a(int i) {
|
||||
this.a = i;
|
||||
}
|
||||
|
||||
@Override // android.widget.Scroller
|
||||
public void startScroll(int i, int i2, int i3, int i4, int i5) {
|
||||
super.startScroll(i, i2, i3, i4, this.a);
|
||||
}
|
||||
|
||||
@Override // android.widget.Scroller
|
||||
public void startScroll(int i, int i2, int i3, int i4) {
|
||||
super.startScroll(i, i2, i3, i4, this.a);
|
||||
}
|
||||
}
|
9
sources/com/youth/banner/R$drawable.java
Normal file
9
sources/com/youth/banner/R$drawable.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.youth.banner;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R$drawable {
|
||||
public static final int black_background = 2131230901;
|
||||
public static final int gray_radius = 2131231202;
|
||||
public static final int no_banner = 2131231534;
|
||||
public static final int white_radius = 2131232014;
|
||||
}
|
22
sources/com/youth/banner/R$id.java
Normal file
22
sources/com/youth/banner/R$id.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.youth.banner;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R$id {
|
||||
public static final int bannerContainer = 2131296333;
|
||||
public static final int bannerDefaultImage = 2131296334;
|
||||
public static final int bannerTitle = 2131296335;
|
||||
public static final int bannerViewPager = 2131296336;
|
||||
public static final int center = 2131296441;
|
||||
public static final int center_crop = 2131296443;
|
||||
public static final int center_inside = 2131296445;
|
||||
public static final int circleIndicator = 2131296453;
|
||||
public static final int fit_center = 2131296612;
|
||||
public static final int fit_end = 2131296613;
|
||||
public static final int fit_start = 2131296614;
|
||||
public static final int fit_xy = 2131296615;
|
||||
public static final int indicatorInside = 2131296970;
|
||||
public static final int matrix = 2131297152;
|
||||
public static final int numIndicator = 2131297199;
|
||||
public static final int numIndicatorInside = 2131297200;
|
||||
public static final int titleView = 2131297561;
|
||||
}
|
6
sources/com/youth/banner/R$layout.java
Normal file
6
sources/com/youth/banner/R$layout.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.youth.banner;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R$layout {
|
||||
public static final int banner = 2131493006;
|
||||
}
|
23
sources/com/youth/banner/R$styleable.java
Normal file
23
sources/com/youth/banner/R$styleable.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.youth.banner;
|
||||
|
||||
import com.ubt.jimu.R;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class R$styleable {
|
||||
public static final int[] Banner = {R.attr.banner_default_image, R.attr.banner_layout, R.attr.delay_time, R.attr.image_scale_type, R.attr.indicator_drawable_selected, R.attr.indicator_drawable_unselected, R.attr.indicator_height, R.attr.indicator_margin, R.attr.indicator_width, R.attr.is_auto_play, R.attr.scroll_time, R.attr.title_background, R.attr.title_height, R.attr.title_textcolor, R.attr.title_textsize};
|
||||
public static final int Banner_banner_default_image = 0;
|
||||
public static final int Banner_banner_layout = 1;
|
||||
public static final int Banner_delay_time = 2;
|
||||
public static final int Banner_image_scale_type = 3;
|
||||
public static final int Banner_indicator_drawable_selected = 4;
|
||||
public static final int Banner_indicator_drawable_unselected = 5;
|
||||
public static final int Banner_indicator_height = 6;
|
||||
public static final int Banner_indicator_margin = 7;
|
||||
public static final int Banner_indicator_width = 8;
|
||||
public static final int Banner_is_auto_play = 9;
|
||||
public static final int Banner_scroll_time = 10;
|
||||
public static final int Banner_title_background = 11;
|
||||
public static final int Banner_title_height = 12;
|
||||
public static final int Banner_title_textcolor = 13;
|
||||
public static final int Banner_title_textsize = 14;
|
||||
}
|
139
sources/com/youth/banner/WeakHandler.java
Normal file
139
sources/com/youth/banner/WeakHandler.java
Normal file
@@ -0,0 +1,139 @@
|
||||
package com.youth.banner;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class WeakHandler {
|
||||
private Lock b = new ReentrantLock();
|
||||
final ChainedRef c = new ChainedRef(this.b, null);
|
||||
private final ExecHandler a = new ExecHandler();
|
||||
|
||||
private static class ExecHandler extends Handler {
|
||||
private final WeakReference<Handler.Callback> a = null;
|
||||
|
||||
ExecHandler() {
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
Handler.Callback callback;
|
||||
WeakReference<Handler.Callback> weakReference = this.a;
|
||||
if (weakReference == null || (callback = weakReference.get()) == null) {
|
||||
return;
|
||||
}
|
||||
callback.handleMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
static class WeakRunnable implements Runnable {
|
||||
private final WeakReference<Runnable> a;
|
||||
private final WeakReference<ChainedRef> b;
|
||||
|
||||
WeakRunnable(WeakReference<Runnable> weakReference, WeakReference<ChainedRef> weakReference2) {
|
||||
this.a = weakReference;
|
||||
this.b = weakReference2;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
Runnable runnable = this.a.get();
|
||||
ChainedRef chainedRef = this.b.get();
|
||||
if (chainedRef != null) {
|
||||
chainedRef.a();
|
||||
}
|
||||
if (runnable != null) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private WeakRunnable c(Runnable runnable) {
|
||||
if (runnable == null) {
|
||||
throw new NullPointerException("Runnable can't be null");
|
||||
}
|
||||
ChainedRef chainedRef = new ChainedRef(this.b, runnable);
|
||||
this.c.a(chainedRef);
|
||||
return chainedRef.d;
|
||||
}
|
||||
|
||||
public final boolean a(Runnable runnable) {
|
||||
return this.a.post(c(runnable));
|
||||
}
|
||||
|
||||
public final void b(Runnable runnable) {
|
||||
WeakRunnable a = this.c.a(runnable);
|
||||
if (a != null) {
|
||||
this.a.removeCallbacks(a);
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean a(Runnable runnable, long j) {
|
||||
return this.a.postDelayed(c(runnable), j);
|
||||
}
|
||||
|
||||
static class ChainedRef {
|
||||
ChainedRef a;
|
||||
ChainedRef b;
|
||||
final Runnable c;
|
||||
final WeakRunnable d;
|
||||
Lock e;
|
||||
|
||||
public ChainedRef(Lock lock, Runnable runnable) {
|
||||
this.c = runnable;
|
||||
this.e = lock;
|
||||
this.d = new WeakRunnable(new WeakReference(runnable), new WeakReference(this));
|
||||
}
|
||||
|
||||
public WeakRunnable a() {
|
||||
this.e.lock();
|
||||
try {
|
||||
if (this.b != null) {
|
||||
this.b.a = this.a;
|
||||
}
|
||||
if (this.a != null) {
|
||||
this.a.b = this.b;
|
||||
}
|
||||
this.b = null;
|
||||
this.a = null;
|
||||
this.e.unlock();
|
||||
return this.d;
|
||||
} catch (Throwable th) {
|
||||
this.e.unlock();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ChainedRef chainedRef) {
|
||||
this.e.lock();
|
||||
try {
|
||||
if (this.a != null) {
|
||||
this.a.b = chainedRef;
|
||||
}
|
||||
chainedRef.a = this.a;
|
||||
this.a = chainedRef;
|
||||
chainedRef.b = this;
|
||||
} finally {
|
||||
this.e.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public WeakRunnable a(Runnable runnable) {
|
||||
this.e.lock();
|
||||
try {
|
||||
for (ChainedRef chainedRef = this.a; chainedRef != null; chainedRef = chainedRef.a) {
|
||||
if (chainedRef.c == runnable) {
|
||||
return chainedRef.a();
|
||||
}
|
||||
}
|
||||
this.e.unlock();
|
||||
return null;
|
||||
} finally {
|
||||
this.e.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package com.youth.banner.listener;
|
||||
|
||||
@Deprecated
|
||||
/* loaded from: classes2.dex */
|
||||
public interface OnBannerClickListener {
|
||||
void OnBannerClick(int i);
|
||||
}
|
6
sources/com/youth/banner/listener/OnBannerListener.java
Normal file
6
sources/com/youth/banner/listener/OnBannerListener.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.youth.banner.listener;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface OnBannerListener {
|
||||
void OnBannerClick(int i);
|
||||
}
|
12
sources/com/youth/banner/loader/ImageLoader.java
Normal file
12
sources/com/youth/banner/loader/ImageLoader.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.youth.banner.loader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class ImageLoader implements ImageLoaderInterface<ImageView> {
|
||||
@Override // com.youth.banner.loader.ImageLoaderInterface
|
||||
public ImageView createImageView(Context context) {
|
||||
return new ImageView(context);
|
||||
}
|
||||
}
|
12
sources/com/youth/banner/loader/ImageLoaderInterface.java
Normal file
12
sources/com/youth/banner/loader/ImageLoaderInterface.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.youth.banner.loader;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface ImageLoaderInterface<T extends View> extends Serializable {
|
||||
T createImageView(Context context);
|
||||
|
||||
void displayImage(Context context, Object obj, T t);
|
||||
}
|
47
sources/com/youth/banner/transformer/ABaseTransformer.java
Normal file
47
sources/com/youth/banner/transformer/ABaseTransformer.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.youth.banner.transformer;
|
||||
|
||||
import android.view.View;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class ABaseTransformer implements ViewPager.PageTransformer {
|
||||
@Override // androidx.viewpager.widget.ViewPager.PageTransformer
|
||||
public void a(View view, float f) {
|
||||
c(view, f);
|
||||
d(view, f);
|
||||
b(view, f);
|
||||
}
|
||||
|
||||
protected boolean a() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void b(View view, float f) {
|
||||
}
|
||||
|
||||
protected abstract boolean b();
|
||||
|
||||
protected void c(View view, float f) {
|
||||
float width = view.getWidth();
|
||||
float f2 = 0.0f;
|
||||
view.setRotationX(0.0f);
|
||||
view.setRotationY(0.0f);
|
||||
view.setRotation(0.0f);
|
||||
view.setScaleX(1.0f);
|
||||
view.setScaleY(1.0f);
|
||||
view.setPivotX(0.0f);
|
||||
view.setPivotY(0.0f);
|
||||
view.setTranslationY(0.0f);
|
||||
view.setTranslationX(b() ? 0.0f : (-width) * f);
|
||||
if (!a()) {
|
||||
view.setAlpha(1.0f);
|
||||
return;
|
||||
}
|
||||
if (f > -1.0f && f < 1.0f) {
|
||||
f2 = 1.0f;
|
||||
}
|
||||
view.setAlpha(f2);
|
||||
}
|
||||
|
||||
protected abstract void d(View view, float f);
|
||||
}
|
15
sources/com/youth/banner/transformer/DefaultTransformer.java
Normal file
15
sources/com/youth/banner/transformer/DefaultTransformer.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.youth.banner.transformer;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class DefaultTransformer extends ABaseTransformer {
|
||||
@Override // com.youth.banner.transformer.ABaseTransformer
|
||||
public boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.youth.banner.transformer.ABaseTransformer
|
||||
protected void d(View view, float f) {
|
||||
}
|
||||
}
|
47
sources/com/youth/banner/view/BannerViewPager.java
Normal file
47
sources/com/youth/banner/view/BannerViewPager.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.youth.banner.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BannerViewPager extends ViewPager {
|
||||
private boolean k0;
|
||||
|
||||
public BannerViewPager(Context context) {
|
||||
super(context);
|
||||
this.k0 = true;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager, android.view.ViewGroup
|
||||
public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
|
||||
if (!this.k0) {
|
||||
return false;
|
||||
}
|
||||
if (getCurrentItem() == 0 && getChildCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
return super.onInterceptTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager, android.view.View
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
if (!this.k0) {
|
||||
return false;
|
||||
}
|
||||
if (getCurrentItem() == 0 && getChildCount() == 0) {
|
||||
return false;
|
||||
}
|
||||
return super.onTouchEvent(motionEvent);
|
||||
}
|
||||
|
||||
public void setScrollable(boolean z) {
|
||||
this.k0 = z;
|
||||
}
|
||||
|
||||
public BannerViewPager(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.k0 = true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user