android.text.method.LinkMovementMethod Java Examples

The following examples show how to use android.text.method.LinkMovementMethod. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextDecorator.java    From text-decorator with Apache License 2.0 8 votes vote down vote up
public TextDecorator makeTextClickable(final OnTextClickListener listener, final int start, final int end, final boolean underlineText) {
  checkIndexOutOfBoundsException(start, end);
  decoratedContent.setSpan(new ClickableSpan() {
    @Override public void onClick(View view) {
      listener.onClick(view, content.substring(start, end));
    }

    @Override public void updateDrawState(TextPaint ds) {
      super.updateDrawState(ds);
      ds.setUnderlineText(underlineText);
    }
  }, start, end, flags);
  textView.setMovementMethod(LinkMovementMethod.getInstance());

  return this;
}
 
Example #2
Source File: AboutActivity.java    From privacy-friendly-pedometer with GNU General Public License v3.0 6 votes vote down vote up
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    ActionBar ab = getSupportActionBar();
    if(ab != null) {
        ab.setDisplayHomeAsUpEnabled(true);
    }

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(BaseActivity.MAIN_CONTENT_FADEIN_DURATION);
    }

    ((TextView)findViewById(R.id.secusoWebsite)).setMovementMethod(LinkMovementMethod.getInstance());
    ((TextView)findViewById(R.id.githubURL)).setMovementMethod(LinkMovementMethod.getInstance());
    ((TextView)findViewById(R.id.textFieldVersionName)).setText(BuildConfig.VERSION_NAME);
    ((TextView)findViewById(R.id.textViewLib)).setMovementMethod(LinkMovementMethod.getInstance());
    overridePendingTransition(0, 0);

}
 
Example #3
Source File: ScleraTextView.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
private void setHtmlContent(int htmlResId, String htmlString) {

        if(htmlResId > 0) {
            htmlString = getResources().getString(htmlResId);
        }

        if (!StringUtils.isEmpty(htmlString)) {
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                setText(Html.fromHtml(htmlString, Html.FROM_HTML_MODE_LEGACY));
            } else {
                setText(Html.fromHtml(htmlString));
            }

            setLinksClickable(true);
            setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
 
Example #4
Source File: AnalyzerViews.java    From audio-analyzer-for-android with Apache License 2.0 6 votes vote down vote up
void showInstructions() {
    TextView tv = new TextView(activity);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    tv.setText(fromHtml(activity.getString(R.string.instructions_text)));
    PackageInfo pInfo = null;
    String version = "\n" + activity.getString(R.string.app_name) + "  Version: ";
    try {
        pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
        version += pInfo.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        version += "(Unknown)";
    }
    tv.append(version);
    new AlertDialog.Builder(activity)
            .setTitle(R.string.instructions_title)
            .setView(tv)
            .setNegativeButton(R.string.dismiss, null)
            .create().show();
}
 
Example #5
Source File: MainActivity.java    From AndroidAppShortcuts with Apache License 2.0 6 votes vote down vote up
private void donationAlertDialog(){
    AlertDialog builder =
            new AlertDialog.Builder(this, R.style.AlertDialogCustom).setTitle(getResources().getString(R.string.app_name))
                    .setCancelable(false)
                    .setIcon(R.mipmap.ic_launcher)
                    .setMessage(R.string.donation_dialog_message)
                    .setPositiveButton(getResources().getString(R.string.disclaimer_dialog_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    }).create();
    builder.show();
    ((TextView)builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
    ((TextView)builder.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_VERTICAL);
   // builder.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
}
 
Example #6
Source File: MainActivity.java    From AndroidAppShortcuts with Apache License 2.0 6 votes vote down vote up
private void aboutAlertDialog()
{
    AlertDialog builder =
            new AlertDialog.Builder(this, R.style.AlertDialogCustom).setTitle(getResources().getString(R.string.app_name))
                    .setCancelable(false)
                    .setIcon(R.mipmap.ic_launcher)
                    .setMessage(R.string.disclaimer_dialog_message)
                    .setPositiveButton(getResources().getString(R.string.disclaimer_dialog_ok), new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.dismiss();
                        }
                    }).create();
    builder.show();
    ((TextView)builder.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
    ((TextView)builder.findViewById(android.R.id.message)).setGravity(Gravity.CENTER_VERTICAL);
    builder.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
}
 
Example #7
Source File: ProjectViewHolder.java    From droidddle with Apache License 2.0 6 votes vote down vote up
public void setData(Project data) {
    mData = data;
    mUserImageView.setImageURI(Uri.parse(data.user.avatarUrl));
    //        Glide.with(mContext).load(data.user.avatarUrl).placeholder(R.drawable.person_image_empty).into(mUserImageView);
    mBucketNameView.setText(data.name);
    String des = data.description;
    //        if (TextUtils.isEmpty(des)) {
    //            mBucketDescView.setVisibility(View.GONE);
    //        } else {
    //            mBucketDescView.setVisibility(View.VISIBLE);
    //        }
    if (!TextUtils.isEmpty(des)) {
        Spanned spannable = GoURLSpan.hackURLSpan(Html.fromHtml(des));
        mBucketDescView.setText(spannable);
        mBucketDescView.setMovementMethod(LinkMovementMethod.getInstance());
    } else {
        mBucketDescView.setText(des);
    }
    mUserNameView.setText(data.user.name);
    String count = mContext.getResources().getQuantityString(R.plurals.shot_count, data.shotsCount, data.shotsCount);
    mShotCountView.setText(count);
}
 
Example #8
Source File: OutgoingMessageViewHolder.java    From weMessage with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void configureLinksBehavior(TextView text) {
    text.setLinksClickable(false);

    text.setMovementMethod(new LinkMovementMethod(){
        @Override
        public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
            if (isSelectionMode) return true;

            if (Patterns.WEB_URL.matcher(buffer.toString()).matches()) {
                getParentFragment().launchWebView(buffer.toString());
                return true;
            }
            itemView.onTouchEvent(event);
            return false;
        }
    });
}
 
