package com.sheep.gamegroup.view.dialog;

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

import com.kfzs.duanduan.utils.dlg.ViewFindUtils;
import com.sheep.gamegroup.model.entity.NewbieTask;
import com.sheep.gamegroup.util.UMConfigUtils;
import com.sheep.gamegroup.view.adapter.NewbieTaskAdp;
import com.sheep.jiuyan.samllsheep.R;

import java.util.List;


public class DialogNewbieTaskList {

    public static AlertDialog showDialog(final Activity activity, List<NewbieTask> newbieTaskList) {
        UMConfigUtils.onEvent(UMConfigUtils.Event.SHEEP_NEWBIE_TASK_LIST_DIALOG);
        View view = View.inflate(activity, R.layout.dialog_newbie_task_list, null);
        final AlertDialog mAlertDialog = new AlertDialog.Builder(activity, R.style.MyDialogActivityTheme)
                .setView(view)
                .create();
        View.OnClickListener onClickListener =  new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mAlertDialog.dismiss();
            }
        };
        final ListView dialog_center_lv = ViewFindUtils.find(view, R.id.dialog_center_lv);
        dialog_center_lv.setAdapter(new NewbieTaskAdp(activity, newbieTaskList).setOnClickListener(onClickListener));
        final View dialog_close = ViewFindUtils.find(view, R.id.dialog_close);
        dialog_close.setOnClickListener(onClickListener);
        try {
            mAlertDialog.show();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return mAlertDialog;
    }
}
