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.ichi2.anki.Info.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Timber.d("onCreate()");
    Themes.applyTheme(this);
    super.onCreate(savedInstanceState);

    Resources res = getResources();

    mType = getIntent().getIntExtra(TYPE_EXTRA, TYPE_ABOUT);

    setTitle(getTitleString());/*from   w  w w  .  j a  va  2s  .  c o m*/

    setContentView(R.layout.info);

    mWebView = (WebView) findViewById(R.id.info);
    mWebView.setBackgroundColor(res.getColor(Themes.getBackgroundColor()));
    Themes.setWallpaper((View) mWebView.getParent().getParent().getParent());

    TextView termsAndConditionsView = (TextView) findViewById(R.id.info_terms_and_conditions);
    termsAndConditionsView.setMovementMethod(LinkMovementMethod.getInstance());
    Button continueButton = (Button) findViewById(R.id.info_continue);
    continueButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (mType == TYPE_ABOUT) {
                if (AnkiDroidApp.isKindle()) {
                    Intent intent = new Intent("android.intent.action.VIEW",
                            Uri.parse("http://www.amazon.com/gp/mas/dl/android?p=com.ichi2.anki"));
                    startActivity(intent);
                } else {
                    Info.this.startActivity(
                            new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.ichi2.anki")));
                }
                return;
            }
            setResult(RESULT_OK);
            switch (mType) {
            case TYPE_NEW_VERSION:
                AnkiDroidApp.getSharedPrefs(Info.this.getBaseContext()).edit()
                        .putString("lastVersion", AnkiDroidApp.getPkgVersionName()).commit();
                break;
            case TYPE_UPGRADE_DECKS:
                break;
            }
            finishWithAnimation();
        }
    });

    StringBuilder sb = new StringBuilder();
    switch (mType) {
    case TYPE_ABOUT:
        String[] content = res.getStringArray(R.array.about_content);
        sb.append("<html><body text=\"#000000\" link=\"#E37068\" alink=\"#E37068\" vlink=\"#E37068\">");
        sb.append(
                String.format(content[0], res.getString(R.string.app_name), res.getString(R.string.link_anki)))
                .append("<br/><br/>");
        sb.append(String.format(content[1], res.getString(R.string.link_issue_tracker),
                res.getString(R.string.link_wiki), res.getString(R.string.link_forum))).append("<br/><br/>");
        sb.append(String.format(content[2], res.getString(R.string.link_wikipedia_open_source),
                res.getString(R.string.link_contribution),
                res.getString(R.string.link_contribution_contributors))).append(" ");
        sb.append(String.format(content[3], res.getString(R.string.link_translation),
                res.getString(R.string.link_donation))).append("<br/><br/>");
        sb.append(String.format(content[4], res.getString(R.string.licence_wiki),
                res.getString(R.string.link_source))).append("<br/><br/>");
        sb.append("</body></html>");
        mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null);
        ((Button) findViewById(R.id.info_continue)).setText(res.getString(R.string.info_rate));
        Button debugCopy = ((Button) findViewById(R.id.info_later));
        debugCopy.setText(res.getString(R.string.feedback_copy_debug));
        debugCopy.setVisibility(View.VISIBLE);
        debugCopy.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                copyDebugInfo();
            }
        });
        break;

    case TYPE_NEW_VERSION:
        sb.append(res.getString(R.string.new_version_message));
        sb.append("<ul>");
        String[] features = res.getStringArray(R.array.new_version_features);
        for (int i = 0; i < features.length; i++) {
            sb.append("<li>");
            sb.append(features[i]);
            sb.append("</li>");
        }
        sb.append("</ul>");
        sb.append(
                "<br><br><br>A new design is coming in v2.5, <a href=\"https://groups.google.com/d/msg/anki-android/DrMPHn9NQtk/aZYXdIZRCwAJ\">preview it here</a>!");
        sb.append("</body></html>");
        mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null);

        // reactivating ssl check for every new version
        AnkiDroidApp.getSharedPrefs(Info.this.getBaseContext()).edit().putBoolean("sslAcceptAll", false)
                .commit();
        break;

    case TYPE_SHARED_DECKS:
        mLoadingLayer = (RelativeLayout) findViewById(R.id.info_loading_layer);
        mLoadingLayer.setVisibility(View.VISIBLE);
        try {
            mShareDecksTemplate = Utils.convertStreamToString(getAssets().open("shared_decks_template.html"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        mWebView.setWebViewClient(new MobileAnkiWebview());
        mWebView.loadUrl(res.getString(R.string.shared_decks_url));
        mWebView.getSettings().setJavaScriptEnabled(true);
        termsAndConditionsView.setVisibility(View.VISIBLE);
        continueButton.setText(res.getString(R.string.download_button_return));
        break;

    case TYPE_UPGRADE_DECKS:
        setTitle(R.string.deck_upgrade_title);
        sb.append("<html><body>");

        // add "later" button
        Button but = (Button) findViewById(R.id.info_later);
        but.setVisibility(View.VISIBLE);

        // add sync button
        Button syncButton = (Button) findViewById(R.id.info_sync);
        syncButton.setVisibility(View.VISIBLE);

        mUpgradeStage = getIntent().getIntExtra(TYPE_UPGRADE_STAGE, -1);
        boolean reupgrading = false;

        switch (mUpgradeStage) {
        case UPGRADE_SCREEN_BASIC1:
            sb.append(getString(R.string.deck_upgrade_major_warning));
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Themes.showThemedToast(Info.this,
                            getString(R.string.deck_upgrade_start_again_to_upgrade_toast), false);
                    setResult(RESULT_CANCELED);
                    finish();
                }
            });
            syncButton.setText(R.string.more_options);
            syncButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_MORE_OPTIONS);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            continueButton.setText(R.string.now);
            continueButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            break;

        case UPGRADE_SCREEN_BASIC2:
            sb.append(getString(R.string.deck_upgrade_recommended_method));
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            syncButton.setEnabled(false);
            syncButton.setText("N/A");
            syncButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_WEB_UPGRADE);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            continueButton.setText(getString(R.string.pc));
            continueButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            break;

        case UPGRADE_SCREEN_MORE_OPTIONS:
            // If re-upgrading a collection exists already, so don't offer to make a new one
            if (new File(AnkiDroidApp.getCollectionPath()).exists()) {
                setTitle(getString(R.string.exit_wizard));
                reupgrading = true;
                sb.append(getString(R.string.deck_upgrade_more_options_exit));
            } else {
                sb.append(getString(R.string.deck_upgrade_more_options_new_collection));
            }
            sb.append(getString(R.string.deck_upgrade_more_options_downgrade));
            but.setText(R.string.upgrade_decks_button);
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC1);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            if (reupgrading) {
                syncButton.setText(getString(R.string.upgrade_deck_dont_upgrade));
                syncButton.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        Intent result = new Intent();
                        result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_CONTINUE);
                        setResult(RESULT_OK, result);
                        finishWithAnimation();
                    }
                });
            } else {
                syncButton.setText(R.string.deck_upgrade_create_new_collection_button);
                syncButton.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        StyledDialog.Builder builder = new StyledDialog.Builder(Info.this);
                        builder.setTitle(R.string.deck_upgrade_create_new_collection_title);
                        builder.setIcon(R.drawable.ic_dialog_alert);
                        builder.setMessage(R.string.deck_upgrade_not_import_warning);
                        builder.setPositiveButton(R.string.dialog_positive_create,
                                new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        Intent result = new Intent();
                                        result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_CONTINUE);
                                        setResult(RESULT_OK, result);
                                        finishWithAnimation();
                                    }
                                });
                        builder.setNegativeButton(R.string.dialog_cancel, null);
                        builder.show();
                    }
                });
            }
            continueButton.setVisibility(View.GONE);
            break;

        case UPGRADE_SCREEN_WEB_UPGRADE:
            sb.append(getString(R.string.deck_upgrade_via_web));
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            syncButton.setVisibility(View.GONE);
            continueButton.setText(R.string.dialog_continue);
            continueButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    lockScreenOrientation();
                    Connection.upgradeDecks(mWebUpgradeListener, new Connection.Payload(
                            new Object[] { AnkiDroidApp.getCurrentAnkiDroidDirectory() }));
                }
            });
            break;

        case UPGRADE_SCREEN_PC_UPGRADE:
            sb.append(getString(R.string.deck_upgrade_via_anki_desktop));
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            syncButton.setText(R.string.usb);
            syncButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_MANUAL_UPGRADE);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            continueButton.setEnabled(false);
            continueButton.setText("N/A");
            continueButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_AUTO_UPGRADE);
                    setResult(RESULT_OK, result);
                    finishWithAnimation();
                }
            });
            break;

        case UPGRADE_SCREEN_MANUAL_UPGRADE:
            sb.append(getString(R.string.deck_upgrade_manual));
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_BASIC2);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            syncButton.setText(R.string._import);
            syncButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    File apkgFile = new File(AnkiDroidApp.getCurrentAnkiDroidDirectory(),
                            DeckPicker.IMPORT_REPLACE_COLLECTION_NAME);
                    List<File> importables = Utils.getImportableDecks();
                    if (importables == null || !importables.contains(apkgFile)) {
                        Themes.showThemedToast(Info.this,
                                getResources().getString(R.string.upgrade_import_no_file_found,
                                        DeckPicker.IMPORT_REPLACE_COLLECTION_NAME),
                                false);
                    } else {
                        lockScreenOrientation();
                        DeckTask.launchDeckTask(DeckTask.TASK_TYPE_IMPORT_REPLACE, mUpgradeImportListener,
                                new DeckTask.TaskData(AnkiDroidApp.getCol(), apkgFile.getAbsolutePath()));
                    }
                }
            });
            continueButton.setVisibility(View.GONE);
            break;

        case UPGRADE_SCREEN_AUTO_UPGRADE:
            sb.append(getString(R.string.deck_upgrade_auto_upgrade));
            but.setText(R.string.back);
            but.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    Intent result = new Intent();
                    result.putExtra(TYPE_UPGRADE_STAGE, UPGRADE_SCREEN_PC_UPGRADE);
                    result.putExtra(TYPE_ANIMATION_RIGHT, true);
                    setResult(RESULT_OK, result);
                    finishWithAnimation(false);
                }
            });
            syncButton.setText(getString(R.string.upgrade_deck_sync_from_ankiweb));
            syncButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View arg0) {
                    StyledDialog.Builder builder = new StyledDialog.Builder(Info.this);
                    builder.setTitle(R.string.upgrade_deck_sync_from_ankiweb);
                    builder.setIcon(R.drawable.ic_dialog_alert);
                    builder.setMessage(getString(R.string.upgrade_deck_have_you_synced));
                    builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            lockScreenOrientation();
                            downloadCollection();
                        }
                    });
                    builder.setNegativeButton(R.string.back, null);
                    builder.show();
                }
            });
            continueButton.setVisibility(View.GONE);
            break;
        }

        // File[] fileList = (new File(AnkiDroidApp.getCurrentAnkiDroidDirectory())).listFiles(new
        // OldAnkiDeckFilter());
        // StringBuilder fsb = new StringBuilder();
        // fsb.append("<ul>");
        // for (File f : fileList) {
        // fsb.append("<li>").append(f.getName().replace(".anki", "")).append("</li>");
        // }
        // fsb.append("</ul>");
        // sb.append(res.getString(R.string.upgrade_decks_message, fsb.toString()));
        // sb.append("<ul><li>");
        // sb.append(res.getString(R.string.upgrade_decks_message_pos1,
        // AnkiDroidApp.getCurrentAnkiDroidDirectory()));
        // sb.append("</li><li>");
        // sb.append(res.getString(R.string.upgrade_decks_message_pos2, res.getString(R.string.link_anki)));
        // sb.append("</li><li>");
        // sb.append(res.getString(R.string.upgrade_decks_message_pos3));
        // sb.append("</li></ul>");
        // sb.append(res.getString(R.string.upgrade_decks_message_finish));
        sb.append("</body></html>");
        mWebView.loadDataWithBaseURL("", sb.toString(), "text/html", "utf-8", null);

        StyledDialog.Builder builder2 = new StyledDialog.Builder(this);
        // builder2.setTitle(res.getString(R.string.connection_error_title));
        builder2.setIcon(R.drawable.ic_dialog_alert);
        builder2.setMessage(res.getString(R.string.youre_offline));
        builder2.setPositiveButton(res.getString(R.string.dialog_ok), null);
        mNoConnectionAlert = builder2.create();
        break;

    default:
        finish();
        break;
    }
}

