use of com.yydcdut.note.entity.user.EvernoteUser in project PhotoNoter by yydcdut.
the class RxUser method getEvernote.
public Observable<IUser> getEvernote() {
return Observable.create(new Observable.OnSubscribe<IUser>() {
@Override
public void call(Subscriber<? super IUser> subscriber) {
if (mEvernoteUser == null) {
String name = mSharedPreferences.getString(EVERNOTE_NAME, NAME_DEFAULT);
if (TextUtils.isEmpty(name)) {
subscriber.onError(new RxException("没有登录!!!"));
} else {
mEvernoteUser = new EvernoteUser(name);
}
}
subscriber.onNext(mEvernoteUser);
subscriber.onCompleted();
}
}).subscribeOn(Schedulers.io());
}
use of com.yydcdut.note.entity.user.EvernoteUser in project PhotoNoter by yydcdut.
the class RxUser method saveEvernote.
public Observable<IUser> saveEvernote() {
return Observable.create(new Observable.OnSubscribe<IUser>() {
@Override
public void call(Subscriber<? super IUser> subscriber) {
if (mEvernoteSession.isLoggedIn()) {
try {
User user = mEvernoteSession.getEvernoteClientFactory().getUserStoreClient().getUser();
mEvernoteUser = new EvernoteUser(user.getUsername());
SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putString(EVERNOTE_NAME, mEvernoteUser.getName());
editor.commit();
subscriber.onNext(mEvernoteUser);
} catch (EDAMUserException e) {
YLog.e(e);
subscriber.onError(e);
} catch (EDAMSystemException e) {
YLog.e(e);
subscriber.onError(e);
} catch (TException e) {
YLog.e(e);
subscriber.onError(e);
}
} else {
subscriber.onError(new RxException("没有登录"));
}
subscriber.onCompleted();
}
}).subscribeOn(Schedulers.io());
}
Aggregations