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:org.amahi.anywhere.activity.AuthenticationActivity.java

private void setUpAuthenticationMessages() {
    TextView authenticationFailureMessage = (TextView) findViewById(R.id.text_message_authentication);
    TextView authenticationConnectionFailureMessage = (TextView) findViewById(
            R.id.text_message_authentication_connection);

    authenticationFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
    authenticationConnectionFailureMessage.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:me.selinali.tribbble.ui.shot.ShotDetailsView.java

public void bind(Shot shot) {
    Glide.with(getContext()).load(shot.getUser().getAvatarUrl()).into(mAvatarImageView);
    mShotNameTextView.setText(shot.getTitle());
    mDateTextView.setText(DateUtils.formatDate(shot.getCreatedAt()));
    mLikesTextView.setText(String.valueOf(shot.getLikesCount()));
    mViewsTextView.setText(String.valueOf(shot.getViewsCount()));
    mBucketsTextView.setText(String.valueOf(shot.getBucketsCount()));
    mCommentsTextView.setText(String.valueOf(shot.getCommentsCount()));
    mArtistNameTextView.setText(shot.getUser().getName());
    mArtistLocationTextView.setText(shot.getUser().getLocation());
    mDescriptionTextView.setMovementMethod(LinkMovementMethod.getInstance());
    String description = shot.getDescription();
    if (description == null) {
        mDescriptionTextView.setVisibility(GONE);
    } else {/*from w w w  . ja  v a  2 s .c  o  m*/
        mDescriptionTextView.setText(StringUtils.trimTrailingNewLines(Html.fromHtml(description)));
    }
}

From source file:com.grokkingandroid.sampleapp.samples.about.AboutFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Resources res = getResources();
    if (getArguments() == null) {
        throw new IllegalStateException("Arguments bundle must not be empty");
    }// w  ww  .  j a va  2 s .co  m
    int[] resIds = getArguments().getIntArray(KEY_RESOURCE_IDS);
    getDialog().setTitle(res.getString(R.string.about));
    View view = inflater.inflate(R.layout.fragment_about, container, false);
    ViewGroup libParent = (ViewGroup) view.findViewById(R.id.about_container);

    String[] libTitles = null;
    String[] libDescriptions = null;
    if (resIds[0] != -1) {
        libTitles = res.getStringArray(resIds[0]);
        libDescriptions = res.getStringArray(resIds[1]);
    }
    if (getArguments().getBoolean(KEY_ADD_DEFAULT_LIBS, true)) {
        if (resIds[0] == -1) {
            libTitles = res.getStringArray(R.array.grokkingandroidsample_about_titles);
            libDescriptions = res.getStringArray(R.array.grokkingandroidsample_about_contents);
        } else {
            String[] defaultTitles = res.getStringArray(R.array.grokkingandroidsample_about_titles);
            String[] target = new String[defaultTitles.length + libTitles.length];
            System.arraycopy(libTitles, 0, target, 0, libTitles.length);
            System.arraycopy(defaultTitles, 0, target, libTitles.length, defaultTitles.length);
            libTitles = target;
            String[] defaultDescriptions = res.getStringArray(R.array.grokkingandroidsample_about_contents);
            target = new String[defaultDescriptions.length + libTitles.length];
            System.arraycopy(libDescriptions, 0, target, 0, libDescriptions.length);
            System.arraycopy(defaultDescriptions, 0, target, libDescriptions.length,
                    defaultDescriptions.length);
            libDescriptions = target;
        }
    }
    String libraryPlural = res.getQuantityString(R.plurals.plural_libraries, libTitles.length);
    String appTitle = res.getString(resIds[3]);
    String copyrightYear = res.getString(resIds[4]);
    String repositoryLink = res.getString(resIds[5]);
    String aboutText = res.getString(resIds[2], appTitle, copyrightYear, repositoryLink, libraryPlural);
    Spanned spannedAboutText = Html.fromHtml(aboutText);
    TextView aboutTv = (TextView) libParent.findViewById(R.id.about_text);
    aboutTv.setText(spannedAboutText);
    aboutTv.setMovementMethod(LinkMovementMethod.getInstance());

    if (libTitles != null) {
        for (int i = 0; i < libTitles.length; i++) {
            View libContainer = inflater.inflate(R.layout.single_library_layout, libParent, false);
            TextView currLibTitle = (TextView) libContainer.findViewById(R.id.library_title);
            currLibTitle.setText(libTitles[i]);
            TextView currLibDesc = (TextView) libContainer.findViewById(R.id.library_text);
            Spanned spanned = Html.fromHtml(libDescriptions[i]);
            currLibDesc.setText(spanned);
            currLibDesc.setMovementMethod(LinkMovementMethod.getInstance());
            libParent.addView(libContainer);
        }
    }
    return view;
}

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

