Search in sources :

Example 1 with AppBean

use of com.pgyersdk.javabean.AppBean in project BBS-Android by bdpqchen.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHomeActivity = this;
    mContext = this;
    LogUtil.dd("token", PrefUtil.getAuthToken());
    // 登录后的渐变,
    if (!PrefUtil.isNoAccountUser()) {
        PrefUtil.setHadLogin(true);
    }
    mMask.setVisibility(View.VISIBLE);
    ObjectAnimator animator = ObjectAnimator.ofFloat(findViewById(R.id.mask_home), "alpha", 0f).setDuration(600);
    animator.setStartDelay(400);
    animator.start();
    mMainFragment = MainFragment.newInstance();
    mForumFragment = ForumFragment.newInstance();
    mIndividualFragment = IndividualFragment.newInstance();
    loadMultipleRootFragment(R.id.fl_main_container, 0, mMainFragment, mForumFragment, mIndividualFragment);
    mNearBy = mBottomBar.getTabWithId(R.id.bottom_bar_tab_individual);
    mBottomBar.setOnTabSelectListener(i -> {
        LogUtil.dd("onTabSelected()");
        if (PrefUtil.hadLogin()) {
            if (i == R.id.bottom_bar_tab_main) {
                mShowingFragment = Constants.FRAGMENT_MAIN;
            } else if (i == R.id.bottom_bar_tab_forum) {
                mShowingFragment = Constants.FRAGMENT_FORUM;
            } else if (i == R.id.bottom_bar_tab_individual) {
                mShowingFragment = Constants.FRAGMENT_INDIVIDUAL;
            }
            loadFragment();
        } else if (i == R.id.bottom_bar_tab_individual && !PrefUtil.hadLogin()) {
            startActivity(new Intent(this, LoginActivity.class));
        }
    });
    // TODO: 17-5-22 解决夜间模式View的空指针问题
    if (PrefUtil.hadLogin()) {
        mPresenter.initIndividualInfo();
    }
    HandlerUtil.postDelay(() -> {
        PgyUpdateManager.register(this, "9981", new UpdateManagerListener() {

            @Override
            public void onNoUpdateAvailable() {
                LogUtil.dd("not update available");
            }

            @Override
            public void onUpdateAvailable(final String result) {
                // 将新版本信息封装到AppBean中
                final AppBean appBean = getAppBeanFromString(result);
                new MaterialDialog.Builder(mContext).cancelable(false).title("最新版本更新").content(appBean.getReleaseNote()).positiveText("立即下载").positiveColor(ResourceUtil.getColor(mContext, R.color.colorPrimary)).onPositive((new MaterialDialog.SingleButtonCallback() {

                    @Override
                    public void onClick(@NonNull MaterialDialog materialDialog, @NonNull DialogAction dialogAction) {
                        hasPermission(appBean);
                    }
                })).negativeText("再说吧").show();
            }
        });
    }, 1000);
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) ObjectAnimator(android.animation.ObjectAnimator) DialogAction(com.afollestad.materialdialogs.DialogAction) Intent(android.content.Intent) UpdateManagerListener(com.pgyersdk.update.UpdateManagerListener) AppBean(com.pgyersdk.javabean.AppBean)

Aggregations

ObjectAnimator (android.animation.ObjectAnimator)1 Intent (android.content.Intent)1 DialogAction (com.afollestad.materialdialogs.DialogAction)1 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)1 AppBean (com.pgyersdk.javabean.AppBean)1 UpdateManagerListener (com.pgyersdk.update.UpdateManagerListener)1