Initial commit
This commit is contained in:
60
sources/com/ubtech/view/fragment/BaseFragment.java
Normal file
60
sources/com/ubtech/view/fragment/BaseFragment.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.ubtech.view.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.ubtrobot.ubtlib.analytics.JimuAnalytics;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class BaseFragment extends Fragment {
|
||||
public final String TAG = getClass().getSimpleName();
|
||||
protected Activity mActivity;
|
||||
protected View mView;
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
this.mActivity = (Activity) context;
|
||||
}
|
||||
|
||||
public boolean onBackPressed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
if (this.mActivity == null) {
|
||||
this.mActivity = getActivity();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
return super.onCreateView(layoutInflater, viewGroup, bundle);
|
||||
}
|
||||
|
||||
protected void onPagePause() {
|
||||
}
|
||||
|
||||
protected void onPageResume() {
|
||||
}
|
||||
|
||||
protected void recordEvent(String str) {
|
||||
JimuAnalytics.b().a(str);
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void setUserVisibleHint(boolean z) {
|
||||
super.setUserVisibleHint(z);
|
||||
if (z) {
|
||||
onPageResume();
|
||||
} else {
|
||||
onPagePause();
|
||||
}
|
||||
}
|
||||
}
|
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