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.adkdevelopment.e_contact.ui.MainActivity.java

/**
 * Initialises Navigation Drawer and adds links movement to the footer
 * sets listener on an item click in the Drawer
 *///from   ww  w  . j  ava2 s.c o  m
private void initNavigationDrawer() {
    // Make links work in the Drawer
    mFooterLinks.setMovementMethod(LinkMovementMethod.getInstance());

    // add listener to the buttons in the navigation drawer
    mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.drawer_map:
                if (Utilities.checkPlayServices(MainActivity.this)) {
                    Intent intent = new Intent(MainActivity.this, MapsActivity.class);
                    startActivity(intent);
                }
                mDrawerLayout.closeDrawers();
                return false;
            case R.id.login_button:
                startActivity(new Intent(MainActivity.this, LoginActivity.class));
                return true;
            case R.id.profile_button:
                startActivity(new Intent(MainActivity.this, ProfileActivity.class));
                return true;
            default:
                item.setChecked(true);
                mDrawerLayout.closeDrawers();
                return true;
            }
        }
    });
}

From source file:org.sufficientlysecure.localcalendar.ui.MainActivity.java

private void showAbout() {
    SpannableString s = new SpannableString(getText(R.string.about));
    Linkify.addLinks(s, Linkify.ALL);/*from w  w  w  .  java 2s  .  c  om*/
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(s);
    AlertDialog alert = builder.create();
    alert.show();
    ((TextView) alert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:org.creativecommons.thelist.fragments.AccountFragment.java

@Override
public void onResume() {
    super.onResume();
    mContext = getActivity();// w w  w . j  a  v  a 2  s.  c om
    mMessageHelper = new MessageHelper(mContext);

    //Get account information
    String accountName = getActivity().getIntent().getStringExtra(ARG_ACCOUNT_NAME);
    final String accountType = getActivity().getIntent().getStringExtra(ARG_ACCOUNT_TYPE);
    mAuthTokenType = getActivity().getIntent().getStringExtra(ARG_AUTH_TYPE);
    if (mAuthTokenType == null)
        mAuthTokenType = AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS;

    if (accountName != null) {
        ((EditText) getView().findViewById(R.id.accountName)).setText(accountName);
    }

    //UI Elements
    final Button cancelButton = (Button) getView().findViewById(R.id.cancelButton);
    final Button loginButton = (Button) getView().findViewById(R.id.loginButton);
    final Button signUpButton = (Button) getView().findViewById(R.id.signUpButton);
    final EditText accountEmailField = (EditText) getView().findViewById(R.id.accountName);
    final EditText accountPasswordField = (EditText) getView().findViewById(R.id.accountPassword);
    accountPasswordField.setTypeface(Typeface.DEFAULT);
    final TextView newAccountButton = (TextView) getView().findViewById(R.id.signUp);

    //Try Login on Click
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final String accountEmail = accountEmailField.getText().toString().trim();
            final String accountPassword = accountPasswordField.getText().toString().trim();

            if (accountEmail.isEmpty() || accountPassword.isEmpty()) {
                mMessageHelper.showDialog(mContext, getString(R.string.login_error_title),
                        getString(R.string.login_error_message));
            } else {
                ListUser mCurrentUser = new ListUser(getActivity());
                try {
                    mCurrentUser.userSignIn(accountEmail, accountPassword, mAuthTokenType,
                            new ListUser.AuthCallback() {
                                @Override
                                public void onSuccess(String authtoken) {
                                    //TODO: authtoken stuff
                                    Bundle data = new Bundle();

                                    data.putString(AccountManager.KEY_ACCOUNT_NAME, accountEmail);
                                    data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
                                    data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
                                    data.putString(PARAM_USER_PASS, accountPassword);

                                    //Create Bundle to create Account
                                    mCallback.onUserSignedIn(data);
                                }
                            });
                } catch (Exception e) {
                    Log.d("LoginFragment", e.getMessage());
                    //data.putString(KEY_ERROR_MESSAGE, e.getMessage());
                }
            }
        }
    });

    //Actually I need an account --> show user Sign Up Button
    if (newAccountButton != null) {
        newAccountButton.setMovementMethod(LinkMovementMethod.getInstance());
    }
    //TODO: hide loginButton and show signUpButton
    //        newAccountButton.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                //loginButton.setVisibility(View.GONE);
    //                //signUpButton.setVisibility(View.VISIBLE);
    //            }
    //        });

    //Cancel Activity
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mCallback.onCancelLogin();
        }
    });

    //TODO: do when we have register user
    //        signUpButton.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                //TODO:userSignUp
    //                final String accountEmail = accountEmailField.getText().toString().trim();
    //                final String accountPassword = accountPasswordField.getText().toString().trim();
    //
    //                if (accountEmail.isEmpty() || accountPassword.isEmpty()) {
    //                    mMessageHelper.showDialog(mContext, getString(R.string.login_error_title),
    //                            getString(R.string.login_error_message));
    //                } else {
    //                    //TODO: Login User + save to sharedPreferences
    //                    ListUser mCurrentUser = new ListUser(getActivity());
    //                    try {
    //                        mCurrentUser.userSignUp(accountEmail, accountPassword, mAuthTokenType, new ListUser.AuthCallback() {
    //                            @Override
    //                            public void onSuccess(String authtoken) {
    //
    //                                Bundle data = new Bundle();
    //
    //                                data.putString(AccountManager.KEY_ACCOUNT_NAME, accountEmail);
    //                                data.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    //                                data.putString(AccountManager.KEY_AUTHTOKEN, authtoken);
    //                                data.putString(PARAM_USER_PASS, accountPassword);
    //
    //                                mCallback.onUserSignedUp(data);
    //                            }
    //                        });
    //                    } catch (Exception e) {
    //                        Log.d("LoginFragment", e.getMessage());
    //                    }
    //                }
    //            }
    //        });

}

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