protected void setHtmlMode(View parent, int viewId) {
    TextView description = (TextView) parent.findViewById(viewId);
    description.setMovementMethod(LinkMovementMethod.getInstance());
    description.setText(Html.fromHtml(getValue(parent.findViewById(viewId))));
}

From source file:com.limewoodmedia.nsdroid.fragments.RegionalHappenings.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.regional_happenings, null, false);
    title = (TextView) root.findViewById(R.id.regional_happenings_header);
    list = (ListView) root.findViewById(R.id.regional_happenings_list);
    layout = (ViewGroup) root.findViewById(R.id.layout);
    ViewTreeObserver observer = title.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override/*from w  ww .  java2  s  .  co  m*/
        public void onGlobalLayout() {
            layout.setPadding(layout.getPaddingLeft(),
                    title.getHeight() - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
                            getResources().getDisplayMetrics()),
                    layout.getPaddingRight(), layout.getPaddingBottom());
        }
    });

    happenings = new ArrayList<RegionHappening>();
    listAdapter = new ArrayAdapter<RegionHappening>(context, 0, happenings) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView msg;

            if (convertView == null) {
                view = inflater.inflate(R.layout.event, null);
                msg = (TextView) view.findViewById(R.id.event_message);
                msg.setMovementMethod(LinkMovementMethod.getInstance());
            } else {
                view = convertView;
                msg = (TextView) view.findViewById(R.id.event_message);
            }
            RegionHappening event = getItem(position);
            long timestamp = event.timestamp;
            String time = TagParser.parseTimestamp(getContext(), timestamp);
            String text = time + ": " + event.text;
            //              text = text.replaceAll("@@([a-z\\d_]+)@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">$1</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">$1</a>");
            msg.setText(Html.fromHtml(text));

            return view;
        }
    };
    list.setAdapter(listAdapter);
    LoadingHelper.startLoading((com.limewoodmedia.nsdroid.views.LoadingView) root.findViewById(R.id.loading));

    return root;
}