From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java

private void initCostPerYear(View fragmentView) {
    final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description);
    final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd);

    serviceDescription.setText(Html.fromHtml(
            getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd)));
    serviceDescription.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:cn.count.easydrive366.home.SettingsFragment.java

private void init_view() {

    containerView.findViewById(R.id.row_resetpassword).setOnClickListener(new OnClickListener() {

        @Override//  w ww.  j  a  va  2 s. c o m
        public void onClick(View v) {
            changePassword();

        }
    });

    containerView.findViewById(R.id.row_maintain).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // setup_maintain();
            get(AppSettings.url_for_get_maintain_record(), 2);

        }
    });
    containerView.findViewById(R.id.row_setup).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            register_step();
        }
    });
    containerView.findViewById(R.id.row_driver).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // setup_driver();
            get(AppSettings.url_get_driver_license(), 3);

        }
    });

    containerView.findViewById(R.id.row_car).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // setup_car_registration();
            get(AppSettings.url_get_car_registration(), 4);

        }
    });

    containerView.findViewById(R.id.row_choose_cellphone).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // start activity bindcellphone
            Intent intent = new Intent(SettingsFragment.this.getActivity(), BindCellphoneActivity.class);
            intent.putExtra("phone", _cellphone);
            intent.putExtra("isbind", _isbind);
            startActivityForResult(intent, BINDCELLPHONE);

        }
    });

    containerView.findViewById(R.id.row_choose_check_version).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            new CheckUpdate(SettingsFragment.this.getActivity(), true);

        }
    });
    containerView.findViewById(R.id.row_choose_findpassword).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            reset_password();

        }
    });
    containerView.findViewById(R.id.row_choose_user_feedback).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            user_feedback();

        }
    });
    containerView.findViewById(R.id.row_card).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            check_activate_code();

        }
    });

    containerView.findViewById(R.id.txt_bound).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            open_bound();

        }
    });
    containerView.findViewById(R.id.btn_pay).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            open_pay();

        }
    });
    containerView.findViewById(R.id.btn_insurance).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            open_insurance();

        }
    });
    containerView.findViewById(R.id.btn_task).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            open_task();

        }
    });
    containerView.findViewById(R.id.btn_friend).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            open_friend();

        }
    });
    /*
     * findViewById(R.id.row_cardview).setOnClickListener(new
     * OnClickListener(){
     * 
     * @Override public void onClick(View v) { cardView(); }});
     * findViewById(R.id.row_cardadd).setOnClickListener(new
     * OnClickListener(){
     * 
     * @Override public void onClick(View v) { cardAdd();
     * 
     * }});
     */
    txtNickname = (TextView) containerView.findViewById(R.id.txt_nickname);
    txtSignature = (TextView) containerView.findViewById(R.id.txt_signature);
    txtBound = (TextView) containerView.findViewById(R.id.txt_bound);
    txtBound.setMovementMethod(LinkMovementMethod.getInstance());
    txtExp = (TextView) containerView.findViewById(R.id.txt_exp);
    imgAvater = (ImageView) containerView.findViewById(R.id.img_picture);
    pbExp = (ProgressBar) containerView.findViewById(R.id.pb_exp);
    txtBind = (TextView) containerView.findViewById(R.id.txt_bindCellphone);
    txtVersion = (TextView) containerView.findViewById(R.id.txt_version);
    txtCellphone = (TextView) containerView.findViewById(R.id.img_choose_cellphone);
    // txtActivate_code = (TextView)findViewById(R.id.txt_activate_code);
    txtVersion.setText(String.format("V%s >", AppSettings.version));

    this.logoutButton = (Button) containerView.findViewById(R.id.btn_logout);
    logoutButton.setText(String.format("-%s", AppSettings.username));
    containerView.findViewById(R.id.btn_logout).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            logout();

        }
    });
    imgAvater.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            openSetupUser();

        }
    });

    // this.get(AppSettings.url_get_user_phone(), 1);
    // this.get(AppSettings.url_get_activate_code(), 11,"");
    load_user_profile();
}