Example #9
Source File: ProductActivity.java    From product-catalogue-android with MIT License 6 votes vote down vote up
private void setBrandText() {
  String companyName = null;
  Brand brand = product.brand();
  if (brand != null) {
    companyName = brand.companyName();
  }

  if (companyName == null) {
    companyNameView.setVisibility(View.GONE);
  } else {
    String link = brand.website();
    if (link == null) {
      link = "#";
    }

    companyNameView.setText(Html.fromHtml(
        getString(R.string.product_company_name, companyName, link)));

    companyNameView.setMovementMethod(LinkMovementMethod.getInstance());
  }
}
 
Example #10
Source File: MultiSelectEditText.java    From AutoCompleteBubbleText with Apache License 2.0 6 votes vote down vote up
protected void init(){
    setInitialComponents();

    setFreezesText(true);
    setMovementMethod(LinkMovementMethod.getInstance());

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SparseBooleanArray checked = listView.getCheckedItemPositions();
            if(checked.get(position))
                addItemChecked(adapter.getItem(position));
            else
                removeItemChecked(adapter.getItem(position));

            setString();
        }
    });

    watcher = new BubbleWatcher();

    addTextChangedListener(watcher);

    setMinHeight(getPaddingBottom() + getPaddingTop() + calculateLineHeight());
}
 
