Search in sources :

Example 11 with Builder

use of android.app.AlertDialog.Builder in project GT by Tencent.

the class GTOpSMActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gt_perf_op_detail_sm);
    Intent intent = this.getIntent();
    Bundle extras = intent.getExtras();
    final String name = extras.getString("name");
    final String alias = extras.getString("alias");
    final String client = extras.getString("client");
    // 出参的性能数据源取法
    dataSet = OpPerfBridge.getProfilerData(name);
    // 在onCreat之前数据源可能被清理了,这样就不打开页面
    if (null == dataSet) {
        finish();
        return;
    }
    // 保存对应的出参变量,以便刷值
    op = ClientManager.getInstance().getClient(client).getOutPara(name);
    about = dataSet.getDesc();
    tvTitle = (TextView) findViewById(R.id.perf_detail_title);
    //		tvTitle.setText(alias);
    tvTitle.setText("SM for Test");
    tvKey = (TextView) findViewById(R.id.op_perf_detail_key);
    tvKey.setText(name);
    tvAbout = (TextView) findViewById(R.id.op_perf_detail_about);
    tvAbout.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            GTOutParaPerfDialog dialog = new GTOutParaPerfDialog(v.getContext(), alias, name, about);
            dialog.show();
        }
    });
    btn_back = (ImageButton) findViewById(R.id.perf_detail_back);
    btn_back.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            finish();
        }
    });
    //		btn_save = (ImageButton)findViewById(R.id.perf_detail_save);
    //		btn_save.setOnClickListener(new OnClickListener() {
    //
    //			public void onClick(View v) {
    //				String lastSaveLog = GTGWInternal.getLastSaveFolder();
    //				if (lastSaveLog != null && lastSaveLog.contains(".")
    //						&& lastSaveLog.endsWith(LogUtils.TLOG_POSFIX))
    //				{
    //					lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    //				}
    //				et_savePath3.setText(lastSaveLog.trim());
    //				dlg_save.show();
    //			}
    //		});
    btn_delete = (ImageButton) findViewById(R.id.perf_detail_delete);
    btn_delete.setOnClickListener(showDeleteDlg);
    // 告警区
    final LinearLayout ll_warnArea = (LinearLayout) findViewById(R.id.op_perf_detail_warnarea);
    img_bottom_arrow = (ImageView) findViewById(R.id.bottom_arrow);
    if (dataSet.getThresholdEntry().isEnable()) {
        img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
        ll_warnArea.setVisibility(View.VISIBLE);
    } else {
        img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
        ll_warnArea.setVisibility(View.GONE);
    }
    // 告警抬头文本
    tvWaringArea = (TextView) findViewById(R.id.op_perf_detail_interval_toast);
    if (!dataSet.getThresholdEntry().isEnable()) {
        tvWaringArea.setText(getString(R.string.warning_title_disable));
    }
    // 折叠线
    ll_fold = (LinearLayout) findViewById(R.id.warning_fold);
    ll_fold.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (dataSet.getThresholdEntry().isEnable()) {
                dataSet.getThresholdEntry().setEnable(false);
                img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
                ll_warnArea.setVisibility(View.GONE);
                tvWaringArea.setText(getString(R.string.warning_title_disable));
            } else {
                dataSet.getThresholdEntry().setEnable(true);
                img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
                ll_warnArea.setVisibility(View.VISIBLE);
                tvWaringArea.setText(getString(R.string.warning_title));
            }
        }
    });
    etUpperInterval = (EditText) findViewById(R.id.op_perf_detail_upper_interval);
    etUpperValue = (EditText) findViewById(R.id.op_perf_detail_upper_value);
    etLowerValue = (EditText) findViewById(R.id.op_perf_detail_lower_value);
    // 从未开始统计过的出参,不允许设置告警
    if (!op.hasMonitorOnce) {
        etUpperInterval.setEnabled(false);
        etUpperValue.setEnabled(false);
        etLowerValue.setEnabled(false);
    //			isfoldWarnArea = true;
    //			img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
    //			ll_warnArea.setVisibility(View.GONE);
    } else {
        etUpperInterval.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etLowerValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperInterval.setOnKeyListener(thresholdKeyListener);
        etUpperValue.setOnKeyListener(thresholdKeyListener);
        etLowerValue.setOnKeyListener(thresholdKeyListener);
        int upperDuration = dataSet.getThresholdEntry().getduration();
        if (upperDuration != Integer.MAX_VALUE) {
            etUpperInterval.setText(Integer.toString(upperDuration));
        }
        double upperValue = dataSet.getThresholdEntry().getUpperValue();
        if (upperValue != Integer.MAX_VALUE) {
            etUpperValue.setText(Double.toString(upperValue));
        }
        double lowerValue = dataSet.getThresholdEntry().getLowerValue();
        if (lowerValue != Integer.MIN_VALUE) {
            etLowerValue.setText(Double.toString(lowerValue));
        }
    }
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.gt_dailog_save_gw, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath3.setText("");
        }
    });
    et_savePath1 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent1);
    et_savePath2 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent2);
    et_savePath3 = (EditText) rl_save.findViewById(R.id.save_editor);
    et_saveTestDesc = (EditText) rl_save.findViewById(R.id.save_editor_desc);
    String lastSaveLog = GTGWInternal.getLastSaveFolder();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    et_savePath3.setText(lastSaveLog);
    et_savePath1.setText(Env.CUR_APP_NAME);
    et_savePath2.setText(Env.CUR_APP_VER);
    dlg_save = new Builder(this).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String path1 = et_savePath1.getText().toString().trim();
            if (!StringUtil.isLetter(path1)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path2 = et_savePath2.getText().toString().trim();
            if (!StringUtil.isLetter(path2)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path3 = et_savePath3.getText().toString().trim();
            if (!StringUtil.isLetter(path3)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String testDesc = et_saveTestDesc.getText().toString().trim();
            GWSaveEntry saveEntry = new GWSaveEntry(path1, path2, path3, testDesc);
            GTGWInternal.saveGWDataForSM(saveEntry, dataSet);
            dialog.dismiss();
        }
    }).create();
    tvValue = (TextView) findViewById(R.id.op_perf_detail_value);
    tvTimes = (TextView) findViewById(R.id.bh_perf_detail_times);
    tvMin = (TextView) findViewById(R.id.bh_perf_detail_min);
    //		tvMax = (TextView) findViewById(R.id.bh_perf_detail_max);
    tvAve = (TextView) findViewById(R.id.bh_perf_detail_ave);
    tvScore = (TextView) findViewById(R.id.bh_perf_detail_score);
    tvGood = (TextView) findViewById(R.id.bh_perf_detail_good);
    tvBad = (TextView) findViewById(R.id.bh_perf_detail_bad);
    tvWarningCnt = (TextView) findViewById(R.id.bh_perf_detail_warning_cnt);
    if (op == null) {
        tvValue.setText(dataSet.getLastValue());
    } else {
        tvValue.setText(op.getValue());
    }
    TagTimeEntry anchorEntry = dataSet;
    if (dataSet.getSubTagEntrys().length > 0) {
        anchorEntry = dataSet.getSubTagEntrys()[0];
    }
    ArrayList<Integer> smrs = SMUtils.getSmDetail(anchorEntry.getRecordList());
    if (smrs.size() < 6) {
        finish();
        return;
    }
    dataSet.exInt_1 = smrs.get(1);
    dataSet.exInt_2 = smrs.get(3);
    dataSet.exInt_3 = smrs.get(5);
    tvTimes.setText(anchorEntry.getRecordSizeText());
    tvMin.setText(anchorEntry.getMin());
    //		tvMax.setText(anchorEntry.getMax());
    tvAve.setText(anchorEntry.getAve());
    tvScore.setText(smrs.get(5).toString());
    tvGood.setText(smrs.get(3).toString());
    tvBad.setText(smrs.get(1).toString());
    tvWarningCnt.setText(Integer.toString(anchorEntry.getThresholdEntry().getUpperWariningCount() + anchorEntry.getThresholdEntry().getLowerWariningCount()));
    LinearLayout ll_chart = (LinearLayout) findViewById(R.id.bh_perf_detail_chart);
    chartView = new GTPerfDetailView(this, dataSet);
    chartView.setInput(0);
    ll_chart.addView(chartView);
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) GTPerfDetailView(com.tencent.wstt.gt.views.GTPerfDetailView) TextView(android.widget.TextView) GTPerfDetailView(com.tencent.wstt.gt.views.GTPerfDetailView) ImageButton(android.widget.ImageButton) RelativeLayout(android.widget.RelativeLayout) GWSaveEntry(com.tencent.wstt.gt.log.GWSaveEntry) OnClickListener(android.view.View.OnClickListener) GTOutParaPerfDialog(com.tencent.wstt.gt.views.GTOutParaPerfDialog) LinearLayout(android.widget.LinearLayout)

