Example usage for android.app Dialog findViewById

List of usage examples for android.app Dialog findViewById

Introduction

In this page you can find the example usage for android.app Dialog findViewById.

Prototype

@Nullable
public <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create() ).

Usage

From source file:com.hughes.android.dictionary.DictionaryActivity.java

void onLanguageButtonLongClick(final Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.setContentView(R.layout.select_dictionary_dialog);
    dialog.setTitle(R.string.selectDictionary);

    final List<DictionaryInfo> installedDicts = application.getDictionariesOnDevice(null);

    ListView listView = (ListView) dialog.findViewById(android.R.id.list);
    final Button button = new Button(listView.getContext());
    final String name = getString(R.string.dictionaryManager);
    button.setText(name);/*w  ww  .ja  v a 2s. c o m*/
    final IntentLauncher intentLauncher = new IntentLauncher(listView.getContext(),
            DictionaryManagerActivity.getLaunchIntent(getApplicationContext())) {
        @Override
        protected void onGo() {
            dialog.dismiss();
            DictionaryActivity.this.finish();
        }
    };
    button.setOnClickListener(intentLauncher);
    listView.addHeaderView(button);

    listView.setAdapter(new BaseAdapter() {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final DictionaryInfo dictionaryInfo = getItem(position);

            final LinearLayout result = new LinearLayout(parent.getContext());

            for (int i = 0; i < dictionaryInfo.indexInfos.size(); ++i) {
                final IndexInfo indexInfo = dictionaryInfo.indexInfos.get(i);
                final View button = application.createButton(parent.getContext(), dictionaryInfo, indexInfo);
                final IntentLauncher intentLauncher = new IntentLauncher(parent.getContext(),
                        getLaunchIntent(getApplicationContext(),
                                application.getPath(dictionaryInfo.uncompressedFilename), indexInfo.shortName,
                                searchView.getQuery().toString())) {
                    @Override
                    protected void onGo() {
                        dialog.dismiss();
                        DictionaryActivity.this.finish();
                    }
                };
                button.setOnClickListener(intentLauncher);
                if (i == indexIndex && dictFile != null
                        && dictFile.getName().equals(dictionaryInfo.uncompressedFilename)) {
                    button.setPressed(true);
                }
                result.addView(button);
            }

            final TextView nameView = new TextView(parent.getContext());
            final String name = application.getDictionaryName(dictionaryInfo.uncompressedFilename);
            nameView.setText(name);
            final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            layoutParams.width = 0;
            layoutParams.weight = 1.0f;
            nameView.setLayoutParams(layoutParams);
            nameView.setGravity(Gravity.CENTER_VERTICAL);
            result.addView(nameView);
            return result;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public DictionaryInfo getItem(int position) {
            return installedDicts.get(position);
        }

        @Override
        public int getCount() {
            return installedDicts.size();
        }
    });
    dialog.show();
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

final static private void setProfileActionMessageListener(final GlobalParameters mGlblParms,
        final Dialog dialog, final AdapterProfileList pfla, final String curr_grp) {
    final Spinner spinnerMessageType = (Spinner) dialog.findViewById(R.id.edit_profile_action_message_type);
    final EditText et_msg_text = (EditText) dialog.findViewById(R.id.edit_profile_action_message_message);
    final CheckBox cb_led_used = (CheckBox) dialog.findViewById(R.id.edit_profile_action_message_led);
    final RadioButton rb_msg_blue = (RadioButton) dialog
            .findViewById(R.id.edit_profile_action_message_led_blue);
    final RadioButton rb_msg_red = (RadioButton) dialog.findViewById(R.id.edit_profile_action_message_led_red);
    final RadioButton rb_msg_green = (RadioButton) dialog
            .findViewById(R.id.edit_profile_action_message_led_green);
    cb_led_used.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override/* ww w  .  j av a  2  s .c o  m*/
        final public void onCheckedChanged(CompoundButton arg0, boolean isChecked) {
            if (isChecked) {
                rb_msg_blue.setEnabled(true);
                rb_msg_red.setEnabled(true);
                rb_msg_green.setEnabled(true);
            } else {
                rb_msg_blue.setEnabled(false);
                rb_msg_red.setEnabled(false);
                rb_msg_green.setEnabled(false);
            }
        }
    });
    spinnerMessageType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        final public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) {
            et_msg_text.setVisibility(EditText.VISIBLE);
            if (spinnerMessageType.getItemAtPosition(pos).toString()
                    .equals(PROFILE_ACTION_TYPE_MESSAGE_NOTIFICATION)) {
                cb_led_used.setVisibility(CheckBox.VISIBLE);
                rb_msg_blue.setVisibility(RadioButton.VISIBLE);
                rb_msg_red.setVisibility(RadioButton.VISIBLE);
                rb_msg_green.setVisibility(RadioButton.VISIBLE);
            } else {
                cb_led_used.setVisibility(CheckBox.GONE);
                rb_msg_blue.setVisibility(RadioButton.GONE);
                rb_msg_red.setVisibility(RadioButton.GONE);
                rb_msg_green.setVisibility(RadioButton.GONE);
            }
        }

        @Override
        final public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}