public void displayUserList(final ParcelableUserList user_list) {
    if (user_list == null || getActivity() == null)
        return;//  w  w  w  .  ja  v  a  2s.  co  m
    getLoaderManager().destroyLoader(0);
    final boolean is_myself = user_list.account_id == user_list.user_id;
    mErrorRetryContainer.setVisibility(View.GONE);
    mUserList = user_list;
    mProfileContainer.drawEnd(getAccountColor(getActivity(), user_list.account_id));
    mListNameView.setText(user_list.name);
    final String display_name = getDisplayName(getActivity(), user_list.user_id, user_list.user_name,
            user_list.user_screen_name, false);
    mCreatedByView.setText(getString(R.string.created_by, display_name));
    final String description = user_list.description;
    mDescriptionContainer.setVisibility(is_myself || !isEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(
            new OnLinkClickHandler(getActivity(), getMultiSelectManager()));
    linkify.applyAllLinks(mDescriptionView, user_list.account_id, false);
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    mProfileImageLoader.displayProfileImage(mProfileImageView, user_list.user_profile_image_url);
    mAdapter.notifyDataSetChanged();
    invalidateOptionsMenu();
}

From source file:org.dharmaseed.android.NavigationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from   w ww .j  a  v a2 s .co  m

    dbManager = DBManager.getInstance(this);

    // Configure search box
    searchBox = (EditText) findViewById(R.id.nav_search_text);
    searchBox.setOnEditorActionListener(this);
    searchBox.setOnFocusChangeListener(this);
    searchCluster = (LinearLayout) findViewById(R.id.nav_search_cluster);

    // Configure header
    header = (LinearLayout) findViewById(R.id.nav_sub_header);
    headerPrimary = (TextView) findViewById(R.id.nav_sub_header_primary);
    headerDescription = (TextView) findViewById(R.id.nav_sub_header_description);
    websiteLink = (TextView) findViewById(R.id.nav_links_website);
    donationLink = (TextView) findViewById(R.id.nav_links_donate);
    websiteLink.setMovementMethod(LinkMovementMethod.getInstance());
    donationLink.setMovementMethod(LinkMovementMethod.getInstance());

    // Configure navigation view
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    // Configure list view
    listView = (ListView) findViewById(R.id.talks_list_view);
    listView.setOnItemClickListener(this);

    // Initialize UI state
    starFilterOn = false;
    searchCluster.setVisibility(View.GONE);
    header.setVisibility(View.GONE);
    downloadedOnly = false;
    setViewMode(VIEW_MODE_TALKS);
    setDetailMode(DETAIL_MODE_NONE);
    extraSearchTerms = "";
    talkRepository = new TalkRepository(dbManager);
    teacherRepository = new TeacherRepository(dbManager);
    centerRepository = new CenterRepository(dbManager);

    // Set swipe refresh listener
    refreshLayout = (SwipeRefreshLayout) findViewById(R.id.talks_list_view_swipe_refresh);
    refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            Log.i("refresh", "onrefresh");
            fetchNewDataFromServer();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    LocalBroadcastManager.getInstance(this).registerReceiver(new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.i("navigationActivity", "Received update broadcast");
            updateDisplayedData();
        }
    }, new IntentFilter("updateDisplayedData"));

}

