Example usage for android.text Html fromHtml

List of usage examples for android.text Html fromHtml

Introduction

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

Prototype

@Deprecated
public static Spanned fromHtml(String source) 

Source Link

Document

Returns displayable styled text from the provided HTML string with the legacy flags #FROM_HTML_MODE_LEGACY .

Usage

From source file:net.olejon.mdapp.NasjonaleRetningslinjerActivity.java

private void search(final String searchString) {
    if (searchString.equals(""))
        return;/*from  w  w  w .ja v a  2 s .c o m*/

    mToolbarSearchLayout.setVisibility(View.GONE);
    mToolbarSearchEditText.setText("");
    mProgressBar.setVisibility(View.VISIBLE);

    RequestQueue requestQueue = Volley.newRequestQueue(mContext);

    try {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET,
                getString(R.string.project_website_uri) + "api/1/correct/?search="
                        + URLEncoder.encode(searchString, "utf-8"),
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {
                        mProgressBar.setVisibility(View.GONE);

                        try {
                            final String correctSearchString = response.getString("correct");

                            if (correctSearchString.equals("")) {
                                saveRecentSearch(searchString);

                                try {
                                    Intent intent = new Intent(mContext, MainWebViewActivity.class);
                                    intent.putExtra("title", getString(R.string.nasjonale_retningslinjer_search)
                                            + ": \"" + searchString + "\"");
                                    intent.putExtra("uri", "https://helsedirektoratet.no/retningslinjer#k="
                                            + URLEncoder.encode(searchString.toLowerCase(), "utf-8"));
                                    startActivity(intent);
                                } catch (Exception e) {
                                    Log.e("NasjonaleRetningslinjer", Log.getStackTraceString(e));
                                }
                            } else {
                                new MaterialDialog.Builder(mContext)
                                        .title(getString(R.string.correct_dialog_title))
                                        .content(Html.fromHtml(getString(R.string.correct_dialog_message)
                                                + ":<br><br><b>" + correctSearchString + "</b>"))
                                        .positiveText(getString(R.string.correct_dialog_positive_button))
                                        .negativeText(getString(R.string.correct_dialog_negative_button))
                                        .callback(new MaterialDialog.ButtonCallback() {
                                            @Override
                                            public void onPositive(MaterialDialog dialog) {
                                                saveRecentSearch(correctSearchString);

                                                try {
                                                    Intent intent = new Intent(mContext,
                                                            MainWebViewActivity.class);
                                                    intent.putExtra("title",
                                                            getString(R.string.nasjonale_retningslinjer_search)
                                                                    + ": \"" + correctSearchString + "\"");
                                                    intent.putExtra("uri",
                                                            "https://helsedirektoratet.no/retningslinjer#k="
                                                                    + URLEncoder.encode(
                                                                            correctSearchString.toLowerCase(),
                                                                            "utf-8"));
                                                    startActivity(intent);
                                                } catch (Exception e) {
                                                    Log.e("NasjonaleRetningslinjer",
                                                            Log.getStackTraceString(e));
                                                }
                                            }

                                            @Override
                                            public void onNegative(MaterialDialog dialog) {
                                                saveRecentSearch(searchString);

                                                try {
                                                    Intent intent = new Intent(mContext,
                                                            MainWebViewActivity.class);
                                                    intent.putExtra("title",
                                                            getString(R.string.nasjonale_retningslinjer_search)
                                                                    + ": \"" + searchString + "\"");
                                                    intent.putExtra("uri",
                                                            "https://helsedirektoratet.no/retningslinjer#k="
                                                                    + URLEncoder.encode(
                                                                            searchString.toLowerCase(),
                                                                            "utf-8"));
                                                    startActivity(intent);
                                                } catch (Exception e) {
                                                    Log.e("NasjonaleRetningslinjer",
                                                            Log.getStackTraceString(e));
                                                }
                                            }
                                        }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue)
                                        .negativeColorRes(R.color.black).show();
                            }
                        } catch (Exception e) {
                            Log.e("NasjonaleRetningslinjer", Log.getStackTraceString(e));
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        mProgressBar.setVisibility(View.GONE);

                        Log.e("NasjonaleRetningslinjer", error.toString());
                    }
                });

        jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(10000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
                DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

        requestQueue.add(jsonObjectRequest);
    } catch (Exception e) {
        Log.e("NasjonaleRetningslinjer", Log.getStackTraceString(e));
    }
}

