package kr.co.hanwha.hifive.admin.admin;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;

import kr.co.hanwha.hifive.R;
import kr.co.hanwha.hifive.admin.AdminInputDialog;
import kr.co.hanwha.hifive.admin.TestModeActivity;
import kr.co.hanwha.hifive.base.BaseActivity;
import kr.co.hanwha.hifive.enums.BaseAnimationType;
import kr.co.hanwha.hifive.enums.BaseToolbarType;
import kr.co.hanwha.hifive.screen.intro.IntroActivity;
import kr.co.hanwha.hifive.util.HFActivityUtil;
import kr.co.hanwha.hifive.util.HFInfoUtil;

/**
 * Created by sanghoonkwon on 2018. 3. 28..
 */

public class AdminMenuActivity extends BaseActivity {
    @Override
    protected int getContentViewResource() {
        return R.layout.activity_admin_menu;
    }

    @Override
    protected BaseToolbarType isToolbarStyle() {
        return BaseToolbarType.DEFAULT;
    }

    @Override
    protected BaseAnimationType isShowActivityAnimation() {
        return null;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setTitle("Admin - " + HFInfoUtil.getDepartmentText(this));

        findViewById(R.id.memberList_button).setOnClickListener(onClickListener);
        findViewById(R.id.version_button).setOnClickListener(onClickListener);
        findViewById(R.id.task_button).setOnClickListener(onClickListener);
        findViewById(R.id.server_button).setOnClickListener(onClickListener);
    }

    /**************************************************
     * View.OnClickListener
     **************************************************/
    View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.memberList_button: {
                    Intent intent = new Intent(AdminMenuActivity.this, AdminMemberListActivity.class);
                    startActivity(intent);
                    break;
                }
                case R.id.version_button: {
                    Intent intent = new Intent(AdminMenuActivity.this, AdminVersionActivity.class);
                    startActivity(intent);
                    break;
                }
                case R.id.task_button:
                    AdminInputDialog dialog = new AdminInputDialog(AdminMenuActivity.this, AdminInputDialog.ADMIN_TYPE.TASK_ID, new AdminInputDialog.OnDialogCallback() {
                        @Override
                        public void onPositive(@NonNull String message) {
                            try {
                                int taskId = Integer.parseInt(message);
                                HFActivityUtil.startTaskDetailActivity(AdminMenuActivity.this, taskId, 0, 0);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }

                        @Override
                        public void onWrongPassword() {

                        }
                    });
                    dialog.show();
                    break;
                case R.id.server_button: {
                    Intent intent = new Intent(AdminMenuActivity.this, TestModeActivity.class);
                    startActivity(intent);
                    break;
                }
            }
        }
    };
}
