Example usage for android.text.method LinkMovementMethod getInstance

List of usage examples for android.text.method LinkMovementMethod getInstance

Introduction

In this page you can find the example usage for android.text.method LinkMovementMethod getInstance.

Prototype

public static MovementMethod getInstance() 

Source Link

Usage

From source file:com.amaze.filemanager.fragments.preference_fragments.Preffrag.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PreferenceUtils.reset();//  w  w w.  j ava2s  .c o m
    // Load the preferences from an XML resource
    addPreferencesFromResource(R.xml.preferences);

    sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());

    final int th1 = Integer.parseInt(sharedPref.getString("theme", "0"));
    theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1;
    findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).donate();
            return false;
        }
    });
    findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            final String[] sort = getResources().getStringArray(R.array.columns);
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.gridcolumnno);
            int current = Integer.parseInt(sharedPref.getString("columns", "-1"));
            current = current == -1 ? 0 : current;
            if (current != 0)
                current = current - 1;
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit();
                    dialog.dismiss();
                    return true;
                }
            });
            a.build().show();
            return true;
        }
    });

    findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            String[] sort = getResources().getStringArray(R.array.theme);
            int current = Integer.parseInt(sharedPref.getString("theme", "0"));
            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
                    sharedPref.edit().putString("theme", "" + which).commit();
                    dialog.dismiss();
                    restartPC(getActivity());
                    return true;
                }
            });
            a.title(R.string.theme);
            a.build().show();
            return true;
        }
    });
    findPreference("colors").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            ((com.amaze.filemanager.activities.Preferences) getActivity()).selectItem(1);
            return true;
        }
    });

    final CheckBx rootmode = (CheckBx) findPreference("rootmode");
    rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            boolean b = sharedPref.getBoolean("rootmode", false);
            if (b) {
                if (RootTools.isAccessGiven()) {
                    rootmode.setChecked(true);

                } else {
                    rootmode.setChecked(false);

                    Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                rootmode.setChecked(false);

            }

            return false;
        }
    });

    // Authors
    Preference preference4 = (Preference) findPreference("authors");
    preference4.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            skin = PreferenceUtils.getPrimaryColorString(sharedPref);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            if (theme == 1)
                a.theme(Theme.DARK);

            a.positiveText(R.string.close);
            a.positiveColor(fab_skin);
            LayoutInflater layoutInflater = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.authors, null);
            a.customView(view, true);
            a.title(R.string.authors);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                }
            });
            /*a.setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.cancel();
            }
            });*/
            a.build().show();

            final Intent intent = new Intent(Intent.ACTION_VIEW);

            TextView googlePlus1 = (TextView) view.findViewById(R.id.googlePlus1);
            googlePlus1.setTextColor(Color.parseColor(skin));
            TextView googlePlus2 = (TextView) view.findViewById(R.id.googlePlus2);
            googlePlus2.setTextColor(Color.parseColor(skin));
            TextView git1 = (TextView) view.findViewById(R.id.git1);
            git1.setTextColor(Color.parseColor(skin));
            TextView git2 = (TextView) view.findViewById(R.id.git2);
            git2.setTextColor(Color.parseColor(skin));

            googlePlus1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/u/0/110424067388738907251/"));
                    startActivity(intent);
                }
            });
            googlePlus2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://plus.google.com/+VishalNehra/"));
                    startActivity(intent);
                }
            });
            git1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/arpitkh96"));
                    startActivity(intent);
                }
            });
            git2.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    intent.setData(Uri.parse("https://github.com/vishal0071"));
                    startActivity(intent);
                }
            });

            // icon credits
            TextView textView = (TextView) view.findViewById(R.id.icon_credits);
            textView.setMovementMethod(LinkMovementMethod.getInstance());
            textView.setLinksClickable(true);
            textView.setText(Html.fromHtml(getActivity().getString(R.string.icon_credits)));

            return false;
        }
    });

    // Changelog
    Preference preference1 = (Preference) findPreference("changelog");
    preference1.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {

            MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity());
            if (theme == 1)
                a.theme(Theme.DARK);
            a.title(R.string.changelog);
            a.content(Html.fromHtml(getActivity().getString(R.string.changelog_version_9)
                    + getActivity().getString(R.string.changelog_change_9)
                    + getActivity().getString(R.string.changelog_version_8)
                    + getActivity().getString(R.string.changelog_change_8)
                    + getActivity().getString(R.string.changelog_version_7)
                    + getActivity().getString(R.string.changelog_change_7)
                    + getActivity().getString(R.string.changelog_version_6)
                    + getActivity().getString(R.string.changelog_change_6)
                    + getActivity().getString(R.string.changelog_version_5)
                    + getActivity().getString(R.string.changelog_change_5)
                    + getActivity().getString(R.string.changelog_version_4)
                    + getActivity().getString(R.string.changelog_change_4)
                    + getActivity().getString(R.string.changelog_version_3)
                    + getActivity().getString(R.string.changelog_change_3)
                    + getActivity().getString(R.string.changelog_version_2)
                    + getActivity().getString(R.string.changelog_change_2)
                    + getActivity().getString(R.string.changelog_version_1)
                    + getActivity().getString(R.string.changelog_change_1)));
            a.negativeText(R.string.close);
            a.positiveText(R.string.fullChangelog);
            int fab_skin = Color.parseColor(PreferenceUtils.getAccentString(sharedPref));
            a.positiveColor(fab_skin);
            a.negativeColor(fab_skin);
            a.callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog materialDialog) {

                    Intent intent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("https://github.com/arpitkh96/AmazeFileManager/commits/master"));
                    startActivity(intent);
                }

                @Override
                public void onNegative(MaterialDialog materialDialog) {

                    materialDialog.cancel();
                }
            }).build().show();
            return false;
        }
    });

    // Open Source Licenses
    Preference preference2 = (Preference) findPreference("os");
    //Defining dialog layout
    final Dialog dialog = new Dialog(getActivity(),
            android.R.style.Theme_Holo_Light_DialogWhenLarge_NoActionBar);
    //dialog.setTitle("Open-Source Licenses");
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    final View dialog_view = inflater.inflate(R.layout.open_source_licenses, null);
    dialog.setContentView(dialog_view);

    preference2.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference arg0) {

            WebView wv = (WebView) dialog_view.findViewById(R.id.webView1);
            PreferenceUtils preferenceUtils = new PreferenceUtils();
            wv.loadData(PreferenceUtils.LICENCE_TERMS, "text/html", null);
            dialog.show();
            return false;
        }
    });

    // Feedback
    Preference preference3 = (Preference) findPreference("feedback");
    preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
                    Uri.fromParts("mailto", "arpitkh96@gmail.com", null));
            emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : Amaze File Manager");
            Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show();
            File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt");
            if (f.exists()) {
                emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
            }
            startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback)));
            return false;
        }
    });

    // rate
    Preference preference5 = (Preference) findPreference("rate");
    preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            Intent intent1 = new Intent(Intent.ACTION_VIEW);
            intent1.setData(Uri.parse("market://details?id=com.amaze.filemanager"));
            startActivity(intent1);
            return false;
        }
    });

    // studio
    Preference studio = findPreference("studio");
    studio.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            COUNT++;
            if (COUNT >= 5) {
                if (toast != null)
                    toast.cancel();
                toast = Toast.makeText(getActivity(), "Studio Mode : " + COUNT, Toast.LENGTH_SHORT);
                toast.show();

                sharedPref.edit().putInt("studio", Integer.parseInt(Integer.toString(COUNT) + "000")).apply();
            } else {
                sharedPref.edit().putInt("studio", 0).apply();
            }
            return false;
        }
    });

    // G+
    gplus = (CheckBx) findPreference("plus_pic");
    gplus.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (gplus.isChecked()) {
                boolean b = checkGplusPermission();
                if (!b)
                    requestGplusPermission();
            }
            return false;
        }
    });
    if (BuildConfig.IS_VERSION_FDROID)
        gplus.setEnabled(false);

    // Colored navigation bar
}