From source file:com.syncedsynapse.kore2.ui.hosts.AddHostFragmentZeroconf.java

/**
 * No host was found, present messages and buttons
 *///ww  w.ja  v  a2s.co  m
public void noHostFound() {
    titleTextView.setText(R.string.no_xbmc_found);
    messageTextView.setText(Html.fromHtml(getString(R.string.wizard_search_no_host_found)));
    messageTextView.setMovementMethod(LinkMovementMethod.getInstance());

    progressBar.setVisibility(View.GONE);
    hostListGridView.setVisibility(View.GONE);

    nextButton.setVisibility(View.VISIBLE);
    nextButton.setText(R.string.next);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            listener.onAddHostZeroconfNoHost();
        }
    });

    previousButton.setVisibility(View.VISIBLE);
    previousButton.setText(R.string.search_again);
    previousButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startSearching();
        }
    });
}

From source file:de.vanita5.twittnuker.fragment.support.UserListDetailsFragment.java

public void displayUserList(final ParcelableUserList userList) {
    if (userList == null || getActivity() == null)
        return;//from w w  w . j a va  2s  .  c  o m
    getLoaderManager().destroyLoader(0);
    final boolean is_myself = userList.account_id == userList.user_id;
    mErrorRetryContainer.setVisibility(View.GONE);
    mUserList = userList;
    mProfileContainer.drawEnd(getAccountColor(getActivity(), userList.account_id));
    mListNameView.setText(userList.name);
    final String display_name = getDisplayName(getActivity(), userList.user_id, userList.user_name,
            userList.user_screen_name, false);
    mCreatedByView.setText(getString(R.string.created_by, display_name));
    final String description = userList.description;
    mDescriptionContainer.setVisibility(is_myself || !isEmpty(description) ? View.VISIBLE : View.GONE);
    mDescriptionView.setText(description);
    final TwidereLinkify linkify = new TwidereLinkify(
            new OnLinkClickHandler(getActivity(), getMultiSelectManager()));
    linkify.applyAllLinks(mDescriptionView, userList.account_id, false);
    mDescriptionView.setMovementMethod(LinkMovementMethod.getInstance());
    mProfileImageLoader.displayProfileImage(mProfileImageView, userList.user_profile_image_url);
    mAdapter.notifyDataSetChanged();
    setMenu(mMenuBar.getMenu());
    mMenuBar.show();
    invalidateOptionsMenu();
}

From source file:com.calgen.udacity.lego.ui.ArticleDetailFragment.java

