Example usage for android.text Html toHtml

List of usage examples for android.text Html toHtml

Introduction

In this page you can find the example usage for android.text Html toHtml.

Prototype

@Deprecated
public static String toHtml(Spanned text) 

Source Link

Usage

From source file:Main.java

private static void append(StringBuilder sb, CharSequence... data) {
    for (CharSequence d : data) {
        if (d != null) {
            if (d instanceof Spanned) {
                String s = Html.toHtml((Spanned) d);
                sb.append(hexStringFromInt(FLAG_SPANNED, NUM_LEN));
                append(sb, s);/*from w  w  w.  jav  a2  s .  com*/
            } else {
                int len = d.length();
                sb.append(hexStringFromInt(len, NUM_LEN)).append(d);
            }
        } else {
            sb.append(hexStringFromInt(FLAG_NULL, NUM_LEN));
        }
    }
}

From source file:org.hopestarter.wallet.util.BitmapFragment.java

private static BitmapFragment instance(final Bitmap bitmap, @Nullable final Spanned label,
        @Nullable final CharSequence address) {
    final BitmapFragment fragment = new BitmapFragment();

    final Bundle args = new Bundle();
    args.putParcelable(KEY_BITMAP, bitmap);
    if (label != null)
        args.putCharSequence(KEY_LABEL, Html.toHtml(label));
    if (address != null)
        args.putCharSequence(KEY_ADDRESS, address);
    fragment.setArguments(args);// ww w. j a  v  a 2 s . co  m

    return fragment;
}

From source file:com.bdevlin.apps.ui.fragments.HelpListFragment.java

private void updateText() {
    // mHelpText = (TextView) getView().findViewById(R.id.help_text);
    mHelpText = (WebView) getView().findViewById(R.id.webView1);
    mHelpText.getSettings().setJavaScriptEnabled(false);

    CharSequence text = Utils.bold(Utils.italic(getResources().getString(R.string.about_eula)),
            Utils.color(Color.RED, getResources().getString(R.string.about_licenses)));
    CharSequence yourHtml = "<table>table</table>";

    CharSequence content = getContent();
    ;/*from  ww  w. ja v a2  s .  co  m*/
    SpannedString sstr = SpannedString.valueOf(content);
    SpannedString message = SpannedString.valueOf(mMessage);
    SpannedString message2 = SpannedString.valueOf(text);
    SpannedString message3 = SpannedString.valueOf(yourHtml);

    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(Html.toHtml(message)));
    aboutBody.append(Html.fromHtml(Html.toHtml(message2)));
    aboutBody.append(Html.fromHtml(Html.toHtml(message3)));
    aboutBody.append(Html.fromHtml(Html.toHtml(sstr)));
    aboutBody.setSpan(new StyleSpan(Typeface.ITALIC), 0, aboutBody.length(), 0);
    // mHelpText.setText(aboutBody);
    // mHelpText.loadData(Html.toHtml(aboutBody), "text/html", null);

    mHelpText.loadUrl("file:///android_asset/" + mTitle + ".html", null);

    //mHelpText.loadUrl("http://www.choosemyplate.gov/tools-supertracker");

}

