Example #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View parentView = inflater.Inflate(Resource.Layout.FileExplorerView, container, false);
            ParentView = parentView;
            var sqliteFilename = "TaskDB.db3";
            string libraryPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var path = Path.Combine(libraryPath, sqliteFilename);
            conn = new Connection(path);
            TranslyteDbGateway = new TranslyteDbGateway(conn);

            UpdateBooksList ();

            return parentView;
        }
Example #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.LibraryView);
            _context = this;
            SetupMenu();

            var sqliteFilename = "TaskDB.db3";
            string libraryPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var path = Path.Combine(libraryPath, sqliteFilename);
            conn = new Connection(path);
            TranslyteDbGateway = new TranslyteDbGateway(conn);

            Java.IO.File dir =  new Java.IO.File(EnvironmentAnd.ExternalStorageDirectory.AbsolutePath + @"/translyte");
            if (!dir.Exists ()) {
                dir.Mkdirs ();
                TranslyteDbGateway.DeleteAllBooks ();
            }
            UpdateView ();
            //_books = TranslyteDbGateway.GetBooksLocalReviewWithoutCurrent();

            //adapter = new GalleryAdapter(this, _books);
            ListView listView = FindViewById<ListView>(Resource.Id.ListView);
            listView.Adapter = adapter;
            listView.ItemClick += OnListItemClick;

            if ((CurrentBook = TranslyteDbGateway.GetCurrentBook()) != null)
            {
                ImageView image = FindViewById<ImageView>(Resource.Id.CoverCurrent);
                if (CurrentBook.Cover != null)
                {
                    var img = new BitmapConverteHelper().GetCover(CurrentBook.Cover);
                    image.SetImageBitmap(img);
                }
                LinearLayout last_book_view = FindViewById<LinearLayout>(Resource.Id.last_book_view);
                last_book_view.Click += delegate
                {
                    string jsonModel = JsonConvert.SerializeObject(CurrentBook);
                    var fragment = new BookView();
                    Bundle bookBundle = new Bundle();
                    bookBundle.PutString("book", jsonModel);
                    fragment.Arguments = bookBundle;
                    ChangeFragment(fragment);
                };
                TextView title = FindViewById<TextView>(Resource.Id.TitleCurrent);
                title.Text = CurrentBook.Title;

                TextView author = FindViewById<TextView>(Resource.Id.AuthorCurrent);
                author.Text = CurrentBook.Author;
            }
        }
Example #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ParentView = inflater.Inflate(Resource.Layout.BookView, container, false);
            LibraryView parentActivity = Activity as LibraryView;
            ParentActivity = parentActivity;

            HasOptionsMenu = true;
            var resideMenu = parentActivity.ResideMenu;

            var title = ParentView.FindViewById<TextView>(Resource.Id.tv_title);
            TextView content = ParentView.FindViewById<TextView>(Resource.Id.tv_book);
            content.SetTextIsSelectable(true);

            ParentView.FindViewById(Resource.Id.tv_book).Click += (s, e) => resideMenu.OpenMenu(global::AndroidResideMenu.ResideMenu.Direction.Left);

            ISharedPreferences prefs = Application.Context.GetSharedPreferences("Settings", FileCreationMode.Private);
            var isDark = prefs.GetBoolean("themeDark", false);
            if (isDark)
            {
                var layout = ParentView.FindViewById<RelativeLayout>(Resource.Id.bookLayout);
                layout.SetBackgroundColor(Color.DarkGray);
                content.SetTextColor(Color.WhiteSmoke);
                title.SetTextColor(Color.WhiteSmoke);
            }
            var size = prefs.GetInt("textSize", 20);
            content.SetTextSize(ComplexUnitType.Dip, size);
            title.SetTextSize(ComplexUnitType.Dip, size + 5);

            var textFont = prefs.GetString("textFont", "Arial");
            var res="";
            switch(textFont)
            {
            case "Arial":
                res = "arial";
                break;
            case "Verdana":
                res = "airstrike";
                break;
            case "Calibri":
                res = "BodoniFLF-Roman";
                break;
            default :
                res = "Raleway-Medium";
                break;
            }
            Typeface tf = Typeface.CreateFromAsset (Application.Context.Assets, "fonts/" + res + ".ttf");
            content.Typeface = tf;
            title.SetTextSize(ComplexUnitType.Dip, 25);

            string extraData = null;
            if (Arguments != null)
                extraData = Arguments.GetString("book");
            if (extraData != null)
            {
                var tempBook = JsonConvert.DeserializeObject<BookReviewModel>(extraData);
                title.Text = tempBook.Title;
                parentActivity.RunOnUiThread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    Book curBook = new BookFullModel(tempBook.BookPath){Position = tempBook.Position};
                    Book.Load(ref curBook);
                    content.Text = ((BookFullModel)curBook).Content;
                    content.CustomSelectionActionModeCallback = new WordSelector(content, ParentActivity, ((BookFullModel)curBook).Language);
                    SetPosition(curBook.Position);
                    _currentBook = (BookFullModel)curBook;
                    var sqliteFilename = "TaskDB.db3";
                    string libraryPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    var path = Path.Combine(libraryPath, sqliteFilename);
                    var conn = new Connection(path);
                    _translyteDbGateway = new TranslyteDbGateway(conn);
                });
            }
            return ParentView;
        }