Example #11
Source File: CsvPickerFragment.java    From AdaptiveTableLayout with MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    SpannableString ss = new SpannableString(getString(R.string.pick_csv_or_demo_file));
    ClickableSpan clickableSpan = new ClickableSpan() {
        @Override
        public void onClick(View textView) {
            if (PermissionHelper.checkOrRequest(CsvPickerFragment.this, REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE_DEMO,
                    Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                createDemoFile();
            }
        }

        @Override
        public void updateDrawState(TextPaint ds) {
            super.updateDrawState(ds);
            ds.setUnderlineText(false);
        }
    };
    ss.setSpan(clickableSpan, START_CHARACTER, END_CHARACTER, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    tvPickFile.setText(ss);
    tvPickFile.setMovementMethod(LinkMovementMethod.getInstance());
    tvPickFile.setHighlightColor(Color.TRANSPARENT);
}
 
Example #12
Source File: AboutActivity.java    From ankihelper with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    if(Settings.getInstance(this).getPinkThemeQ()){
        setTheme(R.style.AppThemePink);
    }else{
        setTheme(R.style.AppTheme);
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ImageButton alipay10 = (ImageButton) findViewById(R.id.alipay10);
    ImageButton alipay20 = (ImageButton) findViewById(R.id.alipay20);
    ImageButton alipayany = (ImageButton) findViewById(R.id.alipayany);
    TextView supportMessage = (TextView) findViewById(R.id.support_message);
    supportMessage.setMovementMethod(LinkMovementMethod.getInstance());

    setAlipayListener(alipay10, "HTTPS://QR.ALIPAY.COM/FKX00121JPEUHZAMZ3LCB7");
    setAlipayListener(alipay20, "HTTPS://QR.ALIPAY.COM/FKX07815DLYKHMJO06FT9D");
    setAlipayListener(alipayany, "HTTPS://QR.ALIPAY.COM/FKX011406PTCIHXZJPW7A1");

}
 
Example #13
Source File: VIPCountDownTimer.java    From LLApp with Apache License 2.0 6 votes vote down vote up
/** 重写父类的setBackgroundSpan方法
 * 我们知道设置Span的样式主要是控制两个变量start,end索引
 * 以确定设置start到end位置的字符串的子串的样式,表示每个数字子串在整个字符串中的位置范围
 * mGapLen = 1,表示一个间隔块的长度,
 * 例如:12时36分27秒的"时","分","秒"的间隔长度
 * 所以通过遍历Span集合,给字符串设置Span,
 * 通过分析不难得出每个数值块的Span的start索引:start = i*numbers[i].length() + i*mGapLen;
 * end = start + numbers[i].length();
 * */
@Override
public void setBackgroundSpan(String timeStr) {
    int mGapLen = 1;
    mSpan = new SpannableString(timeStr);
    initSpanData(timeStr);
    int start = 0 ;
    int count =0;
    for (int i=0;i<vipNumbers.length;i++){

        for (int j=start;j<start + vipNumbers[i].toCharArray().length;j++,count++){
            TimerUtils.setContentSpan(mSpan,mSpanList.get(count),j,j+mGapLen);
        }
        //此时表示遍历完了某一块的数值,从而需要将此时该块数值去更新start变量
        start = start + vipNumbers[i].toCharArray().length;
        if (i < nonNumbers.length){
            TimerUtils.setContentSpan(mSpan,mTextColorSpanList.get(i),start,start+mGapLen);
            start = start +mGapLen;//如果是个间隔还得去加上每个间隔长度最后去更新start变量
        }

    }
    mDateTv.setMovementMethod(LinkMovementMethod.getInstance());
    mDateTv.setText(mSpan);
}
 
Example #14
Source File: ContentTextViewFragment.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
private void initView(View v) {

        tvAbout=(TextView)v.findViewById(R.id.tv_about);
        tvAbout.setMovementMethod(LinkMovementMethod.getInstance());
        tvAbout.setText(Html.fromHtml((getResources().getString((R.string.app_about)))));

        ptr = (PtrClassicFrameLayout) v.findViewById(R.id.ptr_main);

        ptr.setPtrHandler(new PtrDefaultHandler() {
            @Override
            public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        ptr.refreshComplete();
                    }
                }, 2000);
            }
        });
    }
 
Example #15
Source File: MainActivity.java    From busybox with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PrefStore.setLocale(this);
    setContentView(R.layout.activity_main);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

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

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    output = findViewById(R.id.outputView);
    scroll = findViewById(R.id.scrollView);

    // enable context clickable
    output.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #16
Source File: AboutActivity.java    From Moment with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    getWindow().setStatusBarColor(Color.TRANSPARENT);
    setContentView(R.layout.about_activity);

    TextView sourceCode = (TextView) findViewById(R.id.source_code);
    sourceCode.setText(Html.fromHtml(getString(R.string.source_code)));
    sourceCode.setMovementMethod(new LinkMovementMethod());

    TextView appVersion = (TextView) findViewById(R.id.app_version);
    appVersion.setText(String.format("v%s", BuildConfig.VERSION_NAME));

    TextView openSource = (TextView) findViewById(R.id.open_source);
    openSource.setText(Html.fromHtml(getString(R.string.open_source_used)));
    openSource.setMovementMethod(new LinkMovementMethod());
}
 
