List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:com.esri.arcgisruntime.sample.stretchrenderer.ParametersDialogFragment.java
/** * Builds parameter dialog with values pulled through from MainActivity. * * @param savedInstanceState//from w w w .j a v a 2 s.c om * @return create parameter dialog box */ @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Bundle stretchParameters = getArguments(); if (stretchParameters != null) { mMin = stretchParameters.getInt("min"); mMax = stretchParameters.getInt("max"); mPercentClipMin = stretchParameters.getInt("percent_clip_min"); mPercentClipMax = stretchParameters.getInt("percent_clip_max"); mStdDevFactor = stretchParameters.getInt("std_dev_factor"); mStretchType = (MainActivity.StretchType) stretchParameters.getSerializable("stretch_type"); } final AlertDialog.Builder paramDialog = new AlertDialog.Builder(getContext()); @SuppressLint("InflateParams") final View dialogView = inflater.inflate(R.layout.stretch_dialog_box, null); paramDialog.setView(dialogView); paramDialog.setTitle(R.string.stretch_rendering_parameters); paramDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dismiss(); } }); paramDialog.setPositiveButton("Render", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); ParametersListener activity = (ParametersListener) getActivity(); activity.returnParameters(mMin, mMax, mPercentClipMin, mPercentClipMax, mStdDevFactor, mStretchType); } }); // min max ui elements mMinTextView = (TextView) dialogView.findViewById(R.id.min_value_text_view); mMaxTextView = (TextView) dialogView.findViewById(R.id.max_value_text_view); mMinSeekBar = (SeekBar) dialogView.findViewById(R.id.min_seek_bar); mMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.max_seek_bar); mMinSeekBar.setMax(255); mMaxSeekBar.setMax(255); mCurrMinTextView = (TextView) dialogView.findViewById(R.id.curr_min_text_view); mCurrMaxTextView = (TextView) dialogView.findViewById(R.id.curr_max_text_view); updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // percent clip ui elements mPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.percent_clip_min_value_text_view); mPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.percent_clip_max_value_text_view); mPercentClipMinSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_min_seek_bar); mPercentClipMaxSeekBar = (SeekBar) dialogView.findViewById(R.id.percent_clip_max_seek_bar); mPercentClipMinSeekBar.setMax(99); mPercentClipMaxSeekBar.setMax(99); mCurrPercentClipMinTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_min_text_view); mCurrPercentClipMaxTextView = (TextView) dialogView.findViewById(R.id.curr_percent_clip_max_text_view); updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); // standard deviation ui elements mStdDevTextView = (TextView) dialogView.findViewById(R.id.std_dev_text_view); mStdDevSeekBar = (SeekBar) dialogView.findViewById(R.id.std_dev_seek_bar); mStdDevSeekBar.setMax(3); mCurrStdDevTextView = (TextView) dialogView.findViewById(R.id.curr_std_dev_text_view); updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); // set ui to previous selection if (mStretchType == MainActivity.StretchType.MIN_MAX) { setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.PERCENT_CLIP) { setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); } else if (mStretchType == MainActivity.StretchType.STANDARD_DEVIATION) { setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); } // seek bar listeners mMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMin = progress; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); // move max to march min if max goes below min if (mMax < mMin) { mMax = mMin; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mMax = progress; updateSeekBar(mMaxSeekBar, mMax, mCurrMaxTextView); // move min to match max if min goes above max if (mMin > mMax) { mMin = mMax; updateSeekBar(mMinSeekBar, mMin, mCurrMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMinSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMin = progress; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMax = 100 - mPercentClipMin; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mPercentClipMaxSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mPercentClipMax = progress; updateSeekBar(mPercentClipMaxSeekBar, mPercentClipMax, mCurrPercentClipMaxTextView); if (mPercentClipMin + mPercentClipMax > 100) { // constrain min + max <= 100 mPercentClipMin = 100 - mPercentClipMax; updateSeekBar(mPercentClipMinSeekBar, mPercentClipMin, mCurrPercentClipMinTextView); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); mStdDevSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { mStdDevFactor = progress; updateSeekBar(mStdDevSeekBar, mStdDevFactor, mCurrStdDevTextView); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); // stretch type spinner List<String> stretchTypeArray = new ArrayList<>(); stretchTypeArray.add(MainActivity.StretchType.MIN_MAX.toString()); //ordinals:0 stretchTypeArray.add(MainActivity.StretchType.PERCENT_CLIP.toString()); //1 stretchTypeArray.add(MainActivity.StretchType.STANDARD_DEVIATION.toString()); //2 ArrayAdapter<String> stretchTypeSpinnerAdapter = new ArrayAdapter<>(getContext(), R.layout.stretch_spinner_text_view, stretchTypeArray); Spinner stretchTypeSpinner = (Spinner) dialogView.findViewById(R.id.stretch_type_spinner); stretchTypeSpinner.setAdapter(stretchTypeSpinnerAdapter); stretchTypeSpinner.setSelection(mStretchType.ordinal()); stretchTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: mStretchType = MainActivity.StretchType.MIN_MAX; setMinMaxVisibility(true); setPercentClipVisibility(false); setStdDevVisibility(false); break; case 1: mStretchType = MainActivity.StretchType.PERCENT_CLIP; setMinMaxVisibility(false); setPercentClipVisibility(true); setStdDevVisibility(false); break; case 2: mStretchType = MainActivity.StretchType.STANDARD_DEVIATION; setMinMaxVisibility(false); setPercentClipVisibility(false); setStdDevVisibility(true); break; } } @Override public void onNothingSelected(AdapterView<?> parent) { } }); return paramDialog.create(); }
From source file:org.sirimangalo.meditationplus.AdapterCommit.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View rowView = inflater.inflate(R.layout.list_item_commit, parent, false); final View shell = rowView.findViewById(R.id.detail_shell); rowView.setOnClickListener(new View.OnClickListener() { @Override/* w w w. j av a2 s.co m*/ public void onClick(View view) { boolean visible = shell.getVisibility() == View.VISIBLE; shell.setVisibility(visible ? View.GONE : View.VISIBLE); context.setCommitVisible(position, !visible); } }); final JSONObject p = values.get(position); TextView title = (TextView) rowView.findViewById(R.id.title); TextView descV = (TextView) rowView.findViewById(R.id.desc); TextView defV = (TextView) rowView.findViewById(R.id.def); TextView usersV = (TextView) rowView.findViewById(R.id.users); TextView youV = (TextView) rowView.findViewById(R.id.you); try { if (p.getBoolean("open")) shell.setVisibility(View.VISIBLE); title.setText(p.getString("title")); descV.setText(p.getString("description")); String length = p.getString("length"); String time = p.getString("time"); final String cid = p.getString("cid"); String def = ""; boolean repeat = false; if (length.indexOf(":") > 0) { repeat = true; String[] lengtha = length.split(":"); def += lengtha[0] + " minutes walking and " + lengtha[1] + " minutes sitting"; } else def += length + " minutes total meditation"; String period = p.getString("period"); String day = p.getString("day"); if (period.equals("daily")) { if (repeat) def += " every day"; else def += " per day"; } else if (period.equals("weekly")) { if (repeat) def += " every " + dow[Integer.parseInt(day)]; else def += " per week"; } else if (period.equals("monthly")) { if (repeat) def += " on the " + day + (day.substring(day.length() - 1).equals("1") ? "st" : (day.substring(day.length() - 1).equals("2") ? "nd" : (day.substring(day.length() - 1).equals("3") ? "rd" : "th"))) + " day of the month"; else def += " per month"; } else if (period.equals("yearly")) { if (repeat) def += " on the " + day + (day.substring(day.length() - 1).equals("1") ? "st" : (day.substring(day.length() - 1).equals("2") ? "nd" : (day.substring(day.length() - 1).equals("3") ? "rd" : "th"))) + " day of the year"; else def += " per year"; } if (!time.equals("any")) { Calendar utc = Calendar.getInstance(TimeZone.getTimeZone("UTC")); utc.set(Calendar.HOUR_OF_DAY, Integer.parseInt(time.split(":")[0])); utc.set(Calendar.MINUTE, Integer.parseInt(time.split(":")[1])); Calendar here = Calendar.getInstance(); here.setTimeInMillis(utc.getTimeInMillis()); int hours = here.get(Calendar.HOUR_OF_DAY); int minutes = here.get(Calendar.MINUTE); def += " at " + (time.length() == 4 ? "0" : "") + time.replace(":", "") + "h UTC <i>(" + (hours > 12 ? hours - 12 : hours) + ":" + ((minutes < 10 ? "0" : "") + minutes) + " " + (hours > 11 && hours < 24 ? "PM" : "AM") + " your time)</i>"; } defV.setText(Html.fromHtml(def)); JSONObject usersJ = p.getJSONObject("users"); ArrayList<String> committedArray = new ArrayList<String>(); // collect into array for (int i = 0; i < usersJ.names().length(); i++) { try { String j = usersJ.names().getString(i); String k = j; // if(j.equals(p.getString("creator"))) // k = "["+j+"]"; committedArray.add(k); } catch (JSONException e) { e.printStackTrace(); } } String text = context.getString(R.string.committed) + " "; // add spans int committed = -1; int pos = text.length(); // start after "Committed: " text += TextUtils.join(", ", committedArray); Spannable span = new SpannableString(text); span.setSpan(new StyleSpan(Typeface.BOLD), 0, pos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // bold the "Online: " for (int i = 0; i < committedArray.size(); i++) { try { final String oneCom = committedArray.get(i); String userCom = usersJ.getString(oneCom); //String userCom = usersJ.getString(oneCom.replace("[", "").replace("]", "")); //if(oneCom.replace("[","").replace("]","").equals(loggedUser)) if (oneCom.equals(loggedUser)) committed = Integer.parseInt(userCom); int end = pos + oneCom.length(); ClickableSpan clickable = new ClickableSpan() { @Override public void onClick(View widget) { context.showProfile(oneCom); } }; span.setSpan(clickable, pos, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); span.setSpan(new UnderlineSpan() { public void updateDrawState(TextPaint tp) { tp.setUnderlineText(false); } }, pos, end, 0); String color = Utils.makeRedGreen(Integer.parseInt(userCom), true); span.setSpan(new ForegroundColorSpan(Color.parseColor("#FF" + color)), pos, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); pos += oneCom.length() + 2; } catch (JSONException e) { e.printStackTrace(); } } usersV.setText(span); usersV.setMovementMethod(new LinkMovementMethod()); if (loggedUser != null && loggedUser.length() > 0) { LinearLayout bl = (LinearLayout) rowView.findViewById(R.id.commit_buttons); if (!usersJ.has(loggedUser)) { Button commitB = new Button(context); commitB.setId(R.id.commit_button); commitB.setText(R.string.commit); commitB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("commitform_" + cid, nvp, true); } }); bl.addView(commitB); } else { Button commitB = new Button(context); commitB.setId(R.id.uncommit_button); commitB.setText(R.string.uncommit); commitB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("uncommitform_" + cid, nvp, true); } }); bl.addView(commitB); } if (loggedUser.equals(p.getString("creator")) || context.isAdmin) { Button commitB2 = new Button(context); commitB2.setId(R.id.edit_commit_button); commitB2.setText(R.string.edit); commitB2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(context, ActivityCommit.class); i.putExtra("commitment", p.toString()); context.startActivity(i); } }); bl.addView(commitB2); Button commitB3 = new Button(context); commitB3.setId(R.id.uncommit_button); commitB3.setText(R.string.delete); commitB3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(); nvp.add(new BasicNameValuePair("full_update", "true")); context.doSubmit("delcommitform_" + cid, nvp, true); } }); bl.addView(commitB3); } } if (committed > -1) { int color = Color.parseColor("#FF" + Utils.makeRedGreen(committed, false)); rowView.setBackgroundColor(color); } if (committed != -1) { youV.setText(String.format(context.getString(R.string.you_commit_x), committed)); youV.setVisibility(View.VISIBLE); } } catch (Exception e) { e.printStackTrace(); } return rowView; }
From source file:fib.lcfib.raco.Controladors.ControladorLoginRaco.java
private void showAddDialog() { loginDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND); loginDialog.setTitle(R.string.loginRaco); LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogView = li.inflate(R.layout.contingut_login, null); loginDialog.setContentView(dialogView); username = (EditText) dialogView.findViewById(R.id.login); password = (EditText) dialogView.findViewById(R.id.password); Button okButton = (Button) dialogView.findViewById(R.id.acceptar_button); Button cancelButton = (Button) dialogView.findViewById(R.id.cancel_button); loginDialog.setCancelable(false);/*w w w .j a va2 s . c o m*/ loginDialog.show(); okButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { try { String usernameAux = username.getText().toString().trim(); String passwordAux = password.getText().toString().trim(); usernameAux = URLEncoder.encode(usernameAux, "UTF-8"); passwordAux = URLEncoder.encode(passwordAux, "UTF-8"); boolean correcte = check_user(usernameAux, passwordAux); if (correcte) { Toast.makeText(getApplicationContext(), R.string.login_correcte, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); } if ("zonaRaco".equals(queEs)) { Intent intent = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("esLogin", "zonaRaco"); startActivity(intent); } else { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); // Aquestes 2 lnies provoquen una excepci per no peta // simplement informa s normal act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } private boolean check_user(String username, String password) { GestorCertificats.allowAllSSL(); AndroidUtils au = AndroidUtils.getInstance(); /** open connection */ //Aix tanquem les connexions segur System.setProperty("http.keepAlive", "false"); try { InputStream is = null; HttpGet request = new HttpGet(au.URL_LOGIN + "username=" + username + "&password=" + password); HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); final int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpStatus.SC_OK) { Header[] headers = response.getHeaders("Location"); if (headers != null && headers.length != 0) { String newUrl = headers[headers.length - 1].getValue(); request = new HttpGet(newUrl); client.execute(request); } } /** Get Keys */ is = response.getEntity().getContent(); ObjectMapper m = new ObjectMapper(); JsonNode rootNode = m.readValue(is, JsonNode.class); is.close(); client.getConnectionManager().closeExpiredConnections(); if (rootNode.isNull()) { return false; } else { // GenerarUrl(); /** calendari ics */ String KEYportadaCal = rootNode.path("/ical/portada.ics").getTextValue().toString(); /** calendari rss */ String KEYportadaRss = rootNode.path("/ical/portada.rss").getTextValue().toString(); /** Avisos */ String KEYavisos = rootNode.path("/extern/rss_avisos.jsp").getTextValue().toString(); /** Assigraco */ String KEYAssigRaco = rootNode.path("/api/assigList").getTextValue().toString(); /** Horari */ String KEYIcalHorari = rootNode.path("/ical/horari.ics").getTextValue().toString(); /**Notificacions */ String KEYRegistrar = rootNode.path("/api/subscribeNotificationSystem").getTextValue() .toString(); String KEYDesregistrar = rootNode.path("/api/unsubscribeNotificationSystem").getTextValue() .toString(); SharedPreferences sp = getSharedPreferences(PreferenciesUsuari.getPreferenciesUsuari(), MODE_PRIVATE); SharedPreferences.Editor editor = sp.edit(); /** Save Username and Password */ editor.putString(AndroidUtils.USERNAME, username); editor.putString(AndroidUtils.PASSWORD, password); /** Save Keys */ editor.putString(au.KEY_AGENDA_RACO_XML, KEYportadaRss); editor.putString(au.KEY_AGENDA_RACO_CAL, KEYportadaCal); editor.putString(au.KEY_AVISOS, KEYavisos); editor.putString(au.KEY_ASSIG_FIB, "public"); editor.putString(au.KEY_ASSIGS_RACO, KEYAssigRaco); editor.putString(au.KEY_HORARI_RACO, KEYIcalHorari); editor.putString(au.KEY_NOTIFICACIONS_REGISTRAR, KEYRegistrar); editor.putString(au.KEY_NOTIFICACIONS_DESREGISTRAR, KEYDesregistrar); /** Save changes */ editor.commit(); } return true; } catch (ProtocolException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } catch (IOException e) { Toast.makeText(getApplicationContext(), R.string.errorLogin, Toast.LENGTH_LONG).show(); return false; } } }); cancelButton.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { Intent act = new Intent(ControladorLoginRaco.this, ControladorTabIniApp.class); act.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); act.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(act); } }); }
From source file:com.forrestguice.suntimeswidget.LightMapView.java
/** * @param context a context used to access resources *//* www. ja va 2s . com*/ private void initLayout(Context context) { final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.info_time_lightmap, this); }
From source file:com.hybris.mobile.app.commerce.adapter.AccountPaymentAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { View rowView;/* w w w. j a v a 2s .c om*/ if (convertView == null) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); rowView = inflater.inflate(R.layout.item_payment_details, parent, false); rowView.setTag(new PaymentViewHolder(rowView, position)); } else { rowView = convertView; } PaymentViewHolder mPaymentViewHolder = (PaymentViewHolder) rowView.getTag(); final PaymentDetails paymentDetails = getItem(position); if (paymentDetails != null) { mPaymentViewHolder.paymentCardholderName.setText(paymentDetails.getAccountHolderName()); mPaymentViewHolder.cardDetails .setText(paymentDetails.getCardType().getName() + "\n" + paymentDetails.getCardNumber() + "\n" + paymentDetails.getExpiryMonth() + "/" + paymentDetails.getExpiryYear()); if (paymentDetails.getBillingAddress() != null) { mPaymentViewHolder.billingAddress .setText(StringUtils.isNotBlank(paymentDetails.getBillingAddress().getFormattedAddress()) ? paymentDetails.getBillingAddress().getFormattedAddress() : paymentDetails.getBillingAddress().getLine1() + " " + paymentDetails.getBillingAddress().getLine2() + ",\n " + paymentDetails.getBillingAddress().getTown() + " " + paymentDetails.getBillingAddress().getPostalCode()); } mPaymentViewHolder.paymentDefaultImageView.setVisibility(View.GONE); mPaymentViewHolder.paymentSetDefaultButton.setVisibility(View.INVISIBLE); mPaymentViewHolder.paymentDefaultImageView.setVisibility(position == 0 ? View.VISIBLE : View.INVISIBLE); //mPaymentViewHolder.paymentSetDefaultButton.setVisibility(position == 0 ? View.INVISIBLE : View.VISIBLE); mPaymentViewHolder.paymentDeleteButton.setVisibility(View.VISIBLE); mPaymentViewHolder.paymentSetDefaultButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setDefaultPayment(paymentDetails); Alert.showSuccess(getContext(), getContext().getString(R.string.payment_default_updated_message)); } }); mPaymentViewHolder.paymentDetailsLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mOnPaymentSelectedListener.onPaymentSelected(paymentDetails); } }); } mPaymentViewHolder.paymentDeleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog dialog; AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); builder.setMessage(R.string.payment_delete_message) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { QueryPayment queryPayment = new QueryPayment(); queryPayment.setPaymentDetailsId(paymentDetails.getId()); CommerceApplication.getContentServiceHelper() .deleteUserPaymentDetails(new ResponseReceiverEmpty() { @Override public void onResponse(Response<EmptyResponse> response) { Alert.showSuccess(getContext(), getContext() .getString(R.string.payment_delete_success_message)); if (position < mPaymentList.size()) { mPaymentList.remove(position); } mOnPaymentSelectedListener.onPaymentListRefreshed(); //Default is the first but if deleted select the next one as default if (mPaymentList != null && !mPaymentList.isEmpty() && position == 0) { setDefaultPayment(mPaymentList.get(0)); } } @Override public void onError(Response<ErrorList> response) { } }, null, queryPayment, null, false, null, null); dialog.dismiss(); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); dialog = builder.create(); dialog.show(); } }); return rowView; }
From source file:com.android.dialer.filterednumber.BlockedNumbersFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null)); //replace the icon for add number with LetterTileDrawable(), so it will have identical style ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon); LetterTileDrawable drawable = new LetterTileDrawable(getResources()); drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER); drawable.setColor(ActivityCompat.getColor(getActivity(), R.color.add_blocked_number_icon_color)); drawable.setIsCircular(true);// www. ja v a 2 s.com addNumberIcon.setImageDrawable(drawable); if (mAdapter == null) { mAdapter = BlockedNumbersAdapter.newBlockedNumbersAdapter(getContext(), getActivity().getFragmentManager()); } setListAdapter(mAdapter); blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view); migratePromoView = getListView().findViewById(R.id.migrate_promo); getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this); mImportSettings = getListView().findViewById(R.id.import_settings); mBlockedNumbersDisabledForEmergency = getListView() .findViewById(R.id.blocked_numbers_disabled_for_emergency); mBlockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider); getListView().findViewById(R.id.import_button).setOnClickListener(this); getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this); getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this); footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview); mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this); mVoicemailEnabledChecker.asyncUpdate(); updateActiveVoicemailProvider(); }
From source file:com.example.android.supportv4.media.MediaController.java
public MediaController(Context context, AttributeSet attrs) { super(context, attrs); mContext = context;/*from w ww . j a va 2 s . c om*/ mUseFastForward = true; LayoutInflater inflate = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflate.inflate(R.layout.media_controller, this, true); initControllerView(); }
From source file:io.coldstart.android.EditOIDActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_oid); // Show the Up button in the action bar. getActionBar().setDisplayHomeAsUpEnabled(true); oidDescList = (LinearLayout) findViewById(R.id.OIDDescriptionHolder); //((TextView) findViewById(R.id.textView)).setText(getIntent().getStringExtra("payload")); JSONObject oidDescriptions = null;/*w ww.j a v a 2s. c o m*/ int i = 0; try { oidDescriptions = new JSONObject(getIntent().getStringExtra("payload")); Iterator<String> iter = oidDescriptions.keys(); while (iter.hasNext()) { String key = iter.next(); try { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View convertView = inflater.inflate(R.layout.oid_edit, null); ((TextView) convertView.findViewById(R.id.OID)).setText(key); ((EditText) convertView.findViewById(R.id.OIDDescription)) .setText((String) oidDescriptions.get(key)); ((EditText) convertView.findViewById(R.id.OIDDescription)).setTag("e_" + key); ((Button) convertView.findViewById(R.id.submitDescriptionButton)).setTag(key); ((Button) convertView.findViewById(R.id.submitDescriptionButton)) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { //Log.e("onClick", ((EditText) ((View) oidDescList.findViewWithTag(view.getTag())).findViewWithTag("e_"+view.getTag())).getText().toString()); ((Thread) new Thread() { public void run() { try { if (api.submitOIDEdit((String) view.getTag(), ((EditText) ((View) oidDescList .findViewWithTag(view.getTag())) .findViewWithTag("e_" + view.getTag())) .getText().toString())) { runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "OID suggestion successful.", Toast.LENGTH_SHORT).show(); } }); } else { runOnUiThread(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "OID suggestion was not successful.", Toast.LENGTH_SHORT).show(); } }); } } catch (Exception e) { e.printStackTrace(); } } }).start(); } }); convertView.setTag(key); oidDescList.addView(convertView); i++; } catch (Exception e) { // Something went wrong! } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mobileglobe.android.customdialer.filterednumber.BlockedNumbersFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null)); //replace the icon for add number with LetterTileDrawable(), so it will have identical style ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon); LetterTileDrawable drawable = new LetterTileDrawable(getResources()); drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER); drawable.setColor(ActivityCompat.getColor(getActivity(), R.color.add_blocked_number_icon_color)); drawable.setIsCircular(true);/* www .j a va 2 s . c o m*/ addNumberIcon.setImageDrawable(drawable); if (mAdapter == null) { mAdapter = BlockedNumbersAdapter.newBlockedNumbersAdapter(getContext(), getActivity().getFragmentManager()); } setListAdapter(mAdapter); blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view); migratePromoView = getListView().findViewById(R.id.migrate_promo); getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this); mImportSettings = getListView().findViewById(R.id.import_settings); mBlockedNumbersDisabledForEmergency = getListView() .findViewById(R.id.blocked_numbers_disabled_for_emergency); mBlockedNumberListDivider = getActivity().findViewById(R.id.blocked_number_list_divider); getListView().findViewById(R.id.import_button).setOnClickListener(this); getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this); getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this); footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview); }
From source file:com.irccloud.android.fragment.ServerMapListFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Context ctx = getActivity();/*www . j a v a 2 s. c o m*/ if (ctx == null) return null; LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.recyclerview, null); recyclerView = (RecyclerView) v.findViewById(R.id.recycler); recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext())); empty = (TextView) v.findViewById(android.R.id.empty); empty.setText("No results found."); if (savedInstanceState != null && savedInstanceState.containsKey("event")) { event = new IRCCloudJSONObject(savedInstanceState.getString("event")); servers = event.getJsonNode("servers"); adapter = new ServersAdapter(); recyclerView.setAdapter(adapter); if (adapter.getItemCount() > 0) { empty.setVisibility(View.GONE); recyclerView.setVisibility(View.VISIBLE); } else { empty.setVisibility(View.VISIBLE); recyclerView.setVisibility(View.GONE); } } Dialog d = new AlertDialog.Builder(ctx) .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) .setTitle("Server Map").setView(v) .setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); return d; }