From source file:im.ene.lab.attiq.ui.activities.ItemDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_detail);
    ButterKnife.bind(this);
    setSupportActionBar(mToolbar);// www  .  j  av  a2  s  .c o m

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    mSlidingPanel.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
    SlidingUpPanelLayout.LayoutParams lp = ((SlidingUpPanelLayout.LayoutParams) mCommentComposerContainer
            .getLayoutParams());
    if (lp != null) {
        lp.topMargin += UIUtil.getStatusBarHeight(ItemDetailActivity.this) + mToolbar.getMinimumHeight();
        mCommentComposerContainer.setLayoutParams(lp);
    }

    mSlidingPanel.setScrollableViewHelper(new NestedScrollableViewHelper());
    mSlidingPanel.setPanelSlideListener(new PanelSlideListenerAdapter() {
        @Override
        public void onPanelCollapsed(View panel) {
            ImeUtil.hideIme(panel);
        }

        @Override
        public void onPanelAnchored(View panel) {
            ImeUtil.hideIme(panel);
        }

        @Override
        public void onPanelHidden(View panel) {
            ImeUtil.hideIme(panel);
        }
    });

    mCommentComposer.addOnPageChangeListener(mCommentComposerPageChange);
    mComposerTabs.setupWithViewPager(mCommentComposer);

    // empty title at start
    setTitle("");

    trySetupMenuDrawerLayout();
    trySetupContentView();
    trySetupCommentView();

    mAppBarLayout.addOnOffsetChangedListener(mOffsetChangedListener);

    mArticleDescription.setClickable(true);
    mArticleDescription.setMovementMethod(LinkMovementMethod.getInstance());
    // dynamically update padding
    mArticleName.setPadding(mArticleName.getPaddingLeft(),
            mArticleName.getPaddingTop() + UIUtil.getStatusBarHeight(this), mArticleName.getPaddingRight(),
            mArticleName.getPaddingBottom());

    TypedValue typedValue = new TypedValue();
    mToolbar.getContext().getTheme().resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
    int titleColorId = typedValue.resourceId;
    mTitleColorSpan = new AlphaForegroundColorSpan(ContextCompat.getColor(this, titleColorId));

    typedValue = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);
    mCommentThreadColor = ContextCompat.getColor(this, typedValue.resourceId);

    Uri data = getIntent().getData();
    if (data != null) {
        List<String> paths = data.getPathSegments();
        if (!UIUtil.isEmpty(paths)) {
            Iterator<String> iterator = paths.iterator();
            while (iterator.hasNext()) {
                if ("items".equals(iterator.next())) {
                    mItemUuid = iterator.next();
                    break;
                }
            }
        }
    }

    Article article = mRealm.where(Article.class).equalTo("id", mItemUuid).findFirst();
    if (article != null) {
        EventBus.getDefault().post(new ItemDetailEvent(getClass().getSimpleName(), true, null, article));
    }

    ApiClient.isStocked(mItemUuid).enqueue(mStockStatusResponse);
}