private void bindViews() {
    if (rootView == null) {
        return;// w w  w  .  jav a  2s.c  o m
    }
    if (cursor != null) {
        rootView.setAlpha(0);
        rootView.setVisibility(View.VISIBLE);
        titleView.setText(cursor.getString(ArticleLoader.Query.TITLE));
        bylineView.setText(formatByLine(Utils.getModifiedByline(cursor, getContext())));
        bodyView.setText(Html.fromHtml(cursor.getString(ArticleLoader.Query.BODY)));
        bodyView.setMovementMethod(LinkMovementMethod.getInstance());
        photoView.setMaxHeight((int) (getContext().getResources().getDisplayMetrics().heightPixels * 0.8));
        final String photoUrl = cursor.getString(ArticleLoader.Query.PHOTO_URL);
        Picasso.with(getContext()).load(photoUrl).placeholder(placeholder).into(photoView, new Callback() {
            @Override
            public void onSuccess() {
                playAnimation(photoView);
                final Bitmap bitmap = ((BitmapDrawable) photoView.getDrawable()).getBitmap();
                Palette.from(bitmap).clearFilters().generate(new Palette.PaletteAsyncListener() {
                    @Override
                    public void onGenerated(Palette palette) {
                        @ColorUtils.Lightness
                        int lightness = ColorUtils.isDark(palette);
                        if (lightness == ColorUtils.LIGHTNESS_UNKNOWN) {
                            isDark = ColorUtils.isDark(bitmap, bitmap.getWidth() / 2, 0);
                        } else {
                            isDark = lightness == ColorUtils.IS_DARK;
                        }
                        int extraDarkMutedColor = ColorUtils.scrimify(palette.getDarkMutedColor(primaryDark),
                                true, 0.7f); //70% Darker
                        metaBar.setBackgroundColor(extraDarkMutedColor);
                        if (isLand && getActivity() != null
                                && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                            (getActivity()).getWindow().setStatusBarColor(extraDarkMutedColor);
                        }
                    }
                });
            }

            @Override
            public void onError() {
                Log.e(LOG_TAG, "onError: Couldn't load photo - " + photoUrl);
            }
        });
        if (appBarLayout != null) {
            appBarLayout.setExpanded(false, true);
        }
        rootView.animate().alpha(1).setDuration(300);
        getActivity().supportStartPostponedEnterTransition();
    } else {
        rootView.setVisibility(View.GONE);
    }
}

From source file:de.j4velin.pedometer.ui.Activity_Main.java

public boolean optionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        getFragmentManager().popBackStackImmediate();
        break;/*from  w  ww  . j  av a2s . com*/
    case R.id.action_settings:
        getFragmentManager().beginTransaction().replace(android.R.id.content, new Fragment_Settings())
                .addToBackStack(null).commit();
        break;
    case R.id.action_leaderboard:
    case R.id.action_achievements:
        if (mGoogleApiClient.isConnected()) {
            startActivityForResult(item.getItemId() == R.id.action_achievements
                    ? Games.Achievements.getAchievementsIntent(mGoogleApiClient)
                    : Games.Leaderboards.getAllLeaderboardsIntent(mGoogleApiClient), RC_LEADERBOARDS);
        } else {
            AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
            builder2.setTitle(R.string.sign_in_necessary);
            builder2.setMessage(R.string.please_sign_in_with_your_google_account);
            builder2.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    getFragmentManager().beginTransaction()
                            .replace(android.R.id.content, new Fragment_Settings()).addToBackStack(null)
                            .commit();
                }
            });
            builder2.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            builder2.create().show();
        }
        break;
    case R.id.action_faq:
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://j4velin.de/faq/index.php?app=pm"))
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        break;
    case R.id.action_about:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.about);
        TextView tv = new TextView(this);
        tv.setPadding(10, 10, 10, 10);
        tv.setText(R.string.about_text_links);
        try {
            tv.append(getString(R.string.about_app_version,
                    getPackageManager().getPackageInfo(getPackageName(), 0).versionName));
        } catch (NameNotFoundException e1) {
            // should not happen as the app is definitely installed when
            // seeing the dialog
            e1.printStackTrace();
        }
        tv.setMovementMethod(LinkMovementMethod.getInstance());
        builder.setView(tv);
        builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        builder.create().show();
        break;
    }
    return true;
}

From source file:com.eyekabob.EventInfo.java