From source file:com.hichinaschool.flashcards.libanki.Utils.java

/**
 * Takes a string and replaces all the HTML symbols in it with their unescaped representation.
 * This should only affect substrings of the form &something; and not tags.
 * Internet rumour says that Html.fromHtml() doesn't cover all cases, but it doesn't get less
 * vague than that./*from w w w. j a v a2 s  .  c  o  m*/
 * @param html The HTML escaped text
 * @return The text with its HTML entities unescaped.
 */
private static String entsToTxt(String html) {
    // entitydefs defines nbsp as \xa0 instead of a standard space, so we
    // replace it first
    html = html.replace("&nbsp;", " ");
    Matcher htmlEntities = htmlEntitiesPattern.matcher(html);
    StringBuffer sb = new StringBuffer();
    while (htmlEntities.find()) {
        htmlEntities.appendReplacement(sb, Html.fromHtml(htmlEntities.group()).toString());
    }
    htmlEntities.appendTail(sb);
    return sb.toString();
}

From source file:com.hybris.mobile.activity.AbstractProductDetailActivity.java

/**
 * Refresh the UI with data from the product
 *///w w w . j  a  v a2s.  c  om
public void updateUI() {

    // Title
    this.setTitle(mProduct.getName());

    // Images
    if (mProduct.getGalleryImageURLs() != null) {
        GalleryAdapter adapter = new GalleryAdapter(this, mProduct.getGalleryImageURLs());
        Gallery gallery = (Gallery) findViewById(R.id.galleryImages);
        gallery.setAdapter(adapter);

        // Set the onClick listener for the gallery
        gallery.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) {
                viewImage(position);

            }
        });
    }

    // Reviews
    TextView reviewTextView = (TextView) findViewById(R.id.textViewReviews);
    reviewTextView.setText(this.getResources().getString(R.string.show_reviews, mProduct.getReviews().size()));

    // Rating (stars)
    RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBarRating);
    if (mProduct.getAverageRating() != null) {
        ratingBar.setRating(mProduct.getAverageRating().floatValue());
    }

    // Promotions
    TextView promotionsTextView = (TextView) findViewById(R.id.textViewPromotion);
    if (mProduct.getPotentialPromotions().size() == 0) {
        promotionsTextView.setVisibility(View.GONE);
    } else {
        if (mProduct.getPotentialPromotions() != null && !mProduct.getPotentialPromotions().isEmpty()) {
            promotionsTextView.setText(
                    Html.fromHtml(Product.generatePromotionString(mProduct.getPotentialPromotions().get(0))));
            StringUtil.removeUnderlines((Spannable) promotionsTextView.getText());
        }

    }

    TextView priceTextView = (TextView) findViewById(R.id.textViewPrice);
    priceTextView.setText(mProduct.getPrice().getFormattedValue());

    // Description
    TextView descriptionTextView = (TextView) findViewById(R.id.textViewDescription);
    descriptionTextView.setText(mProduct.getDescription());

    // Stock level
    TextView stockLevelTextView = (TextView) findViewById(R.id.textViewStockLevel);
    String stockLevelText = mProduct.getStockLevelText(Hybris.getAppContext());
    if (mProduct.getStock().getStockLevel() > 0) {
        stockLevelText = mProduct.getStock().getStockLevel() + " "
                + mProduct.getStockLevelText(Hybris.getAppContext()).toLowerCase();
    }
    stockLevelTextView.setText(stockLevelText);

    // Disable / Enable the add to cart button
    Button addToCartButton = (Button) findViewById(R.id.buttonAddToCart);

    Button quantityButton = (Button) findViewById(R.id.quantityButton);
    quantityButton.setText(getString(R.string.quantity_button, quantityToAddToCart));

    try {

        if (mProduct.getStock().getStockLevelStatus() != null
                && StringUtils.equalsIgnoreCase(mProduct.getStock().getStockLevelStatus().getCode(),
                        ProductStockLevelStatus.CODE_OUT_OF_STOCK)) {
            addToCartButton.setEnabled(false);
            quantityButton.setEnabled(false);
            quantityButton.setText(R.string.quantity);
        } else {
            addToCartButton.setEnabled(true);
            quantityButton.setEnabled(true);
        }
    } catch (Exception e) {
    }

    invalidateOptionsMenu();
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static TextView getTextView(Context context, LinearLayout.LayoutParams params, StringBuffer buffer) {
    TextView textView = new TextView(context);
    textView.setTextColor(Color.BLACK);
    textView.setLayoutParams(params);/*from   w  w  w .  j  av  a 2  s  . c  o m*/
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setTextSize(getTextSize(context));
    textView.setText(Html.fromHtml(buffer.toString()));
    return textView;
}

