use of io.reactivex.annotations.NonNull in project Mvp-Rxjava-Retrofit-dagger2 by pengMaster.
the class SplashPresenter method toActDownLoadNetKey.
/**
* 下载网络请求验证码
*/
private void toActDownLoadNetKey() {
ThreadUtils.runThread(new Runnable() {
@Override
public void run() {
HttpClient httpClient = new HttpClient();
Map<String, String> msg = new HashMap<String, String>();
msg.put("appKey", "9c3d77f18e4848d095e626e9b3a009a3");
msg.put("appSecret", "ff265c879c4ac08028e77a6c66078f9ce81c15b6fbc76c18f7a12a97c859c92b");
String params = new Gson().toJson(msg);
StringRequestEntity paramEntity = null;
try {
paramEntity = new StringRequestEntity(params, "application/json", "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
PostMethod postMethod = new PostMethod(Api.POST_KEY);
postMethod.setRequestEntity(paramEntity);
try {
httpClient.executeMethod(postMethod);
} catch (IOException e) {
e.printStackTrace();
}
try {
InputStream inputStream = postMethod.getResponseBodyAsStream();
final String resultKey = convertStreamToString(inputStream);
ThreadUtils.runInMainThread(new Runnable() {
@Override
public void run() {
ResultKeyGsonBean resultKeyBean = new Gson().fromJson(resultKey, ResultKeyGsonBean.class);
String access_token = resultKeyBean.getData().getAccess_token();
GlobalConstantUtils.setToken(access_token);
Observable.create(new ObservableOnSubscribe<String>() {
@Override
public void subscribe(@NonNull ObservableEmitter<String> e) throws Exception {
SystemClock.sleep(2000);
e.onNext("");
e.onComplete();
}
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
Intent intent = new Intent(AppLifecyclesImpl.mAppContext, MainActivity.class);
mRootView.launchActivity(intent);
mRootView.killMyself();
}
});
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
use of io.reactivex.annotations.NonNull in project Shuttle by timusus.
the class AestheticEditText method onAttachedToWindow.
@SuppressWarnings("ConstantConditions")
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subscriptions = new CompositeDisposable();
subscriptions.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(new Consumer<ColorIsDarkState>() {
@Override
public void accept(@NonNull ColorIsDarkState colorIsDarkState) {
invalidateColors(colorIsDarkState);
}
}, onErrorLogAndRethrow()));
subscriptions.add(ViewUtil.getObservableForResId(getContext(), textColorResId, Aesthetic.get(getContext()).textColorPrimary()).compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewTextColorAction.create(this), onErrorLogAndRethrow()));
subscriptions.add(ViewUtil.getObservableForResId(getContext(), textColorHintResId, Aesthetic.get(getContext()).textColorSecondary()).compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewHintTextColorAction.create(this), onErrorLogAndRethrow()));
}
use of io.reactivex.annotations.NonNull in project Shuttle by timusus.
the class AestheticRadioButton method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subscriptions = new CompositeDisposable();
// noinspection ConstantConditions
subscriptions.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(new Consumer<ColorIsDarkState>() {
@Override
public void accept(@NonNull ColorIsDarkState colorIsDarkState) {
invalidateColors(colorIsDarkState);
}
}, onErrorLogAndRethrow()));
subscriptions.add(Aesthetic.get(getContext()).textColorPrimary().compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewTextColorAction.create(this)));
}
use of io.reactivex.annotations.NonNull in project Shuttle by timusus.
the class AestheticTextInputEditText method onAttachedToWindow.
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subs = new CompositeDisposable();
subs.add(Aesthetic.get(getContext()).textColorPrimary().compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewTextColorAction.create(this), onErrorLogAndRethrow()));
subs.add(Aesthetic.get(getContext()).textColorSecondary().compose(Rx.<Integer>distinctToMainThread()).subscribe(ViewHintTextColorAction.create(this), onErrorLogAndRethrow()));
// noinspection ConstantConditions
subs.add(Observable.combineLatest(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()), Aesthetic.get(getContext()).isDark(), ColorIsDarkState.creator()).compose(Rx.<ColorIsDarkState>distinctToMainThread()).subscribe(new Consumer<ColorIsDarkState>() {
@Override
public void accept(@NonNull ColorIsDarkState colorIsDarkState) {
invalidateColors(colorIsDarkState);
}
}, onErrorLogAndRethrow()));
}
use of io.reactivex.annotations.NonNull in project Shuttle by timusus.
the class AestheticTextInputLayout method onAttachedToWindow.
@SuppressWarnings("ConstantConditions")
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
subs = new CompositeDisposable();
subs.add(Aesthetic.get(getContext()).textColorSecondary().compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@NonNull Integer color) {
TextInputLayoutUtil.setHint(AestheticTextInputLayout.this, adjustAlpha(color, 0.7f));
}
}, onErrorLogAndRethrow()));
subs.add(ViewUtil.getObservableForResId(getContext(), backgroundResId, Aesthetic.get(getContext()).colorAccent()).compose(Rx.<Integer>distinctToMainThread()).subscribe(new Consumer<Integer>() {
@Override
public void accept(@NonNull Integer color) {
invalidateColors(color);
}
}, onErrorLogAndRethrow()));
}
Aggregations