Example #17
Source File: FeaturesFragment.java    From KernelAdiutor with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void addItems(List<RecyclerViewItem> items) {
    for (SupportedDownloads.KernelContent.Feature feature : mFeatures) {
        DescriptionView descriptionView = new DescriptionView();

        if (feature.hasItems()) {
            StringBuilder stringBuilder = new StringBuilder();
            for (String subFeature : feature.getItems()) {
                if (stringBuilder.length() == 0) {
                    stringBuilder.append("\u2022").append(" ").append(subFeature);
                } else {
                    stringBuilder.append("<br>").append("\u2022").append(" ").append(subFeature);
                }
            }
            descriptionView.setTitle(Utils.htmlFrom(feature.getItem()));
            descriptionView.setSummary(Utils.htmlFrom(stringBuilder.toString()));
        } else {
            descriptionView.setSummary(Utils.htmlFrom(feature.getItem()));
        }
        descriptionView.setMovementMethod(LinkMovementMethod.getInstance());

        items.add(descriptionView);
    }
}
 
Example #18
Source File: NestAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NonNull BaseViewHolder helper, Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    String msg = "\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ((TextView) helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ((TextView) helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #19
Source File: SimpleVrVideoActivity.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main_layout);

  seekBar = (SeekBar) findViewById(R.id.seek_bar);
  seekBar.setOnSeekBarChangeListener(new SeekBarListener());
  statusText = (TextView) findViewById(R.id.status_text);

  // Make the source link clickable.
  TextView sourceText = (TextView) findViewById(R.id.source);
  sourceText.setText(Html.fromHtml(getString(R.string.source)));
  sourceText.setMovementMethod(LinkMovementMethod.getInstance());

  // Bind input and output objects for the view.
  videoWidgetView = (VrVideoView) findViewById(R.id.video_view);
  videoWidgetView.setEventListener(new ActivityEventListener());

  loadVideoStatus = LOAD_VIDEO_STATUS_UNKNOWN;

  // Initial launch of the app or an Activity recreation due to rotation.
  handleIntent(getIntent());
}
 
Example #20
Source File: SpanActivity.java    From MvpRoute with Apache License 2.0 6 votes vote down vote up
@Override
protected void initView(@Nullable Bundle savedInstanceState ){
	super.initView(savedInstanceState);
	seekBar = findViewById(R.id.span_seekbar);
	seekBar.setMax(200);
	seekBar.setOnSeekBarChangeListener(this);
	maxText = findViewById(R.id.span_max_size);
	seekBar.setProgress(100);
	spanTextBack = findViewById(R.id.span_text_back);
	findViewById(R.id.span_color_click).setOnClickListener(this);
	spanColorText = findViewById(R.id.span_color_text);
	spanOne = findViewById(R.id.span_style_one);
	spanTwo = findViewById(R.id.span_style_two);
	SpanThree = findViewById(R.id.span_style_three);
	spanClickText = findViewById(R.id.span_text_clcik);
	//设置文字点击事件必须调用这个方法
	spanClickText.setMovementMethod(LinkMovementMethod.getInstance());

}
 
Example #21
Source File: AddHostFragmentZeroconf.java    From Kore with Apache License 2.0 6 votes vote down vote up
private void noNetworkConnection() {
    titleTextView.setText(R.string.no_network_connection);
    messageTextView.setText(Html.fromHtml(getString(R.string.wizard_search_no_network_connection)));
    messageTextView.setMovementMethod(LinkMovementMethod.getInstance());

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

    nextButton.setVisibility(View.GONE);

    previousButton.setVisibility(View.VISIBLE);
    previousButton.setText(R.string.search_again);
    previousButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startSearching();
        }
    });
}
 
Example #22
Source File: MainActivity.java    From nfcard with GNU General Public License v3.0 6 votes vote down vote up
private void initViews() {
	board = (ViewSwitcher) findViewById(R.id.switcher);

	Typeface tf = ThisApplication.getFontResource(R.string.font_oem1);
	TextView tv = (TextView) findViewById(R.id.txtAppName);
	tv.setTypeface(tf);

	tf = ThisApplication.getFontResource(R.string.font_oem2);

	tv = getFrontPage();
	tv.setMovementMethod(LinkMovementMethod.getInstance());
	tv.setTypeface(tf);

	tv = getBackPage();
	tv.setMovementMethod(LinkMovementMethod.getInstance());
	tv.setTypeface(tf);

	toolbar = new Toolbar((ViewGroup) findViewById(R.id.toolbar));
}
 
