List of usage examples for android.text Html fromHtml
@Deprecated public static Spanned fromHtml(String source)
From source file:com.analysedesgeeks.android.PodcastActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_podcast); final FeedItem msg = rssService.getLastFeed().get(position); title.setText(msg.title);//ww w.j a va 2 s. co m date.setText(msg.formattedDate); String descriptionStr = msg.description; descriptionStr = StringEscapeUtils.unescapeHtml(descriptionStr); descriptionStr = descriptionStr.replace("- ", "<br>- "); descriptionStr = descriptionStr.replaceAll( "<img src=\"http://feeds.feedburner.com/~r/LanalyseDesGeeks.*height=\"1\" width=\"1\"/>", ""); description.setText(Html.fromHtml(descriptionStr)); playButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { podcastPlayer.setVisibility(View.VISIBLE); podcastPlayer.setDisplayedChild(LOADING_INDEX); new PlayTask().execute(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.bangalore.barcamp.DataProcessingUtils.java
public static BarcampData parseBCBJSON(String jsonString) { JSONObject json;/*from w w w . j a v a 2 s. c om*/ Log.e("DataProcessingUtils", jsonString); BarcampData data = null; try { json = (JSONObject) new JSONTokener(jsonString).nextValue(); String status = json.getString("status"); if (status.equals("have stuff")) { JSONArray jsonSlots = json.getJSONArray("slots"); data = new BarcampData(); List<Session> sessionList = null; List<Slot> slotList = new ArrayList<Slot>(); for (int iCount = 0; iCount < jsonSlots.length(); iCount++) { JSONObject curJsonSlot = jsonSlots.getJSONObject(iCount); Slot slot = new Slot(); slot.id = iCount; slot.name = curJsonSlot.getString(SLOT_TITLE); slot.type = curJsonSlot.getString(SLOT_TYPE); slot.startTime = curJsonSlot.getInt(BEGIN_TIME); slot.pos = iCount; if (curJsonSlot.has(SESSIONS)) { JSONArray sessions = curJsonSlot.getJSONArray(SESSIONS); sessionList = new ArrayList<Session>(); for (int jCount = 0; jCount < sessions.length(); jCount++) { Session session = new Session(); JSONObject jsonSession = sessions.getJSONObject(jCount); session.id = jsonSession.getString("id"); session.location = jsonSession.getString("location"); session.pos = jCount; session.presenter = jsonSession.getString("presenter"); session.time = jsonSession.getString("time"); session.title = Html.fromHtml(jsonSession.getString("title")).toString(); session.description = jsonSession.getString("description"); session.photo = jsonSession.getString("photo"); session.photo = session.photo.replace("\\/", ""); session.photo = session.photo.replace("&", "&"); if (session.photo.equals("null")) session.photo = "http://1.gravatar.com/avatar/f8dc8fabdbce2f177e3f5029775a0587?s=96&d=wavatar&r=G"; sessionList.add(session); } slot.sessionsArray = sessionList; } slotList.add(slot); } data.slotsArray = slotList; data.status = ""; } else { data = new BarcampData(); data.status = status; } } catch (JSONException e) { e.printStackTrace(); return null; } return data; }
From source file:com.pursuer.reader.easyrss.data.parser.SubscriptionJSONParser.java
public void parse() throws JsonParseException, IOException, IllegalStateException { final JsonFactory factory = new JsonFactory(); final JsonParser parser = factory.createJsonParser(input); Subscription sub = new Subscription(); int level = 0; boolean found = false; while (parser.nextToken() != null) { final String name = parser.getCurrentName(); switch (parser.getCurrentToken()) { case START_OBJECT: case START_ARRAY: level++;/*from w ww. ja v a 2 s . c o m*/ break; case END_OBJECT: case END_ARRAY: level--; break; case VALUE_STRING: if (level == 3) { if ("id".equals(name)) { sub.setUid(parser.getText()); } else if ("htmlUrl".equals(name)) { sub.setUrl(parser.getText()); } else if ("title".equals(name)) { sub.setTitle(Html.fromHtml(parser.getText()).toString()); } else if ("sortid".equals(name)) { sub.setSortId(parser.getText()); } else if ("firstitemmsec".equals(name)) { sub.setFirstItemMsec(Long.valueOf(parser.getText())); } } else if (level == 5 && "id".equals(name)) { sub.addTag(parser.getText()); } break; case FIELD_NAME: if (level == 1 && "subscriptions".equals(name)) { found = true; } break; default: } if (level == 2) { if (sub.getUid() != null && listener != null) { listener.onSubscriptionRetrieved(sub); } sub = new Subscription(); } } parser.close(); if (!found) { throw new IllegalStateException("Invalid JSON input"); } }
From source file:app.hacked.ChallengeDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.challenge_details, null); ((TextView) view.findViewById(R.id.Title)).setTypeface(Typeface.create("sans-serif-thin", Typeface.NORMAL)); ((TextView) view.findViewById(R.id.Title)).setText(Html.fromHtml(ChallengeTitle)); ((TextView) view.findViewById(R.id.challengeDetails)).setText(Html.fromHtml(ChallengeDetails)); return view;//from www.j a v a 2 s . c om }
From source file:com.awesome.vicky.justetit.fragment.About.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); textViewRecipeIcon = (TextView) getView().findViewById(R.id.recipe_icon_textview); textViewLeftoversIcon = (TextView) getView().findViewById(R.id.leftovers_icon_textview); textViewHelpIcon = (TextView) getView().findViewById(R.id.help_icon_textview); textViewAboutIcon = (TextView) getView().findViewById(R.id.about_icon_textview); textViewRefreshIcon = (TextView) getView().findViewById(R.id.refresh_icon_textview); textViewNoResultIcon = (TextView) getView().findViewById(R.id.no_result_icon_textview); textViewAppIcon = (TextView) getView().findViewById(R.id.app_icon_textview); textViewAppInto1Icon = (TextView) getView().findViewById(R.id.app_intro1_textview); textViewAppIntro2Icon = (TextView) getView().findViewById(R.id.app_intro2_textview); textViewAppIntro3Icon = (TextView) getView().findViewById(R.id.app_intro3_textview); textViewRecipyPuppyLink = (TextView) getView().findViewById(R.id.api_textview); textViewRecipeIcon.setText(Html.fromHtml( "Icon made by <a href='http://www.freepik.com' title='Freepik'>Freepik</a> from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewRecipeIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewLeftoversIcon.setText(Html.fromHtml( "Icon made by <a href='http://www.freepik.com' title = 'Freepik' > Freepik </a > from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewLeftoversIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewHelpIcon.setText(Html.fromHtml( "Icon made by <a href='http://www.danielbruce.se' title='Daniel Bruce'>Daniel Bruce</a> from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewHelpIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewAboutIcon.setText(Html.fromHtml( "Icon made by <a href='http://www.freepik.com' title='Freepik'>Freepik</a> from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewAboutIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewRefreshIcon.setText(Html.fromHtml( "Icon made by <a href='http://icon-works.com' title='Icon Works'>Icon Works</a> from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewRefreshIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewNoResultIcon.setText(Html.fromHtml( "Icon made by <a href='http://catalinfertu.com' title='Catalin Fertu'>Catalin Fertu</a> from <a href='http://www.flaticon.com' title='Flaticon'>www.flaticon.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewNoResultIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewAppIcon.setText(Html.fromHtml( "Icon made by <a href='http://www.iconfinder.com/ArtWhite' title='Artem White'>Artem White</a> from <a href='http://www.iconfinder.com' title='iconfinder'>www.iconfinder.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewAppIcon.setMovementMethod(LinkMovementMethod.getInstance()); textViewAppInto1Icon.setText(Html.fromHtml( "Icon made by <a href='http://www.iconfinder.com/Squid.ink' title='Squid.ink'>Squid.ink</a> from <a href='http://www.iconfinder.com' title='iconfinder'>www.iconfinder.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewAppInto1Icon.setMovementMethod(LinkMovementMethod.getInstance()); textViewAppIntro2Icon.setText(Html.fromHtml( "Icon made by <a href='http://www.iconfinder.com/Squid.ink' title='Squid.ink'>Squid.ink</a> from <a href='http://www.iconfinder.com' title='iconfinder'>www.iconfinder.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewAppIntro2Icon.setMovementMethod(LinkMovementMethod.getInstance()); textViewAppIntro3Icon.setText(Html.fromHtml( "Icon made by <a href='http://www.iconfinder.com/Squid.ink' title='Squid.ink'>Squid.ink</a> from <a href='http://www.iconfinder.com' title='iconfinder'>www.iconfinder.com</a> is licensed under <a href='http://creativecommons.org/licenses/by/3.0/' title='Creative Commons BY 3.0'>CC BY 3.0</a>")); textViewAppIntro3Icon.setMovementMethod(LinkMovementMethod.getInstance()); textViewRecipyPuppyLink.setText(//from w w w. j av a 2 s . c om Html.fromHtml("Powered by <a href='http://www.recipepuppy.com/about/api/'>Recippy Puppy</a>")); textViewRecipyPuppyLink.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:cc.mintcoin.wallet.ui.HelpDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final int messageResId = args.getInt(KEY_MESSAGE); final DialogBuilder dialog = new DialogBuilder(activity); dialog.setMessage(Html.fromHtml(getString(messageResId))); dialog.singleDismissButton(null);/*from w w w. j a v a2s . com*/ return dialog.create(); }
From source file:ca.uwaterloo.magic.goodhikes.RegisterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); /** define variables **/ register_name = (EditText) findViewById(R.id.register_name); register_email = (EditText) findViewById(R.id.register_email); register_password = (EditText) findViewById(R.id.register_password); register = (Button) findViewById(R.id.btn_register); link_login = (TextView) findViewById(R.id.link_login); link_login.setText(Html.fromHtml("Already a member? <u>Login</u>")); link_login.setOnClickListener(new View.OnClickListener() { @Override/* w w w . ja v a 2s. c om*/ public void onClick(View v) { startActivity(new Intent(getApplicationContext(), LoginActivity.class)); finish(); } }); register.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = register_name.getText().toString(); String email = register_email.getText().toString(); String password = register_password.getText().toString(); if (!name.isEmpty() && !email.isEmpty() && !password.isEmpty()) { try { String input = "name="; input += URLEncoder.encode(name, "UTF-8"); input += "&email="; input += URLEncoder.encode(email, "UTF-8"); input += "&password="; input += URLEncoder.encode(password, "UTF-8"); Log.d("Input for AsyncTask", input); new UserRegister().execute(input); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } else { Toast.makeText(RegisterActivity.this, "Please fill in all credentials!", Toast.LENGTH_SHORT) .show(); } } }); }
From source file:org.xbmc.kore.ui.hosts.AddHostFragmentFinish.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (getView() == null) return;/* w w w.j a v a 2s . c om*/ TextView message = (TextView) getView().findViewById(R.id.done_message); message.setText(Html.fromHtml(getString(R.string.wizard_done_message))); message.setMovementMethod(LinkMovementMethod.getInstance()); // Finish button Button next = (Button) getView().findViewById(R.id.next); next.setText(R.string.finish); next.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { listener.onAddHostFinish(); } }); // Previous button Button previous = (Button) getView().findViewById(R.id.previous); previous.setText(null); previous.setEnabled(false); // Check if PVR is enabled for the current host HostManager hostManager = HostManager.getInstance(getActivity()); if (hostManager.getHostInfo() != null) { AddHostFragmentFinish.checkPVREnabledAndSetMenuItems(getActivity(), new Handler()); String prefKey = Settings.KEY_PREF_CHECKED_PVR_ENABLED + String.valueOf(hostManager.getHostInfo().getId()); PreferenceManager.getDefaultSharedPreferences(getActivity()).edit().putBoolean(prefKey, true).apply(); } // Start the syncing process Intent syncIntent = new Intent(this.getActivity(), LibrarySyncService.class); syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MOVIES, true); syncIntent.putExtra(LibrarySyncService.SYNC_ALL_TVSHOWS, true); syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MUSIC, true); syncIntent.putExtra(LibrarySyncService.SYNC_ALL_MUSIC_VIDEOS, true); getActivity().startService(syncIntent); // InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); // imm.hideSoftInputFromWindow(getActivity() // .getWindow() // .getDecorView() // .getRootView() // .getWindowToken(), 0); }
From source file:fm.krui.kruifm.ArticleViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.article_view_layout); // Show loading view showLoadingScreen(true);/* w w w .j a va2 s . c om*/ // Prepare ActionBar ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); // Retrieve article object from intent Article article = new Article(); article = (Article) getIntent().getSerializableExtra(article.ARTICLE_INTENT); // Instantiate views TextView articleTitleTextView = (TextView) findViewById(R.id.view_article_title_textview); TextView authorTextView = (TextView) findViewById(R.id.view_article_author_textview); TextView articleContentTextView = (TextView) findViewById(R.id.view_article_text_textview); // Apply extracted info to views articleTitleTextView.setText(article.getTitle()); authorTextView.setText(getAuthor(article)); articleContentTextView.setText(Html.fromHtml(getArticleText(article))); // Hide loading view showLoadingScreen(false); }
From source file:com.armtimes.fragments.FragmentAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { ViewHolder viewHolder = (ViewHolder) view.getTag(); final String title = cursor.getString(viewHolder.titleIndex); final String description = cursor.getString(viewHolder.shortDescriptionIndex); final int isRead = cursor.getInt(viewHolder.isRead); viewHolder.textViewInfo.setText(Html.fromHtml(String.format("<b>%s</b> %s", title, description))); final String imagePath = cursor.getString(viewHolder.imagePathIndex); if (imagePath != null && !imagePath.isEmpty()) { // Read image from storage. InputStream is = null;//www. j a va 2 s. co m try { is = new FileInputStream(new File(imagePath)); // Set Bitmap to Image View. viewHolder.imageViewThumbnail.setImageBitmap(BitmapFactory.decodeStream(is)); // Set visibility of Image view to VISIBLE. viewHolder.imageViewThumbnail.setVisibility(View.VISIBLE); // In the case if Image was successfully set to the // image view change layout_weight parameter of image // view to (=2) and layout_width to (=0) in order to // show text and image view in a right way. viewHolder.textViewInfo.setLayoutParams(params2f); } catch (IOException ignore) { viewHolder.textViewInfo.setLayoutParams(params3f); // In the case if exception occurs and image can't be set. // Hide Thumbnail image. viewHolder.imageViewThumbnail.setVisibility(View.GONE); } finally { if (is != null) { try { is.close(); } catch (IOException ignore) { } } } } else { viewHolder.imageViewThumbnail.setVisibility(View.GONE); viewHolder.textViewInfo.setLayoutParams(params3f); } view.setBackgroundColor(isRead != 1 ? Color.parseColor("#EEEEEE") : Color.WHITE); }