use of com.funstill.kelefun.data.api.StatusApi in project keleFanfou by kelefun.
the class ImageListFragment method getStatusWithImage.
/**
* 获取带图片的消息
*
* @param param
*/
private void getStatusWithImage(Map<String, String> param) {
param.put("id", tuserId);
StatusApi api = BaseRetrofit.retrofit(new SignInterceptor()).create(StatusApi.class);
Call<List<Status>> call = api.getUserTimeLineWithPhoto(param);
call.enqueue(new Callback<List<Status>>() {
@Override
public void onResponse(Call<List<Status>> call, Response<List<Status>> response) {
LogHelper.d("请求响应code", String.valueOf(response.code()));
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);
data.clear();
data.addAll(statusList);
data.addAll(tempList);
} else {
data.addAll(statusList);
}
// 只重绘新增的数据
mAdapter.notifyItemRangeInserted(lastVisibleItemPosition + 1, statusList.size());
} else {
if (data.size() > 0) {
ToastUtil.showToast(getContext(), "没有更多了");
} else {
// 暂时还没有数据
ToastUtil.showToast(getContext(), "还没有相关数据");
}
}
} else if (response.code() == 403) {
ToastUtil.showToast(getContext(), "对方设置了隐私,需先请求关注");
}
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
t.printStackTrace();
LogHelper.e("请求失败", t.getMessage());
}
});
}
use of com.funstill.kelefun.data.api.StatusApi in project keleFanfou by kelefun.
the class StatusListFragment method loadMoreHomeLineStatus.
private void loadMoreHomeLineStatus(Map<String, String> param) {
StatusApi api = BaseRetrofit.retrofit(new SignInterceptor()).create(StatusApi.class);
Call<List<Status>> call = api.getUserTimeLine(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) {
data.addAll(statusList);
mAdapter.notifyDataSetChanged();
} else {
ToastUtil.showToast(getContext(), "没有更多了");
}
}
isLoadingMore = false;
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
t.printStackTrace();
LogHelper.e("请求失败", t.getMessage());
isLoadingMore = false;
}
});
}
use of com.funstill.kelefun.data.api.StatusApi in project keleFanfou by kelefun.
the class ExploreFragmentChild method getPublicTimeLineStatus.
/**
* 请求public_timeline数据(随便看看)
*/
private void getPublicTimeLineStatus(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) {
LogHelper.d("请求响应code", String.valueOf(response.code()));
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);
data.clear();
data.addAll(statusList);
data.addAll(tempList);
ToastUtil.showToast(_mActivity, "Fun+ " + statusList.size());
} else {
data.addAll(statusList);
}
mAdapter.notifyDataSetChanged();
} else {
ToastUtil.showToast(_mActivity, "没有更多了");
}
}
mRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
mRefreshLayout.setRefreshing(false);
t.printStackTrace();
LogHelper.e("请求失败", t.getMessage());
}
});
}
use of com.funstill.kelefun.data.api.StatusApi 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;
}
});
}
use of com.funstill.kelefun.data.api.StatusApi in project keleFanfou by kelefun.
the class HomeLineFragmentChild method getHomeLineStatus.
/**
* 请求home_timeline数据
*/
private void getHomeLineStatus(Map<String, String> param) {
StatusApi api = BaseRetrofit.retrofit(new SignInterceptor()).create(StatusApi.class);
Call<List<Status>> call = api.getHomeTimeLine(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);
data.clear();
data.addAll(statusList);
data.addAll(tempList);
} else {
data.addAll(statusList);
}
mAdapter.notifyDataSetChanged();
} else {
ToastUtil.showToast(_mActivity, "没有更多了");
}
}
mRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(Call<List<Status>> call, Throwable t) {
mRefreshLayout.setRefreshing(false);
t.printStackTrace();
LogHelper.e("请求失败", t.getMessage());
}
});
}
Aggregations