From source file:com.google.android.gcm.demo.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedState) {
    super.onCreate(savedState);
    setContentView(R.layout.activity_main);
    mLogger = new Logger(this);
    mLogsUI = (TextView) findViewById(R.id.logs);
    mLoggerCallback = new BroadcastReceiver() {
        @Override//w  w  w  .j  a va2s  . com
        public void onReceive(Context context, Intent intent) {
            switch (intent.getAction()) {
            case LoggingService.ACTION_CLEAR_LOGS:
                mLogsUI.setText("");
                break;
            case LoggingService.ACTION_LOG:
                StringBuilder stringBuilder = new StringBuilder();
                String newLog = intent.getStringExtra(LoggingService.EXTRA_LOG_MESSAGE);
                String oldLogs = Html.toHtml(new SpannableString(mLogsUI.getText()));
                appendFormattedLogLine(newLog, stringBuilder);
                stringBuilder.append(oldLogs);
                mLogsUI.setText(Html.fromHtml(stringBuilder.toString()));
                List<Fragment> fragments = getSupportFragmentManager().getFragments();
                for (Fragment fragment : fragments) {
                    if (fragment instanceof RefreshableFragment && fragment.isVisible()) {
                        ((RefreshableFragment) fragment).refresh();
                    }
                }
                break;
            }
        }
    };

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerView = (FrameLayout) findViewById(R.id.navigation_drawer);
    mDrawerMenu = (ListView) findViewById(R.id.navigation_drawer_menu);
    mDrawerScrim = findViewById(R.id.navigation_drawer_scrim);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TypedArray colorPrimaryDark = getTheme().obtainStyledAttributes(new int[] { R.attr.colorPrimaryDark });
    mDrawerLayout.setStatusBarBackgroundColor(colorPrimaryDark.getColor(0, 0xFF000000));
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    colorPrimaryDark.recycle();

    ImageView drawerHeader = new ImageView(this);
    drawerHeader.setImageResource(R.drawable.drawer_gcm_logo);
    mDrawerMenu.addHeaderView(drawerHeader);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // Set the drawer width accordingly with the guidelines: window_width - toolbar_height.
        toolbar.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft,
                    int oldTop, int oldRight, int oldBottom) {
                if (left == 0 && top == 0 && right == 0 && bottom == 0) {
                    return;
                }
                DisplayMetrics metrics = new DisplayMetrics();
                getWindowManager().getDefaultDisplay().getMetrics(metrics);
                float logicalDensity = metrics.density;
                int maxWidth = (int) Math.ceil(320 * logicalDensity);
                DrawerLayout.LayoutParams params = (DrawerLayout.LayoutParams) mDrawerView.getLayoutParams();
                int newWidth = view.getWidth() - view.getHeight();
                params.width = (newWidth > maxWidth ? maxWidth : newWidth);
                mDrawerView.setLayoutParams(params);
            }
        });
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        mDrawerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                // Set scrim height to match status bar height.
                mDrawerScrim.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
                        insets.getSystemWindowInsetTop()));
                return insets;
            }
        });
    }

    int activeItemIndicator = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            ? android.R.layout.simple_list_item_activated_1
            : android.R.layout.simple_list_item_checked;

    mMainMenu = new MainMenu(this);
    mDrawerMenu.setOnItemClickListener(this);
    mDrawerMenu.setAdapter(new ArrayAdapter<>(getSupportActionBar().getThemedContext(), activeItemIndicator,
            android.R.id.text1, mMainMenu.getEntries()));

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            // The user learned how to open the drawer. Do not open it for him anymore.
            getAppPreferences().edit().putBoolean(PREF_OPEN_DRAWER_AT_STARTUP, false).apply();
            super.onDrawerOpened(drawerView);
        }
    };

    boolean activityResumed = (savedState != null);
    boolean openDrawer = getAppPreferences().getBoolean(PREF_OPEN_DRAWER_AT_STARTUP, true);
    int lastScreenId = getAppPreferences().getInt(PREF_LAST_SCREEN_ID, 0);
    selectItem(lastScreenId);
    if (!activityResumed && openDrawer) {
        mDrawerLayout.openDrawer(mDrawerView);
    }
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    /*
     * Here we check if the Activity was created by the user clicking on one of our GCM
     * notifications:
     * 1. Check if the action of the intent used to launch the Activity.
     * 2. Print out any additional data sent with the notification. This is included as extras
     *  on the intent.
     */
    Intent launchIntent = getIntent();
    if ("gcm_test_app_notification_click_action".equals(launchIntent.getAction())) {
        Bundle data = launchIntent.getExtras();
        data.isEmpty(); // Force the bundle to unparcel so that toString() works
        String format = getResources().getString(R.string.notification_intent_received);
        mLogger.log(Log.INFO, String.format(format, data));
    }
}

From source file:com.github.irshulx.Components.InputExtensions.java

@Override
public Node getContent(View view) {
    Node node = this.getNodeInstance(view);
    EditText _text = (EditText) view;/*from   ww w .j a v  a2 s .  c  o  m*/
    EditorControl tag = (EditorControl) view.getTag();
    node.contentStyles = tag.editorTextStyles;
    node.content.add(Html.toHtml(_text.getText()));
    node.textSettings = tag.textSettings;
    return node;
}

