Giter Club home page Giter Club logo

android-social-ui's Introduction

Android Social UI

Android Social UI is a library of android widgets that work well for social apps.

SocialTextView

A SocialTextView is a standard android TextView with callbacks to handle the onClicks of #hashtags @mentions and https://weblinks.com/.

You can use it in any XML file just as you would a normal TextView:

<com.carrotcreative.socialui.widget.SocialTextView
    android:id="@+id/social_text_example"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="This view handles #hashtags, @mentions, and https://weblinks.com/"
    />

Next you'll want to create a SocialActionHandler. This is the thing that defines how to handle the onClicks of each type.

SocialActionHandler mHandler = new SocialActionHandler() {
    @Override
    public void handleHashtag(String hashtag)
    {
        Toast.makeText(SignUpActivity.this, "Hashtag: " + hashtag, Toast.LENGTH_LONG).show();
    }

    @Override
    public void handleMention(String mention)
    {
        Toast.makeText(SignUpActivity.this, "Mention: " + mention, Toast.LENGTH_LONG).show();
    }

    @Override
    public void handleUrl(String url)
    {
        Toast.makeText(SignUpActivity.this, "URL: " + url, Toast.LENGTH_LONG).show();
    }
});

The last thing you have to do for the SocialTextView is to set it's SocialActionHandler to the one you've just created.

socialTextView = (SocialTextView) findViewById(R.id.social_text_example);
socialTextView.linkify(mHandler);

If you update the text in a SocialTextView, be sure to also call linkify() to ensure all elements become clickable.

socialTextView.setText("Hello #World");
socialTextView.linkify();

After this is done, the SocialTextView will display highlighted/underlined hashtags, mentions, and weblinks that are clickable and will be handled by their appropriate method.

License

Android Social UI is licensed under MIT

android-social-ui's People

Contributors

brandonromano avatar roideuniverse avatar

Watchers

James Cloos avatar Seongju Jo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.