List of usage examples for android.widget TextView setMovementMethod
public final void setMovementMethod(MovementMethod movement)
From source file:com.timothy.android.api.fragment.PageFragment.java
public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) { Log.i(LOG_TAG, "setAllComponent()..."); for (HtmlCleanAPI.HtmlContent hc : hcList) { String tag = hc.getTag(); String content = hc.getContent(); String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(StringUtil.mergeBlank(content))); String contentRSpecial = StringUtil.rmvSpecial(contentRBlank); if (StringUtil.isEmpty(content) || StringUtil.isEmpty(contentRBlank) || StringUtil.isEmpty(contentRSpecial)) { continue; }/* w w w . j ava 2 s. com*/ Log.i(LOG_TAG, "tag:" + tag); Log.i(LOG_TAG, "content:" + content); if (tag.equalsIgnoreCase("P")) { final TextView tagPTV = new TextView(mContext); tagPTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagPTV.setLayoutParams(lp); tagPTV.setPadding(3, 3, 3, 3); tagPTV.setPaddingRelative(3, 3, 3, 3); tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPTV.setTextColor(Color.BLACK); tagPTV.setText(contentRSpecial); tagPTV.setTextSize(TEXT_SIZE); tagPTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPTV.getText().toString()); return false; } }); lineLayout.addView(tagPTV); } else if (tag.equalsIgnoreCase("pre")) { final TextView tagPre = new TextView(mContext); tagPre.setBackgroundColor(Color.parseColor("#D2EADE")); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagPre.setLayoutParams(lp); tagPre.setPadding(2, 2, 2, 2); tagPre.setPaddingRelative(2, 2, 2, 2); tagPre.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPre.setTextColor(Color.BLACK); // String contentRSpecial = StringUtil.rmvSpecial(content); tagPre.setText(StringUtil.rmvSpecial(content)); tagPre.setTextSize(TEXT_SIZE); tagPre.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPre.getText().toString()); return false; } }); lineLayout.addView(tagPre); } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2") || tag.equalsIgnoreCase("H3")) {//title TextView tagDtHTV = new TextView(mContext); tagDtHTV.setBackgroundColor(Color.DKGRAY); tagDtHTV.setTypeface(null, Typeface.BOLD); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 0, 2, 0); tagDtHTV.setLayoutParams(lp); tagDtHTV.setPadding(2, 2, 2, 2); tagDtHTV.setPaddingRelative(2, 2, 2, 2); tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDtHTV.setTextColor(Color.WHITE); tagDtHTV.setText(contentRSpecial); tagDtHTV.setTextSize(TEXT_SIZE); lineLayout.addView(tagDtHTV); } else if (tag.equalsIgnoreCase("dd")) { final TextView tagDD = new TextView(mContext); tagDD.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagDD.setLayoutParams(lp); tagDD.setPadding(3, 3, 3, 3); tagDD.setPaddingRelative(3, 3, 3, 3); tagDD.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDD.setTextColor(Color.BLACK); tagDD.setText(contentRSpecial); tagDD.setTextSize(TEXT_SIZE); tagDD.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagDD.getText().toString()); return false; } }); lineLayout.addView(tagDD); } else if (tag.equalsIgnoreCase("li")) { final TextView tagLigTV = new TextView(mContext); tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagLigTV.setLayoutParams(lp); tagLigTV.setPaddingRelative(2, 2, 2, 2); tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagLigTV.setTextColor(Color.BLACK); tagLigTV.setText(contentRSpecial); tagLigTV.setTextSize(TEXT_SIZE); tagLigTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagLigTV.getText().toString()); return false; } }); lineLayout.addView(tagLigTV); } else if (tag.equalsIgnoreCase("img")) { final TextView imgTV = new TextView(mContext); imgTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); imgTV.setLayoutParams(lp); imgTV.setPaddingRelative(2, 2, 2, 2); imgTV.setMovementMethod(ScrollingMovementMethod.getInstance()); imgTV.setTextColor(Color.BLACK); imgTV.setText(content); imgTV.setTextSize(TEXT_SIZE); imgTV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView tv = (TextView) v; String path = tv.getText().toString(); if (path != null && path.trim().length() > 0) { openDialog2(path); } } }); lineLayout.addView(imgTV); } } }
From source file:org.catnut.plugin.zhihu.ZhihuItemFragment.java
@Override public void onViewCreated(final View view, final Bundle savedInstanceState) { final TextView title = (TextView) view.findViewById(android.R.id.title); final TextView author = (TextView) view.findViewById(R.id.author); final TextView lastAlterDate = (TextView) view.findViewById(R.id.last_alter_date); registerForContextMenu(title);// ww w .j a v a2 s . c o m title.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getActivity().openContextMenu(title); } }); (new Thread(new Runnable() { @Override public void run() { Cursor cursor = getActivity().getContentResolver().query(CatnutProvider.parse(Zhihu.MULTIPLE), PROJECTION, Zhihu.ANSWER_ID + "=" + mAnswerId, null, null); if (cursor.moveToNext()) { mQuestionId = cursor.getLong(cursor.getColumnIndex(Zhihu.QUESTION_ID)); final String _title = cursor.getString(cursor.getColumnIndex(Zhihu.TITLE)); final String _question = cursor.getString(cursor.getColumnIndex(Zhihu.DESCRIPTION)); final String _nick = cursor.getString(cursor.getColumnIndex(Zhihu.NICK)); final String _content = cursor.getString(cursor.getColumnIndex(Zhihu.ANSWER)); final long _lastAlterDate = cursor.getLong(cursor.getColumnIndex(Zhihu.LAST_ALTER_DATE)); cursor.close(); // answer Matcher matcher = HTML_IMG.matcher(_content); final List<String> contentSegment = new ArrayList<String>(); processText(_content, matcher, contentSegment); // question matcher = HTML_IMG.matcher(_question); final List<String> questionSegment = new ArrayList<String>(); processText(_question, matcher, questionSegment); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { title.setText(_title); getActivity().getActionBar().setSubtitle(_title); // ??? int l = contentSegment.size() > 1 ? contentSegment.size() >> 1 : 0; l += questionSegment.size() > 1 ? questionSegment.size() >> 1 : 0; if (l > 0) { mImageUrls = new ArrayList<Uri>(l); } // ? boolean useCachedImg = CatnutApp.getBoolean(R.string.pref_enable_cache_zhihu_images, R.bool.default_plugin_status); l = 0; // reset for reuse String text; int screenWidth = CatnutUtils.getScreenWidth(getActivity()); int max = getActivity().getResources().getDimensionPixelSize(R.dimen.max_thumb_width); if (screenWidth > max) { screenWidth = max; } LayoutInflater inflater = LayoutInflater.from(getActivity()); if (!TextUtils.isEmpty(_question)) { ViewGroup questionHolder = (ViewGroup) view.findViewById(R.id.question); for (int i = 0; i < questionSegment.size(); i++) { text = questionSegment.get(i); if (!TextUtils.isEmpty(text)) { if ((i & 1) == 0) { TextView section = (TextView) inflater.inflate(R.layout.zhihu_text, null); section.setTextSize(16); section.setTextColor( getResources().getColor(R.color.black50PercentColor)); section.setText(Html.fromHtml(text)); section.setMovementMethod(LinkMovementMethod.getInstance()); CatnutUtils.removeLinkUnderline(section); questionHolder.addView(section); } else { ImageView imageView = getImageView(); Uri uri = useCachedImg ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text)) : Uri.parse(text); Picasso.with(getActivity()).load(uri).centerCrop() .resize(screenWidth, (int) (Constants.GOLDEN_RATIO * screenWidth)) .error(R.drawable.error).into(imageView); imageView.setTag(l++); // for click imageView.setOnClickListener(ZhihuItemFragment.this); mImageUrls.add(uri); questionHolder.addView(imageView); } } } } Typeface typeface = CatnutUtils.getTypeface(CatnutApp.getTingtingApp().getPreferences(), getString(R.string.pref_customize_tweet_font), getString(R.string.default_typeface)); ViewGroup answerHolder = (ViewGroup) view.findViewById(R.id.answer); for (int i = 0; i < contentSegment.size(); i++) { text = contentSegment.get(i); if (!TextUtils.isEmpty(text)) { if ((i & 1) == 0) { TextView section = (TextView) inflater.inflate(R.layout.zhihu_text, null); section.setText(Html.fromHtml(text)); CatnutUtils.setTypeface(section, typeface); CatnutUtils.removeLinkUnderline(section); section.setMovementMethod(LinkMovementMethod.getInstance()); answerHolder.addView(section); } else { ImageView image = getImageView(); Uri uri = useCachedImg ? Zhihu.getCacheImageLocation(getActivity(), Uri.parse(text)) : Uri.parse(text); Picasso.with(getActivity()).load(uri).centerCrop() .resize(screenWidth, (int) (Constants.GOLDEN_RATIO * screenWidth)) .error(R.drawable.error).into(image); image.setTag(l++); // image.setOnClickListener(ZhihuItemFragment.this); mImageUrls.add(uri); answerHolder.addView(image); } } } author.setText(_nick); lastAlterDate.setText(DateUtils.getRelativeTimeSpanString(_lastAlterDate)); if (mSwipeRefreshLayout != null) { mSwipeRefreshLayout.setRefreshing(false); } } }); } else { cursor.close(); } } })).start(); }
From source file:org.anhonesteffort.flock.SelectServiceProviderFragment.java
private void initRadioButtons(View fragmentView) { final LinearLayout rowSelectOws = (LinearLayout) fragmentView.findViewById(R.id.row_service_ows); final LinearLayout rowSelectOther = (LinearLayout) fragmentView.findViewById(R.id.row_service_other); final RadioButton radioButtonOws = (RadioButton) fragmentView.findViewById(R.id.radio_button_service_ows); final RadioButton radioButtonOther = (RadioButton) fragmentView .findViewById(R.id.radio_button_service_other); final TextView serviceDescription = (TextView) fragmentView.findViewById(R.id.sync_service_description); final Double costPerYearUsd = (double) getResources().getInteger(R.integer.cost_per_year_usd); rowSelectOws.setOnClickListener(new View.OnClickListener() { @Override/* ww w . jav a 2 s. co m*/ public void onClick(View view) { if (!radioButtonOws.isChecked()) { radioButtonOws.setChecked(true); radioButtonOther.setChecked(false); serviceDescription.setText(Html.fromHtml( getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd))); serviceDescription.setMovementMethod(LinkMovementMethod.getInstance()); } } }); rowSelectOther.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (!radioButtonOther.isChecked()) { radioButtonOther.setChecked(true); radioButtonOws.setChecked(false); serviceDescription .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server); } } }); radioButtonOws.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (isChecked) { radioButtonOws.setChecked(true); radioButtonOther.setChecked(false); serviceDescription.setText(Html.fromHtml( getString(R.string.flock_sync_is_a_service_run_by_open_whisper_systems_available, costPerYearUsd))); serviceDescription.setMovementMethod(LinkMovementMethod.getInstance()); } } }); radioButtonOther.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { if (isChecked) { radioButtonOther.setChecked(true); radioButtonOws.setChecked(false); serviceDescription .setText(R.string.you_may_chose_to_run_and_configure_your_own_webdav_compliant_server); } } }); }
From source file:com.teraim.fieldapp.ui.LoginConsoleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_login_console, container, false); TextView versionTxt;//from w w w . j a v a 2 s .c om Log.e("vortex", "oncreatevieww!"); TextView log = view.findViewById(R.id.logger); versionTxt = view.findViewById(R.id.versionTxt); final ImageView logo = view.findViewById(R.id.logo); final ImageView bg = view.findViewById(R.id.bgImg); appTxt = view.findViewById(R.id.appTxt); //Typeface type=Typeface.createFromAsset(getActivity().getAssets(), // "clacon.ttf"); //log.setTypeface(type); log.setMovementMethod(new ScrollingMovementMethod()); versionTxt.setText("Field Pad ver. " + Constants.VORTEX_VERSION); //Create global state globalPh = new PersistenceHelper(getActivity().getApplicationContext() .getSharedPreferences(Constants.GLOBAL_PREFS, Context.MODE_PRIVATE)); debugConsole = Start.singleton.getLogger(); //Send a signal that init starts //First time vortex runs? Then create global folders. if (this.initIfFirstTime()) { if (!Connectivity.isConnected(getActivity())) { showErrorMsg( "You need a network connection first time you start the program. Vortex requires configuration files to run."); return view; } else { this.initialize(); } } //First time this application runs? Then create config folder. if (!new File(Constants.VORTEX_ROOT_DIR + bundleName).isDirectory()) { Log.d("vortex", "First time execution!"); debugConsole.addRow(""); debugConsole.addPurpleText("First time execution of App " + bundleName); } //else // Log.d("vortex","This application has been executed before."); //TODO: Move this code into above in next release. File folder = new File(Constants.VORTEX_ROOT_DIR + bundleName); folder = new File(Constants.VORTEX_ROOT_DIR + bundleName + "/config"); folder = new File(Constants.VORTEX_ROOT_DIR + bundleName + "/cache"); //write down version..quickly! :) globalPh.put(PersistenceHelper.CURRENT_VERSION_OF_PROGRAM, Constants.VORTEX_VERSION); bundleName = globalPh.get(PersistenceHelper.BUNDLE_NAME); if (bundleName == null || bundleName.length() == 0) bundleName = InitialBundleName; ph = new PersistenceHelper(getActivity().getApplicationContext() .getSharedPreferences(globalPh.get(PersistenceHelper.BUNDLE_NAME), Context.MODE_PRIVATE)); oldV = ph.getF(PersistenceHelper.CURRENT_VERSION_OF_APP); appTxt.setText(bundleName + " " + (oldV == -1 ? "" : oldV)); String p_serverURL = globalPh.get(PersistenceHelper.SERVER_URL); String checked_URL = Tools.server(p_serverURL); if (!checked_URL.equals(p_serverURL)) globalPh.put(PersistenceHelper.SERVER_URL, checked_URL); String appBaseUrl = checked_URL + bundleName.toLowerCase() + "/"; final String appRootFolderPath = Constants.VORTEX_ROOT_DIR + globalPh.get(PersistenceHelper.BUNDLE_NAME) + "/"; loginConsole = new PlainLogger(getActivity(), "INITIAL"); loginConsole.setOutputView(log); Tools.onLoadCacheImage(appBaseUrl, "bg_image.jpg", appRootFolderPath + "cache/", new Tools.WebLoaderCb() { @Override public void loaded(Boolean result) { if (result) { Bitmap bm = BitmapFactory.decodeFile(appRootFolderPath + "cache/bg_image.jpg", new BitmapFactory.Options()); if (bm != null) bg.setImageBitmap(bm); } } @Override public void progress(int bytesRead) { } }); Tools.onLoadCacheImage(appBaseUrl, "logo.png", appRootFolderPath + "cache/", new Tools.WebLoaderCb() { @Override public void loaded(Boolean result) { if (result) { Bitmap bm = BitmapFactory.decodeFile(appRootFolderPath + "cache/logo.png", new BitmapFactory.Options()); if (bm != null) logo.setImageBitmap(bm); } } @Override public void progress(int bytesRead) { } }); //Tools.preCacheImage(bgUrl,"logo.png",appRootFolderPath+"cache/",loginConsole); //new DownloadImageTask((ImageView) view.findViewById(R.id.bgImg)) // .execute(bgUrl.toLowerCase()); //create module descriptors for all known configuration files. //Log.d("vortex","Creating Configuration and ModuleLoader"); //Check if configuration should be loaded from server or from file system. if (globalPh.getB("local_config")) myModules = new Configuration(Constants.getCurrentlyKnownModules(ConfigurationModule.Source.file, globalPh, ph, null, bundleName, debugConsole)); else myModules = new Configuration(Constants.getCurrentlyKnownModules(ConfigurationModule.Source.internet, globalPh, ph, globalPh.get(PersistenceHelper.SERVER_URL), bundleName, debugConsole)); String loaderId = "moduleLoader"; boolean allFrozen = ph.getB(PersistenceHelper.ALL_MODULES_FROZEN + loaderId); myLoader = new ModuleLoader(loaderId, myModules, loginConsole, globalPh, allFrozen, debugConsole, this, getActivity()); if (Constants.FreeVersion && expired()) showErrorMsg( "The license has expired. The App still works, but you will not be able to export any data."); return view; }
From source file:com.gh4a.fragment.RepositoryFragment.java
private void fillData() { TextView tvRepoName = (TextView) mContentView.findViewById(R.id.tv_repo_name); SpannableStringBuilder repoName = new SpannableStringBuilder(); repoName.append(mRepository.getOwner().getLogin()); repoName.append("/"); repoName.append(mRepository.getName()); repoName.setSpan(new IntentSpan(tvRepoName.getContext()) { @Override// w w w. j av a 2 s . com protected Intent getIntent() { return IntentUtils.getUserActivityIntent(getActivity(), mRepository.getOwner()); } }, 0, mRepository.getOwner().getLogin().length(), 0); tvRepoName.setText(repoName); tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD); TextView tvParentRepo = (TextView) mContentView.findViewById(R.id.tv_parent); if (mRepository.isFork() && mRepository.getParent() != null) { Repository parent = mRepository.getParent(); tvParentRepo.setVisibility(View.VISIBLE); tvParentRepo.setText( getString(R.string.forked_from, parent.getOwner().getLogin() + "/" + parent.getName())); tvParentRepo.setOnClickListener(this); tvParentRepo.setTag(parent); } else { tvParentRepo.setVisibility(View.GONE); } fillTextView(R.id.tv_desc, 0, mRepository.getDescription()); fillTextView(R.id.tv_language, R.string.repo_language, mRepository.getLanguage()); fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.getHomepage()) ? mRepository.getHomepage() : mRepository.getHtmlUrl()); mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this); mContentView.findViewById(R.id.cell_forks).setOnClickListener(this); mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this); mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this); mContentView.findViewById(R.id.other_info).setOnClickListener(this); mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this); Permissions permissions = mRepository.getPermissions(); updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.hasPushAccess()); updateClickableLabel(R.id.tv_downloads_label, mRepository.isHasDownloads()); updateClickableLabel(R.id.tv_wiki_label, mRepository.isHasWiki()); TextView tvStargazersCount = (TextView) mContentView.findViewById(R.id.tv_stargazers_count); tvStargazersCount.setText(String.valueOf(mRepository.getWatchers())); TextView tvForksCount = (TextView) mContentView.findViewById(R.id.tv_forks_count); tvForksCount.setText(String.valueOf(mRepository.getForks())); LinearLayout llIssues = (LinearLayout) mContentView.findViewById(R.id.cell_issues); if (mRepository.isHasIssues()) { llIssues.setVisibility(View.VISIBLE); llIssues.setOnClickListener(this); // value will be filled when PR count arrives } else { llIssues.setVisibility(View.GONE); } mContentView.findViewById(R.id.tv_private) .setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE); }
From source file:com.andfchat.frontend.activities.ChatScreen.java
@Override public void openAd(Spannable text) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.popup_description, null); int height = (int) (this.height * 0.8f); int width = (int) (this.width * 0.8f); final PopupWindow descriptionPopup = new FListPopupWindow(layout, width, height); descriptionPopup.showAtLocation(frame, Gravity.CENTER, 0, 0); final TextView descriptionText = (TextView) layout.findViewById(R.id.descriptionText); descriptionText.setText(text);//from w w w. j a v a 2 s.co m // Enable touching/clicking links in text descriptionText.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:org.thoughtland.xlocation.ActivityApp.java
@SuppressLint("InflateParams") public static void showHelp(ActivityBase context, View parent, Hook hook) { // Build dialog Dialog dlgHelp = new Dialog(context); dlgHelp.requestWindowFeature(Window.FEATURE_LEFT_ICON); dlgHelp.setTitle(R.string.app_name); dlgHelp.setContentView(R.layout.helpfunc); dlgHelp.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, context.getThemed(R.attr.icon_launcher)); dlgHelp.setCancelable(true);// w w w . j a v a 2 s .co m // Set title TextView tvTitle = (TextView) dlgHelp.findViewById(R.id.tvTitle); tvTitle.setText(hook.getName()); // Set info TextView tvInfo = (TextView) dlgHelp.findViewById(R.id.tvInfo); tvInfo.setText(Html.fromHtml(hook.getAnnotation())); tvInfo.setMovementMethod(LinkMovementMethod.getInstance()); // Set permissions String[] permissions = hook.getPermissions(); if (permissions != null && permissions.length > 0) if (!permissions[0].equals("")) { TextView tvPermissions = (TextView) dlgHelp.findViewById(R.id.tvPermissions); tvPermissions.setText(Html.fromHtml(TextUtils.join("<br />", permissions))); } dlgHelp.show(); }
From source file:eu.iescities.pilot.rovereto.roveretoexplorer.map.InfoDialog.java
@Override public void onStart() { super.onStart(); TextView msg = (TextView) getDialog().findViewById(R.id.mapdialog_msg); if (data instanceof ExplorerObject) { ExplorerObject event = (ExplorerObject) data; String msgText = ""; msgText += "<h2>"; msgText += event.getTitle();//from w ww . j a v a2s .c o m msgText += "</h2><br/><p>"; if (event.getType() != null) { String categoryString = event.categoryString(getActivity()); if (categoryString != null) { msgText += "<p>" + categoryString + "</p><br/>"; } } msgText += "<p>" + event.dateTimeString() + "</p>"; String place = Utils.getEventShortAddress(event); if (place != null) { msgText += "<p>" + place + "</p>"; } msg.setText(Html.fromHtml(msgText)); } msg.setMovementMethod(new ScrollingMovementMethod()); Button b = (Button) getDialog().findViewById(R.id.mapdialog_cancel); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getDialog().dismiss(); } }); b = (Button) getDialog().findViewById(R.id.mapdialog_ok); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager() .beginTransaction(); Bundle args = new Bundle(); if (data instanceof ExplorerObject) { Fragment_EventDetails fragment = new Fragment_EventDetails(); args.putString(Utils.ARG_EVENT_ID, (data.getId())); fragment.setArguments(args); fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); fragmentTransaction.replace(R.id.content_frame, fragment, "me"); fragmentTransaction.addToBackStack(fragment.getTag()); } fragmentTransaction.commit(); getDialog().dismiss(); } }); }
From source file:com.concentricsky.android.khanacademy.app.VideoListActivity.java
private void setParentTopic(Topic topic) { this.topic = topic; if (topic != null) { topicId = topic.getId();// www .ja v a 2 s . c o m // header ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle()); String desc = topic.getDescription(); TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description); if (desc != null && desc.length() > 0) { descView.setText(Html.fromHtml(desc).toString()); descView.setVisibility(View.VISIBLE); descView.setMovementMethod(new ScrollingMovementMethod()); } else { descView.setVisibility(View.GONE); } final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail); if (thumb != null) { new AsyncTask<Void, Void, Bitmap>() { @Override public Bitmap doInBackground(Void... arg) { Bitmap bmp = thumbnailManager.getThumbnail(VideoListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD); return bmp; } @Override public void onPostExecute(Bitmap bmp) { thumb.setImageBitmap(bmp); } }.execute(); } String countFormat; int param; if (isShowingDownloadedVideosOnly()) { countFormat = getString(R.string.format_downloaded_count); param = dataService.getOfflineVideoManager().getDownloadCountForTopic(dataService.getHelper(), topicId, 1); } else { countFormat = getString(R.string.format_video_count); param = topic.getVideo_count(); } ((TextView) headerView.findViewById(R.id.header_video_list_count)) .setText(String.format(countFormat, param)); listView.setAdapter(new VideoAdapter(this)); resetListContents(topic.getId()); } }
From source file:com.timothy.android.api.fragment.PageFragmentNew.java
public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) { Log.i(LOG_TAG, "setAllComponent()..."); for (HtmlCleanAPI.HtmlContent hc : hcList) { String tag = hc.getTag(); String content = hc.getContent(); if (StringUtil.isEmpty(content)) continue; String contentMBlank = StringUtil.mergeBlank(content); if (StringUtil.isEmpty(contentMBlank)) continue; String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(contentMBlank)); if (StringUtil.isEmpty(contentRBlank)) continue; String contentRSpecial = StringUtil.rmvSpecial(contentRBlank); if (StringUtil.isEmpty(contentRSpecial)) continue; Log.i(LOG_TAG, "tag:" + tag); Log.i(LOG_TAG, "content:" + contentRSpecial); if (tag.equalsIgnoreCase("P")) { final TextView tagPTV = new TextView(mContext); tagPTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 3, 2, 3);/*from ww w . j a va 2 s .c om*/ tagPTV.setLayoutParams(lp); tagPTV.setPadding(3, 3, 3, 3); tagPTV.setPaddingRelative(3, 3, 3, 3); tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPTV.setTextColor(Color.BLACK); tagPTV.setText(contentRSpecial); tagPTV.setTextSize(TEXT_SIZE); tagPTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPTV.getText().toString()); return false; } }); lineLayout.addView(tagPTV); } else if (tag.equalsIgnoreCase("pre")) { final TextView tagPre = new TextView(mContext); tagPre.setBackgroundColor(Color.parseColor("#D2EADE")); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagPre.setLayoutParams(lp); tagPre.setPadding(2, 2, 2, 2); tagPre.setPaddingRelative(2, 2, 2, 2); tagPre.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPre.setTextColor(Color.BLACK); // String contentRSpecial = StringUtil.rmvSpecial(content); tagPre.setText(StringUtil.rmvSpecial(content)); tagPre.setTextSize(TEXT_SIZE); tagPre.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPre.getText().toString()); return false; } }); lineLayout.addView(tagPre); } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2") || tag.equalsIgnoreCase("H3")) {//title TextView tagDtHTV = new TextView(mContext); tagDtHTV.setBackgroundColor(Color.DKGRAY); tagDtHTV.setTypeface(null, Typeface.BOLD); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 0, 2, 0); tagDtHTV.setLayoutParams(lp); tagDtHTV.setPadding(2, 2, 2, 2); tagDtHTV.setPaddingRelative(2, 2, 2, 2); tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDtHTV.setTextColor(Color.WHITE); tagDtHTV.setText(contentRSpecial); tagDtHTV.setTextSize(TEXT_SIZE); lineLayout.addView(tagDtHTV); } else if (tag.equalsIgnoreCase("dd")) { final TextView tagDD = new TextView(mContext); tagDD.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagDD.setLayoutParams(lp); tagDD.setPadding(3, 3, 3, 3); tagDD.setPaddingRelative(3, 3, 3, 3); tagDD.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDD.setTextColor(Color.BLACK); tagDD.setText(contentRSpecial); tagDD.setTextSize(TEXT_SIZE); tagDD.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagDD.getText().toString()); return false; } }); lineLayout.addView(tagDD); } else if (tag.equalsIgnoreCase("li")) { final TextView tagLigTV = new TextView(mContext); tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagLigTV.setLayoutParams(lp); tagLigTV.setPaddingRelative(2, 2, 2, 2); tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagLigTV.setTextColor(Color.BLACK); tagLigTV.setText(contentRSpecial); tagLigTV.setTextSize(TEXT_SIZE); tagLigTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagLigTV.getText().toString()); return false; } }); lineLayout.addView(tagLigTV); } else if (tag.equalsIgnoreCase("img")) { final TextView imgTV = new TextView(mContext); imgTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); imgTV.setLayoutParams(lp); imgTV.setPaddingRelative(2, 2, 2, 2); imgTV.setMovementMethod(ScrollingMovementMethod.getInstance()); imgTV.setTextColor(Color.BLACK); imgTV.setText(content); imgTV.setTextSize(TEXT_SIZE); lineLayout.addView(imgTV); ImageView imageView = new ImageView(mContext); LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); imageView.setLayoutParams(imgLP); Bitmap localBt = getLoacalBitmap(baseFolder + File.separator + content); imageView.setImageBitmap(localBt); lineLayout.addView(imageView); } } }