当前位置: 首页>>代码示例>>Java>>正文


Java CommonUtils类代码示例

本文整理汇总了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);
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:AppDataManager.java

示例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);
                }
            });
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:AppDataManager.java

示例3: showLoading

import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void showLoading() {
    hideLoading();
    mProgressDialog = CommonUtils.showLoadingDialog(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:BaseActivity.java

示例4: showLoading

import com.mindorks.framework.mvp.utils.CommonUtils; //导入依赖的package包/类
@Override
public void showLoading() {
    hideLoading();
    mProgressDialog = CommonUtils.showLoadingDialog(this.getContext());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:BaseFragment.java

示例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);
                    }
                }
            }));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:59,代码来源:LoginPresenter.java

示例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);
                    }
                }
            }));
}
 
开发者ID:MindorksOpenSource,项目名称:android-mvp-interactor-architecture,代码行数:59,代码来源:LoginPresenter.java


注:本文中的com.mindorks.framework.mvp.utils.CommonUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。