From source file:com.shearosario.tothepathandback.ClosestStationsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_closest_stations);

    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent intent = getIntent();// ww  w.j  ava  2s. c o m
    context = this;
    activity = this;

    adView = (AdView) this.findViewById(R.id.adViewClosest);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("949F5429A9EC251C1DD4395558D33531").build();
    // AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

    if (intent.hasExtra("Manual")) {
        double[] manual = intent.getDoubleArrayExtra("Manual");
        origin = new LatLng(manual[0], manual[1]);
    } else if (intent.hasExtra("Current")) {
        double[] current = intent.getDoubleArrayExtra("Current");
        origin = new LatLng(current[0], current[1]);
    }

    double[] entranceMeasures = intent.getDoubleArrayExtra("closestSortMeasures");
    ArrayList<Entrance> closestEntrances = intent.getParcelableArrayListExtra("closestEntrances");

    MySimpleArrayAdapter adapter = new MySimpleArrayAdapter(this, R.layout.listitem, closestEntrances,
            entranceMeasures);
    //ListAdapter adapter = createListAdapter(allStationsSortDistance);
    ListView listview = (ListView) findViewById(R.id.ClosestStationsList);
    listview.setAdapter(adapter);
    //setListAdapter(adapter);

    final GoogleMap gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
    gMap.setMyLocationEnabled(false);
    gMap.addMarker(new MarkerOptions().title("Origin").position(origin));
    gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(origin, 13));
    gMap.setBuildingsEnabled(false);
    gMap.getUiSettings().setZoomControlsEnabled(false);

    TextView textView = (TextView) findViewById(R.id.osm_directions);
    textView.setText(Html.fromHtml("Data provided by  OpenStreetMap contributors "
            + "<a href=\"http://www.openstreetmap.org/copyright\">License</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    textView = (TextView) findViewById(R.id.directions_text);
    textView.setText(Html.fromHtml(
            "Directions, Nominatim Search Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>"));
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Entrance item = (Entrance) parent.getItemAtPosition(position);

            gMap.clear();

            LatLngBounds bounds = new LatLngBounds.Builder().include(origin)
                    .include(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])).build();

            gMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));

            gMap.addMarker(new MarkerOptions().title("Origin").position(origin));

            String stationName = null;
            for (int i = 0; i < MainActivity.getAllStations().size(); i++) {
                if (item.getStopid().equalsIgnoreCase(MainActivity.getAllStations().get(i).getStopID())) {
                    stationName = MainActivity.getAllStations().get(i).getStopName();
                    break;
                }
            }

            gMap.addMarker(new MarkerOptions()
                    // .title(item.getStationName())
                    .title(stationName)
                    .position(new LatLng(item.getEntranceLocation()[0], item.getEntranceLocation()[1])));

            Button button = (Button) findViewById(R.id.button_destination);
            button.setEnabled(true);
            // button.setText("Select " + item.getStationName());
            button.setText("Select " + stationName);

            button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    /*
                     * To check if the phone is currently using a network connection. 
                     * Listens to broadcasts when the the device is or is not connected to 
                     * a network
                     */
                    ConnectivityManager cm = (ConnectivityManager) context
                            .getSystemService(Context.CONNECTIVITY_SERVICE);
                    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
                    boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
                    if (!isConnected) {
                        Toast.makeText(context, "No network connection", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    new DisplayDirectionsIntent(context, activity, origin, item);
                }
            });
        }
    });
}

From source file:com.limewoodmedia.nsdroid.fragments.NationalHappenings.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    root = inflater.inflate(R.layout.national_happenings, null, false);
    list = (ListView) root.findViewById(R.id.national_happenings_list);
    layout = (ViewGroup) root.findViewById(R.id.layout);
    title = (TextView) root.findViewById(R.id.national_happenings_header);
    ViewTreeObserver observer = title.getViewTreeObserver();
    observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override//from  www  .  ja v a2  s.  c  o  m
        public void onGlobalLayout() {
            layout.setPadding(layout.getPaddingLeft(),
                    title.getHeight() - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
                            getResources().getDisplayMetrics()),
                    layout.getPaddingRight(), layout.getPaddingBottom());
        }
    });

    happenings = new ArrayList<NationHappening>();
    listAdapter = new ArrayAdapter<NationHappening>(context, 0, happenings) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view;
            TextView msg;

            if (convertView == null) {
                view = inflater.inflate(R.layout.event, null);
                msg = (TextView) view.findViewById(R.id.event_message);
                msg.setMovementMethod(LinkMovementMethod.getInstance());
            } else {
                view = convertView;
                msg = (TextView) view.findViewById(R.id.event_message);
            }
            NationHappening event = getItem(position);
            long timestamp = event.timestamp;
            String time = TagParser.parseTimestamp(getContext(), timestamp);
            String text = time + ": " + event.text;
            //             text = text.replaceAll("@@("+nation.toLowerCase().replace(' ', '_')+")@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">"+nation+"</a>");
            //             text = text.replaceAll("@@([a-z\\d_]+)@@",
            //                    "<a href=\"com.limewoodMedia.nsdroid.nation://$1\">$1</a>");
            //             text = text.replaceAll("%%("+region.toLowerCase().replace(' ', '_')+")%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">"+region+"</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region://$1\">$1</a>");
            //              text = text.replaceAll("%%([a-z\\d_]+)%rmb%%",
            //                    "<a href=\"com.limewoodMedia.nsdroid.region.rmb://$1\">Regional Message Board</a>");
            msg.setText(Html.fromHtml(text));

            return view;
        }
    };
    list.setAdapter(listAdapter);
    LoadingHelper.startLoading((com.limewoodmedia.nsdroid.views.LoadingView) root.findViewById(R.id.loading));

    return root;
}