From source file:com.andrewshu.android.reddit.profile.ProfileActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    switch (id) {
    //       case Constants.DIALOG_LOGIN:
    //          if (mSettings.username != null) {
    //             final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input);
    //             loginUsernameInput.setText(mSettings.username);
    //          }
    //          final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input);
    //          loginPasswordInput.setText("");
    //          break;

    case Constants.DIALOG_COMPOSE:
        final EditText composeDestination = (EditText) dialog.findViewById(R.id.compose_destination_input);
        composeDestination.setText(mUsername);
        new MyCaptchaCheckRequiredTask(dialog).execute();
        break;/*from   ww w  . ja  v a  2 s. co  m*/

    case Constants.DIALOG_THREAD_CLICK:
        ThreadsListActivity.fillThreadClickDialog(dialog, mVoteTargetThingInfo, mSettings,
                threadClickDialogOnClickListenerFactory);
        break;

    default:
        // No preparation based on app state is required.
        break;
    }
}

From source file:com.andrewshu.android.reddit.user.ProfileActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    super.onPrepareDialog(id, dialog);

    switch (id) {
    //       case Constants.DIALOG_LOGIN:
    //          if (mSettings.username != null) {
    //             final TextView loginUsernameInput = (TextView) dialog.findViewById(R.id.login_username_input);
    //             loginUsernameInput.setText(mSettings.username);
    //          }
    //          final TextView loginPasswordInput = (TextView) dialog.findViewById(R.id.login_password_input);
    //          loginPasswordInput.setText("");
    //          break;

    case Constants.DIALOG_COMPOSE:
        final EditText composeDestination = (EditText) dialog.findViewById(R.id.compose_destination_input);
        composeDestination.setText(mUsername);
        new MyCaptchaCheckRequiredTask(dialog).execute();
        break;/* w  w  w .  j  ava  2s.  co m*/

    case Constants.DIALOG_THREAD_CLICK:
        ThreadsListActivity.fillThreadClickDialog(dialog, mVoteTargetThingInfo, mSettings,
                mThreadClickDialogOnClickListenerFactory);
        break;

    default:
        // No preparation based on app state is required.
        break;
    }
}

