use of com.wingjay.jianshi.bean.ShareContent in project jianshi by wingjay.
the class ViewActivity method share.
@OnClick(R.id.view_share)
void share() {
Blaster.log(LoggingData.BTN_CLK_SHARE_DIARY_IMAGE);
final View target = verticalStyle ? container : normalContainer;
final ProgressDialog dialog = ProgressDialog.show(this, "", "加载中...");
screenshotManager.shotScreen(target, "temp.jpg").observeOn(Schedulers.io()).filter(new Func1<String, Boolean>() {
@Override
public Boolean call(String s) {
return !TextUtils.isEmpty(s);
}
}).flatMap(new Func1<String, Observable<Pair<String, ShareContent>>>() {
@Override
public Observable<Pair<String, ShareContent>> call(String path) {
Timber.i("ViewActivity ScreenshotManager 1 %s", Thread.currentThread().getName());
ShareContent shareContent = new ShareContent();
try {
JsonDataResponse<ShareContent> response = userService.getShareContent().toBlocking().first();
if (response.getRc() == Constants.ServerResultCode.RESULT_OK && response.getData() != null) {
shareContent = response.getData();
}
} catch (Exception e) {
Timber.e(e, "getShareContent() error");
return Observable.just(Pair.create(path, shareContent));
}
return Observable.just(Pair.create(path, shareContent));
}
}).observeOn(AndroidSchedulers.mainThread()).doOnTerminate(new Action0() {
@Override
public void call() {
dialog.dismiss();
}
}).subscribe(new Action1<Pair<String, ShareContent>>() {
@Override
public void call(Pair<String, ShareContent> stringShareContentPair) {
Timber.i("ViewActivity ScreenshotManager 2 %s", Thread.currentThread().getName());
if (!isUISafe()) {
return;
}
IntentUtil.shareLinkWithImage(ViewActivity.this, stringShareContentPair.second, Uri.fromFile(new File(stringShareContentPair.first)));
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
makeToast(getString(R.string.share_failure));
Timber.e(throwable, "screenshot share failure");
}
});
}
Aggregations