问题描述
我需要在显示10条模型注释后加载横幅广告。 我如何实现这一点,即当用户每10条评论后加载一条评论时,就会显示一个广告。正在活动中使用此代码。
public void sendCommentRequestFirstTime(){
lastId = "0";
itShouldLoadMore = false; // lock this guy,(itShouldLoadMore) to make sure,user will not load more when volley is processing another request only load more when volley is free
progressWheelInterpolated.setVisibility(View.VISIBLE);
JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET,Config.GET_COMMENT_URL+"?limit="+Config.LOAD_LIMIT+"&content_id="+contentId+"&last_id="+lastId+"&api_key="+Config.API_KEY,null,new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
itShouldLoadMore = true;
if (response.length() == 0)
{
//No result found!
Toast.makeText(ShowComment.this,R.string.txt_no_result,Toast.LENGTH_SHORT).show();
}
for(int i = 0; i < response.length(); i++){
CommentModel commentModel = new CommentModel();
try {
JSONObject jsonObject = response.getJSONObject(i);
lastId = jsonObject.getString("comment_id");
commentModel.setUser_username(jsonObject.getString("user_username"));
commentModel.setComment_user_id(jsonObject.getString("comment_user_id"));
commentModel.setComment_text(jsonObject.getString("comment_text"));
commentModel.setComment_time(jsonObject.getString("comment_time"));
commentModel.setComment_rate(jsonObject.getString("comment_rate"));
commentModel.setUser_image(jsonObject.getString("user_image"));
} catch (JSONException e) {
e.printstacktrace();
}
commentModelsList.add(commentModel);
mAdapter.notifyDataSetChanged();
progressWheelInterpolated.setVisibility(View.GONE);
}
}
},new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressWheelInterpolated.setVisibility(View.GONE);
itShouldLoadMore = true;
Log.i("BlueDev Volley Error: ",error+"");
Snackbar snackbar = Snackbar.make(showCommentConstraintlayout,Snackbar.LENGTH_LONG);
snackbar.show();
}
});
jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(25000,2,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
rqComment.add(jsonArrayRequest);
}```
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)