From source file:pl.edu.agh.mindmapex.gui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.action_settings:
        Intent intent = new Intent(MainActivity.this, EditSheetScreen.class);
        if (sheet1.getStyleId() != null && styleSheet.findStyle(sheet1.getStyleId()) != null
                && styleSheet.findStyle(sheet1.getStyleId()).getProperty(Styles.FillColor) != null) {
            intent.putExtra(BACKGROUNDCOLOR,
                    Color.parseColor(styleSheet.findStyle(sheet1.getStyleId()).getProperty(Styles.FillColor)));
        } else {//from   ww w  .  j a  v  a 2s  . co  m
            intent.putExtra(BACKGROUNDCOLOR, Color.WHITE);
        }
        startActivity(intent);
        return true;
    case R.id.action_undo:
        if (commandsUndo.size() == 1) {
            commandsUndo.getFirst().undo();
            if (commandsUndo.getFirst() instanceof EditBox) {
                Callback call = new Callback() {
                    @Override
                    public void execute() {
                        lay.updateBoxWithText(((EditBox) commandsUndo.getFirst()).box);
                        for (Box b : ((EditBox) commandsUndo.getLast()).edited) {
                            lay.updateBoxWithText(b);
                        }
                    }
                };
            } else if (commandsUndo.getFirst() instanceof EditSheet) {
                lay.setBackgroundColor((Color.parseColor(
                        MainActivity.styleSheet.findStyle(sheet1.getStyleId()).getProperty(Styles.FillColor))));
            } else {
                Callback call = new Callback() {
                    @Override
                    public void execute() {
                    }
                };
                try {
                    AsyncInvalidate async = new AsyncInvalidate(MainActivity.this);
                    async.setCallback(call);
                    async.execute();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
            commandsRedo.add(commandsUndo.getFirst());
            commandsUndo.removeFirst();
            menu.getItem(6).setVisible(true);
            menu.getItem(5).setVisible(false);
        } else {
            commandsUndo.getLast().undo();
            if (commandsUndo.getLast() instanceof EditBox) {
                lay.updateBoxWithText(((EditBox) commandsUndo.getLast()).box);
                for (Box b : ((EditBox) commandsUndo.getLast()).edited) {
                    lay.updateBoxWithText(b);
                }
            } else if (commandsUndo.getLast() instanceof EditSheet) {
                lay.setBackgroundColor(Integer.parseInt(sheet1.getTheme().getProperty(Styles.FillColor)));
            } else if (commandsUndo.getLast() instanceof AddBox || commandsUndo.getLast() instanceof RemoveLine
                    || commandsUndo.getLast() instanceof RemoveBox) {
            }
            commandsRedo.add(commandsUndo.getLast());
            menu.getItem(6).setVisible(true);
            commandsUndo.removeLast();
        }
        return true;
    case R.id.action_new:
        IStyle boxEditedStyle = workbook.getStyleSheet().findStyle(boxEdited.topic.getStyleId());
        Intent intent1 = new Intent(MainActivity.this, EditBoxScreen.class);
        if (boxEditedStyle != null) {

            intent1.putExtra(EditBoxScreen.BOX_COLOR, boxEditedStyle.getProperty(Styles.FillColor));
            intent1.putExtra(EditBoxScreen.TEXT_COLOR, boxEdited.topic.getTitleText());
            intent1.putExtra(EditBoxScreen.LINE_SHAPE, boxEditedStyle.getProperty(Styles.LineClass));
            intent1.putExtra(EditBoxScreen.LINE_COLOR, boxEditedStyle.getProperty(Styles.LineColor));
            intent1.putExtra(EditBoxScreen.BOX_SHAPE, boxEditedStyle.getProperty(Styles.ShapeClass));
            intent1.putExtra(EditBoxScreen.LINE_THICKNESS, boxEditedStyle.getProperty(Styles.LineWidth));
        }
        startActivity(intent1);
        // lay.invalidateDrawable(boxEdited.drawableShape);
        return true;
    case R.id.new_line:
        Properties properties1 = new Properties();
        properties1.put("child", MainActivity.toEditBoxes.getFirst());
        if (MainActivity.toEditBoxes.size() == 2) {
            properties1.put("parent", MainActivity.toEditBoxes.getLast());
        }
        AddLine addLine = new AddLine();
        addLine.execute(properties1);
        MainActivity.addCommendUndo(addLine);
        //   lay.invalidate();
        return true;
    case R.id.action_redo:
        if (commandsRedo.size() == 1) {
            commandsRedo.getFirst().redo();
            if (commandsRedo.getFirst() instanceof EditBox) {
                //     Callback call = new Callback() {
                //         @Override
                //        public void execute() {
                lay.updateBoxWithText(((EditBox) commandsRedo.getFirst()).box);
                for (Box b : ((EditBox) commandsRedo.getLast()).edited) {
                    lay.updateBoxWithText(b);
                }

            } else if (commandsRedo.getFirst() instanceof EditSheet) {
                lay.setBackgroundColor((Color.parseColor(
                        MainActivity.styleSheet.findStyle(sheet1.getStyleId()).getProperty(Styles.FillColor))));
            }
            //    lay.invalidate();
            commandsUndo.add(commandsRedo.getFirst());
            commandsRedo.removeFirst();
            menu.getItem(5).setVisible(true);
            menu.getItem(6).setVisible(false);
        } else {
            commandsRedo.getLast().redo();
            if (commandsRedo.getLast() instanceof EditBox) {
                lay.updateBoxWithText(((EditBox) commandsRedo.getLast()).box);
                for (Box b : ((EditBox) commandsRedo.getLast()).edited) {
                    lay.updateBoxWithText(b);
                }

            } else if (commandsRedo.getLast() instanceof EditSheet) {
                lay.setBackgroundColor(Integer.parseInt(sheet1.getTheme().getProperty(Styles.FillColor)));
            }
            //  lay.invalidate();
            commandsUndo.add(commandsRedo.getLast());
            menu.getItem(5).setVisible(true);
            commandsRedo.removeLast();
        }
        return true;
    case R.id.action_trash:
        RemoveBox removeBox = new RemoveBox();
        Properties properties = new Properties();
        HashMap<Box, Line> boxes = new HashMap<>();
        boxes.put(MainActivity.boxEdited, MainActivity.boxEdited.parent.getLines().get(MainActivity.boxEdited));
        for (Box b : MainActivity.toEditBoxes) {
            b.isSelected = false;
            boxes.put(b, b.parent.getLines().get(b));
            if (boxes.size() > 0) {
                properties.put("boxes", boxes);
                removeBox.execute(properties);
                MainActivity.addCommendUndo(removeBox);
            }
            //  return true;
        }
        menu.getItem(4).setVisible(false);
        menu.getItem(1).setVisible(false);
        menu.getItem(2).setVisible(false);
        menu.getItem(3).setVisible(false);
        MainActivity.toEditBoxes.clear();
        //   lay.invalidate();
        return true;
    case R.id.new_rel:
        if (!MainActivity.toEditBoxes.getFirst().relationships
                .containsValue(MainActivity.toEditBoxes.getLast())) {
            final Dialog dialog = DialogFactory.boxContentDialog(MainActivity.this);
            final Button btn = (Button) dialog.findViewById(R.id.dialogButtonOK);
            final EditText et = (EditText) dialog.findViewById(R.id.editText);
            et.requestFocus();
            final Button btn2 = (Button) dialog.findViewById(R.id.button2);
            btn2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });

            btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Callback call = null;

                    InputMethodManager imm = (InputMethodManager) getSystemService(
                            Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
                    String text = (et.getText().toString());
                    AddRelationship addRel = new AddRelationship();
                    Properties p = new Properties();
                    p.put("boxes", MainActivity.toEditBoxes);
                    p.put("text", text);
                    addRel.execute(p);
                    MainActivity.addCommendUndo(addRel);
                    lay.drawRelationship(MainActivity.toEditBoxes.getFirst(), addRel.relation);
                    dialog.dismiss();

                }
            });

            final int MAX_LINES = 3;

            //ogranicza do 3 linii widok w zawartoci bloczka
            et.addTextChangedListener(new TextWatcher() {
                private int lines;

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }

                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                    lines = Utils.countLines(s.toString());
                }

                @Override
                public void afterTextChanged(Editable s) {
                    int counter = Utils.countLines(s.toString());

                    int diff = lines - counter;
                    if (diff > 0) {
                        //w gore
                        if (counter < MAX_LINES - 1 && et.getLayoutParams().height > 75) {
                            LinearLayout.LayoutParams buttonLayoutParams = (LinearLayout.LayoutParams) btn
                                    .getLayoutParams();
                            buttonLayoutParams.setMargins(buttonLayoutParams.leftMargin,
                                    buttonLayoutParams.topMargin - 30, buttonLayoutParams.rightMargin,
                                    buttonLayoutParams.bottomMargin);
                            btn.setLayoutParams(buttonLayoutParams);
                            btn2.setLayoutParams(buttonLayoutParams);
                            et.getLayoutParams().height -= 30;
                        }
                    } else if (diff < 0) {
                        //w dol
                        if (counter < MAX_LINES && et.getLayoutParams().height < 135) {
                            LinearLayout.LayoutParams buttonLayoutParams = (LinearLayout.LayoutParams) btn
                                    .getLayoutParams();
                            buttonLayoutParams.setMargins(buttonLayoutParams.leftMargin,
                                    buttonLayoutParams.topMargin + 30, buttonLayoutParams.rightMargin,
                                    buttonLayoutParams.bottomMargin);
                            btn.setLayoutParams(buttonLayoutParams);
                            btn2.setLayoutParams(buttonLayoutParams);
                            et.getLayoutParams().height += 30;
                        }
                    }
                }
            });

            //                    et.setText(pair.first.topic.getNotes().getContent(INotes.PLAIN).getFormat());
            int k = Utils.countLines(et.getText().toString());
            int ile = Math.min(MAX_LINES - 1, k);

            et.getLayoutParams().height = 75 + ile * 30;
            LinearLayout.LayoutParams buttonLayoutParams = (LinearLayout.LayoutParams) btn.getLayoutParams();
            buttonLayoutParams.setMargins(buttonLayoutParams.leftMargin,
                    buttonLayoutParams.topMargin + 30 * ((k < 2) ? 0 : (k == 2) ? ile - 1 : ile),
                    buttonLayoutParams.rightMargin, buttonLayoutParams.bottomMargin);
            btn.setLayoutParams(buttonLayoutParams);
            btn2.setLayoutParams(buttonLayoutParams);

            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(et, InputMethodManager.SHOW_IMPLICIT);

            dialog.show();
        } else {
            RemoveRelationship remRel = new RemoveRelationship();
            Properties p = new Properties();
            p.put("boxes", MainActivity.toEditBoxes);
            remRel.execute(p);
            MainActivity.addCommendUndo(remRel);
        }

    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.csp.everyaware.offline.Map.java