Example #23
Source File: MultiActionTextView.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
private void initView(Context context, AttributeSet attrs) {
    setMovementMethod(LinkMovementMethod.getInstance());
    if (!isFocusable()) {
        setFocusable(true);
    }
    if (!isFocusableInTouchMode()) {
        setFocusableInTouchMode(true);
    }
    requestFocus();
    requestFocusFromTouch();
    super.setOnClickListener(new MultiActionListener());
    if (attrs == null)
        return;
    final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
    mHighlightColor = a.getColor(0, Color.TRANSPARENT);
    a.recycle();
}
 
Example #24
Source File: LoadMoreAdapter.java    From BaseRecyclerViewAdapterHelper with MIT License 6 votes vote down vote up
@Override
protected void convert(@NotNull BaseViewHolder helper, @Nullable Status item) {
    switch (helper.getLayoutPosition() % 3) {
        case 0:
            helper.setImageResource(R.id.img, R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img, R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img, R.mipmap.animation_img3);
            break;
        default:
            break;
    }
    helper.setText(R.id.tweetName, "Hoteis in Rio de Janeiro");
    String msg = "\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ((TextView) helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ((TextView) helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #25
Source File: UPnPDeviceAdapter.java    From Android-UPnP-Browser with Apache License 2.0 6 votes vote down vote up
private void linkify(TextView view, CharSequence str, String url) {
	if (TextUtils.isEmpty(str) && TextUtils.isEmpty(url)) {
		view.setVisibility(View.GONE);
		return;
	}

	view.setVisibility(View.VISIBLE);
	if (TextUtils.isEmpty(url)) {
		view.setText(str);
		return;
	}

	if (TextUtils.isEmpty(str)) {
		str = url;
	}

	SpannableBuilder builder = new SpannableBuilder(view.getContext());
	builder.append(str, new URLSpan(url));

	view.setText(builder.build());
	view.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example #26
Source File: SlsPreferenceFragment.java    From Jockey with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
                         @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    binding = DataBindingUtil.inflate(inflater, R.layout.fragment_sls_preference,
            container, false);

    viewModel = new SlsPreferenceViewModel(getContext(), preferenceStore, playerController);
    binding.setViewModel(viewModel);

    binding.readmeMessage.setMovementMethod(new LinkMovementMethod());

    return binding.getRoot();
}
 
Example #27
Source File: SupportIntroSlide.java    From openScale with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(layoutResId, container, false);

    slideMainText = view.findViewById(R.id.slideMainText);
    slideMainText.setLinksClickable(true);
    slideMainText.setMovementMethod(LinkMovementMethod.getInstance());

    return view;
}
 
Example #28
Source File: ChangelogRenderer.java    From changelog with Apache License 2.0 5 votes vote down vote up
@Override
public void bindRow(ChangelogRecyclerViewAdapter adapter, Context context, ViewHolderRow viewHolder, ItemRow row, ChangelogBuilder builder) {
    if (row != null) {
        // 1) update text
        String text = row.getText(context);
        viewHolder.tvText.setText(Html.fromHtml(text));
        viewHolder.tvText.setMovementMethod(LinkMovementMethod.getInstance());

        // 2) update bullet list item
        viewHolder.tvBullet.setVisibility(builder.isUseBulletList() ? View.VISIBLE : View.GONE);
    }
}
 
Example #29
Source File: OtherFormsOfHistoryDialogFragment.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);

    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(
            textView.getText().toString(),
            new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                @Override
                public void onClick(View widget) {
                    new TabDelegate(false /* incognito */).launchUrl(
                            WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
                }
            }));

    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(view)
            .setTitle(R.string.clear_browsing_data_history_dialog_title)
            .setPositiveButton(
                    R.string.ok_got_it, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example #30
Source File: MainActivity.java    From WearPomodoro with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    TextView remark = (TextView) findViewById(R.id.main_remark);
    remark.setText(Html.fromHtml(getString(R.string.main_remark)));
    remark.setMovementMethod(LinkMovementMethod.getInstance());
}