Ejemplo n.º 1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (requestCode == RequestCodeOpenDirectory && resultCode == Result.Ok)
            {
                bool successful;
                (successful, _files) = RequestFiles(Uri.Parse(Uri.Decode(data.DataString)));

                if (_files.Any())
                {
                    _currentFile  = _files.First();
                    _currentIndex = 0;
                    Image.SetImageURI(_currentFile.Uri);
                    ImageText.Text = $"{_currentFile.Name} ({_files.IndexOf(_currentFile) + 1}/{_files.Count})";
                }

                else
                {
                    _currentFile  = null;
                    _currentIndex = 0;
                    Image.SetImageURI(null);
                    ImageText.Text = successful
                        ? "Empty directory, load another."
                        : "An error occured retrieving files from this directory.";
                }

                UpdateSendVisibility();
            }
        }
Ejemplo n.º 2
0
        public override void initDatas()
        {
            var recommendBooksStr = Intent.GetStringExtra(INTENT_BEAN);

            recommendBooks = JsonConvert.DeserializeObject <Recommend.RecommendBooks>(recommendBooksStr);;
            bookId         = recommendBooks._id;
            isFromSD       = Intent.GetBooleanExtra(INTENT_SD, false);

            if (Intent.ActionView.Equals(Intent.Action))
            {
                String filePath = Uri.Decode(Intent.DataString.Replace("file://", ""));
                String fileName;
                if (filePath.LastIndexOf(".") > filePath.LastIndexOf("/"))
                {
                    fileName = filePath.Substring(filePath.LastIndexOf("/") + 1, filePath.LastIndexOf("."));
                }
                else
                {
                    fileName = filePath.Substring(filePath.LastIndexOf("/") + 1);
                }

                CollectionsManager.getInstance().remove(fileName);
                // 转存
                File desc = FileUtils.createWifiTranfesFile(fileName);
                FileUtils.fileChannelCopy(new File(filePath), desc);
                // 建立
                recommendBooks          = new Recommend.RecommendBooks();
                recommendBooks.isFromSD = true;
                recommendBooks._id      = fileName;
                recommendBooks.title    = fileName;

                isFromSD = true;
            }

            MessageBus.Default.Register <DownloadProgress>(showDownProgress);
            MessageBus.Default.Register <DownloadMessage>(downloadMessage);
            showDialog();

            mTvBookReadTocTitle.Text = (recommendBooks.title);

            //mTtsPlayer = TTSPlayerUtils.getTTSPlayer();
            //ttsConfig = TTSPlayerUtils.getTtsConfig();

            intentFilter.AddAction(Intent.ActionBatteryChanged);
            intentFilter.AddAction(Intent.ActionTimeTick);

            CollectionsManager.getInstance().setRecentReadingTime(bookId);
            System.Reactive.Linq.Observable.Timer(new TimeSpan(0, 0, 1)) // 1s
            .Subscribe(_ =>
            {
                //延迟1秒刷新书架
                EventManager.refreshCollectionList();
            });
        }
Ejemplo n.º 3
0
 public override void initToolBar() {
     chmFilePath = Uri.Decode(Intent.DataString.Replace("file://", ""));
     chmFileName = chmFilePath.Substring(chmFilePath.LastIndexOf("/") + 1, chmFilePath.LastIndexOf("."));
     mCommonToolbar.Title = (chmFileName);
     mCommonToolbar.SetNavigationIcon(Resource.Drawable.ab_back);
 }