/********************** SHARE SECTION ***************************************************************/

//get button references and set text on them
private void getShareButtonsRef(Dialog dialog) {
    mValidFbSession = mFacebookManager.isSessionValid();
    mValidTwSession = Utils.getValidTwSession(getApplicationContext());// mTwitterManager.isSessionValid();   

    //if(mButtons[0] == null)
    //{/*  w  ww. j av  a 2 s . c om*/
    mButtons[0] = (Button) dialog.findViewById(R.id.facebook_log_button);
    mButtons[0].setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            //read network type index on which upload data is allowed: 0 - only wifi; 1 - both wifi and mobile
            int networkTypeIndex = Utils.getUploadNetworkTypeIndex(getApplicationContext());

            //1 - is internet connection available? 
            boolean[] connectivity = Utils.haveNetworkConnection(getApplicationContext());

            //if user wants to upload only on wifi networks, connectivity[0] (network connectivity) must be true
            if (networkTypeIndex == 0) {
                if (connectivity[0])
                    mConnectivityOn = true;
                else
                    mConnectivityOn = false;
            } else //if user wants to upload both on wifi/mobile networks
                mConnectivityOn = connectivity[0] || connectivity[1];

            if (mValidFbSession) {
                mFacebookManager.clearCredentials();
            } else {
                if (mConnectivityOn) {
                    mFacebookManager.authorizeFbUser();
                } else {
                    noConnectivityDialog();
                }
            }
        }
    });
    //}
    //if(mButtons[1] == null)
    //{
    mButtons[1] = (Button) dialog.findViewById(R.id.twitter_log_button);
    mButtons[1].setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            //read network type index on which upload data is allowed: 0 - only wifi; 1 - both wifi and mobile
            int networkTypeIndex = Utils.getUploadNetworkTypeIndex(getApplicationContext());

            //1 - is internet connection available? 
            boolean[] connectivity = Utils.haveNetworkConnection(getApplicationContext());

            //if user wants to upload only on wifi networks, connectivity[0] (network connectivity) must be true
            if (networkTypeIndex == 0) {
                if (connectivity[0])
                    mConnectivityOn = true;
                else
                    mConnectivityOn = false;
            } else //if user wants to upload both on wifi/mobile networks
                mConnectivityOn = connectivity[0] || connectivity[1];

            if (mValidTwSession) {
                mTwitterManager.shutdown();

                mValidTwSession = false;
                mButtons[1].setText(getResources().getString(R.string.login_twitter_text));
                Utils.setValidTwSession(false, getApplicationContext());
                Toast.makeText(Map.this, "unauthorized", Toast.LENGTH_SHORT).show();
            } else {
                if (mConnectivityOn) {
                    mTwitterManager.initTwitter();
                } else {
                    noConnectivityDialog();
                }
            }
        }
    });
    //}

    Log.d("Share", "getShareButtonsRef()--> login facebook: " + mValidFbSession);
    Log.d("Share", "getShareButtonsRef()--> login twitter: " + mValidTwSession);

    //display right text (login/logout) on facebook button
    if (mValidFbSession)
        mButtons[0].setText(getResources().getString(R.string.logout_facebook_text));
    else
        mButtons[0].setText(getResources().getString(R.string.login_facebook_text));

    //display text (login/logout) on twitter button
    if (mValidTwSession)
        mButtons[1].setText(getResources().getString(R.string.logout_twitter_text));
    else
        mButtons[1].setText(getResources().getString(R.string.login_twitter_text));
}

