Search in sources :

Example 6 with PublishBean

use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.

the class APublishFragment method refreshUI.

/**
	 * 刷新视图
	 */
void refreshUI() {
    if (getPublishBean() == null)
        return;
    PublishBean bean = getPublishBean();
    // 显示图片
    if (bean.getExtras() != null && (bean.getPics() != null || bean.getParams().containsKey("url"))) {
        String[] images = bean.getPics();
        if (images == null) {
            images = new String[] { bean.getParams().getParameter("url") };
        }
        if (TextUtils.isEmpty(editContent.getText().toString().trim()) && TextUtils.isEmpty(getPublishBean().getText())) {
        //				getPublishBean().setText(getString(R.string.publish_share_pic) + " ");
        }
        // 修改为支持多图
        if (true) {
            layImageCover.setVisibility(View.GONE);
            picShow.setVisibility(View.GONE);
        }
        ImageConfig config = new ImageConfig();
        config.setLoadfaildRes(R.drawable.bg_timeline_loading);
        config.setLoadingRes(R.drawable.bg_timeline_loading);
        config.setMaxWidth(SystemUtils.getScreenWidth(getActivity()));
        config.setMaxHeight(SystemUtils.getScreenHeight(getActivity()) / 2);
        config.setBitmapCompress(TimelineBitmapCompress.class);
        config.setProgress(new PublishDownloadProcess());
        if (layPicContainer != null) {
            layPicContainer.removeAllViews();
            scrollPicContainer.setVisibility(View.VISIBLE);
        }
        for (String path : images) {
            View itemView = View.inflate(getActivity(), R.layout.item_publish_pic, null);
            ImageView img = (ImageView) itemView.findViewById(R.id.img);
            itemView.setTag(path);
            itemView.setOnClickListener(onPictureClickListener);
            if (path.toString().startsWith("content://")) {
                Logger.v(TAG, "相册图片地址, path = " + path);
                config.setDownloaderClass(ContentProviderDownloader.class);
            } else if (path.toString().startsWith("http://") || path.toString().startsWith("https://")) {
                Logger.v(TAG, "网络图片地址, path = " + path);
            } else {
                path = path.toString().replace("file://", "");
                Logger.v(TAG, "拍照图片地址, path = " + path);
                // 扫描文件
                SystemUtils.scanPhoto(getActivity(), new File(path));
                config.setDownloaderClass(SdcardDownloader.class);
            }
            BitmapLoader.getInstance().display(this, path, img, config);
            if (layPicContainer != null) {
                layPicContainer.addView(itemView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
            }
        }
    } else {
        if (scrollPicContainer != null)
            scrollPicContainer.setVisibility(View.GONE);
        layImageCover.setVisibility(View.GONE);
        picShow.setVisibility(View.GONE);
    }
    // 文字内容
    if (!TextUtils.isEmpty(bean.getText())) {
        editContent.setText(bean.getText());
        // 如果是意见反馈,不默认将光标移动到最后
        if (bean.getExtras() != null && bean.getExtras().containsKey("feedback"))
            ;
        else
            editContent.setSelection(editContent.getText().toString().length());
    }
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) PublishBean(org.aisen.weibo.sina.support.bean.PublishBean) SpannableString(android.text.SpannableString) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) File(java.io.File) LinearLayout(android.widget.LinearLayout) SdcardDownloader(org.aisen.android.component.bitmaploader.download.SdcardDownloader)

Example 7 with PublishBean

use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.

the class PublishStatusFragment method newPublishBean.

@Override
PublishBean newPublishBean() {
    PublishBean bean = new PublishBean();
    bean.setStatus(PublishStatus.create);
    bean.setType(PublishType.status);
    Params params = new Params();
    // 默认所有人可见
    params.addParameter("visible", "0");
    bean.setParams(params);
    return bean;
}
Also used : PublishBean(org.aisen.weibo.sina.support.bean.PublishBean) Params(org.aisen.android.network.http.Params)

Example 8 with PublishBean

use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.

the class PublishManager method cancelPublish.

public void cancelPublish() {
    removeMessages(publishDelay);
    PublishBean bean = publishQueue.poll();
    if (bean != null) {
        bean.setStatus(PublishStatus.draft);
        PublishDB.addPublish(bean, loggedIn);
        publishNotifier.notifyPublishCancelled(bean);
        refreshDraftbox();
        onPublish(publishQueue.peek());
    }
}
Also used : PublishBean(org.aisen.weibo.sina.support.bean.PublishBean)

Example 9 with PublishBean

use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.

the class PublishManager method publishInit.

/**
	 * 将添加状态的消息都加入到队列当中
	 */
public void publishInit() {
    List<PublishBean> beans = PublishDB.getPublishOfAddStatus(loggedIn);
    for (PublishBean bean : beans) publishQueue.add(bean);
    onPublish(publishQueue.peek());
}
Also used : PublishBean(org.aisen.weibo.sina.support.bean.PublishBean)

Example 10 with PublishBean

use of org.aisen.weibo.sina.support.bean.PublishBean in project AisenWeiBo by wangdan.

the class PublishManager method handleMessage.

@Override
public void handleMessage(Message msg) {
    super.handleMessage(msg);
    switch(msg.what) {
        case publishDelay:
            PublishBean bean = (PublishBean) msg.obj;
            onPublish(bean);
            break;
    }
}
Also used : PublishBean(org.aisen.weibo.sina.support.bean.PublishBean)

Aggregations

PublishBean (org.aisen.weibo.sina.support.bean.PublishBean)16 Params (org.aisen.android.network.http.Params)8 Intent (android.content.Intent)3 SpannableString (android.text.SpannableString)2 View (android.view.View)2 HorizontalScrollView (android.widget.HorizontalScrollView)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 File (java.io.File)2 ObjectAnimator (android.animation.ObjectAnimator)1 Uri (android.net.Uri)1 Message (android.os.Message)1 LinearLayout (android.widget.LinearLayout)1 PhotoChoice (org.aisen.android.common.utils.PhotoChoice)1 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)1 SdcardDownloader (org.aisen.android.component.bitmaploader.download.SdcardDownloader)1 ABaseFragment (org.aisen.android.ui.fragment.ABaseFragment)1 PublishType (org.aisen.weibo.sina.support.bean.PublishType)1