43 lines
1.2 KiB
Java
43 lines
1.2 KiB
Java
package com.ubt.jimu.community.activity;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import com.ubtech.view.fragment.BaseFragment;
|
|
|
|
/* loaded from: classes.dex */
|
|
public abstract class LazyLoadFragment extends BaseFragment {
|
|
private boolean isLoaded;
|
|
|
|
protected void lazyLoad() {
|
|
if (this.isLoaded && getUserVisibleHint()) {
|
|
loadData();
|
|
this.isLoaded = false;
|
|
}
|
|
}
|
|
|
|
protected abstract void loadData();
|
|
|
|
@Override // com.ubtech.view.fragment.BaseFragment, 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 // com.ubtech.view.fragment.BaseFragment, androidx.fragment.app.Fragment
|
|
public void setUserVisibleHint(boolean z) {
|
|
super.setUserVisibleHint(z);
|
|
if (z) {
|
|
lazyLoad();
|
|
}
|
|
}
|
|
}
|