Java Code Examples for android.content.DialogInterface#show()

The following examples show how to use android.content.DialogInterface#show() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FragmentDialog_Search.java    From Pas with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final EditText editText = new EditText(getActivity());


    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle("输入要搜索的图片信息")
            .setView(editText)
            .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            }).setPositiveButton("搜索", null);


    dialog = alertDialog.create();

    dialog.show();

    if(dialog.getButton(AlertDialog.BUTTON_POSITIVE)!=null) {
        dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (TextUtils.isEmpty(editText.getText().toString().trim())) {
                    ToastUtil.showToast("输入点什么吧");
                    return;
                } else {
                    SearchContentListener searchContentListener = (SearchContentListener) getActivity();
                    searchContentListener.onSearchComplete(editText.getText().toString().trim());
                    dialog.dismiss();
                }
            }
        });
    }

    return dialog;
}
 
Example 2
Source File: CustomUI.java    From socialauth-android with MIT License 5 votes vote down vote up
@Override
public void onComplete(Bundle values) {

	Log.d("Custom-UI", "Successful");

	// Changing Sign In Text to Sign Out
	View v = listview.getChildAt(pos - listview.getFirstVisiblePosition());
	TextView pText = (TextView) v.findViewById(R.id.signstatus);
	pText.setText("Sign Out");

	// Get the provider
	providerName = values.getString(SocialAuthAdapter.PROVIDER);
	Log.d("Custom-UI", "providername = " + providerName);

	Toast.makeText(CustomUI.this, providerName + " connected", Toast.LENGTH_SHORT).show();

	int res = getResources().getIdentifier(providerName + "_array", "array", CustomUI.this.getPackageName());

	AlertDialog.Builder builder = new AlertDialog.Builder(CustomUI.this);
	builder.setTitle("Select Options");
	builder.setCancelable(true);
	builder.setIcon(android.R.drawable.ic_menu_more);

	mDialog = new ProgressDialog(CustomUI.this);
	mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
	mDialog.setMessage("Loading...");

	builder.setSingleChoiceItems(new DialogAdapter(CustomUI.this, R.layout.provider_options, getResources()
			.getStringArray(res)), 0, new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int item) {

			Events(item, providerName);
			dialog.dismiss();
		}
	});
	dialog = builder.create();
	dialog.show();

}
 
Example 3
Source File: MainActivity.java    From MoeGallery with GNU General Public License v3.0 4 votes vote down vote up
void search() {

        View searchView = getLayoutInflater().inflate(R.layout.search_box,
                (ViewGroup) findViewById(android.R.id.content), false);
        final EditText searchText = (EditText) searchView.findViewById(R.id.search);

        searchText.setText(tags.replace('_', ' '));
        searchText.setSelection(searchText.getText().length());

        searchText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                searchText.post(new Runnable() {
                    @Override
                    public void run() {
                        InputMethodManager inputMethodManager =
                                (InputMethodManager) MainActivity.this.getSystemService(
                                        Context.INPUT_METHOD_SERVICE);
                        inputMethodManager.showSoftInput(searchText,
                                InputMethodManager.SHOW_IMPLICIT);
                    }
                });
            }
        });
        searchText.requestFocus();

        AlertDialog.Builder builder = new AlertDialog.Builder(this)
                .setTitle(android.R.string.search_go)
                .setView(searchView)
                .setNegativeButton(android.R.string.cancel, null)
                .setPositiveButton(android.R.string.search_go,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                showProgressDialog();
                                tags = searchText.getText().toString();
                                mDataSource.listTag(tags)
                                        .subscribe(new Action1<List<? extends Tag>>() {
                                            @Override
                                            public void call(List<? extends Tag> tagList) {
                                                listTagDialog(tags, tagList);
                                            }
                                        }, new Action1<Throwable>() {
                                            @Override
                                            public void call(Throwable throwable) {
                                                showErrorDialog(throwable.getMessage());
                                            }
                                        });
                            }
                        });

        dialog = builder.create();
        dialog.show();
    }
 
