Search in sources :

Example 26 with MessageBean

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

the class RepostsByIdTimeLineFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.repostsbyidtimelinefragment_layout, container, false);
    empty = (TextView) view.findViewById(R.id.empty);
    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);
    quick_repost = (LinearLayout) view.findViewById(R.id.quick_repost);
    pullToRefreshListView = (PullToRefreshListView) view.findViewById(R.id.listView);
    pullToRefreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ListView>() {

        @Override
        public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            loadNewMsg();
        }
    });
    pullToRefreshListView.setOnLastItemVisibleListener(new PullToRefreshBase.OnLastItemVisibleListener() {

        @Override
        public void onLastItemVisible() {
            loadOldMsg(null);
        }
    });
    getListView().setScrollingCacheEnabled(false);
    getListView().setHeaderDividersEnabled(false);
    footerView = inflater.inflate(R.layout.listview_footer_layout, null);
    getListView().addFooterView(footerView);
    dismissFooterView();
    getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (actionMode != null) {
                getListView().clearChoices();
                actionMode.finish();
                actionMode = null;
                return;
            }
            getListView().clearChoices();
            if (position - 1 < getList().getSize() && position - 1 >= 0) {
                listViewItemClick(parent, view, position - 1, id);
            } else if (position - 1 >= getList().getSize()) {
                loadOldMsg(view);
            }
        }
    });
    if (savedInstanceState == null && msg != null) {
        if (msg.getRetweeted_status() == null) {
            quick_repost.setVisibility(View.VISIBLE);
        }
    } else if (savedInstanceState != null) {
        msg = (MessageBean) savedInstanceState.getParcelable("msg");
        if (msg.getRetweeted_status() == null) {
            quick_repost.setVisibility(View.VISIBLE);
        }
    }
    et = (EditText) view.findViewById(R.id.content);
    view.findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            sendRepost();
        }
    });
    buildListAdapter();
    return view;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) VelocityListView(org.qii.weiciyuan.support.lib.VelocityListView) View(android.view.View) AdapterView(android.widget.AdapterView) PullToRefreshListView(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) VelocityListView(org.qii.weiciyuan.support.lib.VelocityListView) PullToRefreshListView(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshListView) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) PullToRefreshBase(org.qii.weiciyuan.support.lib.pulltorefresh.PullToRefreshBase)

Example 27 with MessageBean

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

the class FriendsMsgLoader method loadData.

public MessageListBean loadData() throws WeiboException {
    MessageListBean result = null;
    MessageListBean tmp = get(token, currentGroupId, sinceId, maxId);
    result = tmp;
    if (isLoadNewData() && Utility.isWifi(getContext()) && SettingUtility.isWifiUnlimitedMsgCount()) {
        int retryCount = 0;
        while (tmp.getReceivedCount() >= Integer.valueOf(SettingUtility.getMsgCount()) && retryCount < MAX_RETRY_COUNT) {
            String tmpMaxId = tmp.getItemList().get(tmp.getItemList().size() - 1).getId();
            tmp = get(token, currentGroupId, sinceId, tmpMaxId);
            result.addOldData(tmp);
            retryCount++;
        }
        if (tmp.getReceivedCount() >= Integer.valueOf(SettingUtility.getMsgCount())) {
            MessageBean middleUnreadItem = new MessageBean();
            middleUnreadItem.setId(String.valueOf(System.currentTimeMillis()));
            middleUnreadItem.setMiddleUnreadItem(true);
            result.getItemList().add(middleUnreadItem);
        }
    } else {
        return result;
    }
    return result;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) MessageListBean(org.qii.weiciyuan.bean.MessageListBean)

Example 28 with MessageBean

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

the class MentionsWeiboTimeLineFragment method addUnreadMessage.

private void addUnreadMessage(MessageListBean data) {
    if (data != null && data.getSize() > 0) {
        MessageBean last = data.getItem(data.getSize() - 1);
        boolean dup = getList().getItemList().contains(last);
        if (!dup) {
            addNewDataAndRememberPosition(data);
        }
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean)

Example 29 with MessageBean

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

the class WifiAutoDownloadPictureRunnable method startDownload.

private void startDownload(MessageBean msg) {
    if (!msg.isMultiPics()) {
        String url = msg.getOriginal_pic();
        if (!TextUtils.isEmpty(url)) {
            downloadPic(url);
        }
    } else {
        ArrayList<String> urls = msg.getHighPicUrls();
        for (String url : urls) {
            downloadPic(url);
        }
    }
    MessageBean reTweetedMsg = msg.getRetweeted_status();
    if (reTweetedMsg != null) {
        if (!reTweetedMsg.isMultiPics()) {
            String url = reTweetedMsg.getOriginal_pic();
            if (!TextUtils.isEmpty(url)) {
                downloadPic(url);
            }
        } else {
            ArrayList<String> urls = reTweetedMsg.getHighPicUrls();
            for (String url : urls) {
                downloadPic(url);
            }
        }
    }
    UserBean user = msg.getUser();
    if (user != null) {
        downloadAvatar(user.getAvatar_large());
    }
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) UserBean(org.qii.weiciyuan.bean.UserBean)

Example 30 with MessageBean

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

the class SendCommentService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    int lastNotificationId = intent.getIntExtra("lastNotificationId", -1);
    if (lastNotificationId != -1) {
        NotificationUtility.cancel(lastNotificationId);
    }
    String token = intent.getStringExtra("token");
    AccountBean account = (AccountBean) intent.getParcelableExtra("account");
    String content = intent.getStringExtra("content");
    MessageBean oriMsg = (MessageBean) intent.getParcelableExtra("oriMsg");
    boolean comment_ori = intent.getBooleanExtra("comment_ori", false);
    CommentDraftBean commentDraftBean = (CommentDraftBean) intent.getParcelableExtra("draft");
    WeiboSendTask task = new WeiboSendTask(account, token, content, oriMsg, comment_ori, commentDraftBean);
    task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    tasksResult.put(task, false);
    return START_REDELIVER_INTENT;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) CommentDraftBean(org.qii.weiciyuan.support.database.draftbean.CommentDraftBean) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Aggregations

MessageBean (org.qii.weiciyuan.bean.MessageBean)52 Gson (com.google.gson.Gson)21 JsonSyntaxException (com.google.gson.JsonSyntaxException)16 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)8 Cursor (android.database.Cursor)7 Intent (android.content.Intent)6 CommentBean (org.qii.weiciyuan.bean.CommentBean)6 UserBean (org.qii.weiciyuan.bean.UserBean)6 DatabaseUtils (android.database.DatabaseUtils)4 SQLException (android.database.SQLException)4 View (android.view.View)4 PendingIntent (android.app.PendingIntent)3 Drawable (android.graphics.drawable.Drawable)3 SpannableString (android.text.SpannableString)3 AbsListView (android.widget.AbsListView)3 ListView (android.widget.ListView)3 RelativeLayout (android.widget.RelativeLayout)3 TextView (android.widget.TextView)3