public async void SaveReadBook(BooksMapViewModel _model)
        {
            var result = await new BookShelfService().PostBook(_model);

            if (result.Status == 1)
            {
                List <BookViewModel> _listBook = new List <BookViewModel>();
                _listBook.Add(book);
                // BookViewModel _viewModel = new BookViewModel();
                //_viewModel.BookId = _model.BookId;
                //_viewModel.BookStatus = BookStatus.WishList;
                var savedBooks = BookRepository.SaveBookList(_listBook, BookStatus.Read);
                if (savedBooks != null)
                {
                    CustomToast.Show("Book successfully added to read list", true);
                    this.ReloadList(this, (int)_model.BookId);
                }
                else
                {
                    CustomToast.Show("Failed to add book to read list", false);

                    this.ReloadList(this, 0);
                }
            }
            //this.ListReload(this, 0);
        }
 private async void LoadMoreContacts()
 {
     try
     {
         loadList = false;
         paginationModel.SkipRecords += 30;
         var result = await new ContactsService().GetContactsAll(paginationModel);
         if (result.Status == 1)
         {
             ContactList = JsonConvert.DeserializeObject <List <UserProfile> >(result.Response.ToString());
             try
             {
                 if (ContactList != null && ContactList.Count > 0)
                 {
                     addContactsListViewControllerSource.AddMoreContactList(ContactList);
                     tblAddContacts.ReloadData();
                     loadList = true;
                 }
             }
             catch (Exception ex)
             {
                 CustomToast.Show(ex.ToString(), false);
             }
         }
         else
         {
             CustomToast.Show(Message: "No More Contacs", Default: true);
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
         CustomToast.Show(ex.ToString(), false);
     }
 }
Ejemplo n.º 3
0
        public static async Task <bool> Show(Activity owner, string message)
        {
            var tcs = new TaskCompletionSource <bool>();

            if (owner is SplashActivity)
            {
                return(false);
            }

            var dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher>();

            dispatcher.RequestMainThreadAction(() =>
            {
                try
                {
                    Toast       = new CustomToast(owner, message);
                    var isShown = Toast.Show();

                    tcs.TrySetResult(isShown);
                }
                catch (Exception ex)
                {
                    tcs.TrySetException(ex);

                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }
                }
            });

            return(await tcs.Task.ConfigureAwait(false));
        }
 private async void LoadMoreBooks()
 {
     try
     {
         loadList = false;
         paginationModel.SkipRecords += 30;
         var result = await new BookShelfService().GetAllBooks(paginationModel);// 0 = WishList ,  1 = Read , 2 = All
         if (result.Status == 1)
         {
             BookList = JsonConvert.DeserializeObject <List <BookViewModel> >(result.Response.ToString());
             try
             {
                 if (BookList != null && BookList.Count > 0)
                 {
                     BookShelfWishListsource.AddMoreBookList(BookList);
                     tblAddBooksList.ReloadData();
                     loadList = true;
                 }
             }
             catch (Exception ex)
             {
                 CustomToast.Show(ex.ToString(), false);
             }
         }
         else
         {
             CustomToast.Show(Message: "No More Books", Default: true);
         }
     }
     catch (Exception ex)
     {
         CustomToast.Show(ex.ToString(), false);
     }
 }
