Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    final Dialog dialog;
    ProgressDialog pdialog;/* w  ww  . j ava2s. com*/
    AlertDialog.Builder builder;
    LayoutInflater inflater;

    switch (id) {
    case Constants.DIALOG_LOGIN:
        dialog = new LoginDialog(this, mSettings, false) {
            @Override
            public void onLoginChosen(String user, String password) {
                removeDialog(Constants.DIALOG_LOGIN);
                new MyLoginTask(user, password).execute();
            }
        };
        break;

    case Constants.DIALOG_COMMENT_CLICK:
        dialog = new CommentClickDialog(this, mSettings);
        break;

    case Constants.DIALOG_REPLY: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replySaveButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new CommentReplyTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error replying. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mVoteTargetThing.setReplyDraft(replyBody.getText().toString());
                dialog.cancel();
            }
        });
        dialog.setCancelable(false); // disallow the BACK key
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_EDIT: {
        dialog = new Dialog(this, mSettings.getDialogTheme());
        dialog.setContentView(R.layout.compose_reply_dialog);
        final EditText replyBody = (EditText) dialog.findViewById(R.id.body);
        final Button replySaveButton = (Button) dialog.findViewById(R.id.reply_save_button);
        final Button replyCancelButton = (Button) dialog.findViewById(R.id.reply_cancel_button);

        replyBody.setText(mEditTargetBody);

        replySaveButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (mReplyTargetName != null) {
                    new EditTask(mReplyTargetName).execute(replyBody.getText().toString());
                    dialog.dismiss();
                } else {
                    Common.showErrorToast("Error editing. Please try again.", Toast.LENGTH_SHORT,
                            CommentsListActivity.this);
                }
            }
        });
        replyCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
            public void onCancel(DialogInterface dialog) {
                replyBody.setText("");
            }
        });
        break;
    }

    case Constants.DIALOG_DELETE:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really delete this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_DELETE);
                new DeleteTask(mDeleteTargetKind).execute(mReplyTargetName);
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    case Constants.DIALOG_SORT_BY:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Sort by:");
        int selectedSortBy = -1;
        for (int i = 0; i < Constants.CommentsSort.SORT_BY_URL_CHOICES.length; i++) {
            if (Constants.CommentsSort.SORT_BY_URL_CHOICES[i].equals(mSettings.getCommentsSortByUrl())) {
                selectedSortBy = i;
                break;
            }
        }
        builder.setSingleChoiceItems(Constants.CommentsSort.SORT_BY_CHOICES, selectedSortBy,
                sortByOnClickListener);
        dialog = builder.create();
        break;

    case Constants.DIALOG_REPORT:
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setTitle("Really report this?");
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
                removeDialog(Constants.DIALOG_REPORT);
                new ReportTask(mReportTargetName.toString()).execute();
            }
        }).setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        dialog = builder.create();
        break;

    // "Please wait"
    case Constants.DIALOG_DELETING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Deleting...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_EDITING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Submitting edit...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_LOGGING_IN:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Logging in...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_REPLYING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Sending reply...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    case Constants.DIALOG_FIND:
        inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View content = inflater.inflate(R.layout.dialog_find, null);
        final EditText find_box = (EditText) content.findViewById(R.id.input_find_box);
        //          final CheckBox wrap_box = (CheckBox) content.findViewById(R.id.find_wrap_checkbox);

        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        builder.setView(content);
        builder.setTitle(R.string.find).setPositiveButton(R.string.find, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String search_text = find_box.getText().toString().toLowerCase();
                //               findCommentText(search_text, wrap_box.isChecked(), false);
                findCommentText(search_text, true, false);
            }
        }).setNegativeButton("Cancel", null);
        dialog = builder.create();
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.kll.collect.android.activities.FormEntryActivity.java

/**
 * Creates a toast with the specified message.
 *
 * @param message//from  w  w  w . j  a va 2s. c om
 */