From source file:com.sentaroh.android.TaskAutomation.Config.ProfileMaintenanceActionProfile.java

final static private void setProfileActionWaitListener(final GlobalParameters mGlblParms, final Dialog dialog) {
    //        final Spinner spinnerWaitTarget = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_target);
    final Spinner spinnerWaitTimeoutType = (Spinner) dialog.findViewById(R.id.edit_profile_action_wait_timeout);
    final Spinner spinnerWaitTimeoutValue = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_wait_timeout_value);
    final Spinner spinnerWaitTimeoutUnits = (Spinner) dialog
            .findViewById(R.id.edit_profile_action_wait_timeout_units);
    spinnerWaitTimeoutType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override/*from  ww w  .  j av a 2s .  c  o  m*/
        final public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) {
            if (spinnerWaitTimeoutType.getSelectedItem().toString()
                    .equals(PROFILE_ACTION_TYPE_WAIT_TIMEOUT_TYPE_NOTIMEOUT)) {
                spinnerWaitTimeoutValue.setVisibility(Spinner.GONE);
                spinnerWaitTimeoutUnits.setVisibility(Spinner.GONE);
            } else {
                spinnerWaitTimeoutValue.setVisibility(Spinner.VISIBLE);
                spinnerWaitTimeoutUnits.setVisibility(Spinner.VISIBLE);
            }
        }

        @Override
        final public void onNothingSelected(AdapterView<?> arg0) {
        }
    });
}

