Ejemplo n.º 1
0
 void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
 {
     var book = _books[e.Position];
     Book curBook = new BookReviewModel(book.BookPath);
     //curBook.BookPath = book.BookPath;
     Book.Load(ref curBook);
     //Book res = (BookReviewModel) curBook;
     //var intent = new Intent(this, typeof(BookView));
         string jsonModel = JsonConvert.SerializeObject(book);
        // intent.PutExtra("book", jsonModel);
         //StartActivity(intent);
         var fragment = new BookView();
         Bundle bundle = new Bundle();
         bundle.PutString("book", jsonModel);
         fragment.Arguments = bundle;
         ChangeFragment(fragment);
     TranslyteDbGateway.SetCurrentBook(curBook);
     if (curBook.ID != CurrentBook.ID)
     {
         CurrentBook = (BookReviewModel)curBook;
         _books.Clear();
         _books = TranslyteDbGateway.GetBooksLocalReviewWithoutCurrent();
     }
 }
Ejemplo n.º 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;
            }
        }