private void showCustomToast(String message, int duration) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View view = inflater.inflate(R.layout.toast_view, null);

    // set the text in the view
    TextView tv = (TextView) view.findViewById(R.id.message);
    tv.setText(message);

    Toast t = new Toast(this);
    t.setView(view);
    t.setDuration(duration);
    t.setGravity(Gravity.CENTER, 0, 0);
    t.show();
}

From source file:cl.gisred.android.MicroMedidaActivity.java

public void setActionsFormDenuncio(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/* w  w w  .ja v a  2  s .com*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    Spinner spEstado = (Spinner) v.findViewById(R.id.spinnerEstado);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item, arrayEstado);
    spEstado.setAdapter(adapter);

    Spinner spTipoEdif = (Spinner) v.findViewById(R.id.spinnerTipoEdific);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayTipoEdif);
    spTipoEdif.setAdapter(adapter);

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnIdentDireccion = (ImageButton) v.findViewById(R.id.btnDireccion);
    btnIdentDireccion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddDireccion;
            oLyExistAsoc = LyDIRECCIONES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            bMapTap = true;
            formCrear.hide();
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v);
        }
    });

    arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:cl.gisred.android.InspActivity.java

public void setActionsForm(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*w  w  w .j  a  v a  2 s . c  o m*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    boolean bSpinnerMedidor = idRes == R.layout.form_inspec_telemedida;

    Spinner spTipoFase = (Spinner) v.findViewById(R.id.spinnerFase);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayTipoFaseInsp);
    spTipoFase.setAdapter(adapter);

    Spinner spTipoMarca = (Spinner) v.findViewById(R.id.spinnerTipo);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            (bSpinnerMedidor) ? arrayTipoMarcaTM : arrayTipoMarca);
    spTipoMarca.setAdapter(adapter);

    Spinner spMarca = (Spinner) v.findViewById(R.id.spinnerMarca);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            (bSpinnerMedidor) ? arrayMarcaTM : arrayMarca);
    spMarca.setAdapter(adapter);

    final GisEditText txtPoste = (GisEditText) v.findViewById(R.id.txtPoste);
    final EditText txtRotulo = (EditText) v.findViewById(R.id.txtRotulo);

    txtPoste.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (i2 > 1) {
                if (bInspRotulo) {
                    txtRotulo.setText(charSequence);
                    if (!txtRotulo.hasFocus())
                        txtRotulo.requestFocus();
                    bInspRotulo = false;
                    txtPoste.setText(String.format("%s", txtPoste.getIdObjeto()));
                } else
                    bInspRotulo = true;
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    final EditText txtFecha = (EditText) v.findViewById(R.id.txtFechaEjec);
    txtFecha.setText(dateFormatter.format(Calendar.getInstance().getTime()));
    txtFecha.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            datePickerDialog.show();
        }
    });

    Calendar newCalendar = Calendar.getInstance();
    datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            txtFecha.setText(dateFormatter.format(newDate.getTime()));
        }

    }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));

    final EditText txtHoraIni = (EditText) v.findViewById(R.id.txtHoraIni);
    txtHoraIni.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            timePickerDialog.show();
            txtHora = txtHoraIni;
        }
    });

    final EditText txtHoraFin = (EditText) v.findViewById(R.id.txtHoraFin);
    txtHoraFin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            timePickerDialog.show();
            txtHora = txtHoraFin;
        }
    });

    timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
            txtHora.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
        }
    }, newCalendar.get(Calendar.HOUR), newCalendar.get(Calendar.MINUTE), false);

    final EditText txtEjecutor = (EditText) v.findViewById(R.id.txtEjecutor);
    txtEjecutor.setText(Util.getUserWithoutDomain(usuar));

    Spinner spFirmante = (Spinner) v.findViewById(R.id.spinnerFirmante);
    if (spFirmante != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayFirmante);
        spFirmante.setAdapter(adapter);
        spFirmante.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                setRequerido(view, R.id.txtRutInst, i > 0);
                setRequerido(view, R.id.txtNomInst, i > 0);
            }

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

    Spinner spTipoMarcaRet = (Spinner) v.findViewById(R.id.spinnerTipoRet);
    if (spTipoMarcaRet != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayTipoMarca);
        spTipoMarcaRet.setAdapter(adapter);
    }

    Spinner spMarcaRet = (Spinner) v.findViewById(R.id.spinnerMarcaRet);
    if (spMarcaRet != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayMarca);
        spMarcaRet.setAdapter(adapter);
    }

    final CheckBox chkInspFallo = (CheckBox) v.findViewById(R.id.chkInspFallo);
    if (chkInspFallo != null) {
        chkInspFallo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bFallo = chkInspFallo.isChecked();
                modoFallo(v, bFallo);
            }
        });
    }

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v, 0);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v, idRes);
        }
    });

    imgFirmaTec = (ImageView) v.findViewById(R.id.imgFirmaTec);
    imgFirmaInsp = (ImageView) v.findViewById(R.id.imgFirmaIns);
    imgPhoto1 = (ImageView) v.findViewById(R.id.imgPhoto1);
    imgPhoto2 = (ImageView) v.findViewById(R.id.imgPhoto2);
    imgPhoto3 = (ImageView) v.findViewById(R.id.imgPhoto3);

    final ImageButton btnFirmaTec = (ImageButton) v.findViewById(R.id.btnFirmaTec);
    if (btnFirmaTec != null && imgFirmaTec != null) {
        btnFirmaTec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                imgTemp = imgFirmaTec;
                DialogoFirma oDialog = new DialogoFirma();
                oDialog.show(getFragmentManager(), "tagFirma");
            }
        });

        imgFirmaTec.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                crearDialogoImg((ImageView) v).show();
                return false;
            }
        });
    }

    final ImageButton btnFirmaInsp = (ImageButton) v.findViewById(R.id.btnFirmaIns);
    if (btnFirmaInsp != null && imgFirmaInsp != null) {
        btnFirmaInsp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                imgTemp = imgFirmaInsp;
                DialogoFirma oDialog = new DialogoFirma();
                oDialog.show(getFragmentManager(), "tagFirma");
            }
        });

        imgFirmaInsp.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                crearDialogoImg((ImageView) v).show();
                return false;
            }
        });
    }

    imgPhoto1.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    imgPhoto2.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    imgPhoto3.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    ImageButton btnPhoto1 = (ImageButton) v.findViewById(R.id.btnPhoto1);
    btnPhoto1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto1;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto1");
            else
                tomarFoto("foto1");

        }
    });

    ImageButton btnPhoto2 = (ImageButton) v.findViewById(R.id.btnPhoto2);
    btnPhoto2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto2;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto2");
            else
                tomarFoto("foto2");
        }
    });

    ImageButton btnPhoto3 = (ImageButton) v.findViewById(R.id.btnPhoto3);
    btnPhoto3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto3;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto3");
            else
                tomarFoto("foto3");
        }
    });

    ImageButton btnFile1 = (ImageButton) v.findViewById(R.id.btnFile1);
    btnFile1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto1;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto1");
            else
                imageGallery("foto1");
        }
    });

    ImageButton btnFile2 = (ImageButton) v.findViewById(R.id.btnFile2);
    btnFile2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto2;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto2");
            else
                imageGallery("foto2");
        }
    });

    ImageButton btnFile3 = (ImageButton) v.findViewById(R.id.btnFile3);
    btnFile3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto3;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto3");
            else
                imageGallery("foto3");
        }
    });

    arrayTouchs = new ArrayList<>();
    //setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:org.thoughtland.xlocation.ActivityShare.java

@SuppressLint("InflateParams")
public static boolean registerDevice(final ActivityBase context) {
    int userId = Util.getUserId(Process.myUid());
    if (Util.hasProLicense(context) == null
            && !PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingRegistered, false)) {
        // Get accounts
        String email = null;/* w  w  w. ja va  2s  .  c o m*/
        for (Account account : AccountManager.get(context).getAccounts())
            if ("com.google".equals(account.type)) {
                email = account.name;
                break;
            }

        LayoutInflater LayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = LayoutInflater.inflate(R.layout.register, null);
        final EditText input = (EditText) view.findViewById(R.id.etEmail);
        if (email != null)
            input.setText(email);

        // Build dialog
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.msg_register);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setView(view);
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String email = input.getText().toString();
                        if (Patterns.EMAIL_ADDRESS.matcher(email).matches())
                            new RegisterTask(context).executeOnExecutor(mExecutor, email);
                    }
                });
        alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing
                    }
                });

        // Show dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();

        return false;
    }
    return true;
}

