SpEditText
--An EditText for mentioning user and showing topic with highlight and overall deletingGifTextUtil
--A tool for show gif on graph-text mixed TextView/EditText efficiently
- root build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- dependency
dependencies {
compile 'com.github.sunhapper:SpEditTool:{last version}'
}
<com.sunhapper.spedittool.view.SpEditText
android:id="@+id/spEdt"
app:react_keys="#*%@"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
- react the character input
spEditText.setReactKeys("@#%*");
spEditText.setKeyReactListener(new KeyReactListener() {
@Override
public void onKeyReact(String key) {
}
});
- insert special content
spEditText.insertSpecialStr(" @sunhapper ", true, 0, new ForegroundColorSpan(Color.RED));
/**
*
* @param showContent special text content
* @param rollBack true is need to delete on char forward
* @param customData special text`s extra data
* @param customSpan special text`s style
*/
public void insertSpecialStr(String showContent, boolean rollBack, Object customData,
Object customSpan)
- get data from SpEditText
SpData[] spDatas = spEditText.getSpDatas();
public class SpData {
/**
* special text content
*/
private String showContent;
/**
* special text`s extra data
*/
private Object customData;
/**
* special text`s start on EditText
*/
private int start;
/**
* special text`s end on EditText
*/
private int end;
}
define a custom gifDrawable extend Drawable and implements RefreshableDrawable
public interface RefreshableDrawable {
boolean canRefresh();
int getInterval();
void addCallback(Drawable.Callback callback);
void removeCallback(Drawable.Callback callback);
}
bind spannable with gifDrawable to textView
GifTextUtil.setTextWithReuseDrawable(textView, charSequence, false);
-keep class com.sunhapper.spedittool.**{*;}
more detail info and guidance,please see the demo
welcome to star,PR and issue