From source file:com.pepperonas.showcase.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getTitle().equals("About")) {
        new MaterialDialog.Builder(this).title("MaterialDialog library").customView(R.layout.dialog_lib_info)
                .positiveText("OK").positiveColor(R.color.grey_700).icon(R.drawable.ic_launcher)
                .showListener(new MaterialDialog.ShowListener() {
                    @Override/*from w  ww  .j  av a 2  s  .c o  m*/
                    public void onShow(AlertDialog d) {
                        super.onShow(d);
                        TextView tvLibInfo = (TextView) d.findViewById(R.id.tv_lib_info);
                        tvLibInfo.setText(Html.fromHtml(getString(R.string.web_presentation_info)));
                        tvLibInfo.setMovementMethod(LinkMovementMethod.getInstance());
                    }
                }).show();
    } else if (item.getTitle().equals(Const.HIDE_TOASTS)) {
        mSharedPreferences.edit().putBoolean("SHOW_TOASTS", false).apply();
        item.setTitle(Const.SHOW_TOASTS);
    } else if (item.getTitle().equals(Const.SHOW_TOASTS)) {
        mSharedPreferences.edit().putBoolean("SHOW_TOASTS", true).apply();
        item.setTitle(Const.HIDE_TOASTS);
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.jwork.dhammapada.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    log.v(this, "onCreate()");
    if (CrashHandler.getInstance().isCrashFlag()) {
        log.v(this, "Crash flag detected");
        showCrashDialog();/*from   w  w  w.java  2 s  . c o  m*/
    } else {
        //         setTheme(MainActivity.THEME);
        //         requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        mainLayout = (FrameLayout) findViewById(R.id.mainLayout);
        mainLayout.getForeground().setAlpha(0);

        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        aboutWindow = new PopupWindow(inflater.inflate(R.layout.activity_about, null, false),
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
        TextView text = ((TextView) aboutWindow.getContentView().findViewById(R.id.about_text));
        text.setText(Html.fromHtml(
                getString(R.string.about_html).replaceAll("\\{0\\}", CrashHandler.getVersionName(this))
                        .replaceAll("\\{1\\}", "" + CrashHandler.getVersionCode(this))));
        text.setMovementMethod(LinkMovementMethod.getInstance());
        ImageButton button = ((ImageButton) aboutWindow.getContentView().findViewById(R.id.about_ok));
        button.setOnClickListener(this);

        controller = new DhammapadaController(this, viewHandler);

        Message message = Message.obtain();
        message.what = Constant.WHAT_DISPLAY_CHAPTER;
        controller.executeMessage(message);

        message = Message.obtain();
        message.what = Constant.WHAT_INIT;
        controller.executeMessage(message);

        //         ActionBar actionBar = getSupportActionBar();
        //         actionBar.hide();
        //         actionBar.setTitle("Dhammapada");
        //         actionBar.setSubtitle("Chapter");
        //         actionBar.setLogo(R.drawable.ic_launcher);
        //         actionBar.show();
    }
}