From source file:com.krayzk9s.imgurholo.tools.ImageUtils.java

public static void updateInfoFont(JSONParcelable imageData, TextView infoText) {
    try {/*from   www .  j a  va2 s  . com*/
        String albumText = "";
        if (imageData.getJSONObject().has("is_album") && imageData.getJSONObject().getBoolean("is_album"))
            albumText = "[album] ";
        if (!imageData.getJSONObject().getString("section").equals("null"))
            albumText += "/r/" + imageData.getJSONObject().getString("section") + " " + Html.fromHtml("&#8226;")
                    + " ";
        Calendar calendar = Calendar.getInstance();
        long now = calendar.getTimeInMillis();
        infoText.setText(albumText
                + DateUtils.getRelativeTimeSpanString(imageData.getJSONObject().getLong("datetime") * 1000, now,
                        DateUtils.MINUTE_IN_MILLIS)
                + " " + Html.fromHtml("&#8226;") + " ");
    } catch (JSONException e) {
        Log.e("Error!", e.toString());
    }
}

From source file:com.activiti.android.app.fragments.account.SignInFragment.java

private void connect() {
    UIUtils.hideKeyboard(getActivity(), mEmailView);

    session = new ActivitiSession.Builder().connect(endpoint.toString(), username, password).build();
    session.getServiceRegistry().getProfileService().getProfile(new Callback<UserRepresentation>() {
        @Override// w  w  w. j  a v a2  s  . c  o m
        public void onResponse(Call<UserRepresentation> call, Response<UserRepresentation> response) {
            if (response.isSuccessful()) {
                user = response.body();
                retrieveServerInfo();
            } else if (response.code() == 401) {
                mPasswordView.setError(getString(R.string.error_incorrect_password));
                View focusView = mPasswordView;
                UIUtils.showKeyboard(getActivity(), focusView);
            }

        }

        @Override
        public void onFailure(Call<UserRepresentation> call, Throwable error) {
            View focusView = null;

            showProgress(false);
            if (!ActivitiAPI.SERVER_URL_ENDPOINT.equals(endpoint.toString())) {
                show(R.id.server_form);
            }

            if (focusView == null) {
                int messageId = ExceptionMessageUtils.getSignInMessageId(getActivity(), error.getCause());
                if (messageId == R.string.error_session_creation) {
                    Snackbar.make(getActivity().findViewById(R.id.left_panel), error.getMessage(),
                            Snackbar.LENGTH_SHORT).show();
                } else {
                    // Revert to Alfresco WebApp
                    MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity())
                            .title(R.string.error_session_creation_title)
                            .cancelListener(new DialogInterface.OnCancelListener() {
                                @Override
                                public void onCancel(DialogInterface dialog) {
                                    dismiss();
                                }
                            }).content(Html.fromHtml(getString(messageId))).positiveText(R.string.ok);
                    builder.show();
                }
            }
        }
    });
}

