List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.limewoodmedia.nsdroid.fragments.OfficersFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.officers, null, false); list = (ListView) root.findViewById(R.id.officers_list); officers = new ArrayList<Officer>(); officersComparator = new OfficersComparator(); listAdapter = new ArrayAdapter<Officer>(context, 0, officers) { @Override/*from w ww . j a va 2 s .c o m*/ public View getView(int position, View convertView, ViewGroup parent) { View view; TextView name, office, authority; Officer officer; if (convertView == null) { view = inflater.inflate(R.layout.officer, null); } else { view = convertView; } name = (TextView) view.findViewById(R.id.officer_name); name.setMovementMethod(LinkMovementMethod.getInstance()); office = (TextView) view.findViewById(R.id.officer_office); authority = (TextView) view.findViewById(R.id.officer_authority); officer = getItem(position); // Name String oName = TagParser.idToName(officer.nation); name.setText(Html.fromHtml(oName)); // Office office.setText(officer.office); // Authority StringBuilder sb = new StringBuilder(); int i = 0; for (Officer.Authority auth : officer.authority) { sb.append(auth.name); if (i + 1 < officer.authority.size()) { sb.append(", "); } i++; } authority.setText(sb.toString()); view.setTag(officer); view.setOnClickListener(OfficersFragment.this); name.setOnClickListener(OfficersFragment.this); office.setOnClickListener(OfficersFragment.this); return view; } }; list.setAdapter(listAdapter); return root; }
From source file:com.ota.updates.fragments.AvailableFragment.java
private void setupChangelog(View view, Context context) { View changelog = view.findViewById(R.id.changelog); if (changelog != null) { TextView tv = (TextView) changelog; Bypass byPass = new Bypass(context); VersionSQLiteHelper helper = new VersionSQLiteHelper(mContext); VersionItem versionItem = helper.getLastVersionItem(); String changelogStr = versionItem.getChangelog(); CharSequence string = byPass.markdownToSpannable(changelogStr); tv.setText(string);//w w w . j av a2 s .com tv.setMovementMethod(LinkMovementMethod.getInstance()); } }
From source file:org.odk.collect.android.widgets.QuestionWidget.java
private MediaLayout createQuestionMediaLayout(FormEntryPrompt prompt) { String promptText = prompt.getLongText(); // Add the text view. Textview always exists, regardless of whether there's text. TextView questionText = new TextView(getContext()); questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, questionFontsize); questionText.setTypeface(null, Typeface.BOLD); questionText.setTextColor(ContextCompat.getColor(getContext(), R.color.primaryTextColor)); questionText.setPadding(0, 0, 0, 7); questionText.setText(promptText == null ? "" : TextUtils.textToHtml(promptText)); questionText.setMovementMethod(LinkMovementMethod.getInstance()); // Wrap to the size of the parent view questionText.setHorizontallyScrolling(false); if (promptText == null || promptText.length() == 0) { questionText.setVisibility(GONE); }/*from w ww .j av a 2 s . co m*/ String imageURI = prompt.getImageText(); String audioURI = prompt.getAudioText(); String videoURI = prompt.getSpecialFormQuestionText("video"); // shown when image is clicked String bigImageURI = prompt.getSpecialFormQuestionText("big-image"); // Create the layout for audio, image, text MediaLayout questionMediaLayout = new MediaLayout(getContext(), player); questionMediaLayout.setId(ViewIds.generateViewId()); // assign random id questionMediaLayout.setAVT(prompt.getIndex(), "", questionText, audioURI, imageURI, videoURI, bigImageURI); questionMediaLayout.setAudioListener(this); String playColorString = prompt.getFormElement().getAdditionalAttribute(null, "playColor"); if (playColorString != null) { try { playColor = Color.parseColor(playColorString); } catch (IllegalArgumentException e) { Timber.e(e, "Argument %s is incorrect", playColorString); } } questionMediaLayout.setPlayTextColor(playColor); String playBackgroundColorString = prompt.getFormElement().getAdditionalAttribute(null, "playBackgroundColor"); if (playBackgroundColorString != null) { try { playBackgroundColor = Color.parseColor(playBackgroundColorString); } catch (IllegalArgumentException e) { Timber.e(e, "Argument %s is incorrect", playBackgroundColorString); } } questionMediaLayout.setPlayTextBackgroundColor(playBackgroundColor); return questionMediaLayout; }
From source file:com.parse.f8.view.SignInActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); ////////////////////////// // try { // PackageInfo info = getPackageManager().getPackageInfo("com.parse.f8", PackageManager.GET_SIGNATURES); // for (android.content.pm.Signature signature : info.signatures) { // MessageDigest md = MessageDigest.getInstance("SHA"); // md.update(signature.toByteArray()); // String sign=Base64.encodeToString(md.digest(), Base64.DEFAULT); // Log.d("MY KEY HASH:", sign); // // Toast.makeText(getApplicationContext(),sign, Toast.LENGTH_LONG).show(); // } // } catch (NameNotFoundException e1) { // } catch (NoSuchAlgorithmException e1) { // }//from w ww . j a v a 2s . com ////////////////////////// TextView tos = (TextView) findViewById(R.id.tos); tos.setMovementMethod(LinkMovementMethod.getInstance()); Button loginButton = (Button) findViewById(R.id.loginButton); loginButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onLoginButtonClicked(); } }); }
From source file:com.grarak.kerneladiutor.views.recyclerview.downloads.DownloadKernelView.java
@Override public void onCreateView(View view) { super.onCreateView(view); if (mDownloadDrawable == null) { mDownloadDrawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_download); DrawableCompat.setTint(mDownloadDrawable, Color.WHITE); }// w w w .ja v a 2s . c o m if (mCancelDrawable == null) { mCancelDrawable = ContextCompat.getDrawable(view.getContext(), R.drawable.ic_cancel); DrawableCompat.setTint(mCancelDrawable, Color.WHITE); } final TextView title = (TextView) view.findViewById(R.id.title); TextView summary = (TextView) view.findViewById(R.id.summary); TextView changelog = (TextView) view.findViewById(R.id.changelog); mDownloadSection = view.findViewById(R.id.downloadSection); mProgressParent = view.findViewById(R.id.progressParent); mProgressText = (TextView) view.findViewById(R.id.progressText); mProgressBar = (ProgressBar) view.findViewById(R.id.progressbar); mFabButton = (FloatingActionButton) view.findViewById(R.id.fab_button); mCheckMD5 = view.findViewById(R.id.checkmd5); mMismatchMD5 = view.findViewById(R.id.md5_mismatch); mInstallButton = view.findViewById(R.id.install); final CharSequence titleText = Utils.htmlFrom(mDownload.getName()); title.setText(titleText); title.setMovementMethod(LinkMovementMethod.getInstance()); String description = mDownload.getDescription(); if (description != null) { summary.setText(Utils.htmlFrom(description)); summary.setMovementMethod(LinkMovementMethod.getInstance()); } else { summary.setVisibility(View.GONE); } List<String> changelogs = mDownload.getChangelogs(); if (changelogs.size() > 0) { StringBuilder stringBuilder = new StringBuilder(); for (String change : changelogs) { if (stringBuilder.length() == 0) { stringBuilder.append("\u2022").append(" ").append(change); } else { stringBuilder.append("<br>").append("\u2022").append(" ").append(change); } } changelog.setText(Utils.htmlFrom(stringBuilder.toString())); changelog.setMovementMethod(LinkMovementMethod.getInstance()); } else { changelog.setVisibility(View.GONE); } mMismatchMD5.setVisibility(View.GONE); mInstallButton.setVisibility(View.GONE); if (mCheckMD5Task == null) { mDownloadSection.setVisibility(View.VISIBLE); mCheckMD5.setVisibility(View.GONE); } mProgressParent.setVisibility(mDownloadTask == null ? View.INVISIBLE : View.VISIBLE); mFabButton.setImageDrawable(mDownloadTask == null ? mDownloadDrawable : mCancelDrawable); mFabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { if (mDownloadTask == null) { mFabButton.setImageDrawable(mCancelDrawable); mProgressParent.setVisibility(View.VISIBLE); mMismatchMD5.setVisibility(View.GONE); mInstallButton.setVisibility(View.GONE); mProgressBar.setProgress(0); mProgressText.setText(""); mProgressBar.setIndeterminate(true); mDownloadTask = new DownloadTask(mActvity, new DownloadTask.OnDownloadListener() { private int mPercentage; @Override public void onUpdate(int currentSize, int totalSize) { int percentage = Math.round(currentSize * 100f / totalSize); if (mPercentage != percentage) { mPercentage = percentage; mProgressBar.setIndeterminate(false); double current = Utils.roundTo2Decimals(currentSize / 1024D / 1024D); double total = Utils.roundTo2Decimals(totalSize / 1024D / 1024D); mProgressBar.setProgress(mPercentage); mProgressText.setText(view.getContext().getString(R.string.downloading_counting, String.valueOf(current), String.valueOf(total)) + view.getContext().getString(R.string.mb)); } } @Override public void onSuccess(String path) { mFabButton.setImageDrawable(mDownloadDrawable); mProgressParent.setVisibility(View.INVISIBLE); mDownloadTask = null; checkMD5(mDownload.getMD5sum(), path, mDownload.getInstallMethod()); } @Override public void onCancel() { mFabButton.setImageDrawable(mDownloadDrawable); mProgressParent.setVisibility(View.INVISIBLE); mMismatchMD5.setVisibility(View.GONE); mDownloadTask = null; } @Override public void onFailure(String error) { Utils.toast(view.getContext().getString(R.string.download_error, titleText), view.getContext()); mFabButton.setImageDrawable(mDownloadDrawable); mProgressParent.setVisibility(View.INVISIBLE); mDownloadTask = null; } }, Utils.getInternalDataStorage() + "/downloads/" + titleText.toString() + ".zip"); mDownloadTask.execute(mDownload.getUrl()); } else { mFabButton.setImageDrawable(mDownloadDrawable); mProgressParent.setVisibility(View.INVISIBLE); mDownloadTask.cancel(); mDownloadTask = null; } } }); }
From source file:com.liferay.mobile.screens.viewsets.westeros.auth.signup.SignUpView.java
private void initClickableTermsAndConditions() { TextView textView = (TextView) findViewById(R.id.terms); textView.setMovementMethod(LinkMovementMethod.getInstance()); SpannableStringBuilder ssb = new SpannableStringBuilder("I accept the terms and conditions"); ssb.setSpan(new ClickableSpan() { @Override//from w w w. j a v a 2s . c o m public void onClick(View widget) { SignUpScreenlet signUpScreenlet = getSignUpScreenlet(); signUpScreenlet.performUserAction(SignUpScreenlet.TERMS_AND_CONDITIONS); } }, 13, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), 13, ssb.length(), 0); ssb.setSpan(new ForegroundColorSpan(ContextCompat.getColor(getContext(), android.R.color.white)), 13, ssb.length(), 0); textView.setText(ssb, TextView.BufferType.SPANNABLE); }
From source file:com.shearosario.tothepathandback.DisplayDirectionsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_directions); getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent();//w w w .j av a 2s . c om /*if(intent.hasExtra("origin")) { double[] temp = intent.getDoubleArrayExtra("origin"); origin = new LatLng (temp[0], temp[1]); } if (intent.hasExtra("destination")) { double[] temp = intent.getDoubleArrayExtra("destination"); destination = new LatLng (temp[0], temp[1]); }*/ String linkCollection = null; String nodeCollection = null; String points = null; if (intent.hasExtra("GuidanceLinkCollection")) linkCollection = intent.getStringExtra("GuidanceLinkCollection"); if (intent.hasExtra("GuidanceNodeCollection")) nodeCollection = intent.getStringExtra("GuidanceNodeCollection"); if (intent.hasExtra("shapePoints")) points = intent.getStringExtra("shapePoints"); gMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.directionsView)).getMap(); gMap.setMyLocationEnabled(false); gMap.setBuildingsEnabled(false); gMap.getUiSettings().setZoomControlsEnabled(false); TextView textView = (TextView) findViewById(R.id.osm_guidance); 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.guidance_text); textView.setText( Html.fromHtml("Guidance Courtesy of " + "<a href=\"http://www.mapquest.com\">MapQuest</a>")); textView.setMovementMethod(LinkMovementMethod.getInstance()); PolylineOptions rectOptions = new PolylineOptions(); markers = new ArrayList<Marker>(); try { JSONArray jGuidanceLinkCollection = new JSONArray(linkCollection); JSONArray jGuidanceNodeCollection = new JSONArray(nodeCollection); JSONArray jShapePoints = new JSONArray(points); int lastIndex = 0; for (int i = 0; i < jGuidanceNodeCollection.length(); i++) { JSONObject nodeObject = jGuidanceNodeCollection.getJSONObject(i); JSONArray linkIds = nodeObject.getJSONArray("linkIds"); int linkIndex = 0; if (linkIds.length() != 0) linkIndex = linkIds.getInt(0); else continue; JSONObject linkObject = jGuidanceLinkCollection.getJSONObject(linkIndex); int shapeIndex = linkObject.getInt("shapeIndex"); // The index of a specific shape point is i/2, so multiply by 2 to get the beginning index in shapePoints // evens are lat and odds are lng double lat = jShapePoints.getDouble((shapeIndex * 2)); double lng = jShapePoints.getDouble((shapeIndex * 2) + 1); lastIndex = ((shapeIndex * 2) + 1); if (i == 0) { Marker temp = gMap .addMarker(new MarkerOptions().position(new LatLng(lat, lng)).title("Origin")); markers.add(temp); } else if (nodeObject.isNull("infoCollection") == false) { Marker temp = gMap.addMarker(new MarkerOptions().position(new LatLng(lat, lng)) .title(nodeObject.getJSONArray("infoCollection").getString(0))); markers.add(temp); } } for (int i = 0; i < lastIndex; i++) { double lat = jShapePoints.getDouble(i); i++; double lng = jShapePoints.getDouble(i); rectOptions.add(new LatLng(lat, lng)); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } gMap.addPolyline(rectOptions); markersIndex = 0; gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(markers.get(markersIndex).getPosition(), 17)); markers.get(markersIndex).showInfoWindow(); gMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker arg0) { if (arg0 != null) { for (int i = 0; i < markers.size(); i++) { if (markers.get(i).equals(arg0)) { markersIndex = i; break; } } if (markersIndex == 0) { findViewById(R.id.button_nextStep).setEnabled(true); findViewById(R.id.button_previousStep).setEnabled(false); } else if (markersIndex == (markers.size() - 1)) { findViewById(R.id.button_nextStep).setEnabled(false); findViewById(R.id.button_previousStep).setEnabled(true); } else { findViewById(R.id.button_nextStep).setEnabled(true); findViewById(R.id.button_previousStep).setEnabled(true); } gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(arg0.getPosition(), 17)); arg0.showInfoWindow(); return true; } return false; } }); }
From source file:com.pocketsoap.admin.UserDetailFragment.java
private void bindUi() { // header section setText(R.id.detail_name, user.Name); setText(R.id.detail_username, user.Username); setText(R.id.detail_title, user.Title); // contact section setText(R.id.contact_email, user.Email); setText(R.id.contact_phone, user.Phone); setText(R.id.contact_mobile, user.MobilePhone); // no auto link for SMS, so we need to build our own URLSpan for it. if (user.MobilePhone != null && user.MobilePhone.length() > 0) { SpannableStringBuilder b = new SpannableStringBuilder(user.MobilePhone); b.setSpan(new URLSpan("smsto:" + user.MobilePhone), 0, user.MobilePhone.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); setText(R.id.contact_mobile_text, b).setMovementMethod(LinkMovementMethod.getInstance()); } else {/*w w w . j a v a 2 s. co m*/ setText(R.id.contact_mobile_text, ""); } //action section isActive.setChecked(user.IsActive); isActive.setOnClickListener(new ToggleActive()); // user photo // the default person image is https://blah/.../005/T but we don't want to bother fetching that, we'll just use our local default instead. if (user.SmallPhotoUrl != null && user.SmallPhotoUrl.length() > 0 && !user.SmallPhotoUrl.endsWith("/005/T")) { PhotoLoaderTask photoLoader = new PhotoLoaderTask(getActivityHelper()); photoLoader.execute(user.SmallPhotoUrl); } else { this.userPhoto.setImageResource(R.drawable.ic_contact_picture); } }
From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_event_details, container, false); holder = new ViewHolder(); holder.inflater = inflater;/*from ww w . ja va2s. c om*/ ((TextView) view.findViewById(R.id.title)).setText(event.getTitle()); TextView textView = (TextView) view.findViewById(R.id.subtitle); String text = event.getSubtitle(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { textView.setText(text); } MovementMethod linkMovementMethod = LinkMovementMethod.getInstance(); // Set the persons summary text first; replace it with the clickable text when the loader completes holder.personsTextView = (TextView) view.findViewById(R.id.persons); String personsSummary = ""; if (CollectionUtils.isEmpty(event.getPeople())) { holder.personsTextView.setVisibility(View.GONE); } else { personsSummary = StringUtils.join(event.getPeople(), ", "); holder.personsTextView.setText(personsSummary); holder.personsTextView.setMovementMethod(linkMovementMethod); holder.personsTextView.setVisibility(View.VISIBLE); } ((TextView) view.findViewById(R.id.track)).setText(event.getTrack().getTitle()); Date startTime = event.getStartDate(); Date endTime = event.getEndDate(); text = String.format("%1$s, %2$s %3$s", event.getTrack().getDay().getName(), (startTime != null) ? TIME_DATE_FORMAT.format(startTime) : "?", (endTime != null) ? TIME_DATE_FORMAT.format(endTime) : "?"); ((TextView) view.findViewById(R.id.time)).setText(text); final String roomName = event.getTrack().getRoom().getName(); TextView roomTextView = (TextView) view.findViewById(R.id.room); Spannable roomText = new SpannableString(String.format("%1$s", roomName)); // final int roomImageResId = getResources() // .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable", // getActivity().getPackageName()); // // If the room image exists, make the room text clickable to display it // if(roomImageResId != 0) { // roomText.setSpan(new UnderlineSpan(), 0, roomText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // roomTextView.setOnClickListener(new View.OnClickListener() // { // // @Override // public void onClick(View view) // { // RoomImageDialogFragment.newInstance(roomName, roomImageResId).show(getFragmentManager()); // } // }); // roomTextView.setFocusable(true); // } roomTextView.setText(roomText); textView = (TextView) view.findViewById(R.id.abstract_text); text = event.getEventAbstract(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } textView = (TextView) view.findViewById(R.id.description); text = event.getDescription(); if (TextUtils.isEmpty(text)) { textView.setVisibility(View.GONE); } else { String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n"); textView.setText(strippedText); textView.setMovementMethod(linkMovementMethod); } holder.linksContainer = (ViewGroup) view.findViewById(R.id.links_container); return view; }
From source file:com.projects.nosleepreader.ReaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_reader, container, false); setHasOptionsMenu(true);/*ww w . j av a2 s. c o m*/ mDbHelper = ListingDbHelper.getInstance(getContext()); textView = (TextView) view.findViewById(R.id.webView_fragment); title = (TextView) view.findViewById(R.id.reader_title); Bundle bundle = this.getArguments(); String url = this.url = bundle.getString(ReaderActivity.READER_URL_KEY); String base_url = url.substring(0, url.length() - 1); Retrofit retrofit = new Retrofit.Builder().baseUrl(base_url) .addConverterFactory(GsonConverterFactory.create()).build(); service = retrofit.create(ApiService.class); Call<DetailModel[]> call = service.getText(ApiService.RAW_JSON); call.enqueue(new Callback<DetailModel[]>() { @Override public void onResponse(Response<DetailModel[]> response) { try { DetailModel.ChildrenData data = response.body()[0].getData().getChildren().get(0) .getChildrenData(); convertToContentValues(data); htmltext = data.getSelftext_html(); title.setText(data.getTitle()); textView.setText(Html.fromHtml(htmltext)); textView.setMovementMethod(LinkMovementMethod.getInstance()); } catch (Exception e) { } } @Override public void onFailure(Throwable t) { Log.e("detail failure: ", ""); } }); return view; }