Search in sources :

Example 41 with Builder

use of android.app.AlertDialog.Builder in project KeepScore by nolanlawson.

the class InstallFree method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final boolean installed = Helper.isFreeVersionInstalled(this);
    AlertDialog.Builder builder = new Builder(this);
    builder.setTitle(R.string.thanks_title);
    builder.setCancelable(false);
    builder.setPositiveButton(android.R.string.ok, new OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            if (installed) {
                Intent i = new Intent();
                i.setClassName("com.nolanlawson.keepscore", "com.nolanlawson.keepscore.MainActivity");
                i.setAction(Intent.ACTION_MAIN);
                startActivity(i);
            }
            finish();
        }
    });
    if (installed) {
        Helper.setDonateIcon(this, false);
        builder.setMessage(R.string.thanks);
    } else {
        builder.setMessage(R.string.install_free_text);
    }
    builder.create().show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) OnClickListener(android.content.DialogInterface.OnClickListener) Intent(android.content.Intent)

Example 42 with Builder

use of android.app.AlertDialog.Builder in project platform_frameworks_base by android.

the class KeyguardSimPinView method getSimRemainingAttemptsDialog.

private Dialog getSimRemainingAttemptsDialog(int remaining) {
    String msg = getPinPasswordErrorMessage(remaining);
    if (mRemainingAttemptsDialog == null) {
        Builder builder = new AlertDialog.Builder(mContext);
        builder.setMessage(msg);
        builder.setCancelable(false);
        builder.setNeutralButton(R.string.ok, null);
        mRemainingAttemptsDialog = builder.create();
        mRemainingAttemptsDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
    } else {
        mRemainingAttemptsDialog.setMessage(msg);
    }
    return mRemainingAttemptsDialog;
}
Also used : Builder(android.app.AlertDialog.Builder)

Example 43 with Builder

use of android.app.AlertDialog.Builder in project DroidPlugin by DroidPluginTeam.

the class ApkFragment method doUninstall.

private void doUninstall(final ApkItem item) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle("警告,你确定要删除么?");
    builder.setMessage("警告,你确定要删除" + item.title + "么?");
    builder.setNegativeButton("删除", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            new File(item.apkfile).delete();
            adapter.remove(item);
            Toast.makeText(getActivity(), "删除成功", Toast.LENGTH_SHORT).show();
        }
    });
    builder.setNeutralButton("取消", null);
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) File(java.io.File)

Example 44 with Builder

use of android.app.AlertDialog.Builder in project DroidPlugin by DroidPluginTeam.

the class InstalledFragment method doUninstall.

private void doUninstall(final ApkItem item) {
    AlertDialog.Builder builder = new Builder(getActivity());
    builder.setTitle("警告,你确定要删除么?");
    builder.setMessage("警告,你确定要删除" + item.title + "么?");
    builder.setNegativeButton("删除", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (!PluginManager.getInstance().isConnected()) {
                Toast.makeText(getActivity(), "服务未连接", Toast.LENGTH_SHORT).show();
            } else {
                try {
                    PluginManager.getInstance().deletePackage(item.packageInfo.packageName, 0);
                    Toast.makeText(getActivity(), "删除完成", Toast.LENGTH_SHORT).show();
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        }
    });
    builder.setNeutralButton("取消", null);
    builder.show();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) Builder(android.app.AlertDialog.Builder) RemoteException(android.os.RemoteException)

Example 45 with Builder

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

