@Trace @Background void prepareForumPart() { if (!isPantipPick() && !isPantipTrend()) { Log.i("loadData " + forumPagerItem.title, "prepareForumPart start"); forumPart = RESTUtils.parseForumPart(new String(tmpForumPartBytes)); if (forumType == ForumType.Room && forumPart.getRecommendTopic().get(0) == null) { Log.e("forumPath", "CANT PARSE FORUMPATH\n" + new String(tmpForumPartBytes)); } Log.d( "forumPart", "prepareForumPart recommend size : " + forumPart.getRecommendUrl() .size() + " - " + forumPart.getRecommendTopic().size() ); for (String s : forumPart.getRecommendTopic()) { Log.d("recommend", forumPagerItem.title + " " + s); } Log.i("loadData " + forumPagerItem.title, "prepareForumPart finish"); prepareRecommendCard(); } else { prepareRecommendDone = true; joinForum(); } }
@Trace @Background public void getForumPart(String forumName, ForumType type, AsyncHttpResponseHandler cb) { try { forumName = URLEncoder.encode(forumName, "utf-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } String url; if (type == ForumType.Tag) { url = "/tag/"; } else if (type == ForumType.Room) { url = "/forum/"; } else { url = "/club/"; type = ForumType.Club; } get(url + forumName, null, cb); Log.d(TAG, "get forum part - " + forumName); }
@Trace @Background public void getComments(String topicId, int page, boolean justOwner, AsyncHttpResponseHandler cb) { String url; if (justOwner) { url = "/forum/topic_mode/render_comments?tid=" + topicId + "&type=1&page=" + page + "¶m=story" + page + "&_=" + new Date() .getTime(); } else { url = "/forum/topic/render_comments?tid=" + topicId + "&type=1&page=" + page + "¶m=page" + page + "&_=" + new Date() .getTime(); } get(url, null, cb); Log.d(TAG, "get comments - " + url); }
@Trace @Background void prepareTopic() { Log.i("loadData ", "prepareTopic start"); prepareTopicDone = true; joinForum(); Log.i("loadData ", "prepareTopic finish"); }
@Trace(tag = "joinForum") @UiThread void joinForum() { if (forumType != null) { Log.i("loadData " + forumPagerItem.title, "joinForum start"); } else { Log.i("loadData " + userTopicType, " joinForum start"); } // Join Thread if (prepareRecommendDone && prepareTopicDone) { // Update List if (forumType != null && (!isPantipTrend() && !isPantipPick())) { ((ForumAdapter) forumAdapter).setData(forum, forumPart, recommendTopicTitle, recommendTopicUrl); forumAdapter.notifyDataSetChanged(); } else if (userTopicType != null) { forumAdapter.setTopics(myPage.getResult()); } else { adapter.notifyDataSetChanged(); } setRefreshComplete(); if (lastFirstVisibleItem != 0) { list.setSelection(lastFirstVisibleItem); } Log.i("loadData", "joinForum finish"); } else { Log.i("loadData", "joinForum postpone"); } }
@Trace @Background public void login(String username, String password, AsyncHttpResponseHandler cb) { logout(); client.getHttpClient().getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); RequestParams params = new RequestParams(); params.put("member[email]", username); params.put("member[crypted_password]", password); params.put("action", "login"); params.put("redirect", ""); params.put("persistent[remember]", "1"); post("/login/authentication", params, cb); }
@Trace @Background public void reply(int topicId, int commentRefId, int commentNo, long commentTimestamp, String msg, AsyncHttpResponseHandler cb) { RequestParams params = new RequestParams(); params.put("topic_id", topicId); params.put("msg[raw]", msg); params.put("msg[disp]", "msg"); params.put("msg[time]", commentTimestamp); params.put("type", "1"); params.put("msg[ref_id]", commentRefId + "pantip3g"); params.put("msg[ref_comment]", "comment" + commentNo); post("/forum/topic/save_reply", params, cb); }
@Trace @Background public void comment(int topicId, String msg, AsyncHttpResponseHandler cb) { RequestParams params = new RequestParams(); params.put("topic_id", topicId); params.put("msg[raw]", msg); params.put("msg[disp]", "msg"); params.put("type", "1"); post("/forum/topic/save_comment", params, cb); }
@Trace @Background public void getForum(String forum, ForumType type, TopicType topicType, int currentPage, String lastTopicId, boolean thumbnailView, AsyncHttpResponseHandler cb) { int defaultType = topicType == TopicType.All_Except_Sell ? 1 : 0; String url; if (type == ForumType.Tag) { url = "/forum/topic/ajax_json_all_topic_tag"; } else if (type == ForumType.Room) { url = "/forum/topic/ajax_json_all_topic_info_loadmore"; } else { url = "/forum/topic/ajax_json_all_topic_club"; type = ForumType.Tag; } // ห้องไร้สังกัด if (forum == null) { forum = "undefined"; } RequestParams params = new RequestParams(); params.put(String.format("dataSend[%s]", type), forum); params.put("dataSend[topic_type][type]", topicType); params.put("dataSend[topic_type][default_type]", defaultType); params.put("thumbnailview", thumbnailView); params.put("current_page", currentPage); params.put("last_id_current_page", lastTopicId); post(url, params, cb); Log.d(TAG, "get forum - " + params.toString()); }
@Trace @Background public void getTopicPost(String topicId, AsyncHttpResponseHandler cb) { post("/topic/" + topicId, null, cb); Log.d(TAG, "get topic post " + topicId); }
@Trace @Background public void getReplies(int commentId, int lastReply, int maxReplyCount, int parentCommentUserId, AsyncHttpResponseHandler cb) { String url = "/forum/topic/render_replys?last=" + lastReply + "&cid=" + commentId + "&c=" + maxReplyCount + "&ac=n&o=" + parentCommentUserId; get(url, null, cb); Log.d(TAG, "get repiles - " + commentId); }
@Trace @Background public void voteComment(int topic_id, int comment_id, int commentNo, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("vote_status", "1"); params.add("vote_type", VoteType.Comment.toString()); params.add("topic_id", topic_id + ""); params.add("comment_id", comment_id + ""); params.add("comment_no", commentNo + ""); post("/vote1/cal_like", params, cb); }
@Trace @Background public void voteReply(int topic_id, int comment_id, int commentNo, int reply_id, int replyNo, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("vote_status", "1"); params.add("vote_type", VoteType.Reply.toString()); params.add("topic_id", topic_id + ""); params.add("cid", comment_id + ""); params.add("comment_no", commentNo + ""); params.add("rp_id", reply_id + ""); params.add("rp_no", replyNo + ""); post("/vote1/cal_like", params, cb); }
@Trace @Background public void voteTopic(int topic_id, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("vote_status", "1"); params.add("vote_type", VoteType.Topic.toString()); params.add("topic_id", topic_id + ""); post("/vote1/cal_like", params, cb); }
@Trace @Background public void emoTopic(int topic_id, Emo emo, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("id", topic_id + ""); params.add("topic_id", topic_id + ""); params.add("type", "topic"); params.add("emo", emo.toString()); post("/forum/topic/express_emotion", params, cb); }
@Trace @Background public void emoComment(int topic_id, int comment_id, Emo emo, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("id", comment_id + ""); params.add("topic_id", topic_id + ""); params.add("type", "comment"); params.add("emo", emo.toString()); post("/forum/topic/express_emotion", params, cb); }
@Trace @Background public void emoReply(int topic_id, int comment_id, int reply_id, int comment_no, int reply_no, Emo emo, AsyncHttpResponseHandler cb) { client.addHeader("X-Requested-With", "XMLHttpRequest"); RequestParams params = new RequestParams(); params.add("id", reply_id + ""); params.add("rid", comment_id + ""); params.add("topic_id", topic_id + ""); params.add("type", "reply"); params.add("emo", emo.toString()); params.add("comment_no", comment_no + ""); params.add("no", reply_no + ""); post("/forum/topic/express_emotion", params, cb); }
@Trace @Background public void getPantipPick(AsyncHttpResponseHandler cb) { get("", null, cb); Log.d(TAG, "get Pantip Pick"); }
@Trace @Background public void getPantipTrend(AsyncHttpResponseHandler cb) { get("/home/ajax_pantip_trend?p=1", null, cb); Log.d(TAG, "get Pantip Trend"); }
@Trace(tag = TRACE_TAG) protected void init() { configureCalligraphy(); configureTracer(); configureFabric(); configureIconify(); configureSocial(); configureRetrofit(); configureStetho(); }
@Override public Filter getFilter() { return new Filter() { @Override @Trace protected FilterResults performFiltering(CharSequence constraint) { try { List<Song> songsList; if (constraint != null) { List<WordMatch> results = wordDao.query(wordDao.queryBuilder() .limit(20L) .where() .like("word", constraint.toString() + "%") .prepare()); Set<Song> songsSet = new HashSet<Song>(); for (WordMatch match : results) { songsSet.add(match.getSong()); } songsList = new ArrayList<Song>(songsSet.size()); for (Song song : songsSet) { songDao.refresh(song); songsList.add(song); } } else { songsList = songDao.queryForAll(); } Collections.sort(songsList, new Comparator<Song>() { @Override public int compare( Song song1, Song song2 /* woo-hoo, when I feel heavy-metal... */) { return song1.getName().compareTo(song2.getName()); } }); FilterResults out = new FilterResults(); out.count = songsList.size(); out.values = songsList; return out; } catch (Exception e) { throw new RuntimeException(e); } } @Override protected void publishResults(CharSequence charSequence, FilterResults filterResults) { songs = (List<Song>)filterResults.values; notifyDataSetChanged(); } }; }
@Trace @Background public void getRoomsTags(AsyncHttpResponseHandler cb) { RequestParams params = new RequestParams(); post("/forum/new_topic/get_rooms_tags", params, cb); }
@Trace @Background public void saveTopic(AsyncHttpResponseHandler cb) { RequestParams params = new RequestParams(); post("/forum/new_topic/save", params, cb); }
@Trace @Background public void favTopic(int topicId, AsyncHttpResponseHandler cb){ bookmark(topicId, "push", cb); }
@Trace @Background public void unFavTopic(int topicId, AsyncHttpResponseHandler cb){ bookmark(topicId, "pop", cb); }
@Trace(tag = TRACE_TAG) @AfterViews void afterViews() { DPSignInActivity_.intent(this).start(); finish(); }