protected void loadEvent(JSONObject response) {
    try {/*ww  w.j  a va 2 s . c  o  m*/
        JSONObject jsonEvent = response.getJSONObject("event");

        artists = new ArrayList<String>();
        title = jsonEvent.getString("title");
        JSONObject jsonAllArtists = jsonEvent.getJSONObject("artists");
        headliner = jsonAllArtists.getString("headliner");
        Object artistObj = jsonAllArtists.get("artist");
        JSONArray jsonOpeners = new JSONArray();
        if (artistObj instanceof JSONArray) {
            jsonOpeners = (JSONArray) artistObj;
        }
        for (int i = 0; i < jsonOpeners.length(); i++) {
            String artistName = jsonOpeners.getString(i);
            if (!headliner.equals(artistName)) {
                artists.add(artistName);
            }
        }

        JSONObject jsonVenue = jsonEvent.getJSONObject("venue");
        venue = jsonVenue.optString("name");
        venueCity = jsonVenue.optString("city");
        venueStreet = jsonVenue.optString("street");
        venueUrl = jsonVenue.optString("url");
        startDate = EyekabobHelper.LastFM.toReadableDate(jsonEvent.getString("startDate"));
        JSONObject image = EyekabobHelper.LastFM.getLargestJSONImage(jsonEvent.getJSONArray("image"));
        imageUrl = image.getString("#text");
    } catch (JSONException e) {
        Log.e(getClass().getName(), "", e);
    }

    try {
        new EventImageTask().execute(new URL(imageUrl));
    } catch (MalformedURLException e) {
        Log.e(getClass().getName(), "Bad image URL [" + imageUrl + "]", e);
    }

    TextView titleView = (TextView) findViewById(R.id.infoMainHeader);
    titleView.setText(title);

    TextView headlinerView = (TextView) findViewById(R.id.infoSubHeaderOne);
    // TODO: I18N
    headlinerView.setText("Headlining: " + headliner);

    TextView dateTimeView = (TextView) findViewById(R.id.infoSubHeaderTwo);
    dateTimeView.setText(startDate);

    if (!startDate.equals("")) {
        Button tixButton = (Button) findViewById(R.id.infoTicketsButton);
        tixButton.setVisibility(View.VISIBLE);
    }

    LinearLayout artistsView = (LinearLayout) findViewById(R.id.infoFutureEventsContent);
    TextView alsoPerformingView = (TextView) findViewById(R.id.infoFutureEventsHeader);
    if (!artists.isEmpty()) {
        // TODO: I18N
        alsoPerformingView.setText("Also Performing:");
        for (String artist : artists) {
            TextView row = new TextView(this);
            row.setTextColor(Color.WHITE);
            row.setText(artist);
            row.setPadding(20, 0, 0, 20); // Left and bottom padding
            artistsView.addView(row);
        }
    }

    String venueDesc = "";
    TextView venueView = (TextView) findViewById(R.id.infoEventVenue);
    // TODO: Padding instead of whitespace
    venueDesc += "         " + venue;
    if (!venueCity.equals("") && !venueStreet.equals("")) {
        // TODO: I18N
        venueDesc += "\n         Address: " + venueStreet + "\n" + venueCity;
    }
    // TODO: Padding instead of whitespace
    venueDesc += "\n         " + startDate;

    TextView venueTitleView = (TextView) findViewById(R.id.infoBioHeader);
    if (!venue.equals("") || !venueCity.equals("") || !venueStreet.equals("")) {
        // TODO: I18N
        venueTitleView.setText("Venue Details:");
        View vView = findViewById(R.id.infoVenueDetails);
        vView.setVisibility(View.VISIBLE);
    } else {
        // TODO: I18N
        venueTitleView.setText("No Venue Details Available");
    }

    venueView.setVisibility(View.VISIBLE);
    venueView.setText(venueDesc);

    TextView websiteView = (TextView) findViewById(R.id.infoVenueWebsite);
    if (!venueUrl.equals("")) {
        // TODO: I18N
        websiteView.setVisibility(View.VISIBLE);
        websiteView.setText(Html.fromHtml("<a href=\"" + venueUrl + "\">More Information</a>"));
        websiteView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}