From source file:org.freespanish.diccionario.main.MainActivity.java

@Override
public void showAboutDialog() {

    final SpannableString spannableString = new SpannableString(getString(R.string.about_msg));
    Linkify.addLinks(spannableString, Linkify.ALL);

    final AlertDialog aboutDialog = new AlertDialog.Builder(this).setPositiveButton(android.R.string.ok, null)
            .setTitle(getString(R.string.app_name) + " " + getString(R.string.app_version))
            .setMessage(spannableString).create();

    aboutDialog.show();/*from w w w. j  a v a2s . c  o m*/

    ((TextView) aboutDialog.findViewById(android.R.id.message))
            .setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:org.mariotaku.twidere.fragment.UserListDetailsFragment.java

public void changeUserList(final long account_id, final UserList user_list) {
    if (user_list == null || getActivity() == null || !isMyActivatedAccount(getActivity(), account_id))
        return;/* w ww  .j ava 2 s . c o  m*/
    getLoaderManager().destroyLoader(0);
    final User user = user_list.getUser();
    if (user == null)
        return;
    final boolean is_my_activated_account = isMyActivatedAccount(getActivity(), user_list.getId());
    mErrorRetryContainer.setVisibility(View.GONE);
    mAccountId = account_id;
    mUserListId = user_list.getId();
    mUserName = user.getName();
    mUserId = user.getId();
    mUserScreenName = user.getScreenName();
    mListName = user_list.getName();
    mProfileContainer.drawRight(getAccountColor(getActivity(), account_id));
    mListNameView.setText("@" + mUserScreenName + "/" + mListName);
    mUserNameView.setText(mUserName);
    final String description = user_list.getDescription();
    mDescriptionContainer
            .setVisibility(is_my_activated_account || !isEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionContainer.setOnLongClickListener(this);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(mDescriptionView);
    linkify.setOnLinkClickListener(new OnLinkClickHandler(getActivity(), account_id));
    linkify.addAllLinks();
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    final String profile_image_url_string = parseString(user.getProfileImageUrlHttps());
    final boolean hires_profile_image = getResources().getBoolean(R.bool.hires_profile_image);
    mProfileImageLoader.displayImage(mProfileImageView,
            hires_profile_image ? getBiggerTwitterProfileImage(profile_image_url_string)
                    : profile_image_url_string);
    mUserList = user_list;
    if (mUserId == mAccountId) {
        mFollowMoreButton.setText(R.string.more);
        mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.expander_open_holo, 0);
    } else {
        mFollowMoreButton.setText(user_list.isFollowing() ? R.string.unfollow : R.string.follow);
        mFollowMoreButton.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    }
    mAdapter.notifyDataSetChanged();
}

From source file:com.adkdevelopment.earthquakesurvival.ui.DetailFragment.java

/**
 * Sets data to views/*w  w  w.  jav a  2 s  . com*/
 */
public void setDataToViews() {
    mEarthquakeLink.setText(Utilities.getHtmlText(getString(R.string.earthquake_link, mLink)));
    mEarthquakeLink.setMovementMethod(LinkMovementMethod.getInstance());

    mEarthquakeDistance.setText(mDistance);
    mEarthquakeDate.setText(mDate);
    mEarthquakePlace.setText(mDescription);
    mEarthquakeMagnitude.setText(getString(R.string.earthquake_magnitude, mMagnitude));
    mEarthquakeDepth.setText(getString(R.string.earthquake_depth, mDepth));
}

From source file:com.github.michalbednarski.intentslab.editor.IntentGeneralFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.intent_editor_general, container, false);

    // Prepare form
    mActionText = (AutoCompleteTextView) v.findViewById(R.id.action);
    mActionsSpinner = (Spinner) v.findViewById(R.id.action_spinner);
    mDataText = (AutoCompleteTextView) v.findViewById(R.id.data);
    mDataTextWrapper = v.findViewById(R.id.data_wrapper);
    mDataTextHeader = v.findViewById(R.id.data_header);
    mDataTypeHeader = v.findViewById(R.id.data_type_header);
    mDataTypeText = (TextView) v.findViewById(R.id.data_type);
    mDataTypeSpinner = (Spinner) v.findViewById(R.id.data_type_spinner);
    mDataTypeSpinnerWrapper = v.findViewById(R.id.data_type_spinner_wrapper);
    mDataTypeSlash = v.findViewById(R.id.data_type_slash);
    mDataSubtypeText = (TextView) v.findViewById(R.id.data_type_after_slash);
    mComponentText = (TextView) v.findViewById(R.id.component);

    mComponentTypeSpinner = (Spinner) v.findViewById(R.id.componenttype);
    mComponentTypeSpinner.setAdapter(new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.componenttypes)));

    mMethodSpinner = (Spinner) v.findViewById(R.id.method);

    mCategoriesContainer = (ViewGroup) v.findViewById(R.id.categories);
    mAddCategoryButton = (Button) v.findViewById(R.id.category_add);
    mCategoriesHeader = v.findViewById(R.id.categories_header);
    mResponseCodeTextView = (TextView) v.findViewById(R.id.response_code);
    mPackageNameText = (AutoCompleteTextView) v.findViewById(R.id.package_name);

    mResultCodeWrapper = v.findViewById(R.id.result_intent_wrapper);
    mComponentTypeAndMethodSpinners = v.findViewById(R.id.component_and_method_spinners);
    mComponentHeader = v.findViewById(R.id.component_header);
    mComponentFieldWithButtons = v.findViewById(R.id.component_field_with_buttons);
    mPackageNameHeader = v.findViewById(R.id.package_name_header);
    mIntentTrackerSummary = (TextView) v.findViewById(R.id.intent_tracker_summary);
    mIntentTrackerSummary.setMovementMethod(LinkMovementMethod.getInstance());

    // Apparently using android:scrollHorizontally="true" does not work.
    // http://stackoverflow.com/questions/9011944/android-ice-cream-sandwich-edittext-disabling-spell-check-and-word-wrap
    mComponentText.setHorizontallyScrolling(true);

    // Bind button actions (android:onClick="" applies to hosting activity)
    mAddCategoryButton.setOnClickListener(new OnClickListener() {
        @Override/*from   w  w  w. j a v a  2  s .  c  o m*/
        public void onClick(View v) {
            addCategoryTextField("");
        }
    });
    v.findViewById(R.id.component_pick).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pickComponent();
        }
    });
    v.findViewById(R.id.component_pick).setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            findComponent();
            return true;
        }
    });
    v.findViewById(R.id.component_clear).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mComponentText.setText("");
        }
    });
    v.findViewById(R.id.data_query_button).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getIntentEditor().updateIntent();
            startActivity(
                    new Intent(getActivity(), AdvancedQueryActivity.class).setData(mEditedIntent.getData()));
        }
    });
    v.findViewById(R.id.data_query_button)
            .setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
                @Override
                public void onCreateContextMenu(ContextMenu menu, View v,
                        ContextMenu.ContextMenuInfo menuInfo) {
                    getIntentEditor().updateIntent();
                    final Uri uri = mEditedIntent.getData();
                    if (uri != null) {
                        final String scheme = uri.getScheme();
                        final String authority = uri.getAuthority();
                        if ("content".equals(scheme) && authority != null) {
                            menu.add("Wrap").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                                @Override
                                public boolean onMenuItemClick(MenuItem item) {
                                    mDataText.setText("content://" + ((mEditedIntent.getFlags()
                                            & (Intent.FLAG_GRANT_READ_URI_PERMISSION
                                                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0
                                                            ? ProxyProviderForGrantUriPermission.AUTHORITY
                                                            : ProxyProvider.AUTHORITY)
                                            + "/" + authority + uri.getPath());
                                    return true;
                                }
                            });
                        }
                    }
                }
            });

    // Set up autocomplete
    mUriAutocompleteAdapter = new UriAutocompleteAdapter(getActivity());
    mDataText.setAdapter(mUriAutocompleteAdapter);
    mPackageNameText.setAdapter(new PackageNameAutocompleteAdapter(getActivity()));

    // Get edited intent for form filling
    mEditedIntent = getEditedIntent();

    // Component field, affects options menu
    if (mEditedIntent.getComponent() != null) {
        mComponentText.setText(mEditedIntent.getComponent().flattenToShortString());
    }
    mComponentText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateIntentComponent();
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    // Fill the form
    setupActionSpinnerOrField();
    updateNonActionIntentFilter(true);
    mDataText.setText(mEditedIntent.getDataString());
    mPackageNameText.setText(mEditedIntent.getPackage());

    showOrHideFieldsForResultIntent();
    showOrHideAdvancedFields();
    if (getComponentType() == IntentEditorConstants.RESULT) {
        mResponseCodeTextView.setText(String.valueOf(getIntentEditor().getMethodId()));
        mResponseCodeTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                try {
                    getIntentEditor().setMethodId(Integer.parseInt(s.toString()));
                    mResponseCodeTextView.setError(null);
                } catch (NumberFormatException e) {
                    mResponseCodeTextView.setError(getIntentEditor().getText(R.string.value_parse_error));
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });
    } else {
        initComponentAndMethodSpinners();
    }

    setupActionAutocomplete();

    // Prepare intent tracker
    {
        IntentTracker tracker = getIntentEditor().getIntentTracker();
        if (tracker != null) {
            tracker.setUpdateListener(this, true);
        } else {
            onNoTracker();
        }
    }

    return v;
}

