|
@@ -3,8 +3,8 @@
|
|
|
*/
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.view.fragment;
|
|
package kr.co.zumo.app.lifeplus.view.fragment;
|
|
|
|
|
|
|
|
|
|
+import android.content.Context;
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
-import android.support.annotation.CallSuper;
|
|
|
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.NonNull;
|
|
|
import android.support.annotation.Nullable;
|
|
import android.support.annotation.Nullable;
|
|
|
import android.support.v4.app.Fragment;
|
|
import android.support.v4.app.Fragment;
|
|
@@ -40,31 +40,47 @@ public abstract class FragmentBase<P extends Presenter> extends Fragment impleme
|
|
|
* Fragment
|
|
* Fragment
|
|
|
***********************************/
|
|
***********************************/
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onAttach(Context context) {
|
|
|
|
|
+ Log.e("APP# FragmentBase | onAttach", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
|
|
+ super.onAttach(context);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
+ Log.e("APP# FragmentBase | onCreate", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
@Nullable
|
|
|
@Override
|
|
@Override
|
|
|
public final View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
public final View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
- Log.w("APP# FragmentBase | onCreateView", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
|
|
|
|
+ Log.e("APP# FragmentBase | onCreateView", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Presenter/Model 은 onCreateView() 에서 생성하여 popStack() 때에도 사용되도록 한다.
|
|
|
|
|
+ */
|
|
|
presenter = definePresenter();
|
|
presenter = definePresenter();
|
|
|
|
|
+
|
|
|
defineActionBar();
|
|
defineActionBar();
|
|
|
defineActionButton();
|
|
defineActionButton();
|
|
|
|
|
|
|
|
return onAfterCreateView(inflater, container, savedInstanceState);
|
|
return onAfterCreateView(inflater, container, savedInstanceState);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected abstract View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public final void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
+ Log.e("APP# FragmentBase | onViewCreated", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
|
|
+ super.onViewCreated(view, savedInstanceState);
|
|
|
|
|
+
|
|
|
|
|
+ onAfterActivityCreated(savedInstanceState);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public final void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
public final void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
|
|
|
|
+ Log.e("APP# FragmentBase | onActivityCreated", "| >>>>>>>>>>>> " + this.getClass().getSimpleName());
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
|
|
|
- onAfterActivityCreated(savedInstanceState);
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -91,22 +107,40 @@ public abstract class FragmentBase<P extends Presenter> extends Fragment impleme
|
|
|
super.onStop();
|
|
super.onStop();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @CallSuper
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onDestroyView() {
|
|
public void onDestroyView() {
|
|
|
Log.w("APP# FragmentBase | onDestroyView", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName());
|
|
Log.w("APP# FragmentBase | onDestroyView", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName());
|
|
|
-
|
|
|
|
|
if (null != disposable) {
|
|
if (null != disposable) {
|
|
|
disposable.dispose();
|
|
disposable.dispose();
|
|
|
disposable = null;
|
|
disposable = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * fragment 전환 시 onDestroyView() 까지만 실행된다.
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
if (null != presenter) {
|
|
if (null != presenter) {
|
|
|
presenter.destroy();
|
|
presenter.destroy();
|
|
|
presenter = null;
|
|
presenter = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
super.onDestroyView();
|
|
super.onDestroyView();
|
|
|
|
|
+
|
|
|
|
|
+ onAfterDestroyView();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public final void onDestroy() {
|
|
|
|
|
+ Log.w("APP# FragmentBase | onDestroy", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName());
|
|
|
|
|
+ super.onDestroy();
|
|
|
|
|
+
|
|
|
|
|
+ onAfterDestroy();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onDetach() {
|
|
|
|
|
+ Log.w("APP# FragmentBase | onDetach", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName());
|
|
|
|
|
+ super.onDetach();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/***********************************
|
|
/***********************************
|
|
@@ -118,7 +152,17 @@ public abstract class FragmentBase<P extends Presenter> extends Fragment impleme
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * onCreate() 처리 후 호출된다
|
|
|
|
|
|
|
+ * onActivityCreated() 후 호출 된다.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param inflater
|
|
|
|
|
+ * @param container
|
|
|
|
|
+ * @param savedInstanceState
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ protected abstract View onAfterCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState);
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * onViewCreated() 처리 후 호출된다
|
|
|
*
|
|
*
|
|
|
* @param savedInstanceState
|
|
* @param savedInstanceState
|
|
|
*/
|
|
*/
|
|
@@ -142,6 +186,16 @@ public abstract class FragmentBase<P extends Presenter> extends Fragment impleme
|
|
|
*/
|
|
*/
|
|
|
protected abstract P definePresenter();
|
|
protected abstract P definePresenter();
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * onDestroyView() 처리 후 호출된다.
|
|
|
|
|
+ */
|
|
|
|
|
+ protected void onAfterDestroyView() {}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * onDestroy() 처리 후 호출된다.
|
|
|
|
|
+ */
|
|
|
|
|
+ protected void onAfterDestroy() {}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Android life-cycle 에 귀속되는 모델을 반환한다.
|
|
* Android life-cycle 에 귀속되는 모델을 반환한다.
|
|
|
* - 사실 MVVM 사용되는 ViewModel 이지만 MVP 의 Model 로 사용한다.
|
|
* - 사실 MVVM 사용되는 ViewModel 이지만 MVP 의 Model 로 사용한다.
|