package com.sheep.gamegroup.view.dialog;

import android.app.Activity;
import android.support.v7.app.AlertDialog;
import android.text.Html;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.sheep.gamegroup.model.entity.NewbieTask;
import com.sheep.gamegroup.util.UMConfigUtils;
import com.sheep.gamegroup.view.adapter.DialogNewbieTaskAdp;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;


public class DialogNewbieTask1 {

    public static AlertDialog showDialog(final Activity activity, final List<NewbieTask> newbieTaskList, NewbieTask task) {
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_NEWBIE_TASK_LIST_DIALOG);
        View view = View.inflate(activity, R.layout.dialog_newbie_task_1, null);
        final AlertDialog mAlertDialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
                .setView(view)
                .create();
        final TextView dialog_tip_2 = view.findViewById(R.id.dialog_tip_2);
        dialog_tip_2.setVisibility(View.VISIBLE);
        final TextView dialog_tip = view.findViewById(R.id.dialog_tip);
        if(task != null){
            String start = "";
            switch (task.getId()){
                case 1://了解小绵羊奖励
                    start = "获得小绵羊阅读奖励";
                    break;
                case 2://首次提现
                    start = "获得首次提现奖励";
                    break;
                case 3://成功邀请好友注册
                    start = "获得邀请好友注册奖励";
                    break;
                case 4://首次做任务赚钱
                    start = "获得首次做任务赚钱额外奖励";
                    break;
                case 6://加入官方QQ群
                    start = "获得加入官方QQ群奖励";
                    break;
            }
            String sr = start+" <font color='#e2271d'><big>" + task.getAmount() + "</big></font> 元";
            dialog_tip.setText(Html.fromHtml(sr));
        }
        View.OnClickListener onClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAlertDialog.dismiss();
            }
        };

        final ListView dialog_sure_list = view.findViewById(R.id.dialog_sure_list);
        dialog_sure_list.setAdapter(new DialogNewbieTaskAdp(activity, newbieTaskList).setOnClickListener(onClickListener));
        final View dialog_close = view.findViewById(R.id.dialog_close);
        dialog_close.setOnClickListener(onClickListener);
        try {
            mAlertDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mAlertDialog;
    }
}