Example 12 with Builder

use of android.app.AlertDialog.Builder in project GT by Tencent.

the class GTParamOutFragment method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.gt_param_out, container, false);
    btn_gw_on = (Button) layout.findViewById(R.id.btn_monitor);
    btn_gw_off = (Button) layout.findViewById(R.id.btn_monitor_stop);
    save = (ImageButton) layout.findViewById(R.id.gwdata_save);
    cleardata = (ImageButton) layout.findViewById(R.id.gwdata_delete);
    btn_gw_on.setOnClickListener(this);
    btn_gw_off.setOnClickListener(this);
    save.setOnClickListener(this);
    cleardata.setOnClickListener(this);
    // 保存对话框
    View rl_save = inflater.inflate(R.layout.gt_dailog_save_gw, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath3.setText("");
        }
    });
    et_savePath1 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent1);
    et_savePath2 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent2);
    et_savePath3 = (EditText) rl_save.findViewById(R.id.save_editor);
    et_saveTestDesc = (EditText) rl_save.findViewById(R.id.save_editor_desc);
    invalid_alarm = (TextView) rl_save.findViewById(R.id.invalid_alarm);
    gwhis_save = new Builder(getActivity()).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            canCloseDialog(dialog, true);
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            listProjectPair.clear();
            listProjectName.clear();
            // 先判断保存路径参数是否完整
            final String path3 = et_savePath3.getText().toString().trim();
            final String path2 = et_savePath2.getText().toString().trim();
            final String path1 = et_savePath1.getText().toString().trim();
            if (path1.isEmpty() || path2.isEmpty() || path3.isEmpty()) {
                dismissProDialog();
                canCloseDialog(dialog, false);
                showAlam(R.string.cannot_empty);
                return;
            }
            save2Local();
            canCloseDialog(dialog, true);
        }
    }).create();
    return layout;
}
Also used : ImageButton(android.widget.ImageButton) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) OnClickListener(android.view.View.OnClickListener) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 13 with Builder