From source file:com.example.linhdq.test.documents.viewing.single.DocumentPagerFragment.java

@Override
public String getTextOfAllDocuments() {
    final DocumentTextFragment fragment = mAdapter.getFragment(mLastPosition);

    DocumentAdapter adapter = (DocumentAdapter) mPager.getAdapter();
    final int count = adapter.getCount();
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < count; i++) {
        String text = null;//w w  w.j a  v a  2s.  c om
        if (i == mLastPosition && fragment != null) {
            final Spanned documentText = fragment.getDocumentText();
            if (!TextUtils.isEmpty(documentText)) {
                text = Html.toHtml(documentText);
            }
        } else {
            text = adapter.getText(i);
        }
        if (text != null) {
            if (sb.length() > 0) {
                sb.append("\n");
            }
            sb.append(text);
        }
    }
    return sb.toString();
}

From source file:com.tct.email.provider.EmailMessageCursor.java

public EmailMessageCursor(final Context c, final Cursor cursor, final String htmlColumn,
        final String textColumn) {
    super(cursor);
    mHtmlColumnIndex = cursor.getColumnIndex(htmlColumn);
    mTextColumnIndex = cursor.getColumnIndex(textColumn);
    final int cursorSize = cursor.getCount();
    mHtmlParts = new SparseArray<String>(cursorSize);
    mTextParts = new SparseArray<String>(cursorSize);
    //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S
    mHtmlLinkifyColumnIndex = cursor.getColumnIndex(UIProvider.MessageColumns.BODY_HTML_LINKIFY);
    mHtmlLinkifyParts = new SparseArray<String>(cursorSize);
    mTextLinkifyColumnIndex = cursor.getColumnIndex(UIProvider.MessageColumns.BODY_TEXT_LINKIFY);
    mTextLinkifyParts = new SparseArray<String>(cursorSize);
    //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E

    final ContentResolver cr = c.getContentResolver();

    while (cursor.moveToNext()) {
        final int position = cursor.getPosition();
        final long messageId = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID));
        // TS: chao.zhang 2015-09-14 EMAIL BUGFIX-1039046  MOD_S
        InputStream htmlIn = null;
        InputStream textIn = null;
        try {//from   w  w  w .  ja v  a 2 s .  c o m
            if (mHtmlColumnIndex != -1) {
                final Uri htmlUri = Body.getBodyHtmlUriForMessageWithId(messageId);
                //WARNING: Actually openInput will used 2 PIPE(FD) to connect,but if some exception happen during connect,
                //such as fileNotFoundException,maybe the connection will not be closed. just a try!!!
                htmlIn = cr.openInputStream(htmlUri);
                final String underlyingHtmlString;
                try {
                    underlyingHtmlString = IOUtils.toString(htmlIn);
                } finally {
                    htmlIn.close();
                    htmlIn = null;
                }
                //TS: zhaotianyong 2015-04-05 EMAIL BUGFIX_964325 MOD_S
                final String sanitizedHtml = HtmlSanitizer.sanitizeHtml(underlyingHtmlString);
                mHtmlParts.put(position, sanitizedHtml);
                //TS: zhaotianyong 2015-04-05 EMAIL BUGFIX_964325 MOD_E
                //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S
                //NOTE: add links for sanitized html
                if (!TextUtils.isEmpty(sanitizedHtml)) {
                    final String linkifyHtml = com.tct.mail.utils.Linkify.addLinks(sanitizedHtml);
                    mHtmlLinkifyParts.put(position, linkifyHtml);
                } else {
                    mHtmlLinkifyParts.put(position, "");
                }
                //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E
            }
        } catch (final IOException e) {
            LogUtils.v(LogUtils.TAG, e, "Did not find html body for message %d", messageId);
        } catch (final OutOfMemoryError oom) {
            LogUtils.v(LogUtils.TAG, oom,
                    "Terrible,OOM happen durning query EmailMessageCursor in bodyHtml,current message %d",
                    messageId);
            mHtmlLinkifyParts.put(position, "");
        }
        try {
            if (mTextColumnIndex != -1) {
                final Uri textUri = Body.getBodyTextUriForMessageWithId(messageId);
                textIn = cr.openInputStream(textUri);
                final String underlyingTextString;
                try {
                    underlyingTextString = IOUtils.toString(textIn);
                } finally {
                    textIn.close();
                    textIn = null;
                }
                mTextParts.put(position, underlyingTextString);
                //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_S
                //NOTE: add links for underlying text string
                if (!TextUtils.isEmpty(underlyingTextString)) {
                    final SpannableString spannable = new SpannableString(underlyingTextString);
                    Linkify.addLinks(spannable,
                            Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS | Linkify.PHONE_NUMBERS);
                    final String linkifyText = Html.toHtml(spannable);
                    mTextLinkifyParts.put(position, linkifyText);
                } else {
                    mTextLinkifyParts.put(position, "");
                }
                //TS: jian.xu 2015-11-03 EMAIL BUGFIX-845079 ADD_E
            }
        } catch (final IOException e) {
            LogUtils.v(LogUtils.TAG, e, "Did not find text body for message %d", messageId);
        } catch (final OutOfMemoryError oom) {
            LogUtils.v(LogUtils.TAG, oom,
                    "Terrible,OOM happen durning query EmailMessageCursor in bodyText,current message %d",
                    messageId);
            mTextLinkifyParts.put(position, "");
        }
        //NOTE:Remember that this just a protective code,for better release Not used Resources.
        if (htmlIn != null) {
            try {
                htmlIn.close();
            } catch (IOException e1) {
                LogUtils.v(LogUtils.TAG, e1, "IOException happen while close the htmlInput connection ");
            }
        }
        if (textIn != null) {
            try {
                textIn.close();
            } catch (IOException e2) {
                LogUtils.v(LogUtils.TAG, e2, "IOException happen while close the textInput connection ");
            }
        } // TS: chao.zhang 2015-09-14 EMAIL BUGFIX-1039046  MOD_E
    }
    cursor.moveToPosition(-1);
}