From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.UtilityOnClickListeners.java

@Override
public OnClickListener getSubscriptionDownloadButtonOnClickListener(final Activity activity,
        final PropertyDescription subscription, final User user, final String tag) {
    return new OnClickListener() {

        @Override/*from  ww w  . j av a  2s  .  com*/
        public void onClick(View v) {
            OnclickListenerInterface onClickListenerInterface = new UtilityOnClickListeners();
            final FiskInfoUtility fiskInfoUtility = new FiskInfoUtility();
            final Dialog dialog;

            int iconId = fiskInfoUtility.subscriptionApiNameToIconId(subscription.ApiName);

            if (iconId != -1) {
                dialog = new UtilityDialogs().getDialogWithTitleIcon(v.getContext(),
                        R.layout.dialog_download_map_layer, subscription.Name, iconId);
            } else {
                dialog = new UtilityDialogs().getDialog(v.getContext(), R.layout.dialog_download_map_layer,
                        subscription.Name);
            }

            final Button downloadButton = (Button) dialog
                    .findViewById(R.id.select_download_format_download_button);
            Button cancelButton = (Button) dialog.findViewById(R.id.select_download_format_cancel_button);
            final LinearLayout rowsContainer = (LinearLayout) dialog
                    .findViewById(R.id.download_map_formats_container);

            downloadButton.setOnClickListener(getShowToastListener(v.getContext(),
                    v.getContext().getString(R.string.error_no_format_selected)));

            for (String format : subscription.Formats) {
                final RadioButtonRow row = new RadioButtonRow(v.getContext(), format);

                row.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        for (int i = 0; i < ((ViewGroup) v.getParent()).getChildCount(); i++) {
                            ((RadioButton) ((ViewGroup) v.getParent()).getChildAt(i)
                                    .findViewById(R.id.radio_button_row_radio_button)).setChecked(false);
                        }
                        ((RadioButton) v.findViewById(R.id.radio_button_row_radio_button)).setChecked(true);

                        downloadButton.setOnClickListener(new OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                BarentswatchApi barentswatchApi = new BarentswatchApi();
                                barentswatchApi.setAccesToken(user.getToken());
                                IBarentswatchApi api = barentswatchApi.getApi();

                                Response response;
                                String downloadFormat = row.getText();

                                try {
                                    response = api.geoDataDownload(subscription.ApiName, downloadFormat);
                                    if (response == null) {
                                        Log.d(tag, "RESPONSE == NULL");
                                        throw new NullPointerException();
                                    }

                                    byte[] fileData = FiskInfoUtility.toByteArray(response.getBody().in());
                                    if (fiskInfoUtility.isExternalStorageWritable()) {
                                        fiskInfoUtility.writeMapLayerToExternalStorage(activity, fileData,
                                                subscription.Name, downloadFormat,
                                                user.getFilePathForExternalStorage(), true);
                                    } else {
                                        Toast.makeText(v.getContext(), R.string.download_failed,
                                                Toast.LENGTH_LONG).show();
                                    }
                                } catch (Exception e) {
                                    Log.d(tag, "Could not download with ApiName: " + subscription.ApiName
                                            + "  and format: " + downloadFormat);
                                }

                                dialog.dismiss();
                            }
                        });
                    }
                });

                rowsContainer.addView(row.getView());
            }

            cancelButton.setOnClickListener(onClickListenerInterface.getDismissDialogListener(dialog));

            dialog.show();
        }
    };

}

