/*
 * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
 */
package kr.co.zumo.app.lifeplus.view.presenter.signup;

import kr.co.zumo.app.R;
import kr.co.zumo.app.lifeplus.manager.ActionBarManager;
import kr.co.zumo.app.lifeplus.model.SignUpModel;
import kr.co.zumo.app.lifeplus.supervisor.ScreenID;
import kr.co.zumo.app.lifeplus.util.ResourceUtil;
import kr.co.zumo.app.lifeplus.view.Event;
import kr.co.zumo.app.lifeplus.view.command.ActivityChangeCommand;
import kr.co.zumo.app.lifeplus.view.presenter.Presenter;

/**
 * SignUpCompletePresenter
 * <pre>
 * </pre>
 *
 * @author 민효동
 * @version 1.0
 * @history 민효동   [2018. 9. 28.]   [최초 작성]
 * @since 2018. 9. 28.
 */
public class SignUpCompletePresenter extends Presenter<SignUpModel, ISignUpCompletedView> {

  public SignUpCompletePresenter(SignUpModel model, ISignUpCompletedView view) {
    super(model, view);
  }

  @Override
  protected void startInternal() {
    ActionBarManager.getInstance().setProgress(100); // 360/360
  }

  @Override
  protected void stopInternal() {

  }

  @Override
  protected void resumeInternal() {

  }

  @Override
  protected void pauseInternal() {

  }

  @Override
  protected void destroyInternal() {

  }

  @Override
  public void onResult(Event event) throws Throwable {

  }

  @Override
  public boolean onBackPressed() {
    ActionBarManager.getInstance().setProgress(0);
    onCommand(new ActivityChangeCommand(ScreenID.ACTIVITY_MAIN, ScreenID.DIRECTION_BACK));
    return true;
  }

  @Override
  protected void onEventInternal(Event event) {
    switch (event.getEventId()) {
      case Event.SUCCESS:
        ActionBarManager.getInstance().setProgress(0);
        onCommand(new ActivityChangeCommand(ScreenID.ACTIVITY_MAIN, ScreenID.DIRECTION_NEXT));
        break;
      case Event.INIT:
        // todo 회원 전환의 경우 텍스트 달리함
        view.setText(String.format(ResourceUtil.getString(R.string.sign_up_success_message), model.getMobileAuthorizationBean().getName()));
        break;
      default:
        break;
    }
  }
}