From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java

@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
    final TextView title = (TextView) view.findViewById(android.R.id.title);
    final TextView author = (TextView) view.findViewById(R.id.author);
    final TextView lastAlterDate = (TextView) view.findViewById(R.id.last_alter_date);

    registerForContextMenu(title);/* w  w  w  . j a  v a2 s. co  m*/
    title.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().openContextMenu(title);
        }
    });

    (new Thread(new Runnable() {
        @Override
        public void run() {
            Cursor cursor = getActivity().getContentResolver().query(CatnutProvider.parse(Zhihu.MULTIPLE),
                    PROJECTION, Zhihu.ANSWER_ID + "=" + mAnswerId, null, null);
            if (cursor.moveToNext()) {
                mQuestionId = cursor.getLong(cursor.getColumnIndex(Zhihu.QUESTION_ID));
                final String _title = cursor.getString(cursor.getColumnIndex(Zhihu.TITLE));
                final String _question = cursor.getString(cursor.getColumnIndex(Zhihu.DESCRIPTION));
                final String _nick = cursor.getString(cursor.getColumnIndex(Zhihu.NICK));
                final String _content = cursor.getString(cursor.getColumnIndex(Zhihu.ANSWER));
                final long _lastAlterDate = cursor.getLong(cursor.getColumnIndex(Zhihu.LAST_ALTER_DATE));
                cursor.close();

                // answer
                Matcher matcher = HTML_IMG.matcher(_content);
                final List<String> contentSegment = new ArrayList<String>();
                processText(_content, matcher, contentSegment);

                // question
                matcher = HTML_IMG.matcher(_question);
                final List<String> questionSegment = new ArrayList<String>();
                processText(_question, matcher, questionSegment);
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        title.setText(_title);
                        getActivity().getActionBar().setSubtitle(_title);

                        // ???
                        int l = contentSegment.size() > 1 ? contentSegment.size() >> 1 : 0;
                        l += questionSegment.size() > 1 ? questionSegment.size() >> 1 : 0;

                        if (l > 0) {
                            mImageUrls = new ArrayList<Uri>(l);
                        }

                        // ?
                        boolean useCachedImg = CatnutApp.getBoolean(R.string.pref_enable_cache_zhihu_images,
                                R.bool.default_plugin_status);

                        l = 0; // reset for reuse
                        String text;
                        int screenWidth = CatnutUtils.getScreenWidth(getActivity());
                        int max = getActivity().getResources().getDimensionPixelSize(R.dimen.max_thumb_width);
                        if (screenWidth > max) {
                            screenWidth = max;
                        }

                        LayoutInflater inflater = LayoutInflater.from(getActivity());
                        if (!TextUtils.isEmpty(_question)) {
                            ViewGroup questionHolder = (ViewGroup) view.findViewById(R.id.question);
                            for (int i = 0; i < questionSegment.size(); i++) {
                                text = questionSegment.get(i);
                                if (!TextUtils.isEmpty(text)) {
                                    if ((i & 1) == 0) {
                                        TextView section = (TextView) inflater.inflate(R.layout.zhihu_text,
                                                null);
                                        section.setTextSize(16);
                                        section.setTextColor(
                                                getResources().getColor(R.color.black50PercentColor));
                                        section.setText(Html.fromHtml(text));
                                        section.setMovementMethod(LinkMovementMethod.getInstance());
                                        CatnutUtils.removeLinkUnderline(section);
                                        questionHolder.addView(section);
                                    } else {
                                        ImageView imageView = getImageView();
                                        Uri uri = useCachedImg
                                                ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text))
                                                : Uri.parse(text);
                                        Picasso.with(getActivity()).load(uri).centerCrop()
                                                .resize(screenWidth,
                                                        (int) (Constants.GOLDEN_RATIO * screenWidth))
                                                .error(R.drawable.error).into(imageView);
                                        imageView.setTag(l++); // for click
                                        imageView.setOnClickListener(ZhihuItemFragment.this);
                                        mImageUrls.add(uri);
                                        questionHolder.addView(imageView);
                                    }
                                }
                            }
                        }

                        Typeface typeface = CatnutUtils.getTypeface(CatnutApp.getTingtingApp().getPreferences(),
                                getString(R.string.pref_customize_tweet_font),
                                getString(R.string.default_typeface));
                        ViewGroup answerHolder = (ViewGroup) view.findViewById(R.id.answer);
                        for (int i = 0; i < contentSegment.size(); i++) {
                            text = contentSegment.get(i);
                            if (!TextUtils.isEmpty(text)) {
                                if ((i & 1) == 0) {
                                    TextView section = (TextView) inflater.inflate(R.layout.zhihu_text, null);
                                    section.setText(Html.fromHtml(text));
                                    CatnutUtils.setTypeface(section, typeface);
                                    CatnutUtils.removeLinkUnderline(section);
                                    section.setMovementMethod(LinkMovementMethod.getInstance());
                                    answerHolder.addView(section);
                                } else {
                                    ImageView image = getImageView();
                                    Uri uri = useCachedImg
                                            ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text))
                                            : Uri.parse(text);
                                    Picasso.with(getActivity()).load(uri).centerCrop()
                                            .resize(screenWidth, (int) (Constants.GOLDEN_RATIO * screenWidth))
                                            .error(R.drawable.error).into(image);
                                    image.setTag(l++); // 
                                    image.setOnClickListener(ZhihuItemFragment.this);
                                    mImageUrls.add(uri);
                                    answerHolder.addView(image);
                                }
                            }
                        }
                        author.setText(_nick);
                        lastAlterDate.setText(DateUtils.getRelativeTimeSpanString(_lastAlterDate));
                        if (mSwipeRefreshLayout != null) {
                            mSwipeRefreshLayout.setRefreshing(false);
                        }
                    }
                });
            } else {
                cursor.close();
            }
        }
    })).start();
}

From source file:nz.Intelx.DroidNetLogin.DroidNetLoginActivity.java

public void alert(String msg, Activity a) {

    final Activity act = a;
    final AlertDialog builder = new AlertDialog.Builder(a).setMessage(Html.fromHtml(msg)).setCancelable(false)
            .setNegativeButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    if (act != null)
                        act.finish();/*from w w  w  .  j ava2 s . co  m*/
                    else
                        dialog.cancel();
                }
            }).show();
    ((TextView) builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static void linkifyIfEnabled(final TextView tv, final Object autoLink) {
    if (autoLink != null) {
        //Default to Ti.UI.AUTOLINK_NONE
        boolean success = Linkify.addLinks(tv, TiConvert.toInt(autoLink, 0) & Linkify.ALL);
        if (success && tv.getText() instanceof Spanned) {
            tv.setMovementMethod(LinkMovementMethod.getInstance());
        }// w w  w. j  ava2  s. c  om
    }
}