Giter Site home page Giter Site logo

hashgirl's Introduction

#HashGirl

Platform API License

HashGirl is a simple library to make a linkable string for Android. HashGirl can make hash a string which contains spaces. You can set the regular expression to grab a link and also you can set the character to indicate the end of the link.

HashGirl uses method chain to make linkable string like below:

String text = "Hello, I'm #Super Hash Girl^ in the World. You can hash #every^thing what you want. #I will hash you^";

TextView afterTextView = (TextView)findViewById(R.id.afterTextView);
HashGirl
        .with(text)
        .grab("(#((\\w+ *)*)\\^)", "^", "#")
        .underline()
        .color(Color.BLUE)
        .bgcolor(Color.WHITE)
        .click(new OnClickHashListener() {
            @Override
            public void onClickHash(String hash) {
                Toast.makeText(MainActivity.this, hash, Toast.LENGTH_SHORT).show();
            }
        })
        .into(afterTextView);

Setup Gradle

dependencies {
    ...
    compile 'kr.pe.burt.android.lib:hashgirl:1.0.3'
}

HashGirl's methods

  • with(String text)
    • is static method to set the text data.
    • You should start HashGirl from this 'with' method.
  • grab(String regExp)
  • grab(String regExp, String postfixToRemove = "", String prefixToRemove = "")
    • set regular expression to grab linkable string
    • set postfixToRemove or prefixToRemove to remove indicator of the start or end of the linked string.
  • underline()
    • to underline linked string
  • strike()
    • to strike line through the string
  • color(int color)
    • set foreground color of the linked string
  • bgcolor(int color)
    • set background color of the linked string
  • alpha(int alpha)
    • set alpha of the linked string
  • click(OnClickHashListener onClickHashListener)
    • set a handler to process the click action of the linked string
  • into(TextView textVieW)
    • set a TextView to set the result.

Examples

String text = "Hello, I'm #Super Hash Girl^ in the World. You can hash #every^thing what you want. #I will hash you^";

TextView before = (TextView)findViewById(R.id.before);
before.setText(text);

TextView after1 = (TextView)findViewById(R.id.after1);
HashGirl
    .with(text)
    .grab("(#((\\w+ *)*)\\^)", "^")
    .click(new OnClickHashListener() {
        @Override
        public void onClickHash(String hash) {
            Toast.makeText(MainActivity.this, hash, Toast.LENGTH_SHORT).show();
        }
    })
    .into(after1);

TextView after2 = (TextView)findViewById(R.id.after2);
HashGirl
        .with(text)
        .grab("(#((\\w+ *)*)\\^)", "^", "#")
        .underline()
        .color(Color.BLUE)
        .bgcolor(Color.WHITE)
        .click(new OnClickHashListener() {
            @Override
            public void onClickHash(String hash) {
                Toast.makeText(MainActivity.this, hash, Toast.LENGTH_SHORT).show();
            }
        })
        .into(after2);

MIT License

The MIT License (MIT)

Copyright (c) 2016 Sungcheol Kim, https://github.com/skyfe79/HashGirl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hashgirl's People

Contributors

skyfe79 avatar

Watchers

Lerist avatar  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.