use of android.app.AlertDialog.Builder in project GT by Tencent.

the class GTAUTFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View autLayout = inflater.inflate(R.layout.gt_settingactivity, container, false);
    tv_Appstatus = (TextView) autLayout.findViewById(R.id.app_status);
    tv_select = (TextView) autLayout.findViewById(R.id.selected_app_bg);
    tv_select.setOnClickListener(select);
    tv_PkName = (TextView) autLayout.findViewById(R.id.select_tested_pkn);
    tv_selectedApp = (TextView) autLayout.findViewById(R.id.app_pic);
    tv_AppName = (TextView) autLayout.findViewById(R.id.selected_apn);
    tv_refresh = (TextView) autLayout.findViewById(R.id.app_refresh);
    tv_refresh.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                proDialog = ProgressDialog.show(getActivity(), "Searching..", "searching..wait....", true, false);
                tv_refresh.setTextColor(Color.GREEN);
                Thread loginThread = new Thread(new ProcessRefresher());
                loginThread.start();
                v.performClick();
            }
            return true;
        }
    });
    tv_refresh.setVisibility(View.GONE);
    cb_cpu = (CheckBox) autLayout.findViewById(R.id.cb_cpu);
    cb_jiffies = (CheckBox) autLayout.findViewById(R.id.cb_jiffies);
    cb_net = (CheckBox) autLayout.findViewById(R.id.cb_net);
    cb_pss = (CheckBox) autLayout.findViewById(R.id.cb_pss);
    cb_pd = (CheckBox) autLayout.findViewById(R.id.cb_pd);
    cb_boxs = new CheckBox[] { cb_cpu, cb_jiffies, cb_net, cb_pss, cb_pd };
    cb_cpu.setOnClickListener(cb_check);
    cb_jiffies.setOnClickListener(cb_check);
    cb_net.setOnClickListener(cb_check);
    cb_pss.setOnClickListener(cb_check);
    cb_pd.setOnClickListener(cb_check);
    memOn = (TextView) autLayout.findViewById(R.id.btn_memon);
    memOff = (TextView) autLayout.findViewById(R.id.btn_memoff);
    memSwitch = autLayout.findViewById(R.id.memswitch);
    selectDrawable = R.drawable.swbtn_selected;
    defaultDrawable = R.drawable.swbtn_default;
    if (isAutoGetMem) {
        memOn.setText("");
        memOn.setBackgroundResource(selectDrawable);
        memOff.setText("off");
        memOff.setBackgroundResource(defaultDrawable);
    } else {
        memOn.setText("on");
        memOn.setBackgroundResource(selectDrawable);
        memOff.setText("");
        memOff.setBackgroundResource(defaultDrawable);
    }
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.gt_dailog_save, container, false);
    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);
    dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            GTMemHelperFloatview.memInfoList.clear();
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            // 简单保存
            String path = et_savePath.getText().toString();
            LogUtils.writeTagMemData(tv_PkName.getText().toString(), path + ".csv");
            GTMemHelperFloatview.memInfoList.clear();
            dialog.dismiss();
        }
    }).create();
    memSwitch.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!tv_PkName.getText().toString().equals("n/a")) {
                if (isAutoGetMem) {
                    isAutoGetMem = false;
                    memOn.setText("on");
                    memOn.setBackgroundResource(defaultDrawable);
                    memOff.setText("");
                    memOff.setBackgroundResource(selectDrawable);
                    // if(!tv_PkName.getText().toString().equals("n/a")){
                    Intent intent = new Intent(GTApp.getContext(), GTMemHelperFloatview.class);
                    intent.putExtra("pName", tv_PkName.getText().toString());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    PluginManager.getInstance().getPluginControler().startService(GTMemHelperFloatview.getInstance(), intent);
                // }
                } else {
                    isAutoGetMem = true;
                    memOn.setText("");
                    memOn.setBackgroundResource(selectDrawable);
                    memOff.setText("off");
                    memOff.setBackgroundResource(defaultDrawable);
                    GTMemHelperFloatview.tagTimes = 0;
                    PluginManager.getInstance().getPluginControler().stopService(GTMemHelperFloatview.getInstance());
                    dlg_save.show();
                }
            }
            v.performClick();
            return false;
        }
    });
    return autLayout;
}
Also used : OnTouchListener(android.view.View.OnTouchListener) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) CommonString(com.tencent.wstt.gt.utils.CommonString) View(android.view.View) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent) GTMemHelperFloatview(com.tencent.wstt.gt.proInfo.floatView.GTMemHelperFloatview) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener)

