private void bindControls() { FindViewById <TextView>(Resource.Id.head_title).Text = "文章详情"; webView = FindViewById <PullableWebView>(Resource.Id.webview); ptrl = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view); ptrl.setOnRefreshListener(this); webView.Settings.DefaultTextEncodingName = "utf-8"; webView.Settings.LoadsImagesAutomatically = true; webView.SetWebViewClient(new MyWebViewClient()); webView.ScrollBarStyle = ScrollbarStyles.InsideOverlay; webView.Settings.JavaScriptEnabled = false; webView.Settings.SetSupportZoom(false); webView.Settings.BuiltInZoomControls = false; webView.Settings.CacheMode = CacheModes.CacheElseNetwork; webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); btnBack = FindViewById <Button>(Resource.Id.title_bar_back); btnBack.Click += delegate { Finish(); }; Button btnViewComments = FindViewById <Button>(Resource.Id.footbar_comments); btnViewComments.Visibility = ViewStates.Gone; Button btnWriteComments = FindViewById <Button>(Resource.Id.footbar_write_comment); btnWriteComments.Visibility = ViewStates.Gone; CommonHelper.InitalBookMark(this, string.Format(@"http://kb.cnblogs.com/page/{0}/", article.Id), article.Title); CommonHelper.InitalShare(this, null, true, article.Author, article.Title, "", string.Format(@"http://kb.cnblogs.com/page/{0}/", article.Id)); ptrl.AutoRefresh(); }
public TableViewFrontPageView(StateController stateController) { InitializeComponent(); this.stateController = stateController; GetFrontPageArticles(); var masterStackLayout = new StackLayout { Orientation = StackOrientation.Vertical }; IList <StackLayout> articleStackLayouts = new List <StackLayout>(); foreach (var article in articles) { masterStackLayout.Children.Add( new StackLayout { Orientation = StackOrientation.Vertical, Children = { new CachedImage { Source = article.ImageSourceBig }, new Label { Text = article.Title }, new HtmlFormattedLabel { Text = article.Teaser, FontAttributes = FontAttributes.Bold } } }); } foreach (var sl in articleStackLayouts) { } var scrollView = new ScrollView(); var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db") }; //Set Bindings //refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); Content = refreshView; //Additionally, your content could be anything you want including a StackLayout: }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { bookMarks = await BookMarkService.GetBookMarks(CommonHelper.token, 1, 15); comAdaper.RefreshItems(bookMarks); pullToRefreshLayout.refreshFinish(0); }, this); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { news = await NewsService.GetNews(CommonHelper.token, 1, pageSize); comAdaper.RefreshItems(news); pullToRefreshLayout.refreshFinish(0); }, this.Activity); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { comments = (await BlogService.GetArticleComments(CommonHelper.token, currentArticle.BlogApp, currentArticle.Id, 1, 15)); comAdaper.RefreshItems(comments); pullToRefreshLayout.refreshFinish(0); }, this); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { articles = await BlogService.GetBolggerPosts(CommonHelper.token, CommonHelper.userInfo.BlogApp, 1); comAdaper.RefreshItems(articles); pullToRefreshLayout.refreshFinish(0); }, this); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { articles = await BlogService.GetPickedArticles(CommonHelper.token, 1, pageSize); comAdaper.RefreshItems(this.articles); pullToRefreshLayout.refreshFinish(0); }, this.Activity); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { comments = (await NewsService.GetNewsComments(CommonHelper.token, newsInfo.Id, 1, 25)); comAdaper.RefreshItems(comments); pullToRefreshLayout.refreshFinish(0); }, this); }
// overloading se ho già la lista private void OnRefresh(IEnumerable <Team> collezione) { stack.Children.RemoveAt(1); var scrollin = new ScrollView { Content = Create_grid(collezione), Padding = 15 }; var refreshView = new PullToRefreshLayout { Content = scrollin, RefreshColor = Color.FromHex("#00EA75") }; refreshView.RefreshCommand = RefreshCommand; stack.Children.Add(refreshView); }
public void InitModule() { mTitleContainer = FindViewById <LinearLayout>(Resource.Id.title_container); mTitle = FindViewById <TextView>(Resource.Id.title_tv); mMsgList = FindViewById <MessageList>(Resource.Id.msg_list); mChatInput = FindViewById <ChatInputView>(Resource.Id.chat_input); mPtrLayout = FindViewById <PullToRefreshLayout>(Resource.Id.pull_to_refresh_layout); mChatInput.SetMenuContainerHeight(819); mRecordVoiceBtn = mChatInput.RecordVoiceButton; mSelectAlbumIb = mChatInput.SelectAlbumBtn; PtrDefaultHeader header = new PtrDefaultHeader(Context); int[] colors = Resources.GetIntArray(Resource.Array.google_colors); header.SetColorSchemeColors(colors); header.LayoutParameters = new ViewGroup.LayoutParams(-1, -2); header.SetPadding(0, DisplayUtil.Dp2px(Context, 15), 0, DisplayUtil.Dp2px(Context, 10)); header.SetPtrFrameLayout(mPtrLayout); // mMsgList.setDateBgColor(Color.parseColor("#FF4081")); // mMsgList.setDatePadding(5, 10, 10, 5); // mMsgList.setEventTextPadding(5); // mMsgList.setEventBgColor(Color.parseColor("#34A350")); // mMsgList.setDateBgCornerRadius(15); mMsgList.HasFixedSize = true; mPtrLayout.SetLoadingMinTime(1000); mPtrLayout.SetDurationToCloseHeader(1500); mPtrLayout.HeaderView = header; mPtrLayout.AddPtrUIHandler(header); mPtrLayout.PinContent = true; // set show display name or not // mMsgList.setShowReceiverDisplayName(true); // mMsgList.setShowSenderDisplayName(false); CN.Jiguang.Imui.Chatinput.Menu.MenuManager menuManager = mChatInput.MenuManager; menuManager.AddCustomMenu("MY_CUSTOM", Resource.Layout.menu_text_item, Resource.Layout.menu_text_feature); // Custom menu order menuManager.SetMenu(CN.Jiguang.Imui.Chatinput.Menu.Menu.NewBuilder() .Customize(true) .SetRight(CN.Jiguang.Imui.Chatinput.Menu.Menu.TagSend) .SetBottom(CN.Jiguang.Imui.Chatinput.Menu.Menu.TagVoice, CN.Jiguang.Imui.Chatinput.Menu.Menu.TagEmoji, CN.Jiguang.Imui.Chatinput.Menu.Menu.TagGallery, CN.Jiguang.Imui.Chatinput.Menu.Menu.TagCamera, "MY_CUSTOM") .Build()); menuManager.SetCustomMenuClickListener(new CustomMenuEventListener()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_scrollview); // Retrieve PullToRefreshAttacher from PullToRefreshLayout mPullToRefreshAttacher = PullToRefreshLayout.GetAttacher(this, Resource.Id.ptr_layout); // Set Listener to know when a refresh should be started mPullToRefreshAttacher.Refresh += delegate { Task.Factory.StartNew(() => { Thread.Sleep(5000); }) .ContinueWith(task => { mPullToRefreshAttacher.SetRefreshComplete(); }); }; }
/// <summary> /// refreshare la grid dato che non ha un metodo già fatto /// </summary> /// <param name="f"></param> private void OnRefresh(string f = null) { stack.Children.RemoveAt(1); servizio.FilterByName(f); var scrollin = new ScrollView { Content = Create_grid(servizio.GetTeams()), Padding = 15 }; var refreshView = new PullToRefreshLayout { Content = scrollin, RefreshColor = Color.FromHex("#00EA75") }; refreshView.RefreshCommand = RefreshCommand; stack.Children.Add(refreshView); }
void createPeopleTabIfNotCreatedYet() { if (this.findPeopleControl != null) { return; } this.findPeopleControl = new FindPeopleControl(false) { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; this.findPeopleControl.LoadStarted += () => { if (this.rootForPeople != null) { this.rootForPeople.IsRefreshing = true; } }; this.findPeopleControl.LoadCompleted += () => { if (this.rootForNewsfeed != null) { this.rootForNewsfeed.IsRefreshing = false; } if (this.rootForPeople != null) { this.rootForPeople.IsRefreshing = false; } }; this.findPeopleControl.NameAsCommunity = true; this.findPeopleControl.UserClickedOnPerson += async(s1, e1) => { await App.Navigator.GoToPersonProfile(e1.Person.ID); }; this.rootForPeople = new PullToRefreshLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Content = this.findPeopleControl, RefreshColor = Config.ColorRedBackground, }; this.rootForPeople.RefreshCommand = new Command(() => { this.findPeopleControl.ReloadAsync(this.CurrentCommunity, false); }); this.Children.Add(this.rootForPeople, 0, 1); }
void createFeedTabIfNotCreatedYet() { if (this.newsfeedControl != null) { return; } this.newsfeedControl = new NewsfeedControl(); this.newsfeedControl.LoadStarted += () => { if (this.rootForNewsfeed != null) { this.rootForNewsfeed.IsRefreshing = true; } }; this.newsfeedControl.LoadCompleted += () => { if (this.rootForNewsfeed != null) { this.rootForNewsfeed.IsRefreshing = false; } if (this.rootForPeople != null) { this.rootForPeople.IsRefreshing = false; } }; this.scrollViewForNewsfeed = new ScrollView { Padding = new Thickness(0), HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Content = this.newsfeedControl, }; this.rootForNewsfeed = new Refractored.XamForms.PullToRefresh.PullToRefreshLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Content = scrollViewForNewsfeed, RefreshColor = Config.ColorRedBackground, }; this.rootForNewsfeed.RefreshCommand = new Command(() => { this.newsfeedControl.ReloadAsync(this.CurrentCommunity, false); }); this.Children.Add(this.rootForNewsfeed, 0, 1); }
public static StackLayout CreateScrollableFeedView(List <PostItemStackLayout> PostsContent, string placeholder, string scopeName, string groupid = null) { if (PostsContent != null && PostsContent.Count > 0) { Debug.WriteLine("Posts found"); ScrollFeed = new ScrollView { Content = CreateFeed(PostsContent) }; var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = ScrollFeed, RefreshColor = Color.FromHex("#3498db") }; //Set pull-to-refresh Bindings //refreshView.SetBinding<GroupFeed> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //refreshView.SetBinding<GroupFeed> (PullToRefreshLayout.IsRefreshingProperty, new Xamarin.Forms.Binding(){Path="IsBusy", Mode = BindingMode.OneWay}); //refreshView.SetBinding<GroupFeed>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); return(new StackLayout { Orientation = StackOrientation.Vertical, Children = { new ShoutBar("postsample.png", scopeName, groupid), refreshView } }); } else { Label NoPostsLabel = new Label { Text = "Be the first to start this thread!", TextColor = Color.Silver, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center }; return(new StackLayout { Orientation = StackOrientation.Vertical, Children = { new ShoutBar("postsample.png", scopeName, groupid), NoPostsLabel } }); } }
private async void bindControls() { webView = FindViewById <PullableWebView>(Resource.Id.webview); ptrl = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view); ptrl.setOnRefreshListener(this); webView.Settings.DefaultTextEncodingName = "utf-8"; webView.Settings.LoadsImagesAutomatically = true; webView.SetWebViewClient(new MyWebViewClient()); webView.ScrollBarStyle = ScrollbarStyles.InsideOverlay; webView.Settings.JavaScriptEnabled = false; webView.Settings.SetSupportZoom(false); webView.Settings.BuiltInZoomControls = false; webView.Settings.CacheMode = CacheModes.CacheElseNetwork; webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); btnBack = FindViewById <Button>(Resource.Id.title_bar_back); btnBack.Click += delegate { Finish(); }; await ptrl.AutoRefresh(); }
protected void InitalComponents() { BlogApplication.InitImageLoader(this); imgLoader = ImageLoader.Instance; displayImageOptions = new DisplayImageOptions.Builder() .ShowImageForEmptyUri(Resource.Drawable.girl) .ShowImageOnFail(Resource.Drawable.girl) .ShowImageOnLoading(Resource.Drawable.girl) .CacheInMemory(true) .CacheOnDisk(true) .ResetViewBeforeLoading() .Build(); btnBack = FindViewById <Button>(Resource.Id.title_bar_back); btnBack.Click += delegate { Finish(); }; textPageTitle = FindViewById <TextView>(Resource.Id.head_title); ptrl = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view); pListView = FindViewById <PullableListView>(Resource.Id.pListView); }
public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { int pageIndex = articles.Count / 25 + 1; var moreArticles = await BlogService.GetBolggerPosts(CommonHelper.token, blogger.BlogApp, pageIndex); if (moreArticles.Count > 0) { articles.AddRange(moreArticles); comAdaper.RefreshItems(this.articles); int index = (articles.Count - 15) - 3; pListView.Invalidate(); pListView.SetSelection(index); } { Msg.AppMsg.MakeText(this, "No More Item", Msg.AppMsg.STYLE_INFO).Show(); } pullToRefreshLayout.loadmoreFinish(0); }, this); }
private View getPullToRefreshView() { var scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = getView() /* Anything you want in your ScrollView */ }; _refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db"), }; var refreshCommand = new Command(() => //(async () => { sync(); //_refreshView.IsRefreshing = true; //await _db.SynchronizeAzureDb(); //await updateDbOrariUtenza(); //MessagingCenter.Send<TabbedDayView, int>(this, "pullToRefresh", 0); //Debug.WriteLine("Command executed"); //updateLabelInfo(); //aggiorna la label delle information (da aggiornare oppure rilassati) //_refreshView.IsRefreshing = false; }); _refreshView.RefreshCommand = refreshCommand; //Set Bindings //_refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //_refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, command); //_refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); return(_refreshView); }
public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { int pageIndex = comments.Count / 15 + 1; var lastUpdateData = (await BlogService.GetArticleComments(CommonHelper.token, currentArticle.BlogApp, currentArticle.Id, pageIndex, 15)); if (lastUpdateData.Count > 0) { comments.AddRange(lastUpdateData); comAdaper.RefreshItems(comments); int index = (comments.Count - 15) - 3; pListView.Invalidate(); pListView.SetSelection(index); } else { Msg.AppMsg.MakeText(this, "No More Item", Msg.AppMsg.STYLE_INFO).Show(); } pullToRefreshLayout.loadmoreFinish(0); }, this); }
public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { int pageIndex = news.Count / pageSize + 1; var moreNews = await NewsService.GetNews(CommonHelper.token, pageIndex, pageSize); if (moreNews.Count > 0) { news.AddRange(moreNews); comAdaper.RefreshItems(news); int index = (news.Count - 15) - 3; plistView.Invalidate(); plistView.SetSelection(index); } else { Msg.AppMsg.MakeText(this.Activity, "No More Item", Msg.AppMsg.STYLE_INFO).Show(); } pullToRefreshLayout.loadmoreFinish(0); }, this.Activity); }
public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { int pageIndex = bookMarks.Count / 25 + 1; var moreBookMarks = await BookMarkService.GetBookMarks(CommonHelper.token, pageIndex, 15); if (moreBookMarks.Count > 0) { bookMarks.AddRange(moreBookMarks); comAdaper.RefreshItems(bookMarks); int index = (bookMarks.Count - 15) - 3; pListView.Invalidate(); pListView.SetSelection(index); } else { Msg.AppMsg.MakeText(this, "No More Item", Msg.AppMsg.STYLE_INFO).Show(); } pullToRefreshLayout.loadmoreFinish(0); }, this); }
private void ScrollRefresh() { var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = MainScroll, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding <ScrollModel>(PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding <ScrollModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); TabGrid.Children.Add(refreshView, 0, 3); refreshView.RefreshCommand = new Command(() => { refreshView.IsRefreshing = false; LoadingInitAsync(); }); }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { BaseService.ExeRequest(async() => { content = await BlogService.GetArticleContent(CommonHelper.token, article.Id); content = content.Replace("\\r\\n", "</br>").Replace("\\n", "</br>").Replace("\\t", " ").Replace("\\", string.Empty); content = content.Substring(1, content.Length - 2); using (var stream = Assets.Open("articlecontent.html")) { StreamReader sr = new StreamReader(stream); string html = sr.ReadToEnd(); sr.Close(); sr.Dispose(); html = html.Replace("#title#", article.Title) .Replace("#author#", article.Author) .Replace("#time#", article.PostDate.ToShortDateString()) .Replace("#content#", content); webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); } pullToRefreshLayout.refreshFinish(0); }, this); }
public ListViewPage(bool insideLayout) { Title = "ListView (Pull to Refresh)"; BindingContext = new TestViewModel(this); var listView = new ListView(); //ListView now has a built in pull to refresh! //You most likely could enable the listview pull to refresh and use it instead of the refresh view //listView.IsPullToRefreshEnabled = true; // //listView.SetBinding<TestViewModel>(ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //listView.SetBinding<TestViewModel>(ListView.RefreshCommandProperty, vm => vm.RefreshCommand); listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, new Binding("Items")); //ListView now has a built in pull to refresh! //You most likely could disable the listview pull to refresh and re-enable this //However, I wouldn't recommend that. var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, listView } }, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, , new Binding("IsBusy", BindingMode.OneWay)); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Binding("RefreshCommand")); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public void onRefresh(PullToRefreshLayout pullToRefreshLayout) { int id = -1, markType = 1; try { //通过收藏URL判断书签类型 if (bookMark.LinkUrl.Contains("https://news")) { //新闻 int lastIndex = bookMark.LinkUrl.LastIndexOf("/"); if (lastIndex <= 27) { id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27)); } else { id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28)); } markType = 1; CommonHelper.InitalShare(this, null, true, "博客园新闻分享", bookMark.Title, "", bookMark.LinkUrl); } else if (bookMark.LinkUrl.Contains("http://kb.")) { //知识库 int lastIndex = bookMark.LinkUrl.LastIndexOf("/"); if (lastIndex <= 27) { id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 27)); } else { id = Convert.ToInt32(bookMark.LinkUrl.Substring(27, bookMark.LinkUrl.Length - 28)); } markType = 2; Button btnViewComments = FindViewById <Button>(Resource.Id.footbar_comments); btnViewComments.Visibility = ViewStates.Gone; LinearLayout linearWriteComments = FindViewById <LinearLayout>(Resource.Id.footbar_write_comment); linearWriteComments.Visibility = ViewStates.Gone; CommonHelper.InitalShare(this, null, true, "知识库分享", bookMark.Title, "", bookMark.LinkUrl); } else { //默认博客类型 markType = 3; int startindex = bookMark.LinkUrl.LastIndexOf("/"); //bookMark.WzLinkId id = Convert.ToInt32(bookMark.LinkUrl.Substring(startindex + 1, bookMark.LinkUrl.Length - startindex - 6)); CommonHelper.InitalShare(this, null, true, "博客园文章分享", bookMark.Title, "", bookMark.LinkUrl); } } catch (Exception) { } if (id == -1) { using (var stream = Assets.Open("articlecontent.html")) { StreamReader sr = new StreamReader(stream); string html = sr.ReadToEnd(); sr.Close(); sr.Dispose(); html = html.Replace("#title#", bookMark.Title) .Replace("#author#", "") .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss")) .Replace("#content#", "尴尬,这篇文章有点儿小问题,等会儿再看吧"); webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); } pullToRefreshLayout.refreshFinish(0); } else { CommonHelper.InitalBookMark(this, bookMark.LinkUrl, bookMark.Title); BaseService.ExeRequest(async() => { switch (markType) { case 1: content = await NewsService.GetNewInfo(CommonHelper.token, id); break; case 2: content = await BlogService.GetKbArticleContent(CommonHelper.token, id); break; case 3: content = await BlogService.GetArticleContent(CommonHelper.token, id); break; } content = content.Replace("\\r\\n", "</br>").Replace("\\n", "</br>").Replace("\\t", " ").Replace("\\", string.Empty); content = content.Substring(1, content.Length - 2); using (var stream = Assets.Open("articlecontent.html")) { StreamReader sr = new StreamReader(stream); string html = sr.ReadToEnd(); sr.Close(); sr.Dispose(); html = html.Replace("#title#", bookMark.Title) .Replace("#author#", "") .Replace("#time#", "收藏于 " + bookMark.DateAdded.ToString("yyyy/MM/dd hh:mm:ss")) .Replace("#content#", content); webView.LoadDataWithBaseURL("file:///android_asset/", html, "text/html", "utf-8", null); } pullToRefreshLayout.refreshFinish(0); }, this); } }
public ScrollViewPage(bool insideLayout) { var random = new Random(); Title = "ScrollView (Pull to Refresh)"; BindingContext = new TestViewModel(this); var grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0 }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = grid }; for (int i = 0; i < 20; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); for (int j = 0; j < 20; j++) { if (i == 0) { grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } grid.Children.Add(new BoxView { HeightRequest = 50, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }, i, j); } } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, new Binding("IsBusy", BindingMode.OneWay)); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Binding("RefreshCommand")); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), VerticalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public ScrollViewPage(bool insideLayout) { var random = new Random(); Title = "ScrollView (Pull to Refresh)"; BindingContext = new TestViewModel (this); var grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowSpacing = 0, ColumnSpacing = 0 }; var scrollView = new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = grid }; for (int i = 0; i < 20; i++) { grid.ColumnDefinitions.Add(new ColumnDefinition{ Width = GridLength.Auto }); for (int j = 0; j < 20; j++) { if (i == 0) { grid.RowDefinitions.Add(new RowDefinition{ Height = GridLength.Auto }); } grid.Children.Add(new BoxView { HeightRequest = 50, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }, i, j); } } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = scrollView, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public void onLoadMore(PullToRefreshLayout pullToRefreshLayout) { }
public StackLayoutPage(bool insideLayout) { var random = new Random(); Title = "StackLayout (Pull to Refresh)"; BindingContext = new TestViewModel(this); var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0 }; for (int i = 0; i < 20; i++) { stack.Children.Add(new BoxView { HeightRequest = 150, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }); } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = stack, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding <TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding <TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { var activity = new ActivityIndicator(); activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); Content = new StackLayout { Spacing = 0, Children = { activity, new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
public ListViewPage(bool insideLayout) { Title = "ListView (Pull to Refresh)"; BindingContext = new TestViewModel (this); var listView = new ListView (); //ListView now has a built in pull to refresh! //You most likely could enable the listview pull to refresh and use it instead of the refresh view //listView.IsPullToRefreshEnabled = true; // //listView.SetBinding<TestViewModel>(ListView.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); //listView.SetBinding<TestViewModel>(ListView.RefreshCommandProperty, vm => vm.RefreshCommand); listView.SetBinding<TestViewModel> (ItemsView<Cell>.ItemsSourceProperty, vm => vm.Items); //ListView now has a built in pull to refresh! //You most likely could disable the listview pull to refresh and re-enable this //However, I wouldn't recommend that. var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, listView } }, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { Content = new StackLayout { Spacing = 0, Children = { new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }
private async void bindControls() { btnWriteComments = FindViewById <Button>(Resource.Id.footbar_write_comment); btnWriteComments.Click += delegate { BottomSheetDialog bottomSheetDiaolog = new BottomSheetDialog(this); var inflater = GetSystemService(Context.LayoutInflaterService) as LayoutInflater; EditText textComments = FindViewById <EditText>(Resource.Id.text_comments); View view = inflater.Inflate(Resource.Layout.write_comments, null); TextView textCancel = view.FindViewById <TextView>(Resource.Id.text_cancel); textCancel.Click += delegate { bottomSheetDiaolog.Dismiss(); }; TextView textSend = view.FindViewById <TextView>(Resource.Id.text_send_comments); textSend.Click += async delegate { string content = textComments.Text; if (string.IsNullOrWhiteSpace(content)) { Msg.AppMsg.MakeText(this, "请输入评论内容", Msg.AppMsg.STYLE_INFO).Show(); return; } Dialog waitDialog = CommonHelper.CreateLoadingDialog(this, "正在发送评论数据,请稍后..."); try { waitDialog.Show(); if (await BlogService.AddArticleComments(CommonHelper.token, article.BlogApp, article.Id, content)) { Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_success), Msg.AppMsg.STYLE_INFO).Show(); bottomSheetDiaolog.Dismiss(); } else { Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show(); } } catch (Exception ex) { Msg.AppMsg.MakeText(this, GetString(Resource.String.publish_comments_fail), Msg.AppMsg.STYLE_INFO).Show(); Log.Debug("error:", ex.Message); } finally { waitDialog.Cancel(); } }; bottomSheetDiaolog.SetContentView(view); bottomSheetDiaolog.Show(); }; webView = FindViewById <PullableWebView>(Resource.Id.webview); ptrl = FindViewById <PullToRefreshLayout>(Resource.Id.refresh_view); ptrl.setOnRefreshListener(this); webView.Settings.DefaultTextEncodingName = "utf-8"; webView.Settings.LoadsImagesAutomatically = true; webView.SetWebViewClient(new MyWebViewClient()); webView.ScrollBarStyle = ScrollbarStyles.InsideOverlay; webView.Settings.JavaScriptEnabled = false; webView.Settings.SetSupportZoom(false); webView.Settings.BuiltInZoomControls = false; webView.Settings.CacheMode = CacheModes.CacheElseNetwork; webView.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn); //webView.Settings.UseWideViewPort = true;//设置此属性,可任意比例缩放 btnViewComments = FindViewById <Button>(Resource.Id.footbar_comments); btnViewComments.Click += delegate { Intent intent = new Intent(this, typeof(ArticleCommentsActivity)); intent.PutExtra("current", JsonConvert.SerializeObject(article)); StartActivity(intent); }; CommonHelper.InitalShare(this, null, true, article.Author, article.Title, article.Avatar, article.Url); CommonHelper.InitalBookMark(this, article.Url, article.Title); await ptrl.AutoRefresh(); }
public StackLayoutPage(bool insideLayout) { var random = new Random(); Title = "StackLayout (Pull to Refresh)"; BindingContext = new TestViewModel (this); var stack = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 0 }; for (int i = 0; i < 20; i++) { stack.Children.Add(new BoxView { HeightRequest = 150, HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromRgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)) }); } var refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = stack, RefreshColor = Color.FromHex("#3498db") }; refreshView.SetBinding<TestViewModel> (PullToRefreshLayout.IsRefreshingProperty, vm => vm.IsBusy, BindingMode.OneWay); refreshView.SetBinding<TestViewModel>(PullToRefreshLayout.RefreshCommandProperty, vm => vm.RefreshCommand); if (insideLayout) { var activity = new ActivityIndicator(); activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy"); Content = new StackLayout { Spacing = 0, Children = { activity, new Label { TextColor = Color.White, Text = "In a StackLayout", FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)), BackgroundColor = Color.FromHex("#3498db"), XAlign = TextAlignment.Center, HorizontalOptions = LayoutOptions.FillAndExpand }, refreshView } }; } else { Content = refreshView; } }