Ejemplo n.º 5
0
 public override Widget build(BuildContext context)
 {
     return(new StoreConnector <AppState, ArticlesScreenViewModel>(
                converter: state => new ArticlesScreenViewModel {
         isLoggedIn = state.loginState.isLoggedIn,
         feedHasNew = state.articleState.feedHasNew,
         searchSuggest = state.articleState.searchSuggest,
         currentTabBarIndex = state.tabBarState.currentTabIndex,
         nationalDayEnabled = state.serviceConfigState.nationalDayEnabled
     },
                builder: (context1, viewModel, dispatcher) => {
         var actionModel = new ArticlesScreenActionModel {
             pushToSearch = () => {
                 dispatcher.dispatch(new MainNavigatorPushToAction {
                     routeName = MainNavigatorRoutes.Search
                 });
                 AnalyticsManager.ClickEnterSearch("Home_Article");
             },
             pushToLogin = () => dispatcher.dispatch(new MainNavigatorPushToAction {
                 routeName = MainNavigatorRoutes.Login
             }),
             pushToReality = () => {
                 dispatcher.dispatch(new EnterRealityAction());
                 AnalyticsManager.AnalyticsClickEgg(1);
             },
             pushToGame = () => {
                 if (CCommonUtils.isIPhone)
                 {
                     dispatcher.dispatch(new MainNavigatorPushToAction {
                         routeName = MainNavigatorRoutes.Game
                     });
                 }
                 else
                 {
                     var url = LocalDataManager.getTinyGameUrl();
                     if (url.isEmpty() || url.Equals("no_game"))
                     {
                         CustomToast.show(new CustomToastItem(
                                              context: context,
                                              "暂无游戏",
                                              TimeSpan.FromMilliseconds(2000)
                                              ));
                         return;
                     }
                     dispatcher.dispatch(new MainNavigatorPushToWebViewAction {
                         url = url,
                         landscape = true,
                         fullscreen = true,
                         showOpenInBrowser = false
                     });
                 }
             }
         };
         return new ArticlesScreen(viewModel: viewModel, actionModel: actionModel);
     }
                ));
 }
Ejemplo n.º 6
0
        private static void Show_SideToast(string message)
        {
            CustomToast toast = new CustomToast()
            {
                Title = message
            };

            toast.Show();
        }