From source file:com.brq.wallet.activity.modern.ModernMain.java

private void checkGapBug() {
    final WalletManager walletManager = _mbwManager.getWalletManager(false);
    final List<Integer> gaps = walletManager.getGapsBug();
    if (!gaps.isEmpty()) {
        try {//  www. j av a 2 s  .c om
            final List<Address> gapAddresses = walletManager.getGapAddresses(AesKeyCipher.defaultKeyCipher());
            final String gapsString = Joiner.on(", ").join(gapAddresses);
            Log.d("Gaps", gapsString);

            final SpannableString s = new SpannableString(
                    "Sorry to interrupt you... \n \nWe discovered a bug in the account logic that will make problems if you someday need to restore from your 12 word backup.\n\nFor further information see here: https://wallet.mycelium.com/info/gaps \n\nMay we try to resolve it for you? Press OK, to share one address per affected account with us.");
            Linkify.addLinks(s, Linkify.ALL);

            final AlertDialog d = new AlertDialog.Builder(this).setTitle("Account Gap").setMessage(s)

                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            createPlaceHolderAccounts(gaps);
                            _mbwManager.reportIgnoredException(
                                    new RuntimeException("Address gaps: " + gapsString));
                        }
                    }).setNegativeButton("Ignore", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    }).show();

            // Make the textview clickable. Must be called after show()
            ((TextView) d.findViewById(android.R.id.message))
                    .setMovementMethod(LinkMovementMethod.getInstance());

        } catch (KeyCipher.InvalidKeyCipher invalidKeyCipher) {
            throw new RuntimeException(invalidKeyCipher);
        }
    }
}

From source file:com.anton.gavel.GavelMain.java

