Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            CurrContext  = ApplicationContext;
            CurrActivity = this;

            if (IsFullScreen)
            {
                initSystemBar(Resource.Color.actionbar_bg);
            }

            string userinfoStr = (string)SharedPreferencesUtil.GetParam(CurrActivity, AppConfig.SP_USERINFO, "");

            if (!string.IsNullOrEmpty(userinfoStr))
            {
                CurrUserInfo = DataService.Helper.FromJsonTo <LoginUserInfoEntity>(userinfoStr);
            }

            if (CurrUserInfo == null)
            {
                CurrActivity.Finish();
            }

            if (LayoutReourceId > 0)
            {
                SetContentView(LayoutReourceId);
            }

            base.OnCreate(savedInstanceState);
        }
Exemplo n.º 2
0
        private void changedMode(bool isNight, int position)
        {
            SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, isNight);
            AppCompatDelegate.DefaultNightMode = (isNight ? AppCompatDelegate.ModeNightYes
                    : AppCompatDelegate.ModeNightNo);

            if (position >= 0)
            {
                curTheme = position;
            }
            else
            {
                curTheme = Settings.ReadTheme;
            }
            gvAdapter.select(curTheme);

            mPageWidget.setTheme(isNight ? ThemeManager.NIGHT : curTheme);
            mPageWidget.setTextColor(ContextCompat.GetColor(mContext, isNight ? Resource.Color.chapter_content_night : Resource.Color.chapter_content_day),
                                     ContextCompat.GetColor(mContext, isNight ? Resource.Color.chapter_title_night : Resource.Color.chapter_title_day));

            mTvBookReadMode.Text = (GetString(isNight ? Resource.String.book_read_mode_day_manual_setting
                    : Resource.String.book_read_mode_night_manual_setting));
            Drawable drawable = ContextCompat.GetDrawable(this, isNight ? Resource.Drawable.ic_menu_mode_day_manual
                    : Resource.Drawable.ic_menu_mode_night_manual);

            drawable.SetBounds(0, 0, drawable.MinimumWidth, drawable.MinimumHeight);
            mTvBookReadMode.SetCompoundDrawables(null, drawable, null, null);

            ThemeManager.setReaderTheme(curTheme, mRlBookReadRoot);
        }
Exemplo n.º 3
0
        private CustomDialog dialog;//进度条

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(getLayoutId());
            if (statusBarColor == 0)
            {
                statusBarView = StatusBarCompat.compat(this, ContextCompat.GetColor(this, Resource.Color.colorPrimaryDark));
            }
            else if (statusBarColor != -1)
            {
                statusBarView = StatusBarCompat.compat(this, statusBarColor);
            }
            transparent19and20();
            mContext = this;
            bindViews();
            mCommonToolbar = FindViewById <Toolbar>(Resource.Id.common_toolbar);
            if (mCommonToolbar != null)
            {
                initToolBar();
                SetSupportActionBar(mCommonToolbar);
            }
            initDatas();
            configViews();
            mNowMode = SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT);
        }
Exemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_splash);

            string userinfoStr = (string)SharedPreferencesUtil.GetParam(this, AppConfig.SP_USERINFO, "");

            if (!string.IsNullOrEmpty(userinfoStr))
            {
                currUserInfo = DataService.Helper.FromJsonTo <LoginUserInfoEntity>(userinfoStr);
            }

            // 将一些字典数据提前加载
            if (NetUtil.CheckNetWork(this) && currUserInfo != null)
            {
                LoadQuarterData();
                LoadGradeData();
                LoadDistrictData();
            }

            new Handler().PostDelayed(() =>
            {
                Intent intent = new Intent(this, typeof(Login));
                if (currUserInfo != null)
                {
                    intent.SetClass(this, typeof(Main));
                }
                StartActivity(intent);
                Finish();
                OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut);
            }, 1500);
        }
Exemplo n.º 5
0
        /***************Bottom Bar*****************/

        public void onClickChangeMode(object sender, EventArgs e)
        { // 日/夜间模式切换
            gone(rlReadAaSet, rlReadMark);

            bool isNight = !SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false);

            changedMode(isNight, -1);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 退出登录
        /// </summary>
        public void DoLogout()
        {
            SharedPreferencesUtil.SetParam(CurrActivity, AppConfig.SP_USERINFO, "");

            Intent intent = new Intent(CurrActivity, typeof(Login));

            StartActivity(intent);
            CurrActivity.Finish();
            CurrActivity.OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut);
        }