Ejemplo n.º 7
0
 void HandleSaveStatus(UIImage image, NSError error)
 {
     if (error == null)
     {
         CustomToast.Show("Image Saved to your library");
     }
     else
     {
         CustomToast.Show("Image Save Failed", false);
     }
 }
 void AddContactsListViewControllerSource_ReloadList(object sender, long e)
 {
     if (loadList == true)
     {
         if (String.IsNullOrEmpty(paginationModel.SearchText))
         {
             CustomToast.Show(Message: "Loading More Contacts", Default: true);
             LoadMoreContacts();
         }
     }
 }
        void BookShelfWishListsource_ReloadList(object sender, long e)
        {
            if (loadList == true)
            {
                if (String.IsNullOrEmpty(paginationModel.SearchText))
                {
                    CustomToast.Show(Message: "Loading More Books", Default: true);

                    LoadMoreBooks();
                }
            }
        }
 void BookShelfWishListsource_ReloadList(object sender, long e)
 {
     if (loadList && !(BookList.Count < 30))
     {
         CustomToast.Show(Message: "Loading More Books", Default: true);
         if (InternetConnectivityModel.CheckConnection())
         {
             LoadMoreBooks();
         }
         else
         {
             LoadMoreBooksOffline();
         }
     }
 }
        public async void SaveContact(Contact _model)
        {
            var result = await new ContactsService().AddContactService(_model.contactId);

            if (result.Status == 1)
            {
                CustomToast.Show("Contact successfully added", true);
                this.ReloadList(this, (int)_model.contactId);
            }
            else
            {
                CustomToast.Show("Contact not added", false);
                this.ReloadList(this, 0);
            }
            //this.ListReload(this, 0);
        }
        //private void searchBooks()
        //{

        //    LoadServerBooks(searchBar.Text);
        //    tblAddBooksList.ReloadData();


        //}

        private async void LoadServerBooks(string SearchText = null)
        {
            try
            {
                paginationModel.SkipRecords = 0;
                paginationModel.TakeRecords = 30;
                paginationModel.SearchText  = SearchText;
                var result = await new BookShelfService().GetAllBooks(paginationModel);// 0 = WishList ,  1 = Read , 2 = All
                if (result.Status == 1)
                {
                    var booklist = JsonConvert.DeserializeObject <List <BookViewModel> >(result.Response.ToString());
                    loadBookAdapter(booklist);
                }
            }
            catch (Exception ex)
            {
                CustomToast.Show(ex.ToString(), false);
            }
        }
 private async void LoadServerContacts(string SearchText = null)
 {
     try
     {
         paginationModel.SkipRecords = 0;
         paginationModel.TakeRecords = 30;
         paginationModel.SearchText  = SearchText;
         var result = await new ContactsService().GetContactsAll(paginationModel);// 0 = WishList ,  1 = Read , 2 = All
         if (result.Status == 1)
         {
             ContactList = JsonConvert.DeserializeObject <List <UserProfile> >(result.Response.ToString());
             loadContactAdapter(ContactList);
         }
     }
     catch (Exception ex)
     {
         CustomToast.Show(ex.ToString(), false);
     }
 }
        private void LoadMoreBooksOffline()
        {
            try
            {
                loadList = false;
                paginationModel.SkipRecords += 30;

                BookList = BookRepository.GetBooks(BookStatus.WishList, BookList).Skip(paginationModel.SkipRecords).Take(paginationModel.TakeRecords).ToList();
                if (BookList != null && BookList.Count > 0)
                {
                    BookShelfWishListsource.AddMoreBookList(BookList);
                    tblBookWishList.ReloadData();
                    loadList = true;
                }
            }
            catch (Exception ex)
            {
                CustomToast.Show(ex.ToString(), false);
            }
        }
 public void loadBookAdapter(List <BookViewModel> BookList)
 {
     try
     {
         //BookList = BookRepository.GetBooks(BookStatus.WishList, BookList).Skip(paginationModel.SkipRecords).Take(paginationModel.TakeRecords).ToList();
         if (BookList != null && BookList.Count > 0)
         {
             tblAddBooksList.TableFooterView      = new UIView();
             BookShelfWishListsource              = new AddBooksListViewControllerSource(BookList);
             tblAddBooksList.Source               = BookShelfWishListsource;
             BookShelfWishListsource.ReloadList  += BookShelfWishListsource_ReloadList;
             BookShelfWishListsource.ItemRemoved += BookShelfWishListsource_ItemRemoved;
             tblAddBooksList.RowHeight            = 115;
             tblAddBooksList.ReloadData();
         }
     }
     catch (Exception ex)
     {
         CustomToast.Show(ex.ToString(), false);
     }
 }
        partial void BtnAdd_TouchUpInside(UIButton sender)
        {
            var alert = new UIAlertView("Add Contacts", "Do you want to Add this Contact?", null, "No", "Yes");

            alert.Clicked += (object asender, UIButtonEventArgs e) =>
            {
                if (e.ButtonIndex == 1)
                {
                    Contact C = new Contact();
                    C.contactId = addContacts.UserId;
                    SaveContact(C);
                }
                else
                {
                    CustomToast.Show("Add Contacts", false);
                }
                //new UIAlertView("Add Contacts", "Cancelled!", null, "OK", null).Show();
                alert.DismissWithClickedButtonIndex(0, true);
            };
            alert.Show();
        }
        public void loadContactAdapter(List <UserProfile> ContactList)
        {
            try
            {
                if (ContactList != null && ContactList.Count > 0)
                {
                    tblAddContacts.TableFooterView = new UIView();

                    addContactsListViewControllerSource = new AddContactsListViewControllerSource(ContactList);

                    tblAddContacts.Source = addContactsListViewControllerSource;
                    addContactsListViewControllerSource.ReloadList  += AddContactsListViewControllerSource_ReloadList;
                    addContactsListViewControllerSource.ItemRemoved += AddContactsListViewControllerSource_ItemRemoved;
                    tblAddContacts.RowHeight = 50;
                    tblAddContacts.ReloadData();
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
                CustomToast.Show(ex.ToString(), false);
            }
        }
Ejemplo n.º 18
0
        public async void SaveBook(BooksMapViewModel _model)
        {
            var result = await new BookShelfService().UpdateBook(_model);

            if (result.Status == 1)
            {
                BookViewModel _viewModel = new BookViewModel();
                _viewModel.BookId     = _model.BookId;
                _viewModel.BookStatus = BookStatus.Read;
                var savedBooks = BookRepository.UpdateBook(_viewModel);
                if (savedBooks != null)
                {
                    CustomToast.Show("Book successfully added to read list", true);
                    this.ReloadList(this, (int)_model.BookId);
                }
                else
                {
                    CustomToast.Show("Failed to add book to read list", true);
                    this.ReloadList(this, 0);
                }
            }
            //  ListReloadRead("test", 0);
        }
Ejemplo n.º 19
0
        public async void RemoveBook(BooksMapViewModel _model)
        {
            var result = await new BookShelfService().RemoveBook(_model);

            if (result.Status == 1)
            {
                BookViewModel _viewModel = new BookViewModel();
                _viewModel.BookId     = _model.BookId;
                _viewModel.BookStatus = BookStatus.Removed;
                var savedBooks = BookRepository.UpdateBook(_viewModel);
                if (savedBooks != null)
                {
                    CustomToast.Show("Book successfully removed", true);
                    this.ReloadList(this, (int)_model.BookId);
                }
                else
                {
                    CustomToast.Show("Failed to remove book", false);
                    this.ReloadList(this, 0);
                }
            }
            //  this.ListReloadWishList(this, 0);
        }
Ejemplo n.º 20
0
        public override Widget build(BuildContext context)
        {
            GlobalContext.context = context;
            return(new WillPopScope(
                       onWillPop: () => {
                TipMenu.dismiss();
                var promise = new Promise <bool>();
                if (VersionManager.needForceUpdate())
                {
                    promise.Resolve(false);
                }
                else if (LoginScreen.navigator?.canPop() ?? false)
                {
                    LoginScreen.navigator.pop();
                    promise.Resolve(false);
                }
                else if (Screen.orientation != ScreenOrientation.Portrait)
                {
                    //视频全屏时禁止物理返回按钮
                    EventBus.publish(sName: EventBusConstant.fullScreen, new List <object> {
                        true
                    });
                    promise.Resolve(false);
                }
                else if (navigator.canPop())
                {
                    navigator.pop();
                    promise.Resolve(false);
                }
                else
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        if (this._exitApp)
                        {
                            CustomToast.hidden();
                            promise.Resolve(true);
                            if (this._timer != null)
                            {
                                this._timer.Dispose();
                                this._timer = null;
                            }
                        }
                        else
                        {
                            this._exitApp = true;
                            CustomToast.show(new CustomToastItem(
                                                 context: context,
                                                 "再按一次退出",
                                                 TimeSpan.FromMilliseconds(2000)
                                                 ));
                            this._timer = Window.instance.run(TimeSpan.FromMilliseconds(2000),
                                                              () => { this._exitApp = false; });
                            promise.Resolve(false);
                        }
                    }
                    else
                    {
                        promise.Resolve(true);
                    }
                }

                return promise;
            },
                       child: new Navigator(
                           key: globalKey,
                           observers: new List <NavigatorObserver> {
                _routeObserve,
                _heroController
            },
                           onGenerateRoute: settings => new CustomPageRoute(
                               settings: settings,
                               fullscreenDialog: fullScreenRoutes.ContainsKey(key: settings.name),
                               builder: context1 => mainRoutes[key: settings.name](context: context1)
                               )
                           )
                       ));
        }