public void createDialog(int id) {
    if (progressDialog != null) {
        progressDialog.dismiss();//  w w  w. j  a  va2  s.co  m
    }
    // handles creation of any dialogs by other actions
    switch (id) {
    case DIALOG_PI:
        //call custom dialog for collecting Personal Info
        PersonalInfoDialogFragment personalInfoDialog = new PersonalInfoDialogFragment();
        personalInfoDialog.setPersonalInfo(mPersonalInfo);
        personalInfoDialog.show(getSupportFragmentManager(), "PersonalInfoDialogFragment");
        break;
    case DIALOG_ABOUT:
        //construct a simple dialog to show text

        //get about text
        TextView aboutView = new TextView(this);
        aboutView.setText(R.string.about_text);
        aboutView.setMovementMethod(LinkMovementMethod.getInstance());//enable links
        aboutView.setPadding(50, 30, 50, 30);

        //build dialog
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
        alertDialog.setTitle("About")//title
                .setView(aboutView)//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).create() //build
                .show(); //display
        break;

    case DIALOG_SUBMISSION_ERR:
        AlertDialog.Builder submissionErrorDialog = new AlertDialog.Builder(this);
        submissionErrorDialog.setTitle("Submission Error")//title
                .setMessage("There was a problem submitting your complaint on the City's website.")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;

    case DIALOG_OTHER_COMPLAINT:
        final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        final EditText input = new EditText(this);
        input.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_CLASS_TEXT);
        // capitalize letters + seperate words
        AlertDialog.Builder getComplaintDialog = new AlertDialog.Builder(this);
        getComplaintDialog.setTitle("Other...").setView(input)
                .setMessage("Give a categorical title for your complaint:")
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        String value = input.getText().toString();
                        // add the item to list and make it selected
                        complaintsAdapter.insert(value, 0);
                        complaintSpinner.setSelection(0);
                        complaintsAdapter.notifyDataSetChanged();
                        addToSubmitValues(value);

                        imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard   
                        dialog.cancel();

                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        imm.toggleSoftInput(InputMethodManager.RESULT_HIDDEN, 0);//hide keyboard              
                        dialog.cancel();
                    }
                }).create();

        input.requestFocus();
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);// show keyboard

        getComplaintDialog.show();//show dialog
        break;
    case DIALOG_NO_GEOCODING:
        AlertDialog.Builder noGeoCoding = new AlertDialog.Builder(this);
        noGeoCoding.setTitle("Not Available")//title
                .setMessage(
                        "Your version of Android does not support location-based address lookup. This feature is only supported on Gingerbread and above.")//insert textview from above
                .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;
    case DIALOG_INCOMPLETE_PERSONAL_INFORMATION:
        AlertDialog.Builder incompleteInfo = new AlertDialog.Builder(this);
        incompleteInfo.setTitle("Incomplete")//title
                .setMessage(
                        "Your personal information is incomplete. Select 'Edit Personal Information' from the menu and fill in all required fields")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display         
        break;
    case DIALOG_NO_COMPLAINT:
        AlertDialog.Builder noComplaint = new AlertDialog.Builder(this);
        noComplaint.setTitle("No Comlaint Specified")//title
                .setMessage("You must specify a complaint (e.g. barking dog).")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display
        break;
    case DIALOG_NO_LOCATION:
        AlertDialog.Builder incompleteComplaint = new AlertDialog.Builder(this);
        incompleteComplaint.setTitle("No Location Specified")//title
                .setMessage("You must specify a location (approximate street address) of the complaint.")//insert textview from above
                .setPositiveButton("Done", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                }).setIcon(R.drawable.ic_launcher).show(); //display         
    }

}

From source file:com.retroteam.studio.retrostudio.MainActivity.java

/**
 * Show app information in a popup./*from  w w w .ja  v  a 2  s  .co  m*/
 */