From source file:org.opendatakit.tables.activities.TableDisplayActivity.java

private void showDialogLocNuoc() {
    final ViewFragmentType fage = this.mCurrentFragmentType;
    final Dialog dialog = new Dialog(context);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    View layout = inflater.inflate(R.layout.dialog_loc, null);
    dialog.addContentView(layout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    dialog.setContentView(R.layout.dialog_loc);
    final ListView lv = (ListView) dialog.findViewById(R.id.list_loc);
    TextView title = (TextView) dialog.findViewById(R.id.title);
    List<Model> list = new ArrayList<Model>();
    if (this.getTableId().equals("kdv_dnn_hogiadinh")) {
        list = SqliteLoc.getThonNuoc();//from   ww w. j  a  v  a2 s. co  m
    }
    if (this.getTableId().equals("kdv_vs_hogiadinh")) {
        list = SqliteLoc.getThonGiaDinh();
    }
    if (this.getTableId().equals("kdv_vs_congtrinhcongcong")) {
        list = SqliteLoc.getThonCongCong();
    }
    if (loc_position >= 0 && list.size() > 0) {
        Model m = new Model(list.get(loc_position).getName(), true);
        list.set(loc_position, m);
    }
    if (list.size() == 0) {
        title.setText(getString(R.string.dialogloc));
    }
    adapter = new Adapter(this, list);
    lv.setAdapter(adapter);
    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Model model = (Model) (lv.getItemAtPosition(position));
            String selectedFromList = model.getName();
            Intent intent = getIntent();
            intent.putExtra("loc", selectedFromList);
            intent.putExtra("loc_position", String.valueOf(position));
            intent.putExtra("all", "0");
            intent.putExtra("timkiem", "null");
            switch (fage) {
            case SPREADSHEET:
                intent.putExtra("page", "SPREADSHEET");
                break;
            case LIST:
                intent.putExtra("page", "LIST");
                break;
            case MAP:
                intent.putExtra("page", "MAP");
                break;
            case DETAIL:
                intent.putExtra("page", "DETAIL");
                break;
            default:
                break;
            }
            finish();
            startActivity(intent);
        }
    });
    dialog.show();
}

From source file:com.BeatYourRecord.SubmitActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog = new Dialog(SubmitActivity.this);

    switch (id) {
    case 10://from ww  w . ja  v  a2s . c  o m
        // Create out AlterDialog
        /*  Builder builder = new AlertDialog.Builder(this);
          dialog4.setContentView(R.layout.legal1);
          builder.setMessage();
          builder.setCancelable(true);
                
          AlertDialog dialog4 = builder.create();
          dialog4.show();
          return super.onCreateDialog(id);*/

        dialog.setContentView(R.layout.okbutton);

        TextView legalText1 = (TextView) dialog.findViewById(R.id.legal);

        legalText1.setText("Please Login using your email and password.");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;
    case 11:

        dialog.setContentView(R.layout.okbutton);
        dialog.setTitle("Note");
        TextView legalText12 = (TextView) dialog.findViewById(R.id.legal);

        legalText12.setText(
                "You are not connected to wifi. Upload times on 3g/4g can be long. To upload later click ok and then back");

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }

        });
        break;

    //break;
    case DIALOG_LEGAL:
        //dialog.setTitle("Terms of Service");
        dialog.setContentView(R.layout.legal);

        TextView legalText = (TextView) dialog.findViewById(R.id.legal);

        legalText.setText(Util.readFile(this, R.raw.legal).toString());

        dialog.findViewById(R.id.agree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
                ///////////////////////////////////////////////////////////////////////
                File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml");
                if (f.exists() && logout.equals("yes") == false) {
                    Log.v("androids a bitch", "das");
                } else {
                    iregistered();
                }

                getAuthTokenWithPermission(youTubeName);
            }
        });
        dialog.findViewById(R.id.notagree).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });

        break;
    }

    return dialog;
}