use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.
the class PublishManager method onPublish.
public void onPublish(PublishBean bean) {
if (bean == null)
return;
// 如果队列为空,放入首位等待发送,否则,添加到队列等待发布
if (publishQueue.isEmpty()) {
publishQueue.add(bean);
}
PublishBean firstBean = publishQueue.peek();
if (firstBean != null && firstBean.getId().equals(bean.getId())) {
// 定时发布
if (bean.getTiming() > 0) {
Logger.d(TimingBroadcastReceiver.TAG, bean.getText() + "-定时发布");
// 从队列移除
publishQueue.poll();
// 更改状态为草稿
bean.setStatus(PublishStatus.draft);
// 添加到DB
PublishDB.addPublish(bean, loggedIn);
// 刷新草稿
refreshDraftbox();
// 发送广播
publishNotifier.notifyTimingPublish(bean);
// 发布下一个
onPublish(publishQueue.peek());
// 刷新定时
MyApplication.refreshPublishAlarm();
} else // 立即发布
if (bean.getDelay() <= 0) {
Logger.d(TimingBroadcastReceiver.TAG, bean.getText() + "-立即发布");
publishTask = new PublishTask(bean);
publishTask.executeOnSerialExecutor();
} else // 延迟发布
{
Logger.d(TimingBroadcastReceiver.TAG, bean.getText() + "-延迟发布");
publishNotifier.notifyPrePublish(bean);
Message msg = obtainMessage(publishDelay);
msg.obj = bean;
bean.setDelay(bean.getDelay() - 1000);
sendMessageDelayed(msg, 1000);
if (bean.getStatus() != PublishStatus.waiting) {
bean.setStatus(PublishStatus.waiting);
PublishDB.updatePublish(bean, loggedIn);
}
}
} else {
Logger.d(TimingBroadcastReceiver.TAG, bean.getText() + "-添加到队列等等发布");
publishQueue.add(bean);
if (firstBean == null)
onPublish(bean);
if (bean.getStatus() != PublishStatus.waiting) {
bean.setStatus(PublishStatus.waiting);
PublishDB.updatePublish(bean, loggedIn);
}
}
refreshDraftbox();
}
use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.
the class APublishFragment method layoutInit.
@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceState) {
super.layoutInit(inflater, savedInstanceState);
// getActivity().getActionBar().setSubtitle(AppContext.getUser().getScreen_name());
btnLocation.setVisibility(View.GONE);
if (savedInstanceState == null) {
if (getArguments() != null)
mBean = (PublishBean) getArguments().getSerializable("bean");
} else {
mBean = (PublishBean) savedInstanceState.getSerializable("bean");
}
if (mBean == null)
mBean = newPublishBean();
if (savedInstanceState == null) {
emotionFragment = EmotionFragment.newInstance();
getActivity().getFragmentManager().beginTransaction().add(R.id.layEmotion, emotionFragment, "EmotionFragemnt").commit();
} else {
emotionFragment = (EmotionFragment) getActivity().getFragmentManager().findFragmentByTag("EmotionFragemnt");
}
emotionFragment.setOnEmotionListener(this);
// 内容编辑
editContent.addTextChangedListener(editContentWatcher);
// 更换表情
editContent.setFilters(new InputFilter[] { emotionFilter });
editContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideEmotionView(true);
}
});
ObjectAnimator animIn = ObjectAnimator.ofFloat(null, "translationY", SystemUtils.getScreenHeight(getActivity()), emotionHeight).setDuration(transitioner.getDuration(LayoutTransition.APPEARING));
transitioner.setAnimator(LayoutTransition.APPEARING, animIn);
ObjectAnimator animOut = ObjectAnimator.ofFloat(null, "translationY", emotionHeight, SystemUtils.getScreenHeight(getActivity())).setDuration(transitioner.getDuration(LayoutTransition.DISAPPEARING));
transitioner.setAnimator(LayoutTransition.DISAPPEARING, animOut);
layRoot.setLayoutTransition(transitioner);
refreshUI();
String albumPath = SystemUtils.getSdcardPath() + File.separator + "/DCIM/Camera/";
File albumFile = new File(albumPath);
if (!albumFile.exists())
albumFile.mkdirs();
photoChoice = new PhotoChoice(getActivity(), APublishFragment.this, albumPath);
if (savedInstanceState != null)
tempFilePath = savedInstanceState.getString("tempFilePath");
photoChoice.setFileName(tempFilePath);
photoChoice.setMode(PhotoChoice.PhotoChoiceMode.uriType);
}
use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.
the class PublishActivity method publishFeedback.
/**
* 意见反馈
*
* @param from
*/
public static void publishFeedback(Activity from) {
Intent intent = new Intent(from, PublishActivity.class);
intent.putExtra("type", PublishType.status.toString());
PublishBean bean = PublishStatusFragment.generateBean();
String model = android.os.Build.MODEL;
String sysVersion = android.os.Build.VERSION.RELEASE;
String appVersion = SystemUtils.getVersionName(GlobalContext.getInstance());
bean.setText(String.format("#Aisen意见反馈# %s;%s;V%s; @王_dan ", model, sysVersion, appVersion));
bean.setExtras(new Params());
bean.getExtras().addParameter("feedback", "true");
intent.putExtra("bean", bean);
from.startActivity(intent);
}
use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.
the class PublishCommentReplyFragment method generateBean.
public static PublishBean generateBean(StatusComment comment) {
PublishBean bean = new PublishBean();
bean.setStatusComment(comment);
bean.setType(PublishType.commentReply);
bean.setStatus(PublishStatus.create);
bean.setParams(new Params());
bean.getParams().addParameter("cid", comment.getId());
bean.getParams().addParameter("id", comment.getStatus().getId() + "");
// 回复中是否自动加入“回复@用户名”,0:是、1:否,默认为0
bean.getParams().addParameter("without_mention", "0");
bean.setExtras(new Params());
// 评论是否同时转发
bean.getExtras().addParameter("forward", "false");
return bean;
}
use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.
the class PublishStatusCommentFragment method generateBean.
public static PublishBean generateBean(StatusContent status) {
PublishBean bean = new PublishBean();
bean.setStatusContent(status);
bean.setType(PublishType.commentCreate);
bean.setStatus(PublishStatus.create);
bean.setParams(new Params());
bean.getParams().addParameter("id", status.getId() + "");
// 当评论转发微博时,是否评论给原微博,0:否、1:是,默认为0。
bean.getParams().addParameter("comment_ori", "0");
bean.setExtras(new Params());
// 评论是否同时转发
bean.getExtras().addParameter("forward", "false");
return bean;
}
Aggregations