From source file:com.adkdevelopment.earthquakesurvival.data.syncadapter.SyncAdapter.java

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
        SyncResult syncResult) {/*from  w ww.  j  av a2 s .c o m*/

    Context context = getContext();

    App.getApiManager().getEarthquakeService().getData().enqueue(new Callback<EarthquakeObject>() {
        @Override
        public void onResponse(Call<EarthquakeObject> call, Response<EarthquakeObject> response) {
            EarthquakeObject earthquake = response.body();

            Vector<ContentValues> cVVector = new Vector<>(earthquake.getFeatures().size());

            double currentBiggest = 0.0;
            ContentValues notifyValues = null;

            for (Feature each : earthquake.getFeatures()) {

                ContentValues earthquakeValues = new ContentValues();

                earthquakeValues.put(EarthquakeColumns.PLACE, each.getProperties().getPlace());
                earthquakeValues.put(EarthquakeColumns.ID_EARTH, each.getId());
                earthquakeValues.put(EarthquakeColumns.MAG, each.getProperties().getMag());
                earthquakeValues.put(EarthquakeColumns.TYPE, each.getProperties().getType());
                earthquakeValues.put(EarthquakeColumns.ALERT, each.getProperties().getAlert());
                earthquakeValues.put(EarthquakeColumns.TIME, each.getProperties().getTime());
                earthquakeValues.put(EarthquakeColumns.URL, each.getProperties().getUrl());
                earthquakeValues.put(EarthquakeColumns.DETAIL, each.getProperties().getDetail());
                earthquakeValues.put(EarthquakeColumns.DEPTH, each.getGeometry().getCoordinates().get(2));
                earthquakeValues.put(EarthquakeColumns.LONGITUDE, each.getGeometry().getCoordinates().get(0));
                earthquakeValues.put(EarthquakeColumns.LATITUDE, each.getGeometry().getCoordinates().get(1));

                LatLng latLng = new LatLng(each.getGeometry().getCoordinates().get(1),
                        each.getGeometry().getCoordinates().get(0));
                LatLng location = LocationUtils.getLocation(context);
                earthquakeValues.put(EarthquakeColumns.DISTANCE, LocationUtils.getDistance(latLng, location));

                cVVector.add(earthquakeValues);

                if (each.getProperties().getMag() != null && each.getProperties().getMag() > currentBiggest) {
                    currentBiggest = each.getProperties().getMag();
                    notifyValues = new ContentValues(earthquakeValues);
                    notifyValues.put(EarthquakeColumns.PLACE,
                            Utilities.formatEarthquakePlace(each.getProperties().getPlace()));
                }
            }

            int inserted = 0;
            // add to database
            ContentResolver resolver = context.getContentResolver();

            if (cVVector.size() > 0) {
                ContentValues[] cvArray = new ContentValues[cVVector.size()];
                cVVector.toArray(cvArray);
                inserted = resolver.bulkInsert(EarthquakeColumns.CONTENT_URI, cvArray);
            }

            // Set the date to day minus one to delete old data from the database
            Date date = new Date();
            date.setTime(date.getTime() - DateUtils.DAY_IN_MILLIS);

            int deleted = resolver.delete(EarthquakeColumns.CONTENT_URI, EarthquakeColumns.TIME + " <= ?",
                    new String[] { String.valueOf(date.getTime()) });
            Log.v(TAG, "Service Complete. " + inserted + " Inserted, " + deleted + " deleted");
            sendNotification(notifyValues);
        }

        @Override
        public void onFailure(Call<EarthquakeObject> call, Throwable t) {
            Log.e(TAG, "onFailure: " + t.toString());
        }
    });

    App.getNewsManager().getNewsService().getNews().enqueue(new Callback<Rss>() {
        @Override
        public void onResponse(Call<Rss> call, Response<Rss> response) {
            Channel news = response.body().getChannel();

            Vector<ContentValues> cVVector = new Vector<>(news.getItem().size());

            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z",
                    Locale.getDefault());
            Date date = new Date();

            for (Item each : news.getItem()) {

                ContentValues weatherValues = new ContentValues();

                try {
                    date = simpleDateFormat.parse(each.getPubDate());
                } catch (ParseException e) {
                    Log.e(TAG, "e:" + e);
                }

                weatherValues.put(NewsColumns.DATE, date.getTime());
                weatherValues.put(NewsColumns.TITLE, each.getTitle());
                weatherValues.put(NewsColumns.DESCRIPTION,
                        Html.toHtml(new SpannedString(each.getDescription())));
                weatherValues.put(NewsColumns.URL, each.getLink());
                weatherValues.put(NewsColumns.GUID, each.getGuid().getContent());

                cVVector.add(weatherValues);
            }

            int inserted = 0;
            // add to database
            ContentResolver resolver = getContext().getContentResolver();

            if (cVVector.size() > 0) {

                // Student: call bulkInsert to add the weatherEntries to the database here
                ContentValues[] cvArray = new ContentValues[cVVector.size()];
                cVVector.toArray(cvArray);
                inserted = resolver.bulkInsert(NewsColumns.CONTENT_URI, cvArray);
            }

            // Set the date to day minus two to delete old data from the database
            date = new Date();
            date.setTime(date.getTime() - DateUtils.DAY_IN_MILLIS * 3);

            int deleted = resolver.delete(NewsColumns.CONTENT_URI, NewsColumns.DATE + " <= ?",
                    new String[] { String.valueOf(date.getTime()) });
        }

        @Override
        public void onFailure(Call<Rss> call, Throwable t) {
            Log.e(TAG, "onFailure: " + t.toString());
        }
    });

    // TODO: 4/22/16 possible refactoring 
    //checking the last update and notify if it' the first of the day
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String lastNotificationKey = context.getString(R.string.sharedprefs_key_last_countupdate);
    long lastSync = prefs.getLong(lastNotificationKey, DateUtils.DAY_IN_MILLIS);

    if (System.currentTimeMillis() - lastSync >= Utilities.getSyncIntervalPrefs(context)
            * DateUtils.SECOND_IN_MILLIS) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
        Date date = new Date(System.currentTimeMillis());

        String startTime[] = new String[] { simpleDateFormat.format(date.getTime() - DateUtils.YEAR_IN_MILLIS),
                simpleDateFormat.format(date.getTime() - DateUtils.DAY_IN_MILLIS * 30),
                simpleDateFormat.format(date.getTime() - DateUtils.WEEK_IN_MILLIS),
                simpleDateFormat.format(date.getTime() - DateUtils.DAY_IN_MILLIS) };

        String endTime = simpleDateFormat.format(date);

        int iterator = 1;
        while (iterator < CountColumns.ALL_COLUMNS.length) {
            final int round = iterator;

            App.getApiManager().getEarthquakeService().getEarthquakeStats(startTime[round - 1], endTime)
                    .enqueue(new Callback<CountEarthquakes>() {
                        @Override
                        public void onResponse(Call<CountEarthquakes> call,
                                Response<CountEarthquakes> response) {
                            ContentValues count = new ContentValues();
                            count.put(CountColumns.ALL_COLUMNS[round], response.body().getCount());

                            ContentResolver contentResolver = context.getContentResolver();

                            Cursor cursor = contentResolver.query(CountColumns.CONTENT_URI, null, null, null,
                                    null);

                            if (cursor != null) {
                                if (cursor.getCount() < 1) {
                                    long inserted = ContentUris
                                            .parseId(contentResolver.insert(CountColumns.CONTENT_URI, count));
                                    //Log.d(TAG, "inserted:" + inserted);
                                } else {
                                    int updated = contentResolver.update(CountColumns.CONTENT_URI, count,
                                            CountColumns._ID + " = ?", new String[] { "1" });
                                    //Log.d(TAG, "updated: " + updated);
                                }
                                cursor.close();
                            }

                        }

                        @Override
                        public void onFailure(Call<CountEarthquakes> call, Throwable t) {
                            Log.e(TAG, "Error: " + t);
                        }
                    });
            iterator++;
        }

        //refreshing last sync
        prefs.edit().putLong(lastNotificationKey, System.currentTimeMillis()).apply();
    }

    // notify PagerActivity that data has been updated
    context.getContentResolver().notifyChange(EarthquakeColumns.CONTENT_URI, null, false);
    context.getContentResolver().notifyChange(NewsColumns.CONTENT_URI, null, false);
    context.getContentResolver().notifyChange(CountColumns.CONTENT_URI, null, false);

    updateWidgets();
}