From source file:ru.orangesoftware.financisto2.activity.FlowzrSyncActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FlowzrSyncActivity.me = this;
    mNotifyBuilder = new NotificationCompat.Builder(getApplicationContext());
    nm = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
    setContentView(R.layout.flowzr_sync);
    restoreUIFromPref();/*  w ww . j a  v  a 2  s  .c om*/
    if (useCredential != null) {

    }

    AccountManager accountManager = AccountManager.get(getApplicationContext());
    final Account[] accounts = accountManager.getAccountsByType("com.google");
    if (accounts.length < 1) {
        new AlertDialog.Builder(this).setTitle(getString(R.string.flowzr_sync_error))
                .setMessage(R.string.account_required)
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                }).show();
    }
    //radio crendentials
    RadioGroup radioGroupCredentials = (RadioGroup) findViewById(R.id.radioCredentials);
    OnClickListener radio_listener = new OnClickListener() {
        public void onClick(View v) {
            RadioButton radioButtonSelected = (RadioButton) findViewById(v.getId());
            for (Account account : accounts) {
                if (account.name == radioButtonSelected.getText()) {
                    useCredential = account;
                }
            }
        }
    };
    //initialize value
    for (int i = 0; i < accounts.length; i++) {
        RadioButton rb = new RadioButton(this);
        radioGroupCredentials.addView(rb); //, 0, lp); 
        rb.setOnClickListener(radio_listener);
        rb.setText(((Account) accounts[i]).name);
        if (useCredential != null) {
            if (accounts[i].name.equals(useCredential.name)) {
                rb.toggle(); //.setChecked(true);
            }
        }
    }

    bOk = (Button) findViewById(R.id.bOK);
    bOk.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {

            setRunning();
            initProgressDialog();
            //                if (useCredential!=null) {
            //                   flowzrBilling=new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString());  
            //                }               
            if (useCredential == null) {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_choose_account);
                notifyUser(getString(R.string.flowzr_choose_account), 100);
                setReady();
            } else if (!isOnline(FlowzrSyncActivity.this)) {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
                notifyUser(getString(R.string.flowzr_sync_error_no_network), 100);
                setReady();
            } else {
                saveOptionsFromUI();
                //Play Service Billing
                //FlowzrBilling flowzrBilling = new FlowzrBilling(FlowzrSyncActivity.this, getApplicationContext(), http_client, useCredential.toString());  
                //if (flowzrSyncTask.checkSubscription()) {
                flowzrSyncEngine = new FlowzrSyncEngine(FlowzrSyncActivity.this);
                //}

            }
        }
    });

    Button bCancel = (Button) findViewById(R.id.bCancel);
    bCancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            if (flowzrSyncEngine != null) {
                flowzrSyncEngine.isCanceled = true;
            }
            isRunning = false;
            setResult(RESULT_CANCELED);
            setReady();
            startActivity(new Intent(getApplicationContext(), MainActivity.class));
            //finish();
        }
    });

    Button textViewAbout = (Button) findViewById(R.id.buySubscription);
    textViewAbout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(useCredential);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    Button textViewAboutAnon = (Button) findViewById(R.id.visitFlowzr);
    textViewAboutAnon.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (isOnline(FlowzrSyncActivity.this)) {
                visitFlowzr(null);
            } else {
                showErrorPopup(FlowzrSyncActivity.this, R.string.flowzr_sync_error_no_network);
            }
        }
    });

    TextView textViewNotes = (TextView) findViewById(R.id.flowzrPleaseNote);
    textViewNotes.setMovementMethod(LinkMovementMethod.getInstance());
    textViewNotes.setText(Html.fromHtml(getString(R.string.flowzr_terms_of_use)));
    if (MyPreferences.isAutoSync(this)) {
        if (checkPlayServices()) {
            gcm = GoogleCloudMessaging.getInstance(this);
            regid = getRegistrationId(getApplicationContext());

            if (regid.equals("")) {
                registerInBackground();
            }
            Log.i(TAG, "Google Cloud Messaging registered as :" + regid);
        } else {
            Log.i(TAG, "No valid Google Play Services APK found.");
        }
    }
}

From source file:com.dwdesign.tweetings.fragment.StatusFragment.java

