本文整理汇总了Java中com.mindorks.framework.mvp.utils.CommonUtils类的典型用法代码示例。如果您正苦于以下问题:Java CommonUtils类的具体用法?Java CommonUtils怎么用?Java CommonUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonUtils类属于com.mindorks.framework.mvp.utils包,在下文中一共展示了CommonUtils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: seedDatabaseQuestions
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public Observable<Boolean> seedDatabaseQuestions() {
GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
final Gson gson = builder.create();
return mDbHelper.isQuestionEmpty()
.concatMap(new Function<Boolean, ObservableSource<? extends Boolean>>() {
@Override
public ObservableSource<? extends Boolean> apply(Boolean isEmpty)
throws Exception {
if (isEmpty) {
Type type = $Gson$Types
.newParameterizedTypeWithOwner(null, List.class,
Question.class);
List<Question> questionList = gson.fromJson(
CommonUtils.loadJSONFromAsset(mContext,
AppConstants.SEED_DATABASE_QUESTIONS),
type);
return saveQuestionList(questionList);
}
return Observable.just(false);
}
});
}
示例2: seedDatabaseOptions
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public Observable<Boolean> seedDatabaseOptions() {
GsonBuilder builder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
final Gson gson = builder.create();
return mDbHelper.isOptionEmpty()
.concatMap(new Function<Boolean, ObservableSource<? extends Boolean>>() {
@Override
public ObservableSource<? extends Boolean> apply(Boolean isEmpty)
throws Exception {
if (isEmpty) {
Type type = new TypeToken<List<Option>>() {
}
.getType();
List<Option> optionList = gson.fromJson(
CommonUtils.loadJSONFromAsset(mContext,
AppConstants.SEED_DATABASE_OPTIONS),
type);
return saveOptionList(optionList);
}
return Observable.just(false);
}
});
}
示例3: showLoading
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void showLoading() {
hideLoading();
mProgressDialog = CommonUtils.showLoadingDialog(this);
}
示例4: showLoading
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void showLoading() {
hideLoading();
mProgressDialog = CommonUtils.showLoadingDialog(this.getContext());
}
示例5: onServerLoginClick
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void onServerLoginClick(String email, String password) {
//validate email and password
if (email == null || email.isEmpty()) {
getMvpView().onError(R.string.empty_email);
return;
}
if (!CommonUtils.isEmailValid(email)) {
getMvpView().onError(R.string.invalid_email);
return;
}
if (password == null || password.isEmpty()) {
getMvpView().onError(R.string.empty_password);
return;
}
getMvpView().showLoading();
getCompositeDisposable().add(getDataManager()
.doServerLoginApiCall(new LoginRequest.ServerLoginRequest(email, password))
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<LoginResponse>() {
@Override
public void accept(LoginResponse response) throws Exception {
getDataManager().updateUserInfo(
response.getAccessToken(),
response.getUserId(),
DataManager.LoggedInMode.LOGGED_IN_MODE_SERVER,
response.getUserName(),
response.getUserEmail(),
response.getGoogleProfilePicUrl());
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
getMvpView().openMainActivity();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
// handle the login error here
if (throwable instanceof ANError) {
ANError anError = (ANError) throwable;
handleApiError(anError);
}
}
}));
}
示例6: onServerLoginClick
import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void onServerLoginClick(String email, String password) {
//validate email and password
if (email == null || email.isEmpty()) {
getMvpView().onError(R.string.empty_email);
return;
}
if (!CommonUtils.isEmailValid(email)) {
getMvpView().onError(R.string.invalid_email);
return;
}
if (password == null || password.isEmpty()) {
getMvpView().onError(R.string.empty_password);
return;
}
getMvpView().showLoading();
getCompositeDisposable().add(getInteractor()
.doServerLoginApiCall(new LoginRequest.ServerLoginRequest(email, password))
.subscribeOn(getSchedulerProvider().io())
.observeOn(getSchedulerProvider().ui())
.subscribe(new Consumer<LoginResponse>() {
@Override
public void accept(LoginResponse response) throws Exception {
getInteractor().updateUserInfo(
response.getAccessToken(),
response.getUserId(),
AppConstants.LoggedInMode.LOGGED_IN_MODE_SERVER,
response.getUserName(),
response.getUserEmail(),
response.getGoogleProfilePicUrl());
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
getMvpView().openMainActivity();
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (!isViewAttached()) {
return;
}
getMvpView().hideLoading();
// handle the login error here
if (throwable instanceof ANError) {
ANError anError = (ANError) throwable;
handleApiError(anError);
}
}
}));
}