Example 4
Source File: RMBTAboutFragment.java    From open-rmbt with Apache License 2.0 4 votes vote down vote up
private void handleHiddenCode()
{
    if (++developerFeatureCounter >= 10)
    {
        developerFeatureCounter = 0;
        final EditText input = new EditText(getActivity());
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setView(input);
        builder.setTitle(R.string.about_hidden_feature_dialog_title);
        builder.setMessage(R.string.about_hidden_feature_dialog_enter_code);
        builder.setPositiveButton(android.R.string.ok, new OnClickListener()
        {
            @Override
            public void onClick(final DialogInterface dialog, final int which)
            {
                
                try
                {
                    final String data = input.getText().toString();
                    if (! data.matches("\\d{8}"))
                    {
                    	Toast.makeText(getActivity(), R.string.about_hidden_feature_dialog_msg_try_again, Toast.LENGTH_LONG).show();
                        return;
                    }
                    
                    final int dataInt = Integer.parseInt(data);
                    if (dataInt == 0) // deactivate all features
                    {
                        ConfigHelper.setUserLoopModeState(getActivity(), false);
                        ConfigHelper.setDevModeState(getActivity(), false);
                        ConfigHelper.setServerSelectionState(getActivity(), false);
                        ((RMBTMainActivity) getActivity()).checkSettings(true, null); // refresh server list
                        Toast.makeText(getActivity(), R.string.about_hidden_feature_dialog_msg_deactivated, Toast.LENGTH_LONG).show();
                        return;
                    }
                    
                    if (ConfigHelper.isValidCheckSum(dataInt))
                    {   // developer mode
                    	if (dataInt == AppConstants.DEVELOPER_UNLOCK_CODE) {
                    		ConfigHelper.setDevModeState(getActivity(), true);
                    		Toast.makeText(getActivity(), R.string.about_dev_mode_activated, Toast.LENGTH_LONG).show();
                    	}
                    	else if (dataInt == AppConstants.DEVELOPER_LOCK_CODE) {
                    		ConfigHelper.setDevModeState(getActivity(), false);
                    		Toast.makeText(getActivity(), R.string.about_dev_mode_deactivated, Toast.LENGTH_LONG).show();
                    	}
                    	// loop mode
                    	else if (dataInt == AppConstants.LOOP_MODE_UNLOCK_CODE) {
                    		ConfigHelper.setUserLoopModeState(getActivity(), true);
                    		Toast.makeText(getActivity(), R.string.about_loop_mode_activated, Toast.LENGTH_LONG).show();
                    	}
                    	else if (dataInt == AppConstants.LOOP_MODE_LOCK_CODE) {
                    		ConfigHelper.setUserLoopModeState(getActivity(), false);
                    		Toast.makeText(getActivity(), R.string.about_loop_mode_deactivated, Toast.LENGTH_LONG).show();
                    	}
                    	// server selection
                    	else if (dataInt == AppConstants.SERVER_SELECTION_UNLOCK_CODE) {
                    		ConfigHelper.setServerSelectionState(getActivity(), true);
                    		((RMBTMainActivity) getActivity()).checkSettings(true, null); // refresh server list
                    		Toast.makeText(getActivity(), R.string.about_server_selection_activated, Toast.LENGTH_LONG).show();
                    	}
                    	else if (dataInt == AppConstants.SERVER_SELECTION_LOCK_CODE) {
                    		ConfigHelper.setServerSelectionState(getActivity(), false);
                    		((RMBTMainActivity) getActivity()).checkSettings(true, null); // refresh server list
                    		Toast.makeText(getActivity(), R.string.about_server_selection_deactivated, Toast.LENGTH_LONG).show();
                    	}
                    	// code not used
                    	else {
                    		Toast.makeText(getActivity(), R.string.about_hidden_feature_dialog_msg_try_again, Toast.LENGTH_LONG).show();
                    	}
                    }
                    else
                    	Toast.makeText(getActivity(), R.string.about_hidden_feature_dialog_msg_try_again, Toast.LENGTH_LONG).show();
                }
                catch (Exception e) // ignore errors
                {
                    e.printStackTrace();
                }
            }
        });
        builder.setNegativeButton(android.R.string.cancel, null);
        
        dialog = builder.create();
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
        dialog.show();
    }
}