@SuppressWarnings("deprecation")
public void displayStatus(final ParcelableStatus status) {
    mStatus = null;//  w  w w  .ja  va2 s.c o  m
    mImagesPreviewFragment.clear();
    if (status == null || getActivity() == null)
        return;
    mStatus = status;

    final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null);

    mMenuBar.inflate(R.menu.menu_status);

    final MenuItem bufferView = mMenuBar.getMenu().findItem(MENU_ADD_TO_BUFFER);
    if (bufferView != null) {
        if (buffer_authorised != null && !buffer_authorised.equals("")) {
            bufferView.setVisible(true);
        } else {
            bufferView.setVisible(false);
        }
    }
    setMenuForStatus(getActivity(), mMenuBar.getMenu(), status);
    mMenuBar.show();

    final boolean is_multiple_account_enabled = getActivatedAccountIds(getActivity()).length > 1;

    updateUserColor();

    mContentScroller
            .setBackgroundResource(is_multiple_account_enabled ? R.drawable.ic_label_account_nopadding : 0);
    if (is_multiple_account_enabled) {
        final Drawable d = mContentScroller.getBackground();
        if (d != null) {
            d.mutate().setColorFilter(getAccountColor(getActivity(), status.account_id),
                    PorterDuff.Mode.MULTIPLY);
            mContentScroller.invalidate();
        }
    }

    mNameView.setText(status.name);
    mScreenNameView.setText("@" + status.screen_name);
    mScreenNameView.setCompoundDrawablesWithIntrinsicBounds(
            getUserTypeIconRes(status.is_verified, status.is_protected), 0, 0, 0);
    mTextView.setText(status.text);

    final TwidereLinkify linkify = new TwidereLinkify(mTextView);
    linkify.setOnLinkClickListener(new OnLinkClickHandler(getActivity(), mAccountId));
    linkify.addAllLinks();
    final boolean is_reply = status.in_reply_to_status_id > 0;
    final String time = formatToLongTimeString(getActivity(), status.status_timestamp);
    final String strTime = "<a href=\"https://twitter.com/" + status.screen_name + "/status/"
            + String.valueOf(status.status_id) + "\">" + time + "</a>";
    final String source_html = status.source;
    if (!isNullOrEmpty(time) && !isNullOrEmpty(source_html)) {
        mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.time_source, strTime, source_html)));
    } else if (isNullOrEmpty(time) && !isNullOrEmpty(source_html)) {
        mTimeAndSourceView.setText(Html.fromHtml(getString(R.string.source, source_html)));
    } else if (!isNullOrEmpty(time) && isNullOrEmpty(source_html)) {
        mTimeAndSourceView.setText(time);
    }
    mTimeAndSourceView.setMovementMethod(LinkMovementMethod.getInstance());
    mInReplyToView.setVisibility(is_reply ? View.VISIBLE : View.GONE);
    mConversationView.setVisibility(is_reply ? View.VISIBLE : View.GONE);
    if (is_reply) {
        mInReplyToView.setText(getString(R.string.in_reply_to, status.in_reply_to_screen_name));

        Display display = getActivity().getWindowManager().getDefaultDisplay();
        int width = display.getWidth(); // deprecated
        int height = display.getHeight(); // deprecated

        int heightOfConversation = (height / 2) - 48 - 44;
        ViewGroup.LayoutParams params = mConversationView.getLayoutParams();
        params.height = heightOfConversation;
        mConversationView.setLayoutParams(params);

        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction ft = null;

        ft = fragmentManager.beginTransaction();

        final Fragment fragment = new ConversationFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, mAccountId);
        args.putLong(INTENT_KEY_STATUS_ID, status.in_reply_to_status_id);
        fragment.setArguments(args);

        ft.replace(R.id.conversation, fragment, getString(R.string.view_conversation));

        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commit();

    }
    if (status.play_package != null) {
        mMarketView.setVisibility(View.VISIBLE);
        mPlayInfoTask = new PlayStoreInfoTask();
        mPlayInfoTask.execute();
    } else {
        mMarketView.setVisibility(View.GONE);
    }

    final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image);
    final String preview_image = hires_profile_image
            ? getBiggerTwitterProfileImage(status.profile_image_url_string)
            : status.profile_image_url_string;
    mLazyImageLoader.displayProfileImage(mProfileImageView, preview_image);
    final List<ImageSpec> images = getImagesInStatus(status.text_html);
    mImagesPreviewContainer.setVisibility(images.size() > 0 ? View.VISIBLE : View.GONE);
    mImagesPreviewFragment.addAll(images);
    mImagesPreviewFragment.update();
    if (mLoadMoreAutomatically == true) {
        mImagesPreviewFragment.show();
    }
    mRetweetedStatusView.setVisibility(status.is_protected ? View.GONE : View.VISIBLE);
    if (status.retweet_id > 0) {
        final boolean display_name = mPreferences.getBoolean(PREFERENCE_KEY_DISPLAY_NAME, false);
        final String retweeted_by = display_name ? status.retweeted_by_name : status.retweeted_by_screen_name;
        mRetweetedStatusView.setText(status.retweet_count > 1
                ? getString(R.string.retweeted_by_with_count, retweeted_by, status.retweet_count - 1)
                : getString(R.string.retweeted_by, retweeted_by));
        mRetweetedStatusView.setVisibility(View.VISIBLE);
    } else {
        mRetweetedStatusView.setVisibility(View.GONE);
        mRetweetedStatusView.setText(R.string.users_retweeted_this);
    }
    mLocationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE);

    if (mLoadMoreAutomatically) {
        showFollowInfo(true);
        showLocationInfo(true);
    } else {
        mFollowIndicator.setVisibility(View.GONE);
    }
}

From source file:com.cssn.samplesdk.ShowDataActivity.java

