Java Code Examples for com.sina.weibo.sdk.api.ImageObject#setImageObject()

The following examples show how to use com.sina.weibo.sdk.api.ImageObject#setImageObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeiboBaseShareInstance.java    From SimpleProject with MIT License 6 votes vote down vote up
/**
 * 普通分享,支持文字,链接,图片  注意:微博分享设置title无效,链接应追加在desc后面
 * @param activity
 * @param desc
 * @param url
 * @param bitmap
 */
private void shareMediaByWeibo(Activity activity, String desc, String url, Bitmap bitmap) {
	WeiboMultiMessage multiMessage = new WeiboMultiMessage();
	if (!TextUtils.isEmpty(desc)) {
		TextObject textObject = new TextObject();
		textObject.text = desc + " " + url;
		multiMessage.textObject = textObject;
	}
	if (bitmap != null && !bitmap.isRecycled()) {
		ImageObject imageObject = new ImageObject();
		imageObject.setImageObject(bitmap);
		multiMessage.imageObject = imageObject;
	}

	shareHandler.shareMessage(multiMessage, false);
}
 
Example 2
Source File: SharePresenter.java    From the-tech-frontier-app with MIT License 6 votes vote down vote up
/**
 * 分享文章到新浪微博
 * 
 * @param title
 * @param url
 */
public void share(Activity activity, String title, String url) {
    WeiboMultiMessage weiboMessage = new WeiboMultiMessage();// 初始化微博的分享消息
    TextObject textObject = new TextObject();
    textObject.text = "《" + title + "》" + "这篇文章不错, 文章地址 : " + url
            + "。本文来自: 开发技术前线, http://www.devtf.cn 。";
    weiboMessage.textObject = textObject;
    ImageObject imageObject = new ImageObject();
    imageObject.setImageObject(BitmapFactory.decodeResource(activity.getResources(),
            R.drawable.ic_launcher));
    weiboMessage.imageObject = imageObject;
    SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
    request.transaction = String.valueOf(System.currentTimeMillis());
    request.multiMessage = weiboMessage;
    mWeiboShareAPI.sendRequest(activity, request); // 发送请求消息到微博,唤起微博分享界面
}
 
Example 3
Source File: LoginShare.java    From LoginSharePay with Apache License 2.0 5 votes vote down vote up
@Override
protected ImageObject getImageObject(WeiboMessageBody weiboMessageBody) {
    ImageObject imageObject = new ImageObject();
    Bitmap bitmap = BitmapFactory.decodeFile(weiboMessageBody.getLocalImage());
    imageObject.setImageObject(bitmap);
    return imageObject;
}
 
Example 4
Source File: WBHelper.java    From SocialHelper with Apache License 2.0 5 votes vote down vote up
private ImageObject getImageObj(Bundle params) {
    ImageObject imgObj = new ImageObject();
    if (params.containsKey(WBShareEntity.KEY_WB_IMG_LOCAL)) {//分为本地文件和应用内资源图片
        String imgUrl = params.getString(WBShareEntity.KEY_WB_IMG_LOCAL);
        if (notFoundFile(imgUrl)) {
            return null;
        }
        imgObj.imagePath = imgUrl;
    } else {
        Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), params.getInt(WBShareEntity.KEY_WB_IMG_RES));
        imgObj.setImageObject(bitmap);
        bitmap.recycle();
    }
    return imgObj;
}
 
Example 5
Source File: SinaShareImpl.java    From ChinaShare with MIT License 5 votes vote down vote up
/**
 * 创建图片消息对象。
 *
 * @return 图片消息对象。
 */
private ImageObject getImageObj(String imageUrl) {
    ImageObject imageObject = new ImageObject();
    Bitmap bmp = BitmapFactory.decodeFile(imageUrl);
    imageObject.setImageObject(bmp);
    return imageObject;
}
 
Example 6
Source File: SharePopWindow.java    From QiQuYing with Apache License 2.0 5 votes vote down vote up
/**
 * 创建图片消息对象。
 * 
 * @return 图片消息对象。
 */
private ImageObject getImageObj() {
	Bitmap bitmap = BitmapUtil.getBitmapFromCache(mJoke.getImgUrl());
	if(bitmap == null) {
		return null;
	}
    ImageObject imageObject = new ImageObject();
    imageObject.setImageObject(bitmap);
    imageObject.title = title;
    imageObject.description = description;
    imageObject.actionUrl = targetUrl + mJoke.getId();
    return imageObject;
}
 
Example 7
Source File: SinaWBHandler.java    From SocialSDKAndroid with Apache License 2.0 4 votes vote down vote up
@Override
    public void share(Activity activity, IShareMedia shareMedia, ShareListener shareListener) {
        this.mActivity = activity;
        this.mShareListener = shareListener;

        this.mSsoHandler = new SsoHandler(mActivity, mAuthInfo);

        WeiboMultiMessage weiboMessage = new WeiboMultiMessage();

        if(shareMedia instanceof ShareTextImageMedia) {       //文字图片分享
            ShareTextImageMedia shareTextImageMedia = (ShareTextImageMedia) shareMedia;

            if(shareTextImageMedia.getText().length() > 0) {
                TextObject textObject = new TextObject();
                textObject.text = shareTextImageMedia.getText();
                weiboMessage.textObject = textObject;
            }

            if(shareTextImageMedia.getImage() != null) {
                ImageObject imageObject = new ImageObject();
                imageObject.setImageObject(shareTextImageMedia.getImage());
                weiboMessage.imageObject = imageObject;
            }
        } else {
            if(this.mShareListener != null) {
                this.mShareListener.onError(this.mConfig.getName(), "weibo is not support this shareMedia");
            }
            return ;
        }

        SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
        request.transaction = String.valueOf(System.currentTimeMillis());
        request.multiMessage = weiboMessage;

        Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(mContext.getApplicationContext());
        String token = "";
        if (accessToken != null) {
            token = accessToken.getToken();
        }
        mWeiboShareAPI.sendRequest(mActivity, request, mAuthInfo, token, new WeiboAuthListener() {

            @Override
            public void onWeiboException( WeiboException arg0 ) {
            }

            @Override
            public void onComplete( Bundle bundle ) {
                // TODO Auto-generated method stub
                Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
                AccessTokenKeeper.writeAccessToken(mContext.getApplicationContext(), newToken);
            }

            @Override
            public void onCancel() {
            }
        });

//        mWeiboShareAPI.sendRequest(mActivity, request);
    }
 
Example 8
Source File: WeiboShareManager.java    From sharesdk with Apache License 2.0 4 votes vote down vote up
/**
 * 创建图片消息对象。
 *
 * @return 图片消息对象。
 */
private ImageObject getImageObj(Bitmap bitmap) {
    ImageObject imageObject = new ImageObject();
    imageObject.setImageObject(bitmap);
    return imageObject;
}