Initial commit
This commit is contained in:
43
sources/com/ubtech/view/fragment/LazyLoadFragment.java
Normal file
43
sources/com/ubtech/view/fragment/LazyLoadFragment.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package com.ubtech.view.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class LazyLoadFragment extends Fragment {
|
||||
private boolean isLoaded;
|
||||
protected Activity mActivity;
|
||||
|
||||
protected void lazyLoad() {
|
||||
if (this.isLoaded && getUserVisibleHint()) {
|
||||
loadData();
|
||||
this.isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void loadData();
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
this.mActivity = (Activity) context;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onViewCreated(View view, Bundle bundle) {
|
||||
super.onViewCreated(view, bundle);
|
||||
this.isLoaded = true;
|
||||
lazyLoad();
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void setUserVisibleHint(boolean z) {
|
||||
super.setUserVisibleHint(z);
|
||||
if (z) {
|
||||
lazyLoad();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user