Search in sources :

Example 1 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class CommentItemView method onBindData.

@Override
public void onBindData(View convertView, StatusComment data, int position) {
    WeiBoUser user = data.getUser();
    if (user != null) {
        BitmapLoader.getInstance().display(fragment, AisenUtils.getUserPhoto(user), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
        BizFragment.createBizFragment(fragment).userShow(imgPhoto, user);
        txtName.setText(AisenUtils.getUserScreenName(user));
    } else {
        BizFragment.createBizFragment(fragment).userShow(imgPhoto, null);
        txtName.setText(R.string.error_cmts);
        imgPhoto.setImageResource(R.drawable.user_placeholder);
    }
    txtContent.setContent(AisenUtils.getCommentText(data.getText()));
    AisenUtils.setTextSize(txtContent);
    String createAt = AisenUtils.convDate(data.getCreated_at());
    String from = String.format("%s", Html.fromHtml(data.getSource()));
    String desc = String.format("%s %s", createAt, from);
    txtDesc.setText(desc);
    // 源评论
    if (data.getReply_comment() != null) {
        layRe.setVisibility(View.VISIBLE);
        txtReContent.setContent(AisenUtils.getCommentText(data.getReply_comment().getText()));
        AisenUtils.setTextSize(txtReContent);
        if (data.getReply_comment().getUser() != null) {
            BitmapLoader.getInstance().display(fragment, AisenUtils.getUserPhoto(data.getReply_comment().getUser()), imgRePhoto, ImageConfigUtils.getLargePhotoConfig());
            BizFragment.createBizFragment(fragment).userShow(imgRePhoto, data.getReply_comment().getUser());
        } else {
            BizFragment.createBizFragment(fragment).userShow(imgRePhoto, null);
        }
    } else {
        layRe.setVisibility(View.GONE);
    }
    if (layStatus != null) {
        if (data.getStatus() != null && mStatus == null) {
            layDivider.setVisibility(View.VISIBLE);
            layStatus.setVisibility(View.VISIBLE);
            layStatus.setTag(data.getStatus());
            layStatus.setOnClickListener(this);
            txtStatusContent.setContent(data.getStatus().getText());
            AisenUtils.setTextSize(txtStatusContent);
            String image = null;
            // 先取微博的第一张图
            StatusContent status = data.getStatus();
            if (status != null && status.getRetweeted_status() != null)
                status = status.getRetweeted_status();
            if (status == null || status.getPic_urls() == null || status.getPic_urls().length == 0) {
            } else {
                image = status.getPic_urls()[0].getThumbnail_pic();
            }
            // 没图就取头像
            if (TextUtils.isEmpty(image) && status.getUser() != null) {
                image = status.getUser().getAvatar_large();
            }
            if (!TextUtils.isEmpty(image)) {
                imgView.setVisibility(View.VISIBLE);
                ImageConfig config = new ImageConfig();
                config.setId("comments");
                config.setLoadfaildRes(R.drawable.bg_timeline_loading);
                config.setLoadingRes(R.drawable.bg_timeline_loading);
                config.setMaxWidth(300);
                config.setMaxHeight(300);
                config.setBitmapCompress(TimelineThumbBitmapCompress.class);
                BitmapLoader.getInstance().display(fragment, image, imgView, config);
            } else {
                imgView.setVisibility(View.GONE);
            }
            BizFragment.createBizFragment(fragment).bindOnTouchListener(txtStatusContent);
        } else {
            layDivider.setVisibility(View.GONE);
            layStatus.setVisibility(View.GONE);
        }
    }
    if (btnMenus != null) {
        btnMenus.setTag(data);
        btnMenus.setOnClickListener(this);
    }
}
Also used : ImageConfig(org.aisen.android.component.bitmaploader.core.ImageConfig) StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Example 2 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class PublishStatusRepostFragment method layoutInit.

@Override
protected void layoutInit(LayoutInflater inflater, Bundle savedInstanceState) {
    super.layoutInit(inflater, savedInstanceState);
    btnCamera.setVisibility(View.GONE);
    btnOverflow.setVisibility(View.GONE);
    editContent.setHint(R.string.publish_share_def);
    if (getPublishBean().getStatusContent().getRetweeted_status() != null || getPublishBean().getExtras() != null && getPublishBean().getExtras().containsKey("weiguan")) {
        WeiBoUser user = getPublishBean().getStatusContent().getUser();
        if (user != null) {
            editContent.setText(String.format("//@%s:%s", user.getScreen_name(), getPublishBean().getStatusContent().getText()));
            if (getPublishBean().getExtras() != null && getPublishBean().getExtras().containsKey("weiguan"))
                editContent.setText(String.format("→_→%s", editContent.getText().toString()));
        } else {
            showMessage(R.string.publish_status_none);
            return;
        }
    }
    // 当转发,内容为空时,自动添加"转发微博"
    if (TextUtils.isEmpty(editContent.getText().toString().trim())) {
    //			editContent.setText(R.string.publish_also_repost);
    //			editContent.setSelection(editContent.getText().toString().length());
    }
    StatusContent status = getPublishBean().getStatusContent().getRetweeted_status() != null ? getPublishBean().getStatusContent().getRetweeted_status() : getPublishBean().getStatusContent();
    txtContent.setText(AisenUtils.getCommentText(status.getText()));
    if (status.getUser() != null)
        BitmapLoader.getInstance().display(this, AisenUtils.getUserPhoto(status.getUser()), imgPhoto, ImageConfigUtils.getLargePhotoConfig());
    checkBox.setText(R.string.publish_cmt_to_user);
    checkBox.setChecked("3".equals(getPublishBean().getParams().getParameter("is_comment")));
    checkBox.setOnCheckedChangeListener(this);
    ((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ((BaseActivity) getActivity()).getSupportActionBar().setTitle(R.string.title_repost);
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) WeiBoUser(org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)

Example 3 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class TimelineFavoritesFragment method destoryFav.

private void destoryFav(String statusId) {
    for (StatusContent status : getAdapterItems()) {
        if (String.valueOf(status.getId()).equals(String.valueOf(statusId))) {
            // 更新ListView
            getAdapterItems().remove(status);
            getAdapter().notifyDataSetChanged();
            FavoritesCacheUtility.destory(statusId);
            break;
        }
    }
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent)

Example 4 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class SinaSDK method searchsResultStatuss.

/**
	 * H5接口搜索微博
	 *
	 * @param q
	 * @param page
	 * @param cookies
	 * @return
	 * @throws TaskException
	 */
public ArrayList<StatusContent> searchsResultStatuss(String q, int page, String cookies) throws TaskException {
    ArrayList<StatusContent> resultUsers = new ArrayList<>();
    Setting action = newSetting("searchsResultUsers", "page/pageJson", "获取用户");
    action.getExtras().put(BASE_URL, newSettingExtra(BASE_URL, "http://m.weibo.cn/", ""));
    Params params = new Params();
    params.addParameter("containerid", "100103type%3D2%26q%3D" + q + "&page=" + page);
    try {
        String response = doGet(getHttpConfig(), action, params, String.class);
        JSONObject responseJSON = JSONObject.parseObject(response);
        int ok = responseJSON.getInteger("ok");
        if (ok == 1) {
            JSONArray cardsArray = responseJSON.getJSONArray("cards");
            for (int i = 0; i < cardsArray.size(); i++) {
                JSONObject cardGroupsObject = cardsArray.getJSONObject(i);
                JSONArray cardGroupArray = cardGroupsObject.getJSONArray("card_group");
                for (int j = 0; j < cardGroupArray.size(); j++) {
                    JSONObject cardGroup = cardGroupArray.getJSONObject(j);
                    JSONObject mblogObject = cardGroup.getJSONObject("mblog");
                    StatusContent content = JSON.parseObject(mblogObject.toJSONString(), StatusContent.class);
                    // 图片
                    if (mblogObject.containsKey("pics")) {
                        JSONArray picsArray = mblogObject.getJSONArray("pics");
                        if (picsArray != null && picsArray.size() > 0) {
                            PicUrls picUrls = new PicUrls();
                            picUrls.setThumbnail_pic(picsArray.getJSONObject(0).getString("url"));
                            content.setPic_urls(new PicUrls[] { picUrls });
                        }
                    }
                    // 把Html5文本转换一下
                    content.setText(Html.fromHtml(content.getText()).toString());
                    if (content.getRetweeted_status() != null) {
                        content.getRetweeted_status().setText(Html.fromHtml(content.getRetweeted_status().getText()).toString());
                    }
                    // 把时间转换一下
                    try {
                        Calendar calendar = Calendar.getInstance();
                        int year = calendar.get(Calendar.YEAR);
                        SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
                        calendar.setTimeInMillis(format.parse(content.getCreated_at()).getTime());
                        calendar.set(Calendar.YEAR, year);
                        content.setCreated_at(calendar.getTimeInMillis() + "");
                    } catch (ParseException e) {
                        try {
                            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                            content.setCreated_at(format.parse(content.getCreated_at()).getTime() + "");
                        } catch (ParseException ewe) {
                        }
                    }
                    resultUsers.add(content);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        if (e instanceof TaskException) {
            throw (TaskException) e;
        }
    }
    return resultUsers;
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent) Setting(org.aisen.android.common.setting.Setting) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) JSONArray(com.alibaba.fastjson.JSONArray) Params(org.aisen.android.network.http.Params) ParseException(java.text.ParseException) TaskException(org.aisen.android.network.task.TaskException) JSONObject(com.alibaba.fastjson.JSONObject) PicUrls(org.aisen.weibo.sina.sinasdk.bean.PicUrls) TaskException(org.aisen.android.network.task.TaskException) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with StatusContent

use of org.aisen.weibo.sina.sinasdk.bean.StatusContent in project AisenWeiBo by wangdan.

the class TimelinePhotosItemView method onBindData.

@Override
public void onBindData(View convertView, StatusContent data, int position) {
    this.data = data;
    // username
    if (data.getUser() != null) {
        txtName.setText(AisenUtils.getUserScreenName(data.getUser()));
    }
    txtName.setOnClickListener(this);
    // 转自
    if (data.getRetweeted_status() != null) {
        txtDesc.setVisibility(View.VISIBLE);
        if (data.getRetweeted_status().getUser() != null) {
            txtDesc.setText(String.format(GlobalContext.getInstance().getResources().getString(R.string.timeline_feature_repost), AisenUtils.getUserScreenName(data.getRetweeted_status().getUser())));
        }
    } else {
        txtDesc.setVisibility(View.GONE);
    }
    // pictures
    StatusContent s = data.getRetweeted_status() != null ? data.getRetweeted_status() : data;
    layPicturs.setPics(s, fragment);
}
Also used : StatusContent(org.aisen.weibo.sina.sinasdk.bean.StatusContent)

Aggregations

StatusContent (org.aisen.weibo.sina.sinasdk.bean.StatusContent)15 WeiBoUser (org.aisen.weibo.sina.sinasdk.bean.WeiBoUser)6 DialogInterface (android.content.DialogInterface)3 ArrayList (java.util.ArrayList)3 ImageConfig (org.aisen.android.component.bitmaploader.core.ImageConfig)2 Extra (org.aisen.android.component.orm.extra.Extra)2 TaskException (org.aisen.android.network.task.TaskException)2 PicUrls (org.aisen.weibo.sina.sinasdk.bean.PicUrls)2 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 List (java.util.List)1 Setting (org.aisen.android.common.setting.Setting)1 Params (org.aisen.android.network.http.Params)1 ARecycleViewItemView (org.aisen.android.ui.fragment.adapter.ARecycleViewItemView)1