91 lines
3.1 KiB
Java
91 lines
3.1 KiB
Java
|
package com.scb.phone.view.custom.common;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
import android.view.ViewGroup;
|
||
|
import androidx.fragment.app.Fragment;
|
||
|
import androidx.viewpager.widget.ViewPager;
|
||
|
import o.guQ;
|
||
|
|
||
|
/* loaded from: classes5.dex */
|
||
|
public class FragmentWrapContentViewPager extends NonSwipeableViewPager {
|
||
|
private boolean d;
|
||
|
|
||
|
public FragmentWrapContentViewPager(Context context) {
|
||
|
super(context);
|
||
|
this.d = false;
|
||
|
addOnPageChangeListener(new ViewPager.jbe(this) { // from class: com.scb.phone.view.custom.common.FragmentWrapContentViewPager.1
|
||
|
private FragmentWrapContentViewPager d;
|
||
|
|
||
|
{
|
||
|
this.d = this;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.jbe, androidx.viewpager.widget.ViewPager.ojQ
|
||
|
public final void onPageSelected(int i) {
|
||
|
this.d.requestLayout();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
public FragmentWrapContentViewPager(Context context, AttributeSet attributeSet) {
|
||
|
super(context, attributeSet);
|
||
|
this.d = false;
|
||
|
addOnPageChangeListener(new ViewPager.jbe(this) { // from class: com.scb.phone.view.custom.common.FragmentWrapContentViewPager.1
|
||
|
private FragmentWrapContentViewPager d;
|
||
|
|
||
|
{
|
||
|
this.d = this;
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager.jbe, androidx.viewpager.widget.ViewPager.ojQ
|
||
|
public final void onPageSelected(int i) {
|
||
|
this.d.requestLayout();
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
@Override // androidx.viewpager.widget.ViewPager, android.view.View
|
||
|
public void onMeasure(int i, int i2) {
|
||
|
int b;
|
||
|
super.onMeasure(i, i2);
|
||
|
if (getChildCount() <= 0) {
|
||
|
return;
|
||
|
}
|
||
|
boolean z = View.MeasureSpec.getMode(i2) == Integer.MIN_VALUE;
|
||
|
int measuredWidth = getMeasuredWidth();
|
||
|
int measuredHeight = getChildAt(0).getMeasuredHeight();
|
||
|
int makeMeasureSpec = z ? View.MeasureSpec.makeMeasureSpec(measuredWidth, 1073741824) : i;
|
||
|
try {
|
||
|
Object instantiateItem = getAdapter() != null ? getAdapter().instantiateItem((ViewGroup) this, getCurrentItem()) : null;
|
||
|
if (instantiateItem instanceof Fragment) {
|
||
|
b = b(((Fragment) instantiateItem).getView(), i);
|
||
|
} else if (instantiateItem instanceof ViewGroup) {
|
||
|
b = b((ViewGroup) instantiateItem, i);
|
||
|
} else {
|
||
|
b = b((View) instantiateItem, i);
|
||
|
}
|
||
|
super.onMeasure(makeMeasureSpec, View.MeasureSpec.makeMeasureSpec(measuredHeight + b, 1073741824));
|
||
|
} catch (Exception e) {
|
||
|
guQ.a(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private int b(View view, int i) {
|
||
|
if (view == null) {
|
||
|
return 0;
|
||
|
}
|
||
|
if (this.d) {
|
||
|
view.measure(i, View.MeasureSpec.makeMeasureSpec(0, 0));
|
||
|
} else {
|
||
|
view.measure(0, 0);
|
||
|
}
|
||
|
return view.getMeasuredHeight();
|
||
|
}
|
||
|
|
||
|
public void setEnableDrawDynamicViewHeight(boolean z) {
|
||
|
this.d = z;
|
||
|
}
|
||
|
}
|