/**
 * //from w  ww . j a v a 2s.  c o m
 */
private void setResultsForMedicalCard() {
    MedicalCard processedMedicalCard = DataContext.getInstance().getProcessedMedicalCard();

    StringBuilder info = new StringBuilder();

    // First Name
    info.append(("First Name").concat(" - ")).append(processedMedicalCard.getFirstName()).append("<br/>");
    // Last Name
    info.append(("Last Name").concat(" - ")).append(processedMedicalCard.getLastName()).append("<br/>");
    // MemberID
    info.append(("MemberID").concat(" - ")).append(processedMedicalCard.getMemberId()).append("<br/>");
    // Group No
    info.append(("Group No.").concat(" - ")).append(processedMedicalCard.getGroupNumber()).append("<br/>");
    // Copay ER
    info.append(("Copay ER").concat(" - ")).append(processedMedicalCard.getCopayEr()).append("<br/>");
    // Copay OV
    info.append(("Copay OV").concat(" - ")).append(processedMedicalCard.getCopayOv()).append("<br/>");
    // Copay SP
    info.append(("Copay SP").concat(" - ")).append(processedMedicalCard.getCopaySp()).append("<br/>");
    // Copay UC
    info.append(("Copay UC").concat(" - ")).append(processedMedicalCard.getCopayUc()).append("<br/>");
    // Coverage
    info.append(("Coverage").concat(" - ")).append(processedMedicalCard.getCoverage()).append("<br/>");
    // Date of Birth
    info.append(("Date of Birth").concat(" - ")).append(processedMedicalCard.getDateOfBirth()).append("<br/>");
    // Deductible
    info.append(("Deductible").concat(" - ")).append(processedMedicalCard.getDeductible()).append("<br/>");
    // Effective Date
    info.append(("Effective Date").concat(" - ")).append(processedMedicalCard.getEffectiveDate())
            .append("<br/>");
    // Employer
    info.append(("Employer").concat(" - ")).append(processedMedicalCard.getEmployer()).append("<br/>");
    // Expire Date
    info.append(("Expire Date").concat(" - ")).append(processedMedicalCard.getExpirationDate()).append("<br/>");
    // Group Name
    info.append(("Group Name").concat(" - ")).append(processedMedicalCard.getGroupName()).append("<br/>");
    // Issuer Number
    info.append(("Issuer Number").concat(" - ")).append(processedMedicalCard.getIssuerNumber()).append("<br/>");
    // Other
    info.append(("Other").concat(" - ")).append(processedMedicalCard.getOther()).append("<br/>");
    // Payer ID
    info.append(("Payer ID").concat(" - ")).append(processedMedicalCard.getPayerId()).append("<br/>");
    // Plan Admin
    info.append(("Plan Admin").concat(" - ")).append(processedMedicalCard.getPlanAdmin()).append("<br/>");
    // Plan Provider
    info.append(("Plan Provider").concat(" - ")).append(processedMedicalCard.getPlanProvider()).append("<br/>");
    // Plan Type
    info.append(("Plan Type").concat(" - ")).append(processedMedicalCard.getPlanType()).append("<br/>");
    // RX Bin
    info.append(("RX Bin").concat(" - ")).append(processedMedicalCard.getRxBin()).append("<br/>");
    // RX Group
    info.append(("RX Group").concat(" - ")).append(processedMedicalCard.getRxGroup()).append("<br/>");
    // RX ID
    info.append(("RX ID").concat(" - ")).append(processedMedicalCard.getRxId()).append("<br/>");
    // RX PCN
    info.append(("RX PCN").concat(" - ")).append(processedMedicalCard.getRxPcn()).append("<br/>");
    // Telephone
    info.append(("Telephone").concat(" - ")).append(processedMedicalCard.getPhoneNumber()).append("<br/>");
    // Web
    info.append(("Web").concat(" - ")).append(processedMedicalCard.getWebAddress()).append("<br/>");
    // Email
    info.append(("Email").concat(" - ")).append(processedMedicalCard.getEmail()).append("<br/>");
    // Address
    info.append(("Address").concat(" - ")).append(processedMedicalCard.getFullAddress()).append("<br/>");
    // City
    info.append(("City").concat(" - ")).append(processedMedicalCard.getCity()).append("<br/>");
    // Zip
    info.append(("Zip").concat(" - ")).append(processedMedicalCard.getZip()).append("<br/>");
    // State
    info.append(("State").concat(" - ")).append(processedMedicalCard.getState()).append("<br/>");

    textViewCardInfo.setText(Html.fromHtml(info.toString()));

    frontSideCardImageView.setImageBitmap(Util
            .getRoundedCornerBitmap(processedMedicalCard.getReformattedImage(), this.getApplicationContext()));

    if (processedMedicalCard.getReformattedImageTwo() != null) {
        backSideCardImageView.setVisibility(View.VISIBLE);
        backSideCardImageView.setImageBitmap(Util.getRoundedCornerBitmap(
                processedMedicalCard.getReformattedImageTwo(), this.getApplicationContext()));
    }
}

