List of usage examples for android.text.format DateFormat getLongDateFormat
public static java.text.DateFormat getLongDateFormat(Context context)
From source file:com.activiti.android.ui.fragments.task.TaskDetailsFoundationFragment.java
private void displayDueDate(Date due) { dueDateHolder.topText.setText(R.string.task_field_due); dueDateHolder.icon.setImageResource(R.drawable.ic_event_grey); dueAt = due;/*w ww . j a v a 2 s . co m*/ if (due != null) { StringBuilder builder = new StringBuilder(); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(due); if (calendar.before(new GregorianCalendar())) { builder.append("<font color='#F44336'>"); builder.append(DateFormat.getLongDateFormat(getActivity()).format(due.getTime())); builder.append("</font>"); } else { builder.append(DateFormat.getLongDateFormat(getActivity()).format(due.getTime())); } dueDateHolder.bottomText.setText(builder.toString()); dueDateHolder.bottomText.setText(Html.fromHtml(builder.toString()), TextView.BufferType.SPANNABLE); } else { dueDateHolder.bottomText.setText(R.string.task_message_no_duedate); } if (!isEnded) { viewById(R.id.task_details_due_container).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DatePickerFragment.newInstance(DUE_DATE, getTag()).show(getFragmentManager(), DatePickerFragment.TAG); } }); } else { UIUtils.setBackground(viewById(R.id.task_details_due_container), null); } }
From source file:com.bluros.updater.UpdatesSettings.java
private void showSysInfo() { // Build the message Date lastCheck = new Date(mPrefs.getLong(Constants.LAST_UPDATE_CHECK_PREF, 0)); String date = DateFormat.getLongDateFormat(this).format(lastCheck); String time = DateFormat.getTimeFormat(this).format(lastCheck); String cmReleaseType = Constants.CM_RELEASETYPE_NIGHTLY; int updateType = Utils.getUpdateType(); if (updateType == Constants.UPDATE_TYPE_SNAPSHOT) { cmReleaseType = Constants.CM_RELEASETYPE_SNAPSHOT; }//from ww w .ja v a 2s .com String message = getString(R.string.sysinfo_device) + " " + Utils.getDeviceType() + "\n\n" + getString(R.string.sysinfo_running) + " " + Utils.getInstalledVersion() + "\n\n" + getString(R.string.sysinfo_update_channel) + " " + cmReleaseType + "\n\n" + getString(R.string.sysinfo_last_check) + " " + date + " " + time; AlertDialog.Builder builder = new AlertDialog.Builder(this).setTitle(R.string.menu_system_info) .setMessage(message).setPositiveButton(R.string.dialog_ok, null); AlertDialog dialog = builder.create(); dialog.show(); TextView messageView = (TextView) dialog.findViewById(android.R.id.message); messageView.setTextAppearance(this, android.R.style.TextAppearance_DeviceDefault_Small); }
From source file:org.tvbrowser.tvbrowser.TvBrowser.java
private void showAbout() { AlertDialog.Builder builder = new AlertDialog.Builder(TvBrowser.this); RelativeLayout about = (RelativeLayout) getLayoutInflater().inflate(R.layout.about, getParentViewGroup(), false);/*from w w w. j a v a2 s . c o m*/ try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); TextView version = (TextView) about.findViewById(R.id.version); version.setText(pInfo.versionName); } catch (NameNotFoundException e) { e.printStackTrace(); } ((TextView) about.findViewById(R.id.license)) .setText(Html.fromHtml(getResources().getString(R.string.license))); TextView androidVersion = (TextView) about.findViewById(R.id.android_version); androidVersion.setText(Build.VERSION.RELEASE); TextView lastUpdate = (TextView) about.findViewById(R.id.data_update); lastUpdate.setText(DateFormat.getLongDateFormat(TvBrowser.this) .format(new Date(PrefUtils.getLongValue(R.string.LAST_DATA_UPDATE, 0)))); TextView nextUpdate = (TextView) about.findViewById(R.id.next_data_update); switch (Integer.parseInt( PrefUtils.getStringValue(R.string.PREF_AUTO_UPDATE_TYPE, R.string.pref_auto_update_type_default))) { case 0: nextUpdate.setText(R.string.next_data_update_manually); break; case 1: nextUpdate.setText(R.string.next_data_update_connection); break; case 2: { Date date = new Date(PrefUtils.getLongValue(R.string.AUTO_UPDATE_CURRENT_START_TIME, 0)); nextUpdate.setText(DateFormat.getMediumDateFormat(TvBrowser.this).format(date) + " " + DateFormat.getTimeFormat(TvBrowser.this).format(date)); } break; } ((TextView) about.findViewById(R.id.rundate_value)) .setText(DateFormat.getLongDateFormat(getApplicationContext()).format(mRundate.getTime())); builder.setTitle(R.string.action_about); builder.setView(about); builder.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); }
From source file:org.tvbrowser.tvbrowser.TvBrowser.java
private void showInAppDonations(final Inventory inv, boolean showIfAlreadyDonated) { updateProgressIcon(false);//w w w .j a v a 2 s. c o m AlertDialog.Builder alert = new AlertDialog.Builder(TvBrowser.this); alert.setTitle(R.string.donation); View view = getLayoutInflater().inflate(R.layout.in_app_donations, getParentViewGroup(), false); LinearLayout layout = (LinearLayout) view.findViewById(R.id.donation_in_app_layout); alert.setView(view); alert.setNegativeButton(getString(R.string.not_now).replace("{0}", ""), null); if (Locale.getDefault().getCountry().equals("DE")) { alert.setPositiveButton(R.string.donation_info_website, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://android.tvbrowser.org/index.php?id=donations"))); } }); } final AlertDialog d = alert.create(); View.OnClickListener onDonationClick = new View.OnClickListener() { @Override public void onClick(View v) { d.dismiss(); openDonation((SkuDetails) v.getTag()); } }; Purchase donated = null; SkuDetails donatedDetails = null; for (String sku : SettingConstants.SKU_LIST) { SkuDetails details = inv.getSkuDetails(sku); Purchase donatedTest = inv.getPurchase(sku); if (donatedTest != null && details != null) { donated = donatedTest; donatedDetails = details; } if (details != null) { if (!details.getSku().equals(SettingConstants.SKU_EPG_DONATE_ONCE) || hasEpgDonateChannelsSubscribed()) { String title = details.getTitle().substring(0, details.getTitle().indexOf("(") - 1); Button donation = new Button(this); donation.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); donation.setText(title + ": " + details.getPrice()); donation.setTag(details); donation.setOnClickListener(onDonationClick); layout.addView(donation); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) donation.getLayoutParams(); params.setMargins(5, 0, 5, 5); //left, top, right, bottom donation.setLayoutParams(params); } } } if (donated == null || showIfAlreadyDonated) { d.show(); } else if (donated != null) { AlertDialog.Builder alert2 = new AlertDialog.Builder(TvBrowser.this); alert2.setTitle(R.string.donation); String message = getString(R.string.already_donated) .replace("{1}", DateFormat.getLongDateFormat(this).format(new Date(donated.getPurchaseTime()))) .replace("{0}", donatedDetails.getPrice()); alert2.setMessage(message); final Purchase toConsume = donated; alert2.setPositiveButton(R.string.donate_again, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { updateProgressIcon(true); mHelper.consumeAsync(toConsume, new IabHelper.OnConsumeFinishedListener() { @Override public void onConsumeFinished(Purchase purchase, IabResult result) { updateProgressIcon(false); if (result.isSuccess()) { d.show(); } else { handler.post(new Runnable() { @Override public void run() { Toast.makeText(TvBrowser.this, "", Toast.LENGTH_LONG).show(); } }); } } }); } }); alert2.setNegativeButton(R.string.stop_donation, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert2.show(); } }