From source file:com.eng.arab.translator.androidtranslator.translate.TranslateViewActivity.java

@Override
protected void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putInt(STATE_SRC_CARD_VISIBILITY, srcCard.getVisibility());
    savedInstanceState.putInt(STATE_TRG_CARD_VISIBILITY, trgCard.getVisibility());
    savedInstanceState.putString(STATE_SRC_TEXT, Html.toHtml(srcText.getText()));
    if (trgText.getEditableText() != null) {
        savedInstanceState.putString(STATE_TRG_TEXT, Html.toHtml(trgText.getEditableText()));
    }//from  w w w. j  a  v  a  2s.co  m
    storeValueSP();
}

From source file:com.digipom.manteresting.android.adapter.NailCursorAdapter.java

private CachedData cacheDataAndGet(Context context, Cursor cursor, int requestedWidth) throws JSONException {
    final String nailId = cursor.getString(nailIdColumnIndex);

    CachedData cachedDataForThisNailItem = cachedData.get(nailId);

    if (cachedDataForThisNailItem == null) {
        cachedDataForThisNailItem = new CachedData();

        final JSONObject nailObject = new JSONObject(cursor.getString(nailObjectColumnIndex));

        cachedDataForThisNailItem.originalImageUriString = nailObject.getString("original");
        cachedDataForThisNailItem.nailDescription = nailObject.getString("description");

        final String userName = nailObject.getJSONObject("user").getString("username");
        final String userNameFirstLetterCapitalised = userName.substring(0, 1).toUpperCase()
                + userName.substring(1);
        final String workBench = nailObject.getJSONObject("workbench").getString("title");

        cachedDataForThisNailItem.styledUserAndCategory = Html.fromHtml(String.format(
                Html.toHtml(new SpannedString(context.getResources().getText(R.string.nailUserAndCategory))),
                userNameFirstLetterCapitalised, workBench));

        cachedData.put(nailId, cachedDataForThisNailItem);
    }//from w  w  w  .j  a va2s  .co  m

    // Request a bitmap load.
    if (!failedDownloads.contains(cachedDataForThisNailItem.originalImageUriString)
            && serviceConnector.getService() != null) {
        serviceConnector.getService().loadOnlyLifoAsync(cachedDataForThisNailItem.originalImageUriString,
                requestedWidth);
    }

    return cachedDataForThisNailItem;
}