the class GTPerfFragment method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View perfLayout = inflater.inflate(R.layout.gt_perfactivity, container, false);
    tv_perNoStartToast = (TextView) perfLayout.findViewById(R.id.perf_no_start_toast);
    btn_delete = (ImageButton) perfLayout.findViewById(R.id.perf_delete);
    btn_save = (ImageButton) perfLayout.findViewById(R.id.perf_save);
    btn_start = (ImageButton) perfLayout.findViewById(R.id.perf_start);
    btn_stop = (ImageButton) perfLayout.findViewById(R.id.perf_stop);
    listView = (ListView) perfLayout.findViewById(R.id.perf_list);
    dataSet = GTTimeInternal.getEntrys();
    timeAdapter = new TimeAdapter(dataSet);
    listView.setAdapter(timeAdapter);
    /*
		 * 初始化各UI控件初始状态
		 */
    if (GTTimeInternal.isETStarted()) {
        if (dataSet != null && dataSet.length == 0) {
            tv_perNoStartToast.setText(TOAST_STARTED);
            tv_perNoStartToast.setVisibility(View.VISIBLE);
        } else {
            tv_perNoStartToast.setVisibility(View.GONE);
        }
        btn_start.setVisibility(View.INVISIBLE);
        btn_save.setVisibility(View.INVISIBLE);
        btn_delete.setVisibility(View.INVISIBLE);
        btn_stop.setVisibility(View.VISIBLE);
    } else {
        if (dataSet == null || dataSet.length == 0) {
            tv_perNoStartToast.setText(TOAST_NOT_START);
            tv_perNoStartToast.setVisibility(View.VISIBLE);
        } else {
            tv_perNoStartToast.setVisibility(View.GONE);
        }
        btn_start.setVisibility(View.VISIBLE);
        btn_save.setVisibility(View.VISIBLE);
        btn_delete.setVisibility(View.VISIBLE);
        btn_stop.setVisibility(View.INVISIBLE);
    }
    // 删除相关控件
    btn_delete.setOnClickListener(showDeleteDlg);
    /*
		 * 保存相关控件
		 */
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity()).inflate(R.layout.gt_dailog_save, 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_savePath.setText("");
        }
    });
    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);
    String lastSaveLog = GTTimeInternal.getLastSaveTimeLog();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    lastSaveLog = lastSaveLog.trim();
    et_savePath.setText(lastSaveLog);
    dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save_file)).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) {
            GTTimeInternal.saveTimeLog(et_savePath.getText().toString().trim());
            dialog.dismiss();
        }
    }).create();
    btn_save.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            String lastSaveLog = GTTimeInternal.getLastSaveTimeLog();
            if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
                lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
            }
            et_savePath.setText(lastSaveLog);
            dlg_save.show();
        }
    });
    btn_start.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // UI需要隐藏save、delete、start,显示end
            if (!GTTimeInternal.isETStarted()) {
                // 如果想开启,需要先校验
                if (!GTMemoryDaemonHelper.startGWOrProfValid()) {
                    return;
                }
                btn_start.setVisibility(View.INVISIBLE);
                btn_save.setVisibility(View.INVISIBLE);
                btn_delete.setVisibility(View.INVISIBLE);
                btn_stop.setVisibility(View.VISIBLE);
                // 这个属性需要交给控制器去做业务逻辑相关处理
                GTTimeInternal.setETStarted(true);
                handler.postDelayed(task, delaytime);
                if (dataSet != null && dataSet.length == 0) {
                    tv_perNoStartToast.setText(TOAST_STARTED);
                    tv_perNoStartToast.setVisibility(View.VISIBLE);
                } else {
                    tv_perNoStartToast.setVisibility(View.GONE);
                }
            }
        }
    });
    btn_stop.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // UI需要隐藏save、delete、start,显示end
            if (GTTimeInternal.isETStarted()) {
                btn_save.setVisibility(View.VISIBLE);
                btn_delete.setVisibility(View.VISIBLE);
                btn_start.setVisibility(View.VISIBLE);
                btn_stop.setVisibility(View.INVISIBLE);
                // 这个属性需要交给控制器去做业务逻辑相关处理
                GTTimeInternal.setETStarted(false);
                handler.removeCallbacks(task);
                if (dataSet == null || dataSet.length == 0) {
                    tv_perNoStartToast.setText(TOAST_NOT_START);
                    tv_perNoStartToast.setVisibility(View.VISIBLE);
                } else {
                    tv_perNoStartToast.setVisibility(View.GONE);
                }
            }
        }
    });
    return perfLayout;
}
Also used : ImageButton(android.widget.ImageButton) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView)

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