|
|
|
|
@ -14,36 +14,21 @@ public abstract class BaseFragment extends Fragment { |
|
|
|
|
|
|
|
|
|
protected abstract ViewBinding getBinding(@NonNull LayoutInflater inflater, @Nullable ViewGroup container); |
|
|
|
|
|
|
|
|
|
private boolean init; |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
@Override |
|
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
|
|
|
|
return getBinding(inflater, container).getRoot(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initView() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void initEvent() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void resume() { |
|
|
|
|
if (init) return; |
|
|
|
|
@Override |
|
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
|
|
|
|
initView(); |
|
|
|
|
initEvent(); |
|
|
|
|
init = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setUserVisibleHint(boolean isVisibleToUser) { |
|
|
|
|
super.setUserVisibleHint(isVisibleToUser); |
|
|
|
|
if (isVisibleToUser) if (isResumed()) resume(); |
|
|
|
|
protected void initView() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onResume() { |
|
|
|
|
super.onResume(); |
|
|
|
|
if (getUserVisibleHint()) resume(); |
|
|
|
|
protected void initEvent() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|