From source file:com.mercandalli.android.apps.files.file.cloud.FileMyCloudFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_file_files, container, false);
    final Activity activity = getActivity();
    final String succeed = "succeed";

    mProgressBar = (ProgressBar) rootView.findViewById(R.id.circularProgressBar);
    mMessageTextView = (TextView) rootView.findViewById(R.id.message);

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView
            .findViewById(R.id.fragment_file_files_swipe_refresh_layout);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light, android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.fragment_file_files_recycler_view);
    mRecyclerView.setHasFixedSize(true);

    final int nbColumn = getResources().getInteger(R.integer.column_number_card);
    if (nbColumn <= 1) {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
    } else {//from  w  w w.j a v a 2 s  .co m
        mRecyclerView.setLayoutManager(new GridLayoutManager(activity, nbColumn));
    }

    resetPath();

    mFileModelAdapter = new FileModelAdapter(getContext(), mFilesList, new FileModelListener() {
        @Override
        public void executeFileModel(final FileModel fileModel, final View view) {
            final AlertDialog.Builder menuAlert = new AlertDialog.Builder(getContext());
            String[] menuList = { getString(R.string.download), getString(R.string.rename),
                    getString(R.string.delete), getString(R.string.cut), getString(R.string.properties) };
            if (!fileModel.isDirectory()) {
                if (FileTypeModelENUM.IMAGE.type.equals(fileModel.getType())) {
                    menuList = new String[] { getString(R.string.download), getString(R.string.rename),
                            getString(R.string.delete), getString(R.string.cut), getString(R.string.properties),
                            (fileModel.isPublic()) ? "Become private" : "Become public", "Set as profile" };
                } else if (FileTypeModelENUM.APK.type.equals(fileModel.getType()) && Config.isUserAdmin()) {
                    menuList = new String[] { getString(R.string.download), getString(R.string.rename),
                            getString(R.string.delete), getString(R.string.cut), getString(R.string.properties),
                            (fileModel.isPublic()) ? "Become private" : "Become public",
                            (fileModel.isApkUpdate()) ? "Remove the update" : "Set as update" };
                } else {
                    menuList = new String[] { getString(R.string.download), getString(R.string.rename),
                            getString(R.string.delete), getString(R.string.cut), getString(R.string.properties),
                            (fileModel.isPublic()) ? "Become private" : "Become public" };
                }
            }
            menuAlert.setTitle(getString(R.string.action));
            menuAlert.setItems(menuList, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    switch (item) {
                    case 0:
                        mFileManager.download(getActivity(), fileModel, new IListener() {
                            @Override
                            public void execute() {
                                Toast.makeText(getContext(), "Download finished.", Toast.LENGTH_SHORT).show();
                            }
                        });
                        break;

                    case 1:
                        DialogUtils.prompt(getActivity(), "Rename",
                                "Rename " + (fileModel.isDirectory() ? "directory" : "file") + " "
                                        + fileModel.getName() + " ?",
                                "Ok", new DialogUtils.OnDialogUtilsStringListener() {
                                    @Override
                                    public void onDialogUtilsStringCalledBack(String text) {
                                        mFileManager.rename(fileModel, text, new IListener() {
                                            @Override
                                            public void execute() {
                                                if (mFilesToCutList.size() != 0) {
                                                    mFilesToCutList.clear();
                                                    mFileCloudFabManager.updateFabButtons();
                                                }
                                                refreshCurrentList();
                                            }
                                        });
                                    }
                                }, "Cancel", null, fileModel.getFullName());
                        break;

                    case 2:
                        DialogUtils.alert(getActivity(), "Delete",
                                "Delete " + (fileModel.isDirectory() ? "directory" : "file") + " "
                                        + fileModel.getName() + " ?",
                                "Yes", new DialogUtils.OnDialogUtilsListener() {
                                    @Override
                                    public void onDialogUtilsCalledBack() {
                                        mFileManager.delete(fileModel, new IListener() {
                                            @Override
                                            public void execute() {
                                                if (mFilesToCutList.size() != 0) {
                                                    mFilesToCutList.clear();
                                                    mFileCloudFabManager.updateFabButtons();
                                                }
                                                refreshCurrentList();
                                            }
                                        });
                                    }
                                }, "No", null);
                        break;

                    case 3:
                        mFilesToCutList.add(fileModel);
                        Toast.makeText(getContext(), "File ready to cut.", Toast.LENGTH_SHORT).show();
                        mFileCloudFabManager.updateFabButtons();
                        break;

                    case 4:
                        DialogUtils.alert(getActivity(),
                                getString(R.string.properties) + " : " + fileModel.getName(),
                                mFileManager.toSpanned(getContext(), fileModel), "OK", null, null, null);

                        Html.fromHtml("");

                        break;

                    case 5:
                        mFileManager.setPublic(fileModel, !fileModel.isPublic(), new IListener() {
                            @Override
                            public void execute() {
                            }
                        });
                        break;

                    case 6:
                        // Picture set as profile
                        if (FileTypeModelENUM.IMAGE.type.equals(fileModel.getType())) {
                            List<StringPair> parameters = new ArrayList<>();
                            parameters.add(new StringPair("id_file_profile_picture", "" + fileModel.getId()));
                            (new TaskPost(getActivity(), Constants.URL_DOMAIN + Config.ROUTE_USER_PUT,
                                    new IPostExecuteListener() {
                                        @Override
                                        public void onPostExecute(JSONObject json, String body) {
                                            try {
                                                if (json != null && json.has(succeed)
                                                        && json.getBoolean(succeed)) {
                                                    Config.setUserIdFileProfilePicture(getActivity(),
                                                            fileModel.getId());
                                                }
                                            } catch (JSONException e) {
                                                Log.e(getClass().getName(), "Failed to convert Json", e);
                                            }
                                        }
                                    }, parameters)).execute();
                        } else if (FileTypeModelENUM.APK.type.equals(fileModel.getType())
                                && Config.isUserAdmin()) {
                            List<StringPair> parameters = new ArrayList<>();
                            parameters.add(new StringPair("is_apk_update", "" + !fileModel.isApkUpdate()));
                            (new TaskPost(getActivity(),
                                    Constants.URL_DOMAIN + Config.ROUTE_FILE + "/" + fileModel.getId(),
                                    new IPostExecuteListener() {
                                        @Override
                                        public void onPostExecute(JSONObject json, String body) {
                                            try {
                                                if (json != null && json.has(succeed)
                                                        && json.getBoolean(succeed)) {

                                                }
                                            } catch (JSONException e) {
                                                Log.e(getClass().getName(), "Failed to convert Json", e);
                                            }
                                        }
                                    }, parameters)).execute();
                        }
                        break;

                    }
                }
            });
            AlertDialog menuDrop = menuAlert.create();
            menuDrop.show();
        }
    }, new FileModelAdapter.OnFileClickListener() {
        @Override
        public void onFileClick(View view, int position) {
            /*
            if (hasItemSelected()) {
            mFilesList.get(position).selected = !mFilesList.get(position).selected;
            mFileModelAdapter.notifyItemChanged(position);
            }
            else
            */
            if (mFilesList.get(position).isDirectory()) {
                mIdFileDirectoryStack.add(mFilesList.get(position).getId());
                refreshCurrentList(true);
            } else {
                mFileManager.execute(getActivity(), position, mFilesList, view);
            }
        }
    }, new FileModelAdapter.OnFileLongClickListener() {
        @Override
        public boolean onFileLongClick(View view, int position) {
            /*
            mFilesList.get(position).selected = !mFilesList.get(position).selected;
            mFileModelAdapter.notifyItemChanged(position);
            */
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        scaleAnimationAdapter = new ScaleAnimationAdapter(mRecyclerView, mFileModelAdapter);
        scaleAnimationAdapter.setDuration(220);
        scaleAnimationAdapter.setOffsetDuration(32);
        mRecyclerView.setAdapter(scaleAnimationAdapter);
    } else {
        mRecyclerView.setAdapter(mFileModelAdapter);
    }

    refreshCurrentList(true);

    return rootView;
}