From source file:cl.gisred.android.RegEquipoActivity.java

public void setActionsFormRet(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*from w w w.j  a v  a 2s .c  om*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    /*ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        formCrear.hide();
        bMapTap = true;
        bCallOut = true;
        oLySelectAsoc = LyAddPoste;
        oLyExistAsoc = LyPOSTES;
        oLyExistAsoc.setVisible(true);
        setValueToAsoc(getLayoutContenedor(view));
    }
    });
            
    ImageButton btnTramo = (ImageButton) v.findViewById(R.id.btnTramoBt);
    btnTramo.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        formCrear.hide();
        bMapTap = true;
        bCallOut = true;
        nIndentify = 2; //2 = valor para tramo
        oLySelectAsoc = LyAsocTramo;
        setValueToAsoc(getLayoutContenedor(v));
    }
    });
            
    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        bMapTap = true;
        formCrear.hide();
    }
    });*/

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v);
        }
    });

    /*arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);*/

    formCrear.show();
    dialogCur = formCrear;
}

From source file:cl.gisred.android.MicroMedidaActivity.java

public void setActionsForm(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*from   w  ww . j a  va  2  s. c  o  m*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    Spinner spMarcaMed = (Spinner) v.findViewById(R.id.spinnerMarcaMed);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayMarcaMed);
    spMarcaMed.setAdapter(adapter);

    Spinner spObservacion = (Spinner) v.findViewById(R.id.spinnerObservacion);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayObservacion);
    spObservacion.setAdapter(adapter);

    Spinner spFaseConex = (Spinner) v.findViewById(R.id.spinnerFaseCon);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayfaseConex);
    spFaseConex.setAdapter(adapter);

    ImageButton btnDireccion = (ImageButton) v.findViewById(R.id.btnAddress);
    btnDireccion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddDireccion;
            oLyExistAsoc = LyDIRECCIONES;
            oLyExistAsoc.setVisible(true);
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    ImageButton btnTramoBt = (ImageButton) v.findViewById(R.id.btnTramoBt);
    btnTramoBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            nIndentify = 2; //2 = valor para tramo
            oLySelectAsoc = LyAsocTramo;
            setValueToAsoc(getLayoutContenedor(v));
        }
    });

    btnUbicacion = (ImageButton) v.findViewById(R.id.btnUbicacion);
    btnUbicacion.setColorFilter(Color.RED);
    btnUbicacion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            bMapTap = true;
            formCrear.hide();
        }
    });

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v);
        }
    });

    arrayTouchs = new ArrayList<>();
    setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