Exemplo n.º 7
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            CurrActivity = (AppActivity)this.Activity;
            CurrContext  = CurrActivity.ApplicationContext;
            string userinfoStr = (string)SharedPreferencesUtil.GetParam(CurrActivity, AppConfig.SP_USERINFO, "");

            if (!string.IsNullOrEmpty(userinfoStr))
            {
                CurrUserInfo = DataService.Helper.FromJsonTo <LoginUserInfoEntity>(userinfoStr);
            }
        }
        protected void initNightMode()
        {
            bool isNight = SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false);

            LogUtils.d("isNight=" + isNight);
            if (isNight)
            {
                AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightYes);
            }
            else
            {
                AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightNo);
            }
        }
Exemplo n.º 9
0
 public override void initDatas()
 {
     Task.Factory.StartNew(() =>
     {
         String cachesize = CacheManager.GetCacheSize();
         RunOnUiThread(() =>
         {
             mTvCacheSize.Text = (cachesize);
         });
     });
     mTvSort.Text = (Resources.GetStringArray(Resource.Array.setting_dialog_sort_choice)[
                         SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true) ? 0 : 1]);
     mTvFlipStyle.Text = (Resources.GetStringArray(Resource.Array.setting_dialog_style_choice)[
                              SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0)]);
 }
Exemplo n.º 10
0
 public void onClickFlipStyle()
 {
     new AlertDialog.Builder(mContext)
     .SetTitle("阅读页翻页效果")
     .SetSingleChoiceItems(Resources.GetStringArray(Resource.Array.setting_dialog_style_choice),
                           SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0),
                           (sender, e) =>
     {
         var which         = e.Which;
         var dialog        = sender as AlertDialog;
         mTvFlipStyle.Text = (Resources.GetStringArray(Resource.Array.setting_dialog_style_choice)[which]);
         SharedPreferencesUtil.getInstance().putInt(Constant.FLIP_STYLE, which);
         dialog.Dismiss();
     })
     .Create().Show();
 }
Exemplo n.º 11
0
 protected override void OnResume()
 {
     base.OnResume();
     if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false) != mNowMode)
     {
         if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false))
         {
             AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightYes;
         }
         else
         {
             AppCompatDelegate.DefaultNightMode = AppCompatDelegate.ModeNightNo;
         }
         Recreate();
     }
 }
Exemplo n.º 12
0
 public void onClickBookShelfSort()
 {
     new AlertDialog.Builder(mContext)
     .SetTitle("书架排序方式")
     .SetSingleChoiceItems(Resources.GetStringArray(Resource.Array.setting_dialog_sort_choice),
                           SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true) ? 0 : 1,
                           (sender, e) =>
     {
         var which    = e.Which;
         var dialog   = sender as AlertDialog;
         mTvSort.Text = (Resources.GetStringArray(Resource.Array.setting_dialog_sort_choice)[which]);
         SharedPreferencesUtil.getInstance().putBoolean(Constant.ISBYUPDATESORT, which == 0);
         EventManager.refreshCollectionList();
         dialog?.Dismiss();
     })
     .Create().Show();
 }
Exemplo n.º 13
0
 private void initPagerWidget()
 {
     if (SharedPreferencesUtil.getInstance().getInt(Constant.FLIP_STYLE, 0) == 0)
     {
         mPageWidget = new PageWidget(this, bookId, mChapterList, new ReadListener(this));
     }
     else
     {
         mPageWidget = new OverlappedWidget(this, bookId, mChapterList, new ReadListener(this));
     }
     RegisterReceiver(receiver, intentFilter);
     if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false))
     {
         mPageWidget.setTextColor(ContextCompat.GetColor(this, Resource.Color.chapter_content_night),
                                  ContextCompat.GetColor(this, Resource.Color.chapter_title_night));
     }
     flReadWidget.RemoveAllViews();
     flReadWidget.AddView(mPageWidget);
 }
Exemplo n.º 14
0
        /// <summary>
        /// 页面控件
        /// </summary>
        protected void InitViews()
        {
            etAccount       = (EditText)FindViewById(Resource.Id.et_account);
            etPassword      = (EditText)FindViewById(Resource.Id.et_password);
            ivAccountClear  = (ImageView)FindViewById(Resource.Id.iv_account_clear);
            ivPasswordClear = (ImageView)FindViewById(Resource.Id.iv_password_clear);

            btnLogin  = (Button)FindViewById(Resource.Id.btn_login);
            tvProblem = (TextView)FindViewById(Resource.Id.tv_problem);

            AppUtils.HideKeyboard(this);

            var lastLoginAccount = SharedPreferencesUtil.GetParam(this, AppConfig.SP_LAST_LOGIN_ACCOUNT, "");

            if (lastLoginAccount != null && !(string.IsNullOrWhiteSpace(lastLoginAccount.ToString())))
            {
                etAccount.Text            = lastLoginAccount.ToString();
                ivAccountClear.Visibility = ViewStates.Visible;
            }
        }
