Java 类android.text.Html 实例源码
项目:NewAndroidArchitecture
文件:DetailActivity.java
@SuppressWarnings("deprecation")
private void showCountryDetail(@NonNull Country country) {
CollapsingToolbarLayout toolbarLayout =
(CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
toolbarLayout.setTitle(country.getCountryName());
toolbarLayout.setExpandedTitleColor(ContextCompat.getColor(this, android.R.color.white));
if (getSupportActionBar() != null) {
getSupportActionBar().setTitle(country.getCountryName());
}
if (imageView != null ) {
String flagUri = BuildConfig.GEONAME_ICON_URL +"x/" +
country.getCountryCode().toLowerCase() + ".gif";
imageView.setImageURI(Uri.parse(flagUri));
}
tvCapital.setText(getString(R.string.format_country_capital,country.getCapital()));
tvContinent.setText(getString(R.string.format_country_continent,country.getContinentName()));
tvCode.setText(getString(R.string.format_country_code,country.getCountryCode()));
tvArea.setText(Html.fromHtml(getString(R.string.format_country_area,country.getAreaInSqKm())));
tvPopulation.setText(getString(R.string.format_country_population,country.getPopulation()));
tvSouth.setText(getString(R.string.format_country_south,country.getSouth()));
tvEast.setText(getString(R.string.format_country_east,country.getEast()));
tvNorth.setText(getString(R.string.format_country_north,country.getNorth()));
tvWest.setText(getString(R.string.format_country_west,country.getWest()));
}
项目:lurkerhn
文件:StoryContentActivity.java
private void setUpAskHnStoryText(final Item item) {
if (item.getText() != null) {
TextView storyText = (TextView) findViewById(R.id.story_text);
storyText.setText(Html.fromHtml(item.getText()));
storyText.setOnClickListener(new View.OnClickListener() {
private boolean minimized;
@Override
public void onClick(View v) {
if (!minimized) {
storyText.setText("<<Click to expand>>");
minimized = true;
} else {
storyText.setText(Html.fromHtml(item.getText()));
minimized = false;
}
}
});
}
}
项目:NewKakaoBot
文件:KakaoTalkListener.java
private KakaoData getKakaoData(String room, Object text) {
KakaoData result = new KakaoData();
result.room = room;
if(text instanceof String) {
result.sender = room;
result.message = text.toString();
} else {
String html = Html.toHtml((SpannableString) text);
result.sender = Html.fromHtml(html.split("<b>")[1].split("</b>")[0]).toString();
result.message = Html.fromHtml(html.split("</b>")[1].split("</p>")[0].substring(1)).toString();
}
return result;
}
项目:AcopioMX
文件:ActivityHome.java
private void showSupportersDialog() {
final Dialog fullscreenDialog = new Dialog(this, R.style.DialogFullscreen);
fullscreenDialog.setContentView(R.layout.dialog_supporters);
Button logoutB = fullscreenDialog.findViewById(R.id.logout_b);
ImageView img_dialog_fullscreen_close = fullscreenDialog.findViewById(R.id.close_iv);
TextView collaborationTV = fullscreenDialog.findViewById(R.id.info_collaboration_tv);
collaborationTV.setText(Html.fromHtml(getString(R.string.collaboration)));
img_dialog_fullscreen_close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
fullscreenDialog.dismiss();
}
});
logoutB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
saveToken(context, "HOME", null);
Intent intent = new Intent(context, ActivitySplash.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
finish();
}
});
fullscreenDialog.show();
}
项目:MiPushFramework
文件:CheckDozeActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (PushServiceAccessibility.isInDozeWhiteList(this)) {
nextPage();
finish();
return;
}
SetupWizardLayout layout = new SetupWizardLayout(this);
layout.getNavigationBar()
.setNavigationBarListener(this);
TextView textView = new TextView(this);
textView.setText(Html.fromHtml(getString(R.string.wizard_descr_doze_whitelist)));
int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
textView.setPadding(padding, padding, padding, padding);
textView.setMovementMethod(LinkMovementMethod.getInstance());
layout.addView(textView);
layout.setHeaderText(R.string.wizard_title_doze_whitelist);
setContentView(layout);
}
项目:schulcloud-mobile-android
文件:NewsAdapter.java
@Override
public void onBindViewHolder(NewsAdapter.NewsViewHolder holder, int position) {
News news = mNews.get(position);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
SimpleDateFormat dateFormatDeux = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date createdDate = null;
try {
createdDate = dateFormat.parse(news.createdAt);
} catch (Throwable e) {
e.printStackTrace();
}
holder.title.setText(news.title);
if (news.content != null)
holder.description.setText(Html.fromHtml(news.content));
if (news.createdAt != null)
holder.date.setText(dateFormatDeux.format(createdDate));
holder.cardView.setOnClickListener(v -> mNewsPresenter.showNewsDetail(news._id));
int pos = holder.description.getText().toString().indexOf("\n\n");
holder.description.setText(holder.description.getText().toString()
.substring(0, pos));
if (!Html.fromHtml(news.content).toString().substring(pos).trim().isEmpty())
holder.description.append("\n...");
}
项目:MiPushFramework
文件:MainActivity.java
@Override
public boolean onOptionsItemSelected (MenuItem item) {
if (item.getItemId() == R.id.action_about) {
TextView textView = new TextView(this);
int padding = (int) getResources()
.getDimension(android.support.v7.appcompat.R.dimen.abc_dialog_padding_material);
textView.setPadding(padding, padding, padding, padding);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(Html.fromHtml(getString(R.string.about_descr)));
new AlertDialog.Builder(this)
.setTitle(R.string.action_about)
.setView(textView)
.show();
return true;
} else if (item.getItemId() == R.id.action_update) {
startActivity(new Intent(this, UpdateActivity.class));
}
return super.onOptionsItemSelected(item);
}
项目:MiPushFramework
文件:FinishWizardActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WizardSPUtils.setShouldShowWizard(false, this);
SetupWizardLayout layout = new SetupWizardLayout(this);
layout.getNavigationBar()
.setNavigationBarListener(this);
layout.getNavigationBar().getBackButton().setVisibility(View.GONE);
TextView textView = new TextView(this);
textView.setText(Html.fromHtml(getString(R.string.wizard_descr_finish)));
int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
textView.setPadding(padding, padding, padding, padding);
textView.setMovementMethod(LinkMovementMethod.getInstance());
layout.addView(textView);
layout.setHeaderText(R.string.app_name);
setContentView(layout);
}
项目:dynamic-dialogs
文件:AboutDialogFragment.java
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
@Nullable Bundle savedInstanceState) {
View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
new LinearLayout(getContext()), false);
TextView message = view.findViewById(R.id.dialog_about_text);
message.setText(Html.fromHtml(getString(R.string.about_content)
.replace("\n", "<br/>")));
message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
message.setLineSpacing(0f, 1.2f);
message.setMovementMethod(LinkMovementMethod.getInstance());
message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
alertDialog.setView(view);
return alertDialog;
}
项目:2017.2-codigo
文件:GestureDetectorActivity.java
private Spanned formatSingleMotionEvent(String event, MotionEvent me) {
StringBuilder sb = new StringBuilder();
sb.append("<h2>");sb.append(event);sb.append("</h2>");
sb.append("<p>");
sb.append("<b>X:</b> ");sb.append(me.getX());
sb.append("</p>");
sb.append("<p>");
sb.append("<b>Y:</b> ");sb.append(me.getY());
sb.append("</p>");
sb.append("<p>");
sb.append("<b>Pressure:</b> ");sb.append(me.getPressure());
sb.append("</p>");
//me.get...
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Html.fromHtml(sb.toString(),Html.FROM_HTML_MODE_LEGACY);
}
else {
return Html.fromHtml(sb.toString());
}
}
项目:FirebasePost
文件:NotifactionUtil.java
private void showBigNotification(Bitmap bitmap, NotificationCompat.Builder mBuilder, int icon, String title, String message, String timeStamp, PendingIntent resultPendingIntent, Uri alarmSound) {
NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
bigPictureStyle.setBigContentTitle(title);
bigPictureStyle.setSummaryText(Html.fromHtml(message).toString());
bigPictureStyle.bigPicture(bitmap);
Notification notification;
notification = mBuilder.setSmallIcon(icon).setTicker(title).setWhen(0)
.setAutoCancel(true)
.setContentTitle(title)
.setContentIntent(resultPendingIntent)
.setSound(alarmSound)
.setStyle(bigPictureStyle)
.setWhen(getTimeMilliSec(timeStamp))
.setSmallIcon(R.drawable.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(mContext.getResources(), icon))
.setContentText(message)
.build();
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(AppPrefs.NOTIFICATION_ID_BIG_IMAGE, notification);
}
项目:JsoupSample
文件:K567ListFragment.java
@Override
protected void initActivityCreated() {
if (!isPrepared || !isVisible || isLoad) {
return;
}
mAdapter = new XRecyclerViewAdapter<>();
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
recyclerView.setLoadingMore(this);
recyclerView.setAdapter(
mAdapter.setLayoutId(R.layout.item_k567)
.onXBind((holder, position, movieModel) -> {
holder.setTextView(R.id.k567_item_tv, Html.fromHtml(movieModel.title));
ImageLoaderUtils.display(holder.getImageView(R.id.k567_item_iv), movieModel.url);
})
.setOnItemClickListener((view, position, info) -> K567DetailActivity.startIntent(info.title, info.detailUrl, info.url))
);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.post(this::onRefresh);
setLoad();
}
项目:MiPushFramework
文件:StartFailFAQActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!WizardSPUtils.shouldShowWizard(this)) {
startActivity (new Intent(this,
MainActivity.class));
finish();
return;
}
SetupWizardLayout layout = new SetupWizardLayout(this);
layout.getNavigationBar()
.setNavigationBarListener(this);
TextView textView = new TextView(this);
textView.setText(Html.fromHtml(getString(R.string.service_not_running_faq)));
int padding = (int) getResources().getDimension(R.dimen.suw_glif_margin_sides);
textView.setPadding(padding, padding, padding, padding);
textView.setMovementMethod(LinkMovementMethod.getInstance());
layout.addView(textView);
layout.setHeaderText(R.string.wizard_title_start_fail);
layout.getNavigationBar().getNextButton().setVisibility(View.GONE);
setContentView(layout);
}
项目:RoadLab-Pro
文件:NavigationDrawerFragment.java
public void setCurrentProject(FolderModel folder) {
String projectNameStr = "";
double distance = 0;
double pathDistance = 0;
if (folder != null) {
distance = folder.getOverallDistance();
pathDistance = folder.getPathDistance();
projectNameStr = folder.getName();
} else {
projectNameStr = getString(R.string.none_text);
}
if (projectName != null) {
projectName.setText(projectNameStr);
}
if (overallDistance != null) {
String distanceStr = DistanceUtil.getDistanceString(getContext(), distance);
String pathDistanceStr = pathDistance == 0 ?
getString(R.string.overall_path_distance_none) :
DistanceUtil.getDistanceString(getContext(), pathDistance);
String overallDistanceStr = getString(R.string.overall_distance_text, distanceStr, pathDistanceStr);
overallDistance.setText(Html.fromHtml(overallDistanceStr));
}
}
项目:Trinity-App
文件:WelcomeActivity.java
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
项目:android-backup-codelab
文件:PrefUtils.java
static Spanned getDebugText(@NonNull Context context) {
StringBuilder sb = new StringBuilder();
sb.append("<b>SHARED PREFS DEBUG:<br></b>");
sb.append(ACCOUNT_NAME_HINT);
sb.append(": <i>");
sb.append(PrefUtils.getLoginHint(context));
sb.append("</i><br>\n");
sb.append(ACCOUNT_NAME);
sb.append(": <i>");
sb.append(PrefUtils.getLoginAccount(context));
sb.append("</i><br>\n");
sb.append(ACCOUNT_AUTH_KEY);
sb.append(": <i>");
sb.append(PrefUtils.getLoginAuthKey(context));
sb.append("</i><br>\n");
return Html.fromHtml(sb.toString());
}
项目:android-backup-codelab
文件:PrefUtils.java
static Spanned getDebugText(@NonNull Context context) {
StringBuilder sb = new StringBuilder();
sb.append("<b>SHARED PREFS DEBUG:<br></b>");
sb.append(ACCOUNT_NAME_HINT);
sb.append(": <i>");
sb.append(PrefUtils.getLoginHint(context));
sb.append("</i><br>\n");
sb.append(ACCOUNT_NAME);
sb.append(": <i>");
sb.append(PrefUtils.getLoginAccount(context));
sb.append("</i><br>\n");
sb.append(ACCOUNT_AUTH_KEY);
sb.append(": <i>");
sb.append(PrefUtils.getLoginAuthKey(context));
sb.append("</i><br>\n");
return Html.fromHtml(sb.toString());
}
项目:FileCrypt
文件:WelcomeActivity.java
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
项目:R-a-dio-Amazing-Android-App
文件:ActivityMain.java
public void setNewsUI(String jsonString) throws JSONException {
JSONArray newsjson = new JSONArray(jsonString);
View news_view = viewPager.getChildAt(2);
if(news_view != null) {
TextView newst1 = (TextView) news_view.findViewById(R.id.news_title1);
TextView newst2 = (TextView) news_view.findViewById(R.id.news_title2);
TextView newst3 = (TextView) news_view.findViewById(R.id.news_title3);
newst1.setText(newsjson.getJSONObject(0).getString("title"));
newst2.setText(newsjson.getJSONObject(1).getString("title"));
newst3.setText(newsjson.getJSONObject(2).getString("title"));
TextView news1 = (TextView) news_view.findViewById(R.id.news1);
TextView news2 = (TextView) news_view.findViewById(R.id.news2);
TextView news3 = (TextView) news_view.findViewById(R.id.news3);
news1.setText(Html.fromHtml((newsjson.getJSONObject(0).getString("text"))));
news1.setMovementMethod(LinkMovementMethod.getInstance());
news2.setText(Html.fromHtml((newsjson.getJSONObject(1).getString("text"))));
news2.setMovementMethod(LinkMovementMethod.getInstance());
news3.setText(Html.fromHtml((newsjson.getJSONObject(2).getString("text"))));
news3.setMovementMethod(LinkMovementMethod.getInstance());
newsSet = true;
}
}
项目:CryptoSasa
文件:AboutActivity.java
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
ActionBar ab = getSupportActionBar();
ab.setTitle(Html.fromHtml("<font color=#ffffff>" + getString(R.string.app_name) + "</font>"));
//ab.setIcon(getResources().getDrawable(R.drawable.ic_action_back)); white back button
if(ab != null) {
ab.setDisplayHomeAsUpEnabled(true);
}
View mainContent = findViewById(R.id.main_content);
if (mainContent != null) {
mainContent.setAlpha(0);
mainContent.animate().alpha(1).setDuration(2000);
}
((TextView)findViewById(R.id.authorLinkedin)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView)findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView)findViewById(R.id.apiURL)).setMovementMethod(LinkMovementMethod.getInstance());
((TextView)findViewById(R.id.textFieldVersionName)).setText(BuildConfig.VERSION_NAME);
overridePendingTransition(0, 0);
}
项目:anitrend-app
文件:SplashPresenter.java
public void requestAppReset() {
new DialogManager(mContext).createDialogMessage("Authentication Error", Html.fromHtml(mContext.getString(R.string.app_splash_authenticating_message)),
mContext.getString(R.string.Yes), mContext.getString(R.string.No), new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
switch (which) {
case POSITIVE:
makeAlerterInfo("Application has been reset!");
ServiceGenerator.authStateChange(mContext);
new ApplicationPrefs(mContext).setUserDeactivated();
mContext.onRefresh();
break;
case NEGATIVE:
dialog.dismiss();
break;
}
}
});
}
项目:Hillffair17
文件:AppIntro.java
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
;
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
项目:EsperantoRadio
文件:Hentede_udsendelser_frag.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rod = inflater.inflate(R.layout.hentede_udsendelser_frag, container, false);
aq = new AQuery(rod);
listView = aq.id(R.id.listView).adapter(adapter).itemClicked(this).getListView();
View emptyView = aq.id(R.id.tom).typeface(App.skrift_gibson)
.text(Html.fromHtml(getString(R.string.Du_har_ingen_downloads___)))
.getView();
listView.setEmptyView(emptyView);
listView.setCacheColorHint(Color.WHITE);
aq.id(R.id.overskrift).typeface(App.skrift_gibson_fed).text(R.string.Downloadede_udsendelser).getTextView();
aq.id(R.id.supplerende_info).typeface(App.skrift_gibson).clicked(this);
hentedeUdsendelser.observatører.add(this);
run();
return rod;
}
项目:pokequest
文件:HomeActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
ButterKnife.bind(this);
mTvAppLogo.setText(Html.fromHtml(getString(R.string.app_name_html)));
mBtnPokeDict.setEnabled(false);
mBtnPokeQuiz.setEnabled(false);
mBtnPokeDict.setAlpha(0f);
mBtnPokeQuiz.setAlpha(0f);
activityComponent().inject(this);
//loadPokemons();
setupAnimation();
}
项目:IntroApp
文件:WelcomeActivity.java
private void addBottomDots(int currentPage) {
dots = new TextView[layouts.length];
int[] colorsActive = getResources().getIntArray(R.array.array_dot_active);
int[] colorsInactive = getResources().getIntArray(R.array.array_dot_inactive);
dotsLayout.removeAllViews();
for (int i = 0; i < dots.length; i++) {
dots[i] = new TextView(this);
dots[i].setText(Html.fromHtml("•"));
dots[i].setTextSize(35);
dots[i].setTextColor(colorsInactive[currentPage]);
dotsLayout.addView(dots[i]);
}
if (dots.length > 0)
dots[currentPage].setTextColor(colorsActive[currentPage]);
}
项目:AndroidIRCLogViewer
文件:MainActivity.java
private void appendFormatted(final StringBuilder formattedText, final String line) {
final Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
final String user = matcher.group(2);
final String color = "#" + Integer.toHexString(user.hashCode()).substring(0, 6);
final String message = matcher.group(3);
if (nickname != null && message.contains(nickname)) {
formattedText.append("<b>");
}
formattedText.append(matcher.group(1))
.append("<font color=\"").append(color).append("\"> ").append(user).append(": </font>")
.append(Html.escapeHtml(message));
if (nickname != null && message.contains(nickname)) {
formattedText.append("</b>");
}
} else {
formattedText.append("<font color=\"#cccccc\">").append(Html.escapeHtml(line)).append("</font>");
}
formattedText.append("<br/>");
}
项目:diycode
文件:TopicReplyAdapter.java
/**
* 在此处处理数据
*
* @param position 位置
* @param holder view holder
* @param bean 数据
*/
@Override public void convert(int position, RecyclerViewHolder holder, TopicReply bean) {
final User user = bean.getUser();
holder.setText(R.id.username, user.getLogin());
holder.setText(R.id.time, TimeUtil.computePastTime(bean.getUpdated_at()));
ImageView avatar = holder.get(R.id.avatar);
ImageUtils.loadImage(mContext, user.getAvatar_url(), avatar);
TextView content = holder.get(R.id.content);
// TODO 评论区代码问题
content.setText(Html.fromHtml(HtmlUtil.removeP(bean.getBody_html()), new GlideImageGetter(mContext, content), null));
holder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, UserActivity.class);
intent.putExtra(UserActivity.USER, user);
mContext.startActivity(intent);
}
}, R.id.avatar, R.id.username);
}
项目:starcraft-2-build-player
文件:PreviewNotesDialog.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_preview_notes);
this.setTitle(R.string.dlg_preview_notes_title);
if (getIntent().getExtras().containsKey(KEY_NOTES_HTML)) {
String source = getIntent().getExtras().getString(KEY_NOTES_HTML);
TextView notes = (TextView) findViewById(R.id.notesPreviewText);
notes.setText(Html.fromHtml(source));
notes.setMovementMethod(LinkMovementMethod.getInstance()); // makes links clickable
}
Button okBtn = (Button) findViewById(R.id.okButton);
okBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PreviewNotesDialog.this.finish();
}
});
}
项目:anitrend-app
文件:Rank.java
public Spanned getType_string() {
if(year == 0)
if(season != null)
return Html.fromHtml(String.format(Locale.getDefault(), "<b>#%d %s <small>%s<small/></b> <small>(%s)</small>", rank, type_string.toUpperCase(), season.toUpperCase(), format));
else
return Html.fromHtml(String.format(Locale.getDefault(), "<b>#%d %s</b> <small>(%s)</small>", rank, type_string.toUpperCase(), format));
if(season != null)
return Html.fromHtml(String.format(Locale.getDefault(), "<b>#%d %s <small>%s %d</small></b> <small>(%s)</small>", rank, type_string.toUpperCase(), season.toUpperCase(), year, format));
return Html.fromHtml(String.format(Locale.getDefault(), "<b>#%d %s <small>%d</small></b> <small>(%s)</small>", rank, type_string.toUpperCase(), year, format));
}
项目:Customerly-Android-SDK
文件:IAct_FullScreenImage.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(this.getIntent() != null) {
this._SourceUrl = this.getIntent().getStringExtra(EXTRA_IMAGE_SOURCE);
if(this._SourceUrl != null) {
ImageView _ImageView = new TouchImageView(this);
_ImageView.setBackgroundColor(Color.WHITE);
_ImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
_ImageView.setAdjustViewBounds(true);
try {
Customerly.get()._RemoteImageHandler.request(new IU_RemoteImageHandler.Request()
.fitCenter()
.load(this._SourceUrl)
.into(this, _ImageView)
.placeholder(R.drawable.io_customerly__pic_placeholder_fullscreen));
super.setContentView(_ImageView);
final ActionBar actionBar = this.getSupportActionBar();
if (actionBar != null) {
String title;
if(Customerly.get().__PING__LAST_widget_color != 0) {
actionBar.setBackgroundDrawable(new ColorDrawable(Customerly.get().__PING__LAST_widget_color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.getWindow().setStatusBarColor(IU_Utils.alterColor(Customerly.get().__PING__LAST_widget_color, 0.8f));
}
if (IU_Utils.getContrastColor(Customerly.get().__PING__LAST_widget_color) == Color.BLACK) {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_black_24dp);
title = String.format("<font color='#000000'>%1$s</font>", actionBar.getTitle());
} else {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_white_24dp);
title = String.format("<font color='#ffffff'>%1$s</font>", actionBar.getTitle());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
actionBar.setTitle(Html.fromHtml(title, 0));
} else {
//noinspection deprecation
actionBar.setTitle(Html.fromHtml(title));
}
}
actionBar.setDisplayHomeAsUpEnabled(true);
}
return;
} catch (Exception glideException) {
IEr_CustomerlyErrorHandler.sendError(IEr_CustomerlyErrorHandler.ERROR_CODE__GLIDE_ERROR, "Error during Glide loading in FullScreenImage_Activity", glideException);
}
}
}
this.finish();
}
项目:Anagram
文件:AnagramsActivity.java
public boolean defaultAction(View view) {
TextView gameStatus = (TextView) findViewById(R.id.gameStatusView);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
EditText editText = (EditText) findViewById(R.id.editText);
TextView resultView = (TextView) findViewById(R.id.resultView);
if (currentWord != null) {
currentWord = dictionary.pickGoodStarterWord();
anagrams = dictionary.getAnagrams(currentWord);
gameStatus.setText(Html.fromHtml(String.format(START_MESSAGE, currentWord.toUpperCase(), currentWord)));
fab.setImageResource(android.R.drawable.ic_menu_help);
fab.hide();
resultView.setText("");
editText.setText("");
editText.setEnabled(true);
editText.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
} else {
editText.setText(currentWord);
editText.setEnabled(false);
fab.setImageResource(android.R.drawable.ic_media_play);
currentWord = null;
resultView.append(TextUtils.join("\n", anagrams));
gameStatus.append(" Hit 'Play' to start again");
}
return true;
}
项目:Camera-Roll-Android-App
文件:AlbumHolder.java
public void setAlbum(Album album) {
if (album == null) {
//Error album
album = MediaProvider.getErrorAlbum();
}
this.album = album;
TextView nameTv = itemView.findViewById(R.id.name);
nameTv.setText(album.getName());
//to fix ellipsize
nameTv.requestLayout();
//pinned indicator
/*Drawable pinIndicator = null;
if (album.pinned) {
pinIndicator = AppCompatResources
.getDrawable(getContext(), R.drawable.pin_indicator);
if (pinIndicator != null) {
int color = nameTv.getTextColors().getDefaultColor();
DrawableCompat.wrap(pinIndicator);
DrawableCompat.setTint(pinIndicator, color);
DrawableCompat.unwrap(pinIndicator);
}
}
nameTv.setCompoundDrawablesRelativeWithIntrinsicBounds(
null, null, pinIndicator, null);*/
//set album itemCount
int itemCount = album.getAlbumItems().size();
boolean oneItem = itemCount == 1;
String count = getContext().getString(oneItem ?
R.string.item_count : R.string.items_count, itemCount);
((TextView) itemView.findViewById(R.id.count)).setText(Html.fromHtml(count));
ImageView hiddenFolderIndicator = itemView.findViewById(R.id.hidden_folder_indicator);
if (hiddenFolderIndicator != null) {
hiddenFolderIndicator
.setVisibility(album.isHidden() ? View.VISIBLE : View.GONE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !(album instanceof VirtualAlbum)) {
ImageView removableStorageIndicator = itemView.findViewById(R.id.removable_storage_indicator);
if (removableStorageIndicator != null) {
try {
boolean removable = Environment
.isExternalStorageRemovable(new File(album.getPath()));
removableStorageIndicator
.setVisibility(removable ? View.VISIBLE : View.GONE);
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
}
项目:hsv-alpha-color-picker
文件:NonDeveloperMessage.java
private static void showMessage(Context context) {
final Spanned message = Html.fromHtml(MESSAGE);
final AlertDialog d = new AlertDialog.Builder(context)
.setTitle(TITLE)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.create();
d.show();
((TextView)d.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
项目:VelocityCalculator
文件:ShowTranslationsActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_translations);
try {
getSupportActionBar().setTitle(getString(R.string.about_translations));
}catch(NullPointerException e) {
e.printStackTrace();
}
TextView textView = (TextView)findViewById(R.id.textView2);
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setText(Html.fromHtml(getString(R.string.html_translations)));
}
项目:anitrend-app
文件:MainActivity.java
@Override
public void onNormalStart() {
AppVersionTracking remote = mPresenter.getAppPrefs().getRepoVersions();
if(remote.checkAgainstCurrent()) {
// there is a new version of getRepoVersions()
app_update.setText(Html.fromHtml(getString(R.string.app_update, remote.getVersion())));
app_update.setVisibility(View.VISIBLE);
}
}
项目:darryncampbell-cordova-plugin-intent
文件:IntentShim.java
private void startActivity(String action, Uri uri, String type, Map<String, String> extras, boolean bExpectResult, int requestCode, CallbackContext callbackContext) {
// Credit: https://github.com/chrisekelley/cordova-webintent
Intent i = (uri != null ? new Intent(action, uri) : new Intent(action));
if (type != null && uri != null) {
i.setDataAndType(uri, type); //Fix the crash problem with android 2.3.6
} else {
if (type != null) {
i.setType(type);
}
if (uri != null)
{
i.setData(uri);
}
}
for (String key : extras.keySet()) {
String value = extras.get(key);
// If type is text html, the extra text must sent as HTML
if (key.equals(Intent.EXTRA_TEXT) && type.equals("text/html")) {
i.putExtra(key, Html.fromHtml(value));
} else if (key.equals(Intent.EXTRA_STREAM)) {
// allowes sharing of images as attachments.
// value in this case should be a URI of a file
final CordovaResourceApi resourceApi = webView.getResourceApi();
i.putExtra(key, resourceApi.remapUri(Uri.parse(value)));
} else if (key.equals(Intent.EXTRA_EMAIL)) {
// allows to add the email address of the receiver
i.putExtra(Intent.EXTRA_EMAIL, new String[] { value });
} else {
i.putExtra(key, value);
}
}
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (i.resolveActivityInfo(this.cordova.getActivity().getPackageManager(), 0) != null)
{
if (bExpectResult)
{
cordova.setActivityResultCallback(this);
((CordovaActivity) this.cordova.getActivity()).startActivityForResult(i, requestCode);
}
else
{
((CordovaActivity)this.cordova.getActivity()).startActivity(i);
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK));
}
}
else
{
// Return an error as there is no app to handle this intent
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR));
}
}
项目:postixdroid
文件:MainActivity.java
private void asset_dialog(@RawRes int htmlRes, @StringRes int title) {
final View view = LayoutInflater.from(this).inflate(R.layout.dialog_about, null, false);
final AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(title)
.setView(view)
.setPositiveButton(R.string.dismiss, null)
.create();
TextView textView = (TextView) view.findViewById(R.id.aboutText);
String text = "";
StringBuilder builder = new StringBuilder();
InputStream fis;
try {
fis = getResources().openRawResource(htmlRes);
BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "utf-8"));
String line;
while ((line = reader.readLine()) != null) {
builder.append(line);
}
text = builder.toString();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
textView.setText(Html.fromHtml(text));
textView.setMovementMethod(LinkMovementMethod.getInstance());
dialog.show();
}
项目:BBSSDK-for-Android
文件:PageEditSignature.java
@Override
protected void onViewCreated(View contentView) {
titleBar.setLeftImageResource(getDrawableId("bbs_titlebar_back_black"));
titleBar.setTitle(getStringRes("theme0_pageeditsignature_title"));
editTextSignature = (EditText) contentView.findViewById(getIdRes("editTextSignature"));
editTextSignature.setText(strSig == null ? "" : Html.fromHtml(strSig));
}
项目:CSI-KJSCEOfficial
文件:EventDetailsActivity.java
@Override
protected void onResume() {
super.onResume();
fbIcon.setOnClickListener(this);
instaIcon.setOnClickListener(this);
whatsappIcon.setOnClickListener(this);
shareIcon.setOnClickListener(this);
Intent intent = getIntent();
event = intent.getParcelableExtra("Event");
FloatingActionButton fab = findViewById(R.id.fab);
if(!URLUtil.isValidUrl(event.getRegister())){
fab.setVisibility(View.GONE);
} else fab.setOnClickListener(this);
eventDate = findViewById(R.id.event_date_textview);
eventDescrip = findViewById(R.id.eventdetails_textview);
eventImage = findViewById(R.id.Event_imageview);
eventTitle = findViewById(R.id.event_title_textview);
eventCategory = findViewById(R.id.category_tag);
eventAudience = findViewById(R.id.audience_tag);
toolbar.setTitle(event.getTitle());
eventTitle.setText(event.getTitle());
eventDate.setText(event.getEventdt());
eventDescrip.setText(Html.fromHtml(event.getDesc()));
eventCategory.setText(event.getCategory());
eventAudience.setText(event.getAudience());
Glide.with(this)
.load(event.getImg_url())
.into(eventImage);
}
项目:utils-android
文件:FontUtils.java
/**
* Показывает текст HTML в TextView, соблюдая совместимость с разными версиями Android
*
* @param textView необходимый TextView
* @param text текст в виде HTML
*/
public static void htmlCompat(@Nullable TextView textView, @Nullable String text) {
if (textView != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
//noinspection deprecation
textView.setText(Html.fromHtml(text));
} else {
textView.setText((Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY)));
}
}
}