/**
 * Helper function to add links from mVoteTargetThing to the button
 * @param linkButton Button that should open list of links
 *///  w  ww  .j a  v a2  s . co m
private void linkToEmbeddedURLs(Button linkButton) {
    final ArrayList<String> urls = new ArrayList<String>();
    final ArrayList<MarkdownURL> vtUrls = mVoteTargetThing.getUrls();
    int urlsCount = vtUrls.size();
    for (int i = 0; i < urlsCount; i++) {
        urls.add(vtUrls.get(i).url);
    }
    if (urlsCount == 0) {
        linkButton.setEnabled(false);
    } else {
        linkButton.setEnabled(true);
        linkButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_COMMENT_CLICK);

                ArrayAdapter<MarkdownURL> adapter = new ArrayAdapter<MarkdownURL>(CommentsListActivity.this,
                        android.R.layout.select_dialog_item, vtUrls) {
                    public View getView(int position, View convertView, ViewGroup parent) {
                        TextView tv;
                        if (convertView == null) {
                            tv = (TextView) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                                    .inflate(android.R.layout.select_dialog_item, null);
                        } else {
                            tv = (TextView) convertView;
                        }

                        String url = getItem(position).url;
                        String anchorText = getItem(position).anchorText;
                        if (Constants.LOGGING)
                            Log.d(TAG, "links url=" + url + " anchorText=" + anchorText);

                        Drawable d = null;
                        try {
                            d = getPackageManager()
                                    .getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                        } catch (NameNotFoundException ignore) {
                        }
                        if (d != null) {
                            d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight());
                            tv.setCompoundDrawablePadding(10);
                            tv.setCompoundDrawables(d, null, null, null);
                        }

                        final String telPrefix = "tel:";
                        if (url.startsWith(telPrefix)) {
                            url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length()));
                        }

                        if (anchorText != null)
                            tv.setText(Html.fromHtml(
                                    "<span>" + anchorText + "</span><br /><small>" + url + "</small>"));
                        else
                            tv.setText(Html.fromHtml(url));

                        return tv;
                    }
                };

                AlertDialog.Builder b = new AlertDialog.Builder(
                        new ContextThemeWrapper(CommentsListActivity.this, mSettings.getDialogTheme()));

                DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {
                    public final void onClick(DialogInterface dialog, int which) {
                        if (which >= 0) {
                            Common.launchBrowser(CommentsListActivity.this, urls.get(which),
                                    Util.createThreadUri(getOpThingInfo()).toString(), false, false,
                                    mSettings.isUseExternalBrowser(), mSettings.isSaveHistory());
                        }
                    }
                };

                b.setTitle(R.string.select_link_title);
                b.setCancelable(true);
                b.setAdapter(adapter, click);

                b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    public final void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });

                b.show();
            }
        });
    }
}