Exemplo n.º 15
0
        /**
         * 按排序方式获取收藏列表
         *
         * @return
         */
        public List <Recommend.RecommendBooks> getCollectionListBySort()
        {
            List <Recommend.RecommendBooks> list = getCollectionList();

            if (list == null)
            {
                return(null);
            }
            else
            {
                if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISBYUPDATESORT, true))
                {
                    list.Sort(new LatelyUpdateTimeComparator());
                }
                else
                {
                    list.Sort(new RecentReadingTimeComparator());
                }
                return(list);
            }
        }
Exemplo n.º 16
0
 /**
  * 初始化SharedPreference
  */
 protected void initPrefs()
 {
     SharedPreferencesUtil.init(ApplicationContext, PackageName + "_preference", FileCreationMode.MultiProcess);
 }
Exemplo n.º 17
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            switch (id)
            {
            case Resource.Id.action_search:
                StartActivity(new Intent(this, typeof(SearchActivity)));
                break;

            case Resource.Id.action_login:
                if (popupWindow == null)
                {
                    popupWindow = new LoginPopupWindow(this);
                    popupWindow.setLoginTypeListener(this);
                }
                popupWindow.ShowAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0);
                break;

            case Resource.Id.action_my_message:
                if (popupWindow == null)
                {
                    popupWindow = new LoginPopupWindow(this);
                    popupWindow.setLoginTypeListener(this);
                }
                popupWindow.ShowAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0);
                break;

            case Resource.Id.action_sync_bookshelf:
                showDialog();
                syncBookShelf();

                /* if (popupWindow == null) {
                 *   popupWindow = new LoginPopupWindow(this);
                 *   popupWindow.setLoginTypeListener(this);
                 * }
                 * popupWindow.showAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0);*/
                break;

            case Resource.Id.action_scan_local_book:
                ScanLocalBookActivity.startActivity(this);
                break;

            case Resource.Id.action_wifi_book:
                // TODO:WifiBookActivity.startActivity(this);
                ToastUtils.showSingleToast("等待开发中");
                break;

            case Resource.Id.action_feedback:
                FeedbackActivity.startActivity(this);
                break;

            case Resource.Id.action_night_mode:
                if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false))
                {
                    SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, false);
                    AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightNo);
                }
                else
                {
                    SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, true);
                    AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightYes);
                }
                Recreate();
                break;

            case Resource.Id.action_settings:
                SettingActivity.startActivity(this);
                break;

            default:
                break;
            }
            return(base.OnOptionsItemSelected(item));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 登录操作
        /// </summary>
        public void DoLogin()
        {
            var account = etAccount.Text.Trim();

            if (string.IsNullOrEmpty(account))
            {
                ToastUtil.ShowWarningToast(this, "请输入您的手机号码或者邮箱");
                etAccount.RequestFocus();
                return;
            }
            if (!CheckUtil.IsValidEmail(account) && !CheckUtil.IsValidPhone(account))
            {
                ToastUtil.ShowWarningToast(this, "登录账号错误");
                etAccount.RequestFocus();
                return;
            }

            var passwrod = etPassword.Text.Trim();

            if (string.IsNullOrEmpty(passwrod))
            {
                ToastUtil.ShowWarningToast(this, "请输入您的登录密码");
                etPassword.RequestFocus();
                return;
            }

            if (!NetUtil.CheckNetWork(this))
            {
                ToastUtil.ShowWarningToast(this, "网络未连接!");
                return;
            }


            LoadingDialogUtil.ShowLoadingDialog(this, "登录中...");

            try
            {
                new Thread(new ThreadStart(() =>
                {
                    var result = DataService.UserService.GetUser(account, passwrod);
                    RunOnUiThread(() =>
                    {
                        LoadingDialogUtil.DismissLoadingDialog();
                        if (result.State == 1 && result.Data != null)
                        {
                            var loginUserJson = Helper.ToJsonItem(result.Data);
                            SharedPreferencesUtil.SetParam(this, AppConfig.SP_LAST_LOGIN_ACCOUNT, account);
                            SharedPreferencesUtil.SetParam(this, AppConfig.SP_USERINFO, loginUserJson);

                            Intent intent = new Intent(this, typeof(Main));
                            StartActivity(intent);
                            OverridePendingTransition(Android.Resource.Animation.FadeIn, Android.Resource.Animation.FadeOut);
                            this.Finish();
                        }
                        else
                        {
                            ToastUtil.ShowWarningToast(this, result.Error ?? "登录失败");
                        }
                    });
                })).Start();
            }
            catch (Exception ex)
            {
                var msg = ex.Message.ToString();
                LoadingDialogUtil.DismissLoadingDialog();
                ToastUtil.ShowWarningToast(this, msg);
            }
        }