Ejemplo n.º 21
0
        public override Widget build(BuildContext context)
        {
            GlobalContext.context = context;
            return(new WillPopScope(
                       onWillPop: () => {
                var promise = new Promise <bool>();
                if (LoginScreen.navigator?.canPop() ?? false)
                {
                    LoginScreen.navigator.pop();
                    promise.Resolve(false);
                }
                else if (Screen.orientation != ScreenOrientation.Portrait)
                {
                    //视频全屏时禁止物理返回按钮
                    EventBus.publish(EventBusConstant.fullScreen, new List <object> {
                        true
                    });
                    promise.Resolve(false);
                }
                else if (navigator.canPop())
                {
                    navigator.pop();
                    promise.Resolve(false);
                }
                else
                {
                    if (Application.platform == RuntimePlatform.Android)
                    {
                        if (this._exitApp)
                        {
                            CustomToast.hidden();
                            promise.Resolve(true);
                            if (this._timer != null)
                            {
                                this._timer.Dispose();
                                this._timer = null;
                            }
                        }
                        else
                        {
                            this._exitApp = true;
                            CustomToast.show(new CustomToastItem(
                                                 context: context,
                                                 "再按一次退出",
                                                 TimeSpan.FromMilliseconds(2000)
                                                 ));
                            this._timer = Window.instance.run(TimeSpan.FromMilliseconds(2000),
                                                              () => { this._exitApp = false; });
                            promise.Resolve(false);
                        }
                    }
                    else
                    {
                        promise.Resolve(true);
                    }
                }

                return promise;
            },
                       child: new Navigator(
                           key: globalKey,
                           observers: new List <NavigatorObserver> {
                _routeObserve
            },
                           onGenerateRoute: settings => {
                if (fullScreenRoutes.ContainsKey(settings.name))
                {
                    return new PageRouteBuilder(
                        settings: settings,
                        (context1, animation, secondaryAnimation) => mainRoutes[settings.name](context1),
                        (context1, animation, secondaryAnimation, child) => {
                        return new PushPageTransition(
                            routeAnimation: animation,
                            child: child
                            );
                    }
                        );
                }
                else
                {
                    return new CustomPageRoute(
                        settings: settings,
                        builder: (context1) => mainRoutes[settings.name](context1)
                        );
                }
            }
                           )
                       ));
        }