Example 14 with Builder

use of android.app.AlertDialog.Builder in project GT by Tencent.

the class GTAUTFragment method hashistory.

private void hashistory(final int type) {
    // 当去除性能指标项的勾选时,查看是否该项存在历史数据,有则提示,无则直接删除
    String outparaname = cb_alias[type];
    AlertDialog.Builder builder = new Builder(getActivity());
    boolean hasdata = true;
    ArrayList<String> tempL = new ArrayList<String>();
    tempL = (ArrayList<String>) AUTManager.registOpTable.get(outparaname);
    if (tempL != null) {
        for (int i = 0; i < tempL.size(); i++) {
            TagTimeEntry tte = OpPerfBridge.getProfilerData((String) tempL.get(i));
            if (tte == null) {
                hasdata = false;
            } else {
                if (tte.hasChild() && tte.getChildren()[0].getRecordSize() > 0) {
                    hasdata = true;
                } else if (tte.getRecordSize() <= 0) {
                    hasdata = false;
                }
            }
        }
        if (!hasdata) {
            unregisterOutpara(type);
        } else {
            builder.setMessage(getString(R.string.AUT_page_tip1));
            builder.setTitle(getString(R.string.AUT_page_tip_title));
            builder.setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    cb_boxs[type].setChecked(true);
                }
            });
            builder.setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // UI需要清理dataSet
                    unregisterOutpara(type);
                    dialog.dismiss();
                }
            });
            builder.setCancelable(false);
            builder.show();
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) ArrayList(java.util.ArrayList) CommonString(com.tencent.wstt.gt.utils.CommonString)

Example 15 with Builder

use of android.app.AlertDialog.Builder in project ignition by mttkay.

the class IgnitedDialogs method newYesNoDialog.

/**
     * Builds a new Yes/No AlertDialog
     * 
     * @param context
     * @param title
     * @param message
     * @param positiveButtonMessage
     * @param negativeButtonMessage
     * @param iconId
     * @param listener
     * @return
     */
public static AlertDialog.Builder newYesNoDialog(final Context context, String title, String message, String positiveButtonMessage, String negativeButtonMessage, int iconId, OnClickListener listener) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);
    builder.setPositiveButton(positiveButtonMessage, listener);
    builder.setNegativeButton(negativeButtonMessage, listener);
    builder.setTitle(title);
    builder.setMessage(message);
    builder.setIcon(iconId);
    return builder;
}
Also used : AlertDialog(android.app.AlertDialog) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder)

Aggregations

Builder (android.app.AlertDialog.Builder)71 DialogInterface (android.content.DialogInterface)50 AlertDialog (android.app.AlertDialog)32 OnClickListener (android.content.DialogInterface.OnClickListener)18 Intent (android.content.Intent)18 View (android.view.View)16 TextView (android.widget.TextView)14 OnClickListener (android.view.View.OnClickListener)11 ArrayList (java.util.ArrayList)10 SuppressLint (android.annotation.SuppressLint)9 Bundle (android.os.Bundle)9 ImageView (android.widget.ImageView)8 ImageButton (android.widget.ImageButton)7 RelativeLayout (android.widget.RelativeLayout)7 List (java.util.List)7 Point (android.graphics.Point)6 ExpandableListView (android.widget.ExpandableListView)5 TileInfo (com.android.systemui.qs.customize.TileQueryHelper.TileInfo)5 LinearLayout (android.widget.LinearLayout)4 ListView (android.widget.ListView)4