https://github.com/skyfe79/hashgirl
HashGirl is a simple library to make a linkable string for Android.
https://github.com/skyfe79/hashgirl
Last synced: 12 months ago
JSON representation
HashGirl is a simple library to make a linkable string for Android.
- Host: GitHub
- URL: https://github.com/skyfe79/hashgirl
- Owner: skyfe79
- License: mit
- Created: 2016-08-11T12:40:52.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-12T12:47:26.000Z (almost 10 years ago)
- Last Synced: 2025-04-04T23:35:03.735Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 569 KB
- Stars: 20
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# #HashGirl
[](http://developer.android.com/index.html)
[](https://android-arsenal.com/api?level=7)
[](http://opensource.org/licenses/MIT)
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:
```java
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
```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
```java
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](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.