List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:de.sourcestream.movieDB.MainActivity.java
/** * This method is used in MovieDetails, CastDetails and TVDetails. * We update the text value of a TextView, from runOnUiThread() because we can't update it from async task. * * @param text the TextView to update.//w w w.j a v a 2s . co m * @param value the new text value. */ public void setTextFromHtml(final TextView text, final String value) { runOnUiThread(new Runnable() { @Override public void run() { text.setText(Html.fromHtml(value)); } }); }
From source file:com.androzic.vnspeech.MapFragment.java
@Override public void updateFileInfo() { final String title = application.getMapTitle(); final String license = application.getMapLicense(); getActivity().runOnUiThread(new Runnable() { @Override// ww w.j a v a 2 s. c om public void run() { if (title != null) { currentFile.setText(title); } else { currentFile.setText("-no map-"); } if (license != null) { mapLicense.setText(Html.fromHtml(license)); mapLicense.setVisibility(View.VISIBLE); } else { mapLicense.setText(null); mapLicense.setVisibility(View.GONE); } updateMapViewArea(); double zoom = application.getZoom() * 100; if (zoom == 0.0) { mapZoom.setText("---%"); } else { int rz = (int) Math.floor(zoom); String zoomStr = zoom - rz != 0.0 ? String.format(Locale.getDefault(), "%.1f", zoom) : String.valueOf(rz); mapZoom.setText(zoomStr + "%"); } // ImageButton zoomin = (ImageButton) findViewById(R.id.zoomin); // ImageButton zoomout = (ImageButton) findViewById(R.id.zoomout); // zoomin.setEnabled(application.getNextZoom() != 0.0); // zoomout.setEnabled(application.getPrevZoom() != 0.0); // LightingColorFilter disable = new LightingColorFilter(0xFFFFFFFF, 0xFF444444); // zoomin.setColorFilter(zoomin.isEnabled() ? null : disable); // zoomout.setColorFilter(zoomout.isEnabled() ? null : disable); } }); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Manage click on GameSet./*from w w w .java2s .com*/ * * @param pos */ private void onListItemClick(final int pos) { final GameSet gameSet = (GameSet) getListAdapter().getItem(pos); final Item[] items = AppContext.getApplication().isAppLimited() ? limitedItems : allItems; ListAdapter adapter = new ArrayAdapter<Item>(this, android.R.layout.select_dialog_item, android.R.id.text1, items) { @Override public View getView(int position, View convertView, ViewGroup parent) { // User super class to create the View View v = super.getView(position, convertView, parent); TextView tv = (TextView) v.findViewById(android.R.id.text1); // Put the image on the TextView tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0); // Add margin between image and text (support various screen // densities) int dp5 = (int) (5 * getResources().getDisplayMetrics().density + 0.5f); tv.setCompoundDrawablePadding(dp5); return v; } }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format(this.getString(R.string.lblGameSetHistoryActivityMenuTitle), new SimpleDateFormat("dd/MM/yy").format(gameSet.getCreationTs()))); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int itemIndex) { Item item = items[itemIndex]; if (item.itemType == Item.ItemTypes.publishOnFacebook) { // check for active internet connexion first // see post // http://stackoverflow.com/questions/2789612/how-can-i-check-whether-an-android-device-is-connected-to-the-web ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isConnected()) { if (gameSet.getGameCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookImpossibleToPublishGamesetWithNoGame, Toast.LENGTH_SHORT) .show(); } else if (!AppContext.getApplication().getNotificationIds().isEmpty()) { Toast.makeText(GameSetHistoryActivity.this, R.string.lblFacebookGamesetBeingPublished, Toast.LENGTH_SHORT).show(); } else { tempGameSet = gameSet; // // TODO Improve in later version // ShortenUrlTask shortenUrlTask = new // ShortenUrlTask(FacebookHelper.buildGameSetUrl(tempGameSet)); // shortenUrlTask.setCallback(urlShortenedCallback); // shortenUrlTask.execute(); startPostProcess(); } } else { Toast.makeText(GameSetHistoryActivity.this, getString(R.string.titleInternetConnexionNecessary), Toast.LENGTH_LONG).show(); } } else if (item.itemType == Item.ItemTypes.publishOnTwitter) { Toast.makeText(GameSetHistoryActivity.this, "TODO: Publish on twitter", Toast.LENGTH_LONG) .show(); Intent intent = new Intent(GameSetHistoryActivity.this, TwitterConnectActivity.class); startActivity(intent); } else if (item.itemType == Item.ItemTypes.remove) { RemoveGameSetDialogClickListener removeGameSetDialogClickListener = new RemoveGameSetDialogClickListener( gameSet); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.titleRemoveGameSetYesNo)); builder.setMessage(Html.fromHtml( GameSetHistoryActivity.this.getText(R.string.msgRemoveGameSetYesNo).toString())); builder.setPositiveButton(GameSetHistoryActivity.this.getString(R.string.btnOk), removeGameSetDialogClickListener); builder.setNegativeButton(GameSetHistoryActivity.this.getString(R.string.btnCancel), removeGameSetDialogClickListener).show(); builder.setIcon(android.R.drawable.ic_dialog_alert); } else if (item.itemType == Item.ItemTypes.transferOverBluetooth) { if (!GameSetHistoryActivity.this.bluetoothHelper.isBluetoothEnabled()) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgActivateBluetooth), Toast.LENGTH_LONG).show(); } try { // make sure at least one device was discovered if (GameSetHistoryActivity.this.bluetoothHelper.getBluetoothDeviceCount() == 0) { Toast.makeText(GameSetHistoryActivity.this, GameSetHistoryActivity.this.getString(R.string.msgRunDiscoverDevicesFirst), Toast.LENGTH_LONG).show(); } // display devices and download final String[] items = GameSetHistoryActivity.this.bluetoothHelper .getBluetoothDeviceNames(); AlertDialog.Builder builder = new AlertDialog.Builder(GameSetHistoryActivity.this); builder.setTitle(GameSetHistoryActivity.this.getString(R.string.lblSelectBluetoothDevice)); builder.setItems(items, new BluetoothDeviceClickListener(gameSet, items)); AlertDialog alert = builder.create(); alert.show(); } catch (Exception e) { AuditHelper.auditError(ErrorTypes.gameSetHistoryActivityError, e, GameSetHistoryActivity.this); } } else if (item.itemType == Item.ItemTypes.exportToExcel) { try { if (!AppContext.getApplication().isAppLimited()) { ExportToExcelTask task = new ExportToExcelTask(GameSetHistoryActivity.this, progressDialog); task.setCallback(excelExportCallback); task.execute(gameSet); } } catch (Exception e) { Toast.makeText( GameSetHistoryActivity.this, AppContext.getApplication().getResources() .getText(R.string.msgGameSetExportError).toString() + e.getMessage(), Toast.LENGTH_LONG).show(); AuditHelper.auditError(ErrorTypes.excelFileStorage, e); } } else if (item.itemType == Item.ItemTypes.edit) { // SharedPreferences preferences = // PreferenceManager.getDefaultSharedPreferences(GameSetHistoryActivity.this); // set selected gameset as session gameset // AppContext.getApplication().getBizService().setGameSet(gameSet); // // Get non DAL stored parameters property from shared // preferences // UIHelper.fillNonComputationPreferences(gameSet.getGameSetParameters(), // preferences); // start tab gameset activity Intent intent = new Intent(GameSetHistoryActivity.this, TabGameSetActivity.class); intent.putExtra(ActivityParams.PARAM_GAMESET_ID, gameSet.getId()); GameSetHistoryActivity.this.startActivityForResult(intent, RequestCodes.DISPLAY_WITH_FACEBOOK); } } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:ch.ethz.twimight.net.opportunistic.ScanningService.java
/** * Creates content values for a Tweet from a JSON object TODO: Move this to * where it belongs/*from w w w .j ava 2s.c o m*/ * * @param o * @return * @throws JSONException */ protected ContentValues getTweetCV(JSONObject o) throws JSONException { ContentValues cv = new ContentValues(); if (o.has(Tweets.COL_CERTIFICATE)) cv.put(Tweets.COL_CERTIFICATE, o.getString(Tweets.COL_CERTIFICATE)); if (o.has(Tweets.COL_SIGNATURE)) cv.put(Tweets.COL_SIGNATURE, o.getString(Tweets.COL_SIGNATURE)); if (o.has(Tweets.COL_CREATED_AT)) cv.put(Tweets.COL_CREATED_AT, o.getLong(Tweets.COL_CREATED_AT)); if (o.has(Tweets.COL_TEXT)) { cv.put(Tweets.COL_TEXT, o.getString(Tweets.COL_TEXT)); cv.put(Tweets.COL_TEXT_PLAIN, Html.fromHtml(o.getString(Tweets.COL_TEXT)).toString()); } if (o.has(Tweets.COL_USER_TID)) { cv.put(Tweets.COL_USER_TID, o.getLong(Tweets.COL_USER_TID)); } if (o.has(Tweets.COL_TID)) { cv.put(Tweets.COL_TID, o.getLong(Tweets.COL_TID)); } if (o.has(Tweets.COL_REPLY_TO_TWEET_TID)) cv.put(Tweets.COL_REPLY_TO_TWEET_TID, o.getLong(Tweets.COL_REPLY_TO_TWEET_TID)); if (o.has(Tweets.COL_LAT)) cv.put(Tweets.COL_LAT, o.getDouble(Tweets.COL_LAT)); if (o.has(Tweets.COL_LNG)) cv.put(Tweets.COL_LNG, o.getDouble(Tweets.COL_LNG)); if (o.has(Tweets.COL_SOURCE)) cv.put(Tweets.COL_SOURCE, o.getString(Tweets.COL_SOURCE)); if (o.has(Tweets.COL_MEDIA_URIS)) { String userID = cv.getAsString(Tweets.COL_USER_TID); photoPath = PHOTO_PATH + "/" + userID; String photoFileName = o.getString(Tweets.COL_MEDIA_URIS); File targetFile = sdCardHelper.getFileFromSDCard(photoPath, photoFileName); cv.put(Tweets.COL_MEDIA_URIS, Uri.fromFile(targetFile).toString()); } if (o.has(Tweets.COL_HTML_PAGES)) cv.put(Tweets.COL_HTML_PAGES, o.getString(Tweets.COL_HTML_PAGES)); if (o.has(TwitterUsers.COL_SCREEN_NAME)) { cv.put(Tweets.COL_SCREEN_NAME, o.getString(TwitterUsers.COL_SCREEN_NAME)); } return cv; }
From source file:cl.ipp.katbag.fragment.Develop.java
public void setMotion(String title, final String humanTextRow, final int dialogIdObjectItemList, final long object_id) { int resource = getResources().getIdentifier("dialog_motion_" + dialogIdObjectItemList, "layout", mainActivity.getPackageName()); LayoutInflater inflater = LayoutInflater.from(mainActivity.context); final View dialog_layout = inflater.inflate(resource, null); if (object_id != -1) { dev.clear();//w w w .j a v a 2 s .c o m dev = mainActivity.katbagHandler.selectDevelopForId(object_id); } spinner_drawing_1 = (Spinner) dialog_layout.findViewById(R.id.dialog_drawing); spinnerList.clear(); drawing1List.clear(); spinnerList = mainActivity.katbagHandler.selectDevelopAllDrawing(id_app); if (spinnerList.size() == 0) { KatbagUtilities.message(mainActivity.context, getString(R.string.develop_message_not_drawing)); return; } for (int i = 0; i < spinnerList.size(); i++) { drawing1List.add(getString(R.string.drawings_row_name) + " " + spinnerList.get(i)); } ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(mainActivity.context, R.layout.simple_spinner_item_custom, drawing1List); arrayAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item_custom); spinner_drawing_1.setAdapter(arrayAdapter); switch (dialogIdObjectItemList) { case 0: editN = (EditText) dialog_layout.findViewById(R.id.dialog_n); if (object_id == -1) { editN.setText(getString(R.string.develop_edittext_number_default_value)); editN.setSelection(editN.getText().length()); } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } editN.setText(dev.get(4)); editN.setSelection(editN.getText().length()); } break; case 1: editX = (EditText) dialog_layout.findViewById(R.id.dialog_x); editY = (EditText) dialog_layout.findViewById(R.id.dialog_y); if (object_id == -1) { editX.setText(getString(R.string.develop_edittext_number_default_value)); editX.setSelection(editX.getText().length()); editY.setText(getString(R.string.develop_edittext_number_default_value)); editY.setSelection(editY.getText().length()); } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } editX.setText(dev.get(4)); editX.setSelection(editX.getText().length()); editY.setText(dev.get(5)); editY.setSelection(editY.getText().length()); } break; case 2: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 3: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 4: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 5: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 6: editN = (EditText) dialog_layout.findViewById(R.id.dialog_n); if (object_id == -1) { editN.setText(getString(R.string.develop_edittext_number_default_value)); editN.setSelection(editN.getText().length()); } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(4))) { spinner_drawing_1.setSelection(i); break; } } editN.setText(dev.get(3)); editN.setSelection(editN.getText().length()); } break; case 7: editN = (EditText) dialog_layout.findViewById(R.id.dialog_n); if (object_id == -1) { editN.setText(getString(R.string.develop_edittext_number_default_value)); editN.setSelection(editN.getText().length()); } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(4))) { spinner_drawing_1.setSelection(i); break; } } editN.setText(dev.get(3)); editN.setSelection(editN.getText().length()); } break; case 8: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 9: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 10: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 11: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; case 12: if (object_id == -1) { } else { for (int i = 0; i < spinnerList.size(); i++) { if (spinnerList.get(i).contentEquals(dev.get(3))) { spinner_drawing_1.setSelection(i); break; } } } break; } AlertDialog.Builder builder = new AlertDialog.Builder(mainActivity.context); builder.setView(dialog_layout); builder.setTitle(Html.fromHtml(title)); builder.setNegativeButton(getString(R.string.dialog_button_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mainActivity.hideSoftKeyboard(); } }); builder.setPositiveButton(getString(R.string.dialog_button_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mainActivity.hideSoftKeyboard(); drawingText = spinner_drawing_1.getSelectedItem().toString(); drawingId = spinnerList.get(spinner_drawing_1.getSelectedItemPosition()); switch (dialogIdObjectItemList) { case 0: // validate field if (editN.getText().toString().contentEquals("")) { KatbagUtilities.message(mainActivity.context, getString(R.string.develop_message_empty_n)); return; } if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText, editN.getText().toString()), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected editN.getText().toString(), // number of steps "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText, editN.getText().toString()), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected editN.getText().toString(), // number of steps "", "", "", "", ""); } break; case 1: // validate field if (editX.getText().toString().contentEquals("") || editY.getText().toString().contentEquals("")) { KatbagUtilities.message(mainActivity.context, getString(R.string.develop_message_empty_n)); return; } if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText, editX.getText().toString(), editY.getText().toString()), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected editX.getText().toString(), // X coordinates editY.getText().toString(), // Y coordinates "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText, editX.getText().toString(), editY.getText().toString()), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected editX.getText().toString(), // X coordinates editY.getText().toString(), // Y coordinates "", "", "", ""); } break; case 2: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 3: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 4: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 5: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 6: // validate field if (editN.getText().toString().contentEquals("")) { KatbagUtilities.message(mainActivity.context, getString(R.string.develop_message_empty_n)); return; } if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, editN.getText().toString(), drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion editN.getText().toString(), // X degrees drawingId, // id of drawing selected "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, editN.getText().toString(), drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion editN.getText().toString(), // X degrees drawingId, // id of drawing selected "", "", "", "", ""); } break; case 7: // validate field if (editN.getText().toString().contentEquals("")) { KatbagUtilities.message(mainActivity.context, getString(R.string.develop_message_empty_n)); return; } if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, editN.getText().toString(), drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion editN.getText().toString(), // Y degrees drawingId, // id of drawing selected "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, editN.getText().toString(), drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion editN.getText().toString(), // Y degrees drawingId, // id of drawing selected "", "", "", "", ""); } break; case 8: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 9: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 10: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 11: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; case 12: if (object_id == -1) { mainActivity.katbagHandler.insertDevelop(id_app, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", "", 0, 0); } else { mainActivity.katbagHandler.updateDevelop(object_id, "motion", String.format(humanTextRow, drawingText), // row text String.valueOf(dialogIdObjectItemList), // first parameter is the type motion drawingId, // id of drawing selected "", "", "", "", "", ""); } break; } loadListView(); } }); builder.show(); }
From source file:github.daneren2005.dsub.util.Util.java
public static void showHTMLDialog(Context context, int title, int message) { AlertDialog dialog = new AlertDialog.Builder(context).setIcon(android.R.drawable.ic_dialog_info) .setTitle(title).setMessage(Html.fromHtml(context.getResources().getString(message))) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override/*from w w w .j av a 2s.c om*/ public void onClick(DialogInterface dialog, int i) { dialog.dismiss(); } }).show(); }
From source file:com.dycody.android.idealnote.ListFragment.java
public void toggleSearchLabel(boolean activate) { if (activate) { searchQueryView.setText(Html.fromHtml(getString(R.string.search) + ":<b> " + searchQuery + "</b>")); searchLayout.setVisibility(View.VISIBLE); searchCancel.setOnClickListener(v -> toggleSearchLabel(false)); searchLabelActive = true;//from w ww. j a va 2 s . c o m } else { if (searchLabelActive) { searchLabelActive = false; AnimationsHelper.expandOrCollapse(searchLayout, false); searchTags = null; searchQuery = null; if (!goBackOnToggleSearchLabel) { mainActivity.getIntent().setAction(Intent.ACTION_MAIN); if (searchView != null) { MenuItemCompat.collapseActionView(searchMenuItem); } initNotesList(mainActivity.getIntent()); } else { mainActivity.onBackPressed(); } goBackOnToggleSearchLabel = false; if (Intent.ACTION_VIEW.equals(mainActivity.getIntent().getAction())) { mainActivity.getIntent().setAction(null); } } } }
From source file:com.klinker.android.twitter.utils.NotificationUtils.java
public static void notifySecondMentions(Context context, int secondAccount) { MentionsDataSource data = MentionsDataSource.getInstance(context); int numberNew = data.getUnreadCount(secondAccount); int smallIcon = R.drawable.ic_stat_icon; Bitmap largeIcon;/*from w w w . j av a 2s .c om*/ Intent resultIntent = new Intent(context, SwitchAccountsRedirect.class); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, 0); NotificationCompat.Builder mBuilder; String title = context.getResources().getString(R.string.app_name) + " - " + context.getResources().getString(R.string.sec_acc); ; String name = null; String message; String messageLong; String tweetText = null; NotificationCompat.Action replyAction = null; if (numberNew == 1) { name = data.getNewestName(secondAccount); SharedPreferences sharedPrefs = context.getSharedPreferences( "com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); // if they are muted, and you don't want them to show muted mentions // then just quit if (sharedPrefs.getString("muted_users", "").contains(name) && !sharedPrefs.getBoolean("show_muted_mentions", false)) { return; } message = context.getResources().getString(R.string.mentioned_by) + " @" + name; tweetText = data.getNewestMessage(secondAccount); messageLong = "<b>@" + name + "</b>: " + tweetText; largeIcon = getImage(context, name); Intent reply = new Intent(context, NotificationComposeSecondAcc.class); sharedPrefs.edit().putString("from_notification_second", "@" + name).commit(); long id = data.getLastIds(secondAccount)[0]; PendingIntent replyPending = PendingIntent.getActivity(context, 0, reply, 0); sharedPrefs.edit().putLong("from_notification_long_second", id).commit(); sharedPrefs.edit() .putString("from_notification_text_second", "@" + name + ": " + TweetLinkUtils.removeColorHtml(tweetText, AppSettings.getInstance(context))) .commit(); // Create the remote input RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel("@" + name + " ").build(); // Create the notification action replyAction = new NotificationCompat.Action.Builder(R.drawable.ic_action_reply_dark, context.getResources().getString(R.string.noti_reply), replyPending).addRemoteInput(remoteInput) .build(); } else { // more than one mention message = numberNew + " " + context.getResources().getString(R.string.new_mentions); messageLong = "<b>" + context.getResources().getString(R.string.mentions) + "</b>: " + numberNew + " " + context.getResources().getString(R.string.new_mentions); largeIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.drawer_user_dark); } Intent markRead = new Intent(context, MarkReadSecondAccService.class); PendingIntent readPending = PendingIntent.getService(context, 0, markRead, 0); AppSettings settings = AppSettings.getInstance(context); Intent deleteIntent = new Intent(context, NotificationDeleteReceiverTwo.class); mBuilder = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(TweetLinkUtils.removeColorHtml(message, settings)).setSmallIcon(smallIcon) .setLargeIcon(largeIcon).setContentIntent(resultPendingIntent).setAutoCancel(true) .setDeleteIntent(PendingIntent.getBroadcast(context, 0, deleteIntent, 0)) .setPriority(NotificationCompat.PRIORITY_HIGH); if (numberNew == 1) { mBuilder.addAction(replyAction); mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(Html.fromHtml( settings.addonTheme ? messageLong.replaceAll("FF8800", settings.accentColor) : messageLong))); } else { NotificationCompat.InboxStyle inbox = getMentionsInboxStyle(numberNew, secondAccount, context, TweetLinkUtils.removeColorHtml(message, settings)); mBuilder.setStyle(inbox); } if (settings.vibrate) { mBuilder.setDefaults(Notification.DEFAULT_VIBRATE); } if (settings.sound) { try { mBuilder.setSound(Uri.parse(settings.ringtone)); } catch (Exception e) { mBuilder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)); } } if (settings.led) mBuilder.setLights(0xFFFFFF, 1000, 1000); if (settings.notifications) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.notify(9, mBuilder.build()); // if we want to wake the screen on a new message if (settings.wakeScreen) { PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); final PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(5000); } // Pebble notification if (context .getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE) .getBoolean("pebble_notification", false)) { sendAlertToPebble(context, title, messageLong); } // Light Flow notification sendToLightFlow(context, title, messageLong); } }
From source file:com.vuze.android.remote.SessionInfo.java
public void openTorrent(final Activity activity, final String name, InputStream is) { try {//from w ww .j a v a2 s . c o m int available = is.available(); if (available <= 0) { available = 32 * 1024; } ByteArrayBuffer bab = new ByteArrayBuffer(available); boolean ok = AndroidUtils.readInputStreamIfStartWith(is, bab, new byte[] { 'd' }); if (!ok) { String s; if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && bab.length() == 0) { s = activity.getResources().getString(R.string.not_torrent_file_kitkat, name); } else { s = activity.getResources().getString(R.string.not_torrent_file, name, Math.max(bab.length(), 5)); } AndroidUtils.showDialog(activity, R.string.add_torrent, Html.fromHtml(s)); return; } final String metainfo = Base64Encode.encodeToString(bab.buffer(), 0, bab.length()); openTorrentWithMetaData(activity, name, metainfo); } catch (IOException e) { if (AndroidUtils.DEBUG) { e.printStackTrace(); } VuzeEasyTracker.getInstance(activity).logError(e); } catch (OutOfMemoryError em) { VuzeEasyTracker.getInstance(activity).logError(em); AndroidUtils.showConnectionError(activity, "Out of Memory", true); } }
From source file:cgeo.geocaching.connector.gc.GCParser.java
public static List<PocketQueryList> searchPocketQueryList() { final Parameters params = new Parameters(); final String page = GCLogin.getInstance().getRequestLogged("http://www.geocaching.com/pocket/default.aspx", params);/*from www .j a v a2s .co m*/ if (StringUtils.isBlank(page)) { Log.e("GCParser.searchPocketQueryList: No data from server"); return null; } String subPage = StringUtils.substringAfter(page, "class=\"PocketQueryListTable"); if (StringUtils.isEmpty(subPage)) { Log.e("GCParser.searchPocketQueryList: class \"PocketQueryListTable\" not found on page"); return Collections.emptyList(); } List<PocketQueryList> list = new ArrayList<PocketQueryList>(); final MatcherWrapper matcherPocket = new MatcherWrapper(GCConstants.PATTERN_LIST_PQ, subPage); while (matcherPocket.find()) { int maxCaches; try { maxCaches = Integer.parseInt(matcherPocket.group(1)); } catch (NumberFormatException e) { maxCaches = 0; Log.e("GCParser.searchPocketQueryList: Unable to parse max caches", e); } final String guid = Html.fromHtml(matcherPocket.group(2)).toString(); final String name = Html.fromHtml(matcherPocket.group(3)).toString(); final PocketQueryList pqList = new PocketQueryList(guid, name, maxCaches); list.add(pqList); } // just in case, lets sort the resulting list Collections.sort(list, new Comparator<PocketQueryList>() { @Override public int compare(PocketQueryList left, PocketQueryList right) { return String.CASE_INSENSITIVE_ORDER.compare(left.getName(), right.getName()); } }); return list; }