Ejemplo n.º 22
0
        private void Toast_Loaded(object sender, RoutedEventArgs e)
        {
            setting = Application.Current.LoadSetting();

            try
            {
                parentWindow = Window.GetWindow(this);
                if (parentWindow is Window)
                {
                    parentWindow.Closing += Window_Closing;
                    Application.Current.AddToast(parentWindow);
                }
            }
            catch (Exception ex) { ex.ERROR("ToastLoaded"); }

            try
            {
                ButtonOk = new CustomButton()
                {
                    Button = OK, Kind = ButtonOKIcon, Text = ButtonOKLabel
                };
                ButtonCancel = new CustomButton()
                {
                    Button = CANCEL, Kind = ButtonCancelIcon, Text = ButtonCancelLabel
                };
                ButtonOpenFile = new CustomButton()
                {
                    Button = OpenFile, Kind = ButtonOpenFileIcon, Text = ButtonOpenFileLabel
                };
                ButtonOpenFolder = new CustomButton()
                {
                    Button = OpenFolder, Kind = ButtonOpenFolderIcon, Text = ButtonOpenFolderLabel
                };
            }
            catch (Exception ex) { ex.ERROR("ToastLoaded"); }

            try
            {
                if (Tag is Notification)
                {
                    var toast = Tag as Notification;
                    if (string.IsNullOrEmpty(toast.ImgURL))
                    {
                        Preview.Hide();
                    }
                    else
                    {
                        Preview.Show();
                    }
                }
            }
            catch (Exception ex) { ex.ERROR(); }

            try
            {
                StateMark.Hide();
                if (Tag is CustomToast)
                {
                    toast = Tag as CustomToast;
                    SetState(toast.State, toast.StateDescription);
                }
            }
            catch (Exception ex) { ex.ERROR(); }

            try
            {
                SetButton(ItemType);
            }
            catch (Exception ex) { ex.ERROR(); }

            try
            {
                CheckImageSource();
            }
            catch (Exception ex) { ex.ERROR(); }
        }