Search in sources :

Example 26 with CommentBean

use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.

the class CommentsTimeLineByMeDao method getGSONMsgList.

public CommentListBean getGSONMsgList() throws WeiboException {
    String url = URLHelper.COMMENTS_BY_ME_TIMELINE;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("since_id", since_id);
    map.put("max_id", max_id);
    map.put("count", count);
    map.put("page", page);
    map.put("filter_by_source", filter_by_source);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    CommentListBean value = null;
    try {
        value = gson.fromJson(jsonData, CommentListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null && value.getSize() > 0) {
        List<CommentBean> msgList = value.getItemList();
        Iterator<CommentBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            CommentBean msg = iterator.next();
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 27 with CommentBean

use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.

the class MainCommentsTimeLineDao method getGSONMsgListWithoutClearUnread.

public CommentListBean getGSONMsgListWithoutClearUnread() throws WeiboException {
    String url = getUrl();
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("since_id", since_id);
    map.put("max_id", max_id);
    map.put("count", count);
    map.put("page", page);
    map.put("filter_by_author", filter_by_author);
    map.put("filter_by_source", filter_by_source);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    CommentListBean value = null;
    try {
        value = gson.fromJson(jsonData, CommentListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null && value.getSize() > 0) {
        List<CommentBean> msgList = value.getItemList();
        Iterator<CommentBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            CommentBean msg = iterator.next();
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 28 with CommentBean

use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.

the class CommentsTimeLineByIdDao method getGSONMsgList.

public CommentListBean getGSONMsgList() throws WeiboException {
    String url = URLHelper.COMMENTS_TIMELINE_BY_MSGID;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);
    map.put("since_id", since_id);
    map.put("max_id", max_id);
    map.put("count", count);
    map.put("page", page);
    map.put("filter_by_author", filter_by_author);
    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
    Gson gson = new Gson();
    CommentListBean value = null;
    try {
        value = gson.fromJson(jsonData, CommentListBean.class);
    } catch (JsonSyntaxException e) {
        AppLogger.e(e.getMessage());
    }
    if (value != null && value.getItemList().size() > 0) {
        List<CommentBean> msgList = value.getItemList();
        Iterator<CommentBean> iterator = msgList.iterator();
        while (iterator.hasNext()) {
            CommentBean msg = iterator.next();
            if (msg.getUser() == null) {
                iterator.remove();
            } else {
                msg.getListViewSpannableString();
                TimeUtility.dealMills(msg);
            }
        }
    }
    return value;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CommentListBean(org.qii.weiciyuan.bean.CommentListBean) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 29 with CommentBean

use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.

the class BrowserCommentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent intent = getIntent();
    CommentBean bean = (CommentBean) intent.getParcelableExtra("comment");
    token = intent.getStringExtra("token");
    if (getFragmentManager().findFragmentByTag(BrowserCommentActivity.class.getName()) == null) {
        getFragmentManager().beginTransaction().replace(android.R.id.content, new BrowserCommentFragment(bean), BrowserCommentFragment.class.getName()).commit();
    }
}
Also used : Intent(android.content.Intent) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 30 with CommentBean

use of org.qii.weiciyuan.bean.CommentBean in project weiciyuan by qii.

the class CommentListAdapter method setTopTipBar.

public void setTopTipBar(TopTipBar bar) {
    this.topTipBar = bar;
    AutoScrollListView autoScrollListView = (AutoScrollListView) listView;
    autoScrollListView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            View childView = Utility.getListViewItemViewFromPosition(listView, firstVisibleItem);
            if (childView == null) {
                return;
            }
            int position = firstVisibleItem - ((ListView) view).getHeaderViewsCount();
            if (childView.getTop() == 0 && position <= 0) {
                topTipBar.clearAndReset();
            } else {
                handle(position + 1);
            }
        }

        private void handle(int position) {
            if (position > 0 && topTipBar != null && position < bean.size()) {
                CommentBean next = bean.get(position);
                if (next != null) {
                    CommentBean helperMsg = bean.get(position - 1);
                    long helperId = 0L;
                    if (helperMsg != null) {
                        helperId = helperMsg.getIdLong();
                    }
                    topTipBar.handle(next.getIdLong(), helperId);
                }
            }
        }
    });
}
Also used : AutoScrollListView(org.qii.weiciyuan.support.lib.AutoScrollListView) AbsListView(android.widget.AbsListView) AutoScrollListView(org.qii.weiciyuan.support.lib.AutoScrollListView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) AbsListView(android.widget.AbsListView) AutoScrollListView(org.qii.weiciyuan.support.lib.AutoScrollListView) View(android.view.View) ListView(android.widget.ListView) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Aggregations

CommentBean (org.qii.weiciyuan.bean.CommentBean)30 Gson (com.google.gson.Gson)13 JsonSyntaxException (com.google.gson.JsonSyntaxException)9 Intent (android.content.Intent)8 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)7 TimeLinePosition (org.qii.weiciyuan.bean.android.TimeLinePosition)7 MessageBean (org.qii.weiciyuan.bean.MessageBean)6 CommentTimeLineData (org.qii.weiciyuan.bean.android.CommentTimeLineData)5 PendingIntent (android.app.PendingIntent)4 Cursor (android.database.Cursor)4 Notification (android.app.Notification)3 NotificationManager (android.app.NotificationManager)3 Context (android.content.Context)3 IntentFilter (android.content.IntentFilter)3 DatabaseUtils (android.database.DatabaseUtils)3 SQLException (android.database.SQLException)3 View (android.view.View)3 ListView (android.widget.ListView)3