|
|
@@ -3,30 +3,17 @@
|
|
|
*/
|
|
|
package kr.co.zumo.app.lifeplus.activity;
|
|
|
|
|
|
-import android.arch.lifecycle.ViewModelProviders;
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.support.annotation.CallSuper;
|
|
|
-import android.support.v7.app.AppCompatActivity;
|
|
|
-import android.util.Log;
|
|
|
-
|
|
|
-import com.bumptech.glide.Glide;
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
-import kr.co.zumo.app.R;
|
|
|
-import kr.co.zumo.app.lifeplus.application.App;
|
|
|
import kr.co.zumo.app.lifeplus.bean.ContentsDeliveryBean;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.ActionBarHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.ActionButtonHelper;
|
|
|
+import kr.co.zumo.app.lifeplus.bean.api.LifeplusContentsBean;
|
|
|
import kr.co.zumo.app.lifeplus.helper.DeliveryHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.FacebookHelper;
|
|
|
-import kr.co.zumo.app.lifeplus.helper.Helper;
|
|
|
import kr.co.zumo.app.lifeplus.helper.ScreenChangerHelper;
|
|
|
import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.FragmentSkipBackChanger;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ScreenChanger;
|
|
|
import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
|
|
|
-import kr.co.zumo.app.lifeplus.view.screen.FragmentBase;
|
|
|
+import kr.co.zumo.app.lifeplus.util.StringUtil;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.contents.ContentsFlagHelper;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.factory.BasicFragmentFactory;
|
|
|
import kr.co.zumo.app.lifeplus.view.screen.factory.FragmentFactory;
|
|
|
@@ -41,45 +28,23 @@ import kr.co.zumo.app.lifeplus.view.screen.factory.FragmentFactory;
|
|
|
* @history 민효동 [2018. 9. 5.] [최초 작성]
|
|
|
* @since 2018. 9. 5.
|
|
|
*/
|
|
|
-public class MainActivity extends AppCompatActivity {
|
|
|
-
|
|
|
- /***********************************
|
|
|
- * Activity
|
|
|
- ***********************************/
|
|
|
+public class MainActivity extends ActivityBase {
|
|
|
|
|
|
@Override
|
|
|
- protected final void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
-
|
|
|
- setContentView(R.layout.activity_main);
|
|
|
-
|
|
|
- Log.w("APP# MainActivity | onCreate", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
-
|
|
|
- new AppInitializer().init(App.getInstance().getContext());
|
|
|
-
|
|
|
- // actionbar
|
|
|
- setSupportActionBar(findViewById(R.id.toolbar));
|
|
|
- getHelper(ActionBarHelper.class).init(this, this.getSupportActionBar(), findViewById(R.id.layout_app_bar), findViewById(R.id.container_main));
|
|
|
-
|
|
|
- // floating action button
|
|
|
- getHelper(ActionButtonHelper.class).init(findViewById(R.id.floating_action_button));
|
|
|
-
|
|
|
- ScreenChangerHelper screenChangerHelper = getHelper(ScreenChangerHelper.class);
|
|
|
- screenChangerHelper.setAppCompatActivity(this);
|
|
|
- screenChangerHelper.setContainerId(R.id.container_main);
|
|
|
+ protected void renderScreen(@ScreenID.ID int screenId) {
|
|
|
+ ScreenChangerHelper helper = getHelper(ScreenChangerHelper.class);
|
|
|
|
|
|
// 첫 화면 전환
|
|
|
FragmentFactory factory = new BasicFragmentFactory();
|
|
|
- ScreenChangerHelper helper = screenChangerHelper;
|
|
|
ScreenChanger screenChanger = new FragmentSkipBackChanger(helper.getAppCompatActivity().getSupportFragmentManager(), helper.getContainerId(), factory, helper.getSkipBackIds());
|
|
|
|
|
|
- // ScreenStarter 에서 설정된 프래그먼트를 선택한다.
|
|
|
- int fragmentFlag = getIntent().getIntExtra(ScreenStarter.FLAG_FRAGMENT, ScreenStarter.START_FROM_MAIN);
|
|
|
- int screenId = new ScreenStarterIDMapper().getScreenId(fragmentFlag);
|
|
|
+ // kakao 로 부터 진입했는지 확인
|
|
|
String contentsString = getIntent().getStringExtra(ScreenStarter.SHARE_PARAMETER);
|
|
|
- if(null != contentsString) {
|
|
|
- ContentsDeliveryBean contentsDeliveryBean = new Gson().fromJson(contentsString, ContentsDeliveryBean.class);
|
|
|
- if(null != contentsDeliveryBean) {
|
|
|
+ if(StringUtil.isFull(contentsString)) {
|
|
|
+ LifeplusContentsBean lifeplusContentsBean = new Gson().fromJson(contentsString, LifeplusContentsBean.class);
|
|
|
+ ContentsDeliveryBean contentsDeliveryBean = new ContentsDeliveryBean.Builder(lifeplusContentsBean).build();
|
|
|
+
|
|
|
+ if(null != lifeplusContentsBean) {
|
|
|
DeliveryHelper deliveryHelper = getHelper(DeliveryHelper.class);
|
|
|
deliveryHelper.setPackaging(contentsDeliveryBean);
|
|
|
|
|
|
@@ -87,109 +52,14 @@ public class MainActivity extends AppCompatActivity {
|
|
|
}
|
|
|
}
|
|
|
screenChanger.changeTo(screenId);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onNewIntent(Intent intent) {
|
|
|
- super.onNewIntent(intent);
|
|
|
- Log.w("APP# MainActivity | onNewIntent", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
|
- super.onRestoreInstanceState(savedInstanceState);
|
|
|
- Log.w("APP# MainActivity | onRestoreInstanceState", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onRestart() {
|
|
|
- Log.w("APP# MainActivity | onRestart", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
- super.onRestart();
|
|
|
- }
|
|
|
-
|
|
|
- @CallSuper
|
|
|
- @Override
|
|
|
- protected void onDestroy() {
|
|
|
- Log.w("APP# MainActivity | onDestroy", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
-
|
|
|
+ protected void onAfterDestroy() {
|
|
|
SuperModel.getInstance().dispose();
|
|
|
ContentsFlagHelper.getInstance().dispose();
|
|
|
-
|
|
|
- Glide.get(this).clearMemory();
|
|
|
-
|
|
|
- super.onDestroy();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onPause() {
|
|
|
- Log.w("APP# MainActivity | onPause", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
- super.onPause();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onStart() {
|
|
|
- Log.w("APP# MainActivity | onStart", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
- super.onStart();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onResume() {
|
|
|
- Log.w("APP# MainActivity | onResume", "| >>>>>>>>>>>>>> " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
- super.onResume();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onStop() {
|
|
|
- Log.w("APP# MainActivity | onStop", "| <<<<<<<<<<<<< " + this.getClass().getSimpleName() + " HC: " + this.hashCode());
|
|
|
- super.onStop();
|
|
|
- }
|
|
|
-
|
|
|
- private boolean exitToBack() {
|
|
|
- final FragmentBase fragment = (FragmentBase) getSupportFragmentManager().findFragmentById(R.id.container_main);
|
|
|
- if (null != fragment) {
|
|
|
- return fragment.onBackPressed();
|
|
|
- }
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Device back key
|
|
|
- */
|
|
|
- @Override
|
|
|
- public void onBackPressed() {
|
|
|
- if (exitToBack() == false) {
|
|
|
- super.onBackPressed();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onSaveInstanceState(Bundle outState) {
|
|
|
- super.onSaveInstanceState(outState);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 각종 Helper 객체를 반환한다.
|
|
|
- * - Activity 에 종속되는 객체로 그 안에서 싱글톤처럼 사용.
|
|
|
- *
|
|
|
- * @param helperClass DeliveryHelper.class
|
|
|
- * @return new DeliveryHelper() or exist object
|
|
|
- */
|
|
|
- public <H extends Helper> H getHelper(Class<H> helperClass) {
|
|
|
- return ViewModelProviders.of(this).get(helperClass);
|
|
|
- }
|
|
|
-
|
|
|
- /***********************************
|
|
|
- * facebook call back
|
|
|
- ***********************************/
|
|
|
- @Override
|
|
|
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- super.onActivityResult(requestCode, resultCode, data);
|
|
|
- Log.i("APP# MainActivity | onActivityResult", "|" + "들어옴==========");
|
|
|
-
|
|
|
- getHelper(FacebookHelper.class).onActivityResult(requestCode, resultCode, data);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|