use of com.zzhoujay.richtext.callback.ImageFixCallback in project RichText by zzhoujay.
the class ListViewActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
ListView listView = (ListView) findViewById(R.id.listView);
listView.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
return testString__.length + 1;
}
@Override
public Object getItem(int position) {
return testString[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
Holder holder;
if (convertView == null) {
convertView = LayoutInflater.from(ListViewActivity.this).inflate(R.layout.item_list, parent, false);
holder = new Holder(convertView);
convertView.setTag(holder);
} else {
holder = (Holder) convertView.getTag();
}
Log.i("RichText", "position:" + position + ",textView:" + System.identityHashCode(holder.text));
String text;
if (position == 0) {
text = test;
} else {
text = testString__[position - 1];
}
RichText.from(text).autoFix(false).fix(new ImageFixCallback() {
@Override
public void onFix(ImageHolder holder, boolean imageReady) {
if (holder.getImageType() != ImageHolder.ImageType.GIF) {
holder.setAutoFix(true);
} else {
holder.setHeight(200 + position * 10);
holder.setWidth(200 + position * 10);
}
if (position == 0) {
holder.setAutoPlay(true);
} else {
holder.setAutoPlay(false);
}
// holder.setAutoPlay(false);
}
}).into(holder.text);
return convertView;
}
class Holder {
public final TextView text;
public Holder(View view) {
text = (TextView) view.findViewById(R.id.text_item);
}
}
});
}
Aggregations