use of com.funstill.kelefun.data.model.Status in project keleFanfou by kelefun.
the class ImageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Status status = result.get(position);
if (status != null) {
Glide.with(context).load(status.getPhoto().getImageurl()).into(holder.image);
holder.imageText.setText(status.getText());
}
}
use of com.funstill.kelefun.data.model.Status in project keleFanfou by kelefun.
the class SendStatusFragmentChild method postStatus.
/**
* 发送
*/
private void postStatus() {
ToastUtil.showToast(_mActivity, "正在发布中...");
// backToHome();
StatusApi api = BaseRetrofit.retrofit(new SignInterceptor()).create(StatusApi.class);
if (imageUrl != null) {
// 带图片
RequestBody status = RequestBody.create(MediaType.parse("text/plain"), editText.getText().toString());
// TODO 如果不是gif则压缩图片
Luban.with(_mActivity).load(imageUrl).ignoreBy(// 2MB
1024 * 2).putGear(4).setCompressListener(new OnCompressListener() {
@Override
public void onStart() {
}
@Override
public void onSuccess(File file) {
RequestBody photo = RequestBody.create(MediaType.parse("multipart/form-data"), file);
MultipartBody.Part body = MultipartBody.Part.createFormData("photo", file.getName(), photo);
Call<Status> call = api.uploadPhoto(status, body);
enqueue(call);
}
@Override
public void onError(Throwable e) {
}
}).launch();
} else {
// 只有文字
if ("".equals(editText.getText().toString())) {
ToastUtil.showToast(_mActivity, "输入不能为空");
return;
}
String status = editText.getText().toString();
Map<String, String> partMap = new ArrayMap<>();
partMap.put("status", status);
Call<Status> call = api.postStatus(partMap);
enqueue(call);
}
}
use of com.funstill.kelefun.data.model.Status in project keleFanfou by kelefun.
the class StatusAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ItemViewHolder) {
ItemViewHolder itemHolder = (ItemViewHolder) holder;
if (data.size() != 0) {
Status status = data.get(position);
itemHolder.screenNameView.setText(status.getUser().getScreenName());
itemHolder.timeSourceView.setText(DateUtil.toAgo(status.getCreatedAt()) + Html.fromHtml(status.getSource()).toString());
// 处理文本点击跳转
// 格式化<a herf ,mobile等标签
Spannable statusSpan = (Spannable) Html.fromHtml(status.getText());
CharSequence text = statusSpan.toString();
statusSpan.getSpans(0, text.length(), TextAppearanceSpan.class);
URLSpan[] urls = statusSpan.getSpans(0, text.length(), URLSpan.class);
SpannableStringBuilder activitySpan = new SpannableStringBuilder(statusSpan);
activitySpan.clearSpans();
for (URLSpan url : urls) {
ActivitySpan myURLSpan = new ActivitySpan(url.getURL());
activitySpan.setSpan(myURLSpan, statusSpan.getSpanStart(url), statusSpan.getSpanEnd(url), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
itemHolder.statusView.setText(activitySpan);
// 使标签可点击
itemHolder.statusView.setOnTouchListener(TextLinkMovementMethod.getInstance());
// 图片加载
Glide.with(mContext).load(status.getUser().getProfileImageUrl()).into(itemHolder.avatarView);
if (status.getPhoto() != null) {
itemHolder.photoView.setVisibility(View.VISIBLE);
if (status.getPhoto().getLargeurl().endsWith("gif")) {
// 动图标签
itemHolder.photoView.setTagEnable(true);
} else {
itemHolder.photoView.setTagEnable(false);
}
Glide.with(mContext).load(status.getPhoto().getImageurl()).into(itemHolder.photoView);
} else {
itemHolder.photoView.setVisibility(View.GONE);
}
}
}
}
use of com.funstill.kelefun.data.model.Status in project keleFanfou by kelefun.
the class ExploreFragmentChild method loadMore.
private void loadMore(Map<String, String> param) {
StatusApi api = BaseRetrofit.retrofit(new SignInterceptor()).create(StatusApi.class);
Call<List<Status>> call = api.getPublicTimeLine(param);
call.enqueue(new Callback<List<Status>>() {
@Override
public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
if (response.code() == 200) {
List<Status> statusList = response.body();
if (statusList.size() > 0) {
// 去除重复数据
if (data.size() > 0) {
List<Status> tempList = new ArrayList<>();
tempList.addAll(data);
for (Status status : statusList) {
// 是否重复
boolean exist = false;
for (Status temp : tempList) {
if (temp.getId().equals(status.getId())) {
exist = true;
}
}
if (!exist) {
data.add(status);
}
}
} else {
data.addAll(statusList);
}
mAdapter.notifyDataSetChanged();
} else {
ToastUtil.showToast(_mActivity, "没有更多了");
}
}
isLoadingMore = false;
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
t.printStackTrace();
LogHelper.e("请求失败", t.getMessage());
isLoadingMore = false;
}
});
}
Aggregations