From source file:brighton.uni.usmappedapp.Map.java

private void AboutPopupWindow() {
    try {/*from w ww .java  2 s .c om*/
        // We need to get the instance of the LayoutInflater
        LayoutInflater inflater = (LayoutInflater) Map.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); //
        View layout = inflater.inflate(R.layout.popup_layout, (ViewGroup) findViewById(R.id.popup_element)); //
        String pp = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(this); //Retrieves a information set from google
        pwindo = new PopupWindow(layout, 400, 700, true); // creates and sets the valuse of the popup window
        pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0); // sets the location
        pwindo.setOutsideTouchable(true);
        pwindo.setTouchable(true);

        // create button to be able to close the popup
        btnClosePopup = (Button) layout.findViewById(R.id.btn_close_popup);
        btnClosePopup.setOnClickListener(close_bnt_CL);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:brighton.uni.usmappedapp.Map.java

private void HowToPopupWindow() {
    try {/*from   w  ww.jav  a  2  s  .  c o m*/
        // We need to get the instance of the LayoutInflater
        LayoutInflater inflater = (LayoutInflater) Map.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.popup_layout2, (ViewGroup) findViewById(R.id.popup_element));
        pwindo2 = new PopupWindow(layout, 500, 870, true);
        pwindo2.showAtLocation(layout, Gravity.CENTER, 0, 0);
        pwindo2.setOutsideTouchable(true);
        pwindo2.setTouchable(true);

        //
        btnClosePopup = (Button) layout.findViewById(R.id.btn_close_popup);
        btnClosePopup.setOnClickListener(close_bnt_CL_2);

    } catch (Exception e) {
        e.printStackTrace();
    }
}