com.sina.weibo.sdk.api.TextObject Java Examples
The following examples show how to use
com.sina.weibo.sdk.api.TextObject.
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 |
/** * 普通分享,支持文字,链接,图片 注意:微博分享设置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: WeiboBaseShareInstance.java From SimpleProject with MIT License | 6 votes |
/** * 多图分享 * @param activity * @param desc * @param url * @param imageList */ private void shareMediaByWeibo(Activity activity, String desc, String url, ArrayList<Uri> imageList) { WeiboMultiMessage multiMessage = new WeiboMultiMessage(); if (!TextUtils.isEmpty(desc)) { TextObject textObject = new TextObject(); textObject.text = desc + " " + url; multiMessage.textObject = textObject; } if (!CollectionUtil.isEmpty(imageList)) { MultiImageObject multiImageObj = new MultiImageObject(); multiImageObj.setImageList(imageList); multiMessage.multiImageObject = multiImageObj; } shareHandler.shareMessage(multiMessage, false); }
Example #3
Source File: SharePresenter.java From the-tech-frontier-app with MIT License | 6 votes |
/** * 分享文章到新浪微博 * * @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 #4
Source File: Share.java From UPMiss with GNU General Public License v3.0 | 6 votes |
private static void shareToWeibo(Activity activity, String title, String summary, Bitmap img) { ImageObject imageObject = new ImageObject(); imageObject.imageData = bmpToByteArray(img); TextObject textObject = new TextObject(); textObject.text = title + "\n" + summary + Constants.SUMMARY; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; message.imageObject = imageObject; WbShareHandler wbApi = getWbApi(activity); wbApi.shareMessage(message, false); // Bind cache activity.getWindow().getDecorView().setTag(wbApi); }
Example #5
Source File: WeiboShareProxy.java From ESSocialSDK with Apache License 2.0 | 5 votes |
private static void shareTo(final Context context, final String appKey, final String redirectUrl, final String scop, final String title, final String desc, final String imageUrl, final String shareUrl, final WeiboAuthListener listener) { new Thread(new Runnable() { @Override public void run() { WeiboMultiMessage msg = new WeiboMultiMessage(); TextObject text = new TextObject(); text.text = desc; msg.textObject = text; WebpageObject web = new WebpageObject(); web.description = desc; byte[] thumb = SocialUtils.getHtmlByteArray(imageUrl); if (null != thumb) web.thumbData = SocialUtils.compressBitmap(thumb, 32); else web.thumbData = SocialUtils.compressBitmap(SocialUtils.getDefaultShareImage(context), 32); web.actionUrl = shareUrl; web.identify = imageUrl; web.title = title; msg.mediaObject = web; SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest(); request.transaction = String.valueOf(System.currentTimeMillis()); request.multiMessage = msg; AuthInfo authInfo = new AuthInfo(context, appKey, redirectUrl, scop); Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(context); String token = ""; if (accessToken != null) { token = accessToken.getToken(); } getInstance(context, appKey).sendRequest((Activity) context, request, authInfo, token, listener); } }).start(); }
Example #6
Source File: WeiboShareInstance.java From ShareLoginPayUtil with Apache License 2.0 | 5 votes |
/** * 创建文本消息对象。 * * @return 文本消息对象。 */ private TextObject getTextObj(String title, String targetUrl, String summary) { TextObject textObject = new TextObject(); textObject.text = summary; textObject.title = title; textObject.actionUrl = targetUrl; return textObject; }
Example #7
Source File: WeiboShareInstance.java From smart-farmer-android with Apache License 2.0 | 5 votes |
@Override public void shareText(int platform, String text, Activity activity, ShareListener listener) { TextObject textObject = new TextObject(); textObject.text = text; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; sendRequest(activity, message); }
Example #8
Source File: WeiboShareInstance.java From ShareUtil with Apache License 2.0 | 5 votes |
@Override public void shareText(int platform, String text, Activity activity, ShareListener listener) { TextObject textObject = new TextObject(); textObject.text = text; WeiboMultiMessage message = new WeiboMultiMessage(); message.textObject = textObject; sendRequest(activity, message); }
Example #9
Source File: SinaShareHandler.java From BiliShare with Apache License 2.0 | 5 votes |
/** * 创建文本消息对象。 * * @return 文本消息对象。 */ private TextObject getTextObj(BaseShareParam params) { TextObject textObject = new TextObject(); if (params != null) { textObject.title = params.getTitle(); textObject.text = params.getContent(); textObject.actionUrl = params.getTargetUrl(); if (!TextUtils.isEmpty(textObject.actionUrl)) { textObject.text = String.format("%s %s", textObject.text, textObject.actionUrl); } } return textObject; }
Example #10
Source File: LoginShare.java From LoginSharePay with Apache License 2.0 | 5 votes |
@Override protected TextObject getTextObject(WeiboMessageBody weiboMessageBody) { TextObject textObject = new TextObject(); textObject.text = weiboMessageBody.getText(); textObject.title = weiboMessageBody.getTitle(); textObject.actionUrl = weiboMessageBody.getActionUrl(); return textObject; }
Example #11
Source File: WbPlatform.java From SocialSdkLibrary with Apache License 2.0 | 4 votes |
private TextObject getTextObj(String summary) { TextObject textObject = new TextObject(); textObject.text = summary; return textObject; }
Example #12
Source File: WeiboShareInstance.java From ShareUtil with Apache License 2.0 | 4 votes |
private void shareTextOrImage(final ShareImageObject shareImageObject, final String text, final Activity activity, final ShareListener listener) { Observable.fromEmitter(new Action1<Emitter<Pair<String, byte[]>>>() { @Override public void call(Emitter<Pair<String, byte[]>> emitter) { try { String path = ImageDecoder.decode(activity, shareImageObject); emitter.onNext(Pair.create(path, ImageDecoder.compress2Byte(path, TARGET_SIZE, TARGET_LENGTH))); emitter.onCompleted(); } catch (Exception e) { emitter.onError(e); } } }, Emitter.BackpressureMode.DROP) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnRequest(new Action1<Long>() { @Override public void call(Long aLong) { listener.shareRequest(); } }) .subscribe(new Action1<Pair<String, byte[]>>() { @Override public void call(Pair<String, byte[]> pair) { ImageObject imageObject = new ImageObject(); imageObject.imageData = pair.second; imageObject.imagePath = pair.first; WeiboMultiMessage message = new WeiboMultiMessage(); message.imageObject = imageObject; if (!TextUtils.isEmpty(text)) { TextObject textObject = new TextObject(); textObject.text = text; message.textObject = textObject; } sendRequest(activity, message); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { activity.finish(); listener.shareFailure(new Exception(throwable)); } }); }
Example #13
Source File: WBHelper.java From SocialHelper with Apache License 2.0 | 4 votes |
private TextObject getTextObj(Bundle params) { TextObject textObj = new TextObject(); textObj.text = params.getString(WBShareEntity.KEY_WB_TEXT); return textObj; }
Example #14
Source File: WeiboShareInstance.java From smart-farmer-android with Apache License 2.0 | 4 votes |
private void shareTextOrImage(final ShareImageObject shareImageObject, final String text, final Activity activity, final ShareListener listener) { Flowable.create(new FlowableOnSubscribe<Pair<String, byte[]>>() { @Override public void subscribe(@NonNull FlowableEmitter<Pair<String, byte[]>> emitter) throws Exception { try { String path = ImageDecoder.decode(activity, shareImageObject); emitter.onNext(Pair.create(path, ImageDecoder.compress2Byte(path, TARGET_SIZE, TARGET_LENGTH))); emitter.onComplete(); } catch (Exception e) { emitter.onError(e); } } }, BackpressureStrategy.DROP) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .doOnRequest(new LongConsumer() { @Override public void accept(long aLong) { listener.shareRequest(); } }) .subscribe(new Consumer<Pair<String,byte[]>>() { @Override public void accept(Pair<String, byte[]> pair) { ImageObject imageObject = new ImageObject(); imageObject.imageData = pair.second; imageObject.imagePath = pair.first; WeiboMultiMessage message = new WeiboMultiMessage(); message.imageObject = imageObject; if (!TextUtils.isEmpty(text)) { TextObject textObject = new TextObject(); textObject.text = text; message.textObject = textObject; } sendRequest(activity, message); } }, new Consumer<Throwable>() { @Override public void accept(Throwable throwable) { activity.finish(); listener.shareFailure(new Exception(throwable)); } }); }
Example #15
Source File: SinaShareImpl.java From ChinaShare with MIT License | 4 votes |
/** * 创建文本消息对象。 * * @return 文本消息对象。 */ private TextObject getTextObj(String text) { TextObject textObject = new TextObject(); textObject.text = text; return textObject; }
Example #16
Source File: SinaWBHandler.java From SocialSDKAndroid with Apache License 2.0 | 4 votes |
@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 #17
Source File: WeiboShareManager.java From sharesdk with Apache License 2.0 | 4 votes |
/** * 创建文本消息对象。 * * @return 文本消息对象。 */ private TextObject getTextObj(String text) { TextObject textObject = new TextObject(); textObject.text = text; return textObject; }
Example #18
Source File: SharePopWindow.java From QiQuYing with Apache License 2.0 | 4 votes |
/** * 创建文本消息对象。 * * @return 文本消息对象。 */ private TextObject getTextObj() { TextObject textObject = new TextObject(); textObject.text = "分享自#奇趣营#" + description; return textObject; }
Example #19
Source File: WBShare.java From sdk3rd with Apache License 2.0 | 4 votes |
TextObject toText(String text) { TextObject object = new TextObject(); object.text = text; return object; }
Example #20
Source File: ShareImpl.java From LoginSharePay with Apache License 2.0 | votes |
protected abstract TextObject getTextObject(WeiboMessageBody weiboMessageBody);