private void showAbout() {
    AlertDialog.Builder about = new AlertDialog.Builder(this);
    about.setTitle("About").setIcon(R.mipmap.ic_launcher)
            .setMessage(Html.fromHtml(getString(R.string.about_us_html))).setCancelable(false)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    AlertDialog aboutpop = about.create();
    aboutpop.show();
    // make links clickable
    ((TextView) aboutpop.findViewById(android.R.id.message))
            .setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.deliciousdroid.fragment.ViewBookmarkFragment.java

public void loadBookmark() {
    if (bookmark != null) {

        if (isMyself() && bookmark.getId() != 0) {
            try {
                int id = bookmark.getId();
                bookmark = BookmarkManager.GetById(id, base);
            } catch (ContentNotFoundException e) {
            }//from w  ww  . ja  v  a2s .  co m
        }

        if (viewType == BookmarkViewType.VIEW) {
            mBookmarkView.setVisibility(View.VISIBLE);
            readSection.setVisibility(View.GONE);
            mWebContent.setVisibility(View.GONE);
            if (isMyself()) {
                Date d = new Date(bookmark.getTime());

                mTitle.setText(bookmark.getDescription());
                mUrl.setText(bookmark.getUrl());
                mNotes.setText(bookmark.getNotes());
                mTime.setText(d.toString());
                mUsername.setText(bookmark.getAccount());

                if (mIcon != null) {
                    if (!bookmark.getShared()) {
                        mIcon.setImageResource(R.drawable.padlock);
                    }
                }

                SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

                for (Tag t : bookmark.getTags()) {
                    addTag(tagBuilder, t, tagOnClickListener);
                }

                mTags.setText(tagBuilder);
                mTags.setMovementMethod(LinkMovementMethod.getInstance());
            } else {

                Date d = new Date(bookmark.getTime());

                if (bookmark.getDescription() != null && !bookmark.getDescription().equals("null"))
                    mTitle.setText(bookmark.getDescription());

                mUrl.setText(bookmark.getUrl());

                if (bookmark.getNotes() != null && !bookmark.getNotes().equals("null"))
                    mNotes.setText(bookmark.getNotes());

                mTime.setText(d.toString());

                SpannableStringBuilder tagBuilder = new SpannableStringBuilder();

                for (Tag t : bookmark.getTags()) {
                    addTag(tagBuilder, t, userTagOnClickListener);
                }

                mTags.setText(tagBuilder);
                mTags.setMovementMethod(LinkMovementMethod.getInstance());

                if (bookmark.getAccount() != null) {
                    SpannableStringBuilder builder = new SpannableStringBuilder();
                    int start = builder.length();
                    builder.append(bookmark.getAccount());
                    int end = builder.length();

                    AccountSpan span = new AccountSpan(bookmark.getAccount());
                    span.setOnAccountClickListener(accountOnClickListener);

                    builder.setSpan(span, start, end, 0);

                    mUsername.setText(builder);
                }

                mUsername.setMovementMethod(LinkMovementMethod.getInstance());
            }
        } else if (viewType == BookmarkViewType.READ) {
            new GetArticleTask().execute(bookmark.getUrl());
        } else if (viewType == BookmarkViewType.WEB) {
            showInWebView();
        }
    }
}

From source file:com.juick.android.TagsFragment.java

private void reloadTags(final View view) {
    final View selectedContainer = myView.findViewById(R.id.selected_container);
    final View progressAll = myView.findViewById(R.id.progress_all);
    Thread thr = new Thread(new Runnable() {

        public void run() {
            Bundle args = getArguments();
            MicroBlog microBlog;//  w  ww . j  a  v  a2  s.c  o  m
            JSONArray json = null;
            final int tagsUID = showMine ? uid : 0;
            if (PointMessageID.CODE.equals(args.getString("microblog"))) {
                microBlog = MainActivity.microBlogs.get(PointMessageID.CODE);
                json = ((PointMicroBlog) microBlog).getUserTags(view, uidS);
            } else {
                microBlog = MainActivity.microBlogs.get(JuickMessageID.CODE);
                json = ((JuickMicroBlog) microBlog).getUserTags(view, tagsUID);
            }
            if (isAdded()) {
                final SpannableStringBuilder tagsSSB = new SpannableStringBuilder();
                if (json != null) {
                    try {
                        int cnt = json.length();
                        ArrayList<TagSort> sortables = new ArrayList<TagSort>();
                        for (int i = 0; i < cnt; i++) {
                            final String tagg = json.getJSONObject(i).getString("tag");
                            final int messages = json.getJSONObject(i).getInt("messages");
                            sortables.add(new TagSort(tagg, messages));
                        }
                        Collections.sort(sortables);
                        HashMap<String, Double> scales = new HashMap<String, Double>();
                        for (int sz = 0, sortablesSize = sortables.size(); sz < sortablesSize; sz++) {
                            TagSort sortable = sortables.get(sz);
                            if (sz < 10) {
                                scales.put(sortable.tag, 2.0);
                            } else if (sz < 20) {
                                scales.put(sortable.tag, 1.5);
                            }
                        }
                        int start = 0;
                        if (microBlog instanceof JuickMicroBlog
                                && getArguments().containsKey("add_system_tags")) {
                            start = -4;
                        }
                        for (int i = start; i < cnt; i++) {
                            final String tagg;
                            switch (i) {
                            case -4:
                                tagg = "public";
                                break;
                            case -3:
                                tagg = "friends";
                                break;
                            case -2:
                                tagg = "notwitter";
                                break;
                            case -1:
                                tagg = "readonly";
                                break;
                            default:
                                tagg = json.getJSONObject(i).getString("tag");
                                break;

                            }
                            int index = tagsSSB.length();
                            tagsSSB.append("*" + tagg);
                            tagsSSB.setSpan(new URLSpan(tagg) {
                                @Override
                                public void onClick(View widget) {
                                    onTagClick(tagg, tagsUID);
                                }
                            }, index, tagsSSB.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            Double scale = scales.get(tagg);
                            if (scale != null) {
                                tagsSSB.setSpan(new RelativeSizeSpan((float) scale.doubleValue()), index,
                                        tagsSSB.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                            }
                            tagOffsets.put(tagg, new TagOffsets(index, tagsSSB.length()));
                            tagsSSB.append(" ");

                        }
                    } catch (Exception ex) {
                        tagsSSB.append("Error: " + ex.toString());
                    }
                }
                if (getActivity() != null) {
                    // maybe already closed?
                    getActivity().runOnUiThread(new Runnable() {

                        public void run() {
                            TextView tv = (TextView) myView.findViewById(R.id.tags);
                            progressAll.setVisibility(View.GONE);
                            if (multi)
                                selectedContainer.setVisibility(View.VISIBLE);
                            tv.setText(tagsSSB, TextView.BufferType.SPANNABLE);
                            tv.setMovementMethod(LinkMovementMethod.getInstance());
                            MainActivity.restyleChildrenOrWidget(view);
                            final TextView selected = (TextView) myView.findViewById(R.id.selected);
                            selected.setVisibility(View.VISIBLE);
                        }
                    });
                }
            }
        }
    });
    thr.start();
}

From source file:com.heath_bar.tvdb.SeriesOverview.java

/** Populate the interface with the data pulled from the webz */
private void PopulateStuff(TvSeries seriesInfo) {

    if (seriesInfo == null) {
        Toast.makeText(getApplicationContext(), "Something bad happened. No data was found.",
                Toast.LENGTH_SHORT).show();
        return;//w  ww.ja  va  2 s.co  m
    }

    // Set title
    getSupportActionBar().setTitle(seriesInfo.getName());

    // Hide/Activate the favorites button
    if (seriesInfo.isFavorite(getApplicationContext())) {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.GONE);
    } else {
        Button b = (Button) findViewById(R.id.btn_add_to_favorites);
        b.setVisibility(View.VISIBLE);
        b.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Button b = (Button) findViewById(R.id.btn_add_to_favorites);
                b.setVisibility(View.GONE);
                addToFavorites();
            }
        });
    }

    // Set the banner
    ImageView imageView = (ImageView) findViewById(R.id.series_banner);
    imageView.setImageBitmap(seriesInfo.getImage().getBitmap());
    imageView.setVisibility(View.VISIBLE);
    final String seriesName = seriesInfo.getName();

    imageView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            shareImage();
        }
    });

    // Set the banner link
    TextView textview = (TextView) findViewById(R.id.banner_listing_link);
    textview.setTextColor(getResources().getColor(R.color.tvdb_green));
    textview.setVisibility(View.VISIBLE);
    textview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(getApplicationContext(), BannerListing.class);
            i.putExtra("seriesId", seriesId);
            i.putExtra("seriesName", seriesName);
            startActivity(i);
        }
    });

    // Set air info
    textview = (TextView) findViewById(R.id.airs_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.last_episode);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.next_episode);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.series_air_info);
    StringBuffer sb = new StringBuffer();
    sb.append(seriesInfo.getAirDay());
    if (!seriesInfo.getAirTime().equals(""))
        sb.append(" at " + seriesInfo.getAirTime());
    if (!seriesInfo.getNetwork().equals(""))
        sb.append(" on " + seriesInfo.getNetwork());
    textview.setText(sb.toString());
    textview.setVisibility(View.VISIBLE);

    // Set actors
    textview = (TextView) findViewById(R.id.starring);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.series_actors);
    textview.setVisibility(View.VISIBLE);

    SpannableStringBuilder text = tagsBuilder(seriesInfo.getActors(), "|");
    textview.setText(text, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());

    // Set rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.rating);
    textview.setText(seriesInfo.getRating() + " / 10");
    textview.setVisibility(View.VISIBLE);

    // Set genre
    textview = (TextView) findViewById(R.id.genre_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.genre);
    textview.setText(StringUtil.commafy(seriesInfo.getGenre()));
    textview.setVisibility(View.VISIBLE);

    // Set runtime
    textview = (TextView) findViewById(R.id.runtime_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.runtime);
    textview.setText(seriesInfo.getRuntime() + " minutes");
    textview.setVisibility(View.VISIBLE);

    // Set overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);

    textview = (TextView) findViewById(R.id.overview);
    textview.setText(seriesInfo.getOverview());
    textview.setVisibility(View.VISIBLE);

    // Show Seasons header
    textview = (TextView) findViewById(R.id.seasons_header);
    textview.setVisibility(View.VISIBLE);

    // IMDB Link
    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = seriesInfo.getIMDB();
    SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
    ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.imdb.com/title/" + imdbId));
            startActivity(myIntent);
        }
    }, 0, ssb.length(), 0);

    ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
    textview.setText(ssb, BufferType.SPANNABLE);
    textview.setMovementMethod(LinkMovementMethod.getInstance());
}

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  ww .  j  av a  2 s . co m*/
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    textView.setTextSize(getTextSize(context));
    textView.setText(Html.fromHtml(buffer.toString()));
    return textView;
}

From source file:com.heath_bar.tvdb.EpisodeDetails.java

/** Populate the GUI with the data we've found */
public void PopulateStuff(TvEpisode theEpisode) {

    // Set Title//from w  ww.  j a  va 2s  . co m
    TextView textview = (TextView) findViewById(R.id.title);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getSeason() + "x" + String.format("%02d", theEpisode.getNumber()) + " "
            + theEpisode.getName());

    // Set Thumb
    if (theEpisode.getImage() != null
            && (theEpisode.getImage().getBitmap() == null || theEpisode.getImage().getUrl().equals(""))) {
        // do nothin
    } else {
        imageId = theEpisode.getImage().getId();
        ImageButton banner = (ImageButton) findViewById(R.id.episode_thumb);
        banner.setImageBitmap(theEpisode.getImage().getBitmap());
        banner.setVisibility(View.VISIBLE);
        banner.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                shareImage();
            }
        });
    }

    // Overview
    textview = (TextView) findViewById(R.id.overview_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.overview);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getOverview());

    // Director
    textview = (TextView) findViewById(R.id.director_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.director);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getDirector());

    // Writer
    textview = (TextView) findViewById(R.id.writer_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.writer);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getWriter());

    // Rating
    textview = (TextView) findViewById(R.id.rating_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.rating);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getRating() + " / 10");

    // First Aired
    textview = (TextView) findViewById(R.id.first_aired_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.first_aired);
    textview.setVisibility(View.VISIBLE);
    textview.setText(DateUtil.toString(theEpisode.getAirDate()));

    // Guest Stars
    textview = (TextView) findViewById(R.id.guest_stars_header);
    textview.setVisibility(View.VISIBLE);
    textview = (TextView) findViewById(R.id.guest_stars);
    textview.setVisibility(View.VISIBLE);
    textview.setText(theEpisode.getGuestStars());

    textview = (TextView) findViewById(R.id.imdb_link);
    textview.setVisibility(View.VISIBLE);

    final String imdbId = theEpisode.getIMDB();
    if (imdbId != "") {
        SpannableStringBuilder ssb = new SpannableStringBuilder(getResources().getString(R.string.imdb));
        ssb.setSpan(new NonUnderlinedClickableSpan(getResources().getString(R.string.imdb)) {
            @Override
            public void onClick(View v) {
                Intent myIntent = new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://www.imdb.com/title/" + imdbId));
                startActivity(myIntent);
            }
        }, 0, ssb.length(), 0);

        ssb.setSpan(new TextAppearanceSpan(this, R.style.episode_link), 0, ssb.length(), 0); // Set the style of the text
        textview.setText(ssb, BufferType.SPANNABLE);
        textview.setMovementMethod(LinkMovementMethod.getInstance());
    }
}