public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); _swipeRefreshLayout.SetOnRefreshListener(this); _swipeRefreshLayout.Post(() => { _swipeRefreshLayout.Refreshing = true; }); _swipeRefreshLayout.PostDelayed(() => { System.Diagnostics.Debug.Write("PostDelayed方法已经完成"); _swipeRefreshLayout.Refreshing = false; }, 3000); _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity)); kbArticlesList = await listKbArticleLocal(); if (kbArticlesList.Count > 0) { initRecycler(); } else { kbArticlesList = await listKbArticlesServer(); if (kbArticlesList.Count > 0) { initRecycler(); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); #if DEBUG Xamarin.Insights.Initialize("ef02f98fd6fb47ce8624862ab7625b933b6fb21d", this); #else Xamarin.Insights.Initialize("8da86f8b3300aa58f3dc9bbef455d0427bb29086", this); #endif mapView = FindViewById <MapView> (Resource.Id.map); mapView.OnCreate(bundle); mapView.Visibility = ViewStates.Invisible; viewModel = new CoffeeFilterViewModel(); ServiceContainer.Register <CoffeeFilterViewModel> (viewModel); adapter = new PlacesPagerAdapter(SupportFragmentManager, viewModel); pager = FindViewById <ViewPager> (Resource.Id.pager); pager.Adapter = adapter; progressBar = FindViewById <ImageView> (Resource.Id.progressBar); errorImage = FindViewById <ImageView> (Resource.Id.error); coffeeProgress = (AnimationDrawable)progressBar.Background; progressBar.Visibility = ViewStates.Gone; pager.PageSelected += (sender, e) => UpdateMap(e.Position); pager.PageScrollStateChanged += (sender, e) => { if (e.State == (int)ScrollState.TouchScroll) { refresher.Enabled = false; } else { refresher.Enabled = true; } }; refresher = FindViewById <SwipeRefreshLayout> (Resource.Id.refresher); refresher.SetColorSchemeColors(Resource.Color.accent); refresher.Refresh += (sender, args) => { RefreshData(true); refresher.PostDelayed(() => { refresher.Refreshing = false; }, 250); }; SupportActionBar.SetDisplayHomeAsUpEnabled(false); SupportActionBar.SetHomeButtonEnabled(false); mapView.GetMapAsync(this); CheckGooglePlayServices(); // No savedInstanceState, so it is the first launch of this activity if (bundle == null && AppInviteReferral.HasReferral(Intent)) { // In this case the referral data is in the intent launching the MainActivity, // which means this user already had the app installed. We do not have to // register the Broadcast Receiver to listen for Play Store Install information LaunchDeepLinkActivity(Intent); } }
//ÇëÇóÉÁ´æÆÀÂ۳ɹ¦µÄ»Øµ÷ async void callBackSuccess(List <StatusCommentsModel> list) { AlertUtil.ToastShort(this, "Ïß³ÌID" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString()); try { await SQLiteUtil.UpdateStatuscommentList(list); } catch (Exception ex) { } listStatusComment = list; initRecycler(); _swipeRefreshLayout.PostDelayed(() => { _swipeRefreshLayout.Refreshing = false; }, 500); }
private async void initRecyclerView() { var result = await QuestionService.ListQuestionAnswer(AccessTokenUtil.GetToken(this), questionId); if (result.Success) { answerList = result.Data; initRecycler(); } else { AlertUtil.ToastShort(this, result.Message); } _swipeRefreshLayout.PostDelayed(() => { _swipeRefreshLayout.Refreshing = false; }, 1000); }
public void OnRefresh() { swipeRefreshLayout.Post(() => { swipeRefreshLayout.Refreshing = true; }); UpdateViewStatus(() => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); }, () => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); }); }
public async void OnRefresh() { _swipeRefreshLayout.Post(() => { _swipeRefreshLayout.Refreshing = true; }); pageIndex = 1; var result = await ArticleService.ListArticle(accessToken, pageIndex, position); if (result.Success) { var tempList = result.Data; if (tempList != null && tempList.Count > 0) { articleList = tempList; if (isFirstRefresh) { initRecycler(); } else { adapter.SetNewData(tempList); isFirstRefresh = false; } await SQLiteUtil.UpdateArticleList(tempList); } else { AlertUtil.ToastShort(Activity, "ÍøÂ粻̫ºÃŶ"); } _swipeRefreshLayout.PostDelayed(() => { _swipeRefreshLayout.Refreshing = false; }, 800); } else { AlertUtil.ToastShort(Activity, result.Message); _swipeRefreshLayout.PostDelayed(() => { _swipeRefreshLayout.Refreshing = false; }, 800); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetToolBarNavBack(); StatusBarUtil.SetColorStatusBars(this); SetToolBarTitle(Resources.GetString(Resource.String.bookmark_my)); _swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); _swipeRefreshLayout.SetOnRefreshListener(this); _swipeRefreshLayout.Post(() => { _swipeRefreshLayout.Refreshing = true; }); _swipeRefreshLayout.PostDelayed(() => { System.Diagnostics.Debug.Write("PostDelayed方法已经完成"); _swipeRefreshLayout.Refreshing = false; }, 3000); ly_expire = FindViewById <LinearLayout>(Resource.Id.ly_expire); tv_startLogin = FindViewById <TextView>(Resource.Id.tv_startLogin); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this)); token = UserTokenUtil.GetToken(this); if (token.IsExpire) { ly_expire.Visibility = ViewStates.Visible; _swipeRefreshLayout.Visibility = ViewStates.Gone; tv_startLogin.Click += (s, e) => { StartActivity(new Intent(this, typeof(loginactivity))); }; return; } else { ly_expire.Visibility = ViewStates.Gone; _swipeRefreshLayout.Visibility = ViewStates.Visible; } bookMarkList = await listBookmarkServer(); if (bookMarkList != null && bookMarkList.Count > 0) { initRecycler(); } }
public override async void OnViewCreated(View view, Bundle savedInstanceState) { base.OnViewCreated(view, savedInstanceState); ly_expire = view.FindViewById <LinearLayout>(Resource.Id.ly_expire); tv_startLogin = view.FindViewById <TextView>(Resource.Id.tv_startLogin); _swipeRefreshLayout = view.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); _swipeRefreshLayout.SetOnRefreshListener(this); _swipeRefreshLayout.Post(() => { _swipeRefreshLayout.Refreshing = true; }); _swipeRefreshLayout.PostDelayed(() => { System.Diagnostics.Debug.Write("PostDelayed刷新已经完成"); _swipeRefreshLayout.Refreshing = false; }, 4000); _recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this.Activity)); //_recyclerView.AddItemDecoration(new RecyclerViewDecoration(this.Activity, (int)Orientation.Vertical)); Token token = UserTokenUtil.GetToken(Activity); if (position == 3) { //kbArticlesList = await listKbArticleLocal(); kbArticlesList = await SQLiteUtil.SelectKbArticleList(Constact.PageSize); if (kbArticlesList != null) { initRecyclerKbArticles(); } } else { newsList = await listNewsLocal(); if (newsList != null) { initRecycler(); } } OnRefresh(); }
private void OnRefreshed() { swipeRefresh.Post(() => swipeRefresh.Refreshing = false); if (stop != null && timeSteps != null) { TimeStep[] lineSteps = timeSteps.Where(s => s.Step.Stop.Line == line) .OrderBy(s => s.Step.Route.Id) .ThenBy(s => s.Date) .ToArray(); listStopList.SetAdapter(new TimeStepsAdapter(lineSteps)); TimeStep[] otherSteps = timeSteps.Where(s => s.Step.Stop.Line != line) .OrderBy(s => s.Date) .ToArray(); otherStopList.SetAdapter(new TimeStepsAdapter(otherSteps)); otherLabel.Visibility = otherSteps.Length == 0 ? ViewStates.Gone : ViewStates.Visible; } swipeRefresh.PostDelayed(() => swipeRefresh.Refreshing = false, 1000); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.searchResult); var app = ((InitApp)ApplicationContext); if (app != null) { app.addActivity(this); } tv_question = FindViewById <TextView>(Resource.Id.tv_question); tv_news = FindViewById <TextView>(Resource.Id.tv_news); tv_kb = FindViewById <TextView>(Resource.Id.tv_kb); tv_blog = FindViewById <TextView>(Resource.Id.tv_blog); search_keyword = FindViewById <SearchView>(Resource.Id.search_keyword); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); swipeRefreshLayout.SetColorScheme(Resource.Color.primary); swipeRefreshLayout.Refreshing = false; StatusBarUtil.SetColorStatusBars(this); category = Intent.GetStringExtra("category"); keyword = Intent.GetStringExtra("keyword"); startQuery = Intent.GetBooleanExtra("startquery", false); initCategoryClick(); //初始化category单击事件 initCategoryByCategory(); //初始化category 选中的状态 toolbar.SetNavigationIcon(Resource.Drawable.back_24dp); toolbar.NavigationClick += (s, e) => { ActivityCompat.FinishAfterTransition(this); }; swipeRefreshLayout.Refresh += (s, e) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); }; _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this)); //search_keyword.SubmitButtonEnabled = true; //默认为false 不显示提交按钮,是否启用提交按钮 search_keyword.OnActionViewExpanded(); //手动展开SearchView输入框,初始可以点击输入的状态 //search_keyword.SetIconifiedByDefault(false); //默认是为true 不显示输入框键盘,默认提交按钮不显示,该属性设置为false,则直接展开输入框弹出键盘 // search_keyword.RequestFocus(); //将控件设置成可获取焦点状态,默认是无法获取焦点的,只有设置成true,才能获取控件的点击事件 //search_keyword.Focusable = true; search_keyword.ClearFocus(); search_keyword.Focusable = true; if (!string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = keyword; } search_keyword.FocusChange += (s, e) => { System.Diagnostics.Debug.Write(e.HasFocus); if (e.HasFocus) { SearchInputActivity.Enter(category, this); } }; search_keyword.SetOnQueryTextFocusChangeListener(this); search_keyword.QueryTextSubmit += async(s, e) => { keyword = search_keyword.Query.Trim(); if (keyword == null || keyword.Length == 0) { return; } SearchHistoryShared.SetSearchHistory(keyword, this); swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); }; if (startQuery) { initCategoryByCategory(); SearchHistoryShared.SetSearchHistory(keyword, this); if (!string.IsNullOrEmpty(keyword)) { swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); } } }
async void initCategoryById(View v) { setUnSelected(); switch (v.Id) { case Resource.Id.tv_blog: if (tv_blog.Selected) { return; } tv_blog.Selected = true; if (string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = "搜博客"; } category = "Blog"; break; case Resource.Id.tv_news: if (tv_news.Selected) { return; } tv_news.Selected = true; if (string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = "搜新闻"; } category = "News"; break; case Resource.Id.tv_question: if (tv_question.Selected) { return; } tv_question.Selected = true; if (string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = "搜问答"; } category = "Question"; break; case Resource.Id.tv_kb: if (tv_kb.Selected) { return; } tv_kb.Selected = true; if (string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = "搜知识库"; } category = "Kb"; break; default: if (tv_blog.Selected) { return; } tv_blog.Selected = true; if (string.IsNullOrEmpty(keyword)) { search_keyword.QueryHint = "搜博客"; } category = "Blog"; break; } if (!string.IsNullOrEmpty(keyword)) { swipeRefreshLayout.Refreshing = true; await listSearchService((list) => { swipeRefreshLayout.PostDelayed(() => { swipeRefreshLayout.Refreshing = false; }, 1000); searchList = list; initRecycler(); }); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); blogApp = Intent.GetStringExtra("blogApp"); postId = Intent.GetIntExtra("postId", 0); SetToolBarNavBack(); StatusBarUtil.SetColorStatusBars(this); SetToolBarTitle(Resources.GetString(Resource.String.comment)); //显示图片配置 options = new DisplayImageOptions.Builder() .ShowImageForEmptyUri(Resource.Drawable.icon_yuanyou) .ShowImageOnFail(Resource.Drawable.icon_yuanyou) .ShowImageOnLoading(Resource.Drawable.icon_user) .CacheInMemory(true) .BitmapConfig(Bitmap.Config.Rgb565) .CacheOnDisk(true) // .Displayer(new DisplayerImageCircle(20)) .Build(); edit_content = FindViewById <EditText>(Resource.Id.edit_content); btn_submit = FindViewById <Button>(Resource.Id.btn_submit); //btn_submit.enabvle btn_submit.Click += (s, e) => { Add(); }; edit_content.TextChanged += (s, e) => { string temp = edit_content.Text.TrimStart().TrimEnd(); if (!string.IsNullOrEmpty(temp)) { btn_submit.Enabled = true; if (atUserName != null && atUserName.Length > 0 && temp.Contains(atUserName)) { isAt = true; } else { isAt = false; } } else { btn_submit.Enabled = false; } }; _swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout); _swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary); _swipeRefreshLayout.SetOnRefreshListener(this); _swipeRefreshLayout.Post(() => { _swipeRefreshLayout.Refreshing = true; }); _swipeRefreshLayout.PostDelayed(() => { System.Diagnostics.Debug.Write("PostDelayed方法已经完成"); _swipeRefreshLayout.Refreshing = false; }, 3000); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); _recyclerView.SetLayoutManager(new Android.Support.V7.Widget.LinearLayoutManager(this)); _recyclerView.AddItemDecoration(new RecyclerViewDecoration(this, (int)Orientation.Vertical)); try { commentList = await listArticleCommentServer(); if (commentList != null) { initRecycler(); } } catch (Exception ex) { MobclickAgent.ReportError(this, ex.ToString()); System.Diagnostics.Debug.Write(ex.ToString()); } }
private async Task Search(Stop from, Stop to, DateConstraint constraint, DateTime date) { swipeRefresh?.Post(() => swipeRefresh.Refreshing = true); await Task.Run(() => { routeSegments.Clear(); // Build a new route searcher RouteSearch routeSearch = new RouteSearch(); routeSearch.Settings.AllowWalkLinks = false; routeSearch.Prepare(TramUrWayApplication.Lines); // Start enumeration DateTime end = DateTime.Now + TimeSpan.FromSeconds(5); IEnumerable <RouteLink[]> routesEnumerable = routeSearch.FindRoutes(from, to); IEnumerator <RouteLink[]> routesEnumerator = routesEnumerable.GetEnumerator(); while (true) { Task <bool> moveNextTask = Task.Run(() => routesEnumerator.MoveNext()); // Exit if timed out TimeSpan timeout = end - DateTime.Now; if (!moveNextTask.Wait(timeout)) { break; } // Exit if enumeration finished if (moveNextTask.Result == false) { break; } RouteLink[] route = routesEnumerator.Current; TimeSpan tolerance = TimeSpan.FromMinutes(15); // We found a route, try to find times if (constraint == DateConstraint.Now) { routeSegments.AddRange(routeSearch.SimulateTimeStepsFrom(route, date, TimeSpan.Zero, tolerance)); } else if (constraint == DateConstraint.From) { routeSegments.AddRange(routeSearch.SimulateTimeStepsFrom(route, date, tolerance, tolerance)); } else if (constraint == DateConstraint.To) { throw new NotImplementedException(); } else if (constraint == DateConstraint.Last) { throw new NotImplementedException(); } // Filter out too long times TimeSpan maxTime = TimeSpan.FromMinutes(0.05 * (to.Position - from.Position)); routeSegments.RemoveAll(r => r.Last().DateTo - r.First().DateFrom > maxTime); routeSegments.Sort((r1, r2) => (int)(ComputeRouteWeight(constraint, date, r1) - ComputeRouteWeight(constraint, date, r2))); // Group routes by from and to time steps RouteSegment[][] routeSegmentsCopy = routeSegments.GroupBy(r => GetRouteHash(r)).Select(g => g.First()).ToArray(); RunOnUiThread(() => routeSegmentAdapter.RouteSegments = routeSegmentsCopy); } RunOnUiThread(() => { noResultsView.Visibility = routeSegments.Count == 0 ? ViewStates.Visible : ViewStates.Gone; recyclerView.Visibility = routeSegments.Count > 0 ? ViewStates.Visible : ViewStates.Gone; swipeRefresh?.PostDelayed(() => swipeRefresh.Refreshing = false, 200); }); }); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); #if DEBUG Xamarin.Insights.Initialize("ef02f98fd6fb47ce8624862ab7625b933b6fb21d", this); #else Xamarin.Insights.Initialize ("8da86f8b3300aa58f3dc9bbef455d0427bb29086", this); #endif mapView = FindViewById<MapView> (Resource.Id.map); mapView.OnCreate (bundle); mapView.Visibility = ViewStates.Invisible; viewModel = new CoffeeFilterViewModel (); ServiceContainer.Register<CoffeeFilterViewModel> (viewModel); adapter = new PlacesPagerAdapter (SupportFragmentManager, viewModel); pager = FindViewById<ViewPager> (Resource.Id.pager); pager.Adapter = adapter; progressBar = FindViewById<ImageView> (Resource.Id.progressBar); errorImage = FindViewById<ImageView> (Resource.Id.error); coffeeProgress = (AnimationDrawable)progressBar.Background; progressBar.Visibility = ViewStates.Gone; pager.PageSelected += (sender, e) => UpdateMap (e.Position); pager.PageScrollStateChanged += (sender, e) => { if (e.State == (int)ScrollState.TouchScroll) refresher.Enabled = false; else refresher.Enabled = true; }; refresher = FindViewById<SwipeRefreshLayout> (Resource.Id.refresher); refresher.SetColorSchemeColors (Resource.Color.accent); refresher.Refresh += (sender, args) => { RefreshData (true); refresher.PostDelayed (() => { refresher.Refreshing = false; }, 250); }; SupportActionBar.SetDisplayHomeAsUpEnabled (false); SupportActionBar.SetHomeButtonEnabled (false); mapView.GetMapAsync (this); CheckGooglePlayServices (); // No savedInstanceState, so it is the first launch of this activity if (bundle == null && AppInviteReferral.HasReferral(Intent)) { // In this case the referral data is in the intent launching the MainActivity, // which means this user already had the app installed. We do not have to // register the Broadcast Receiver to listen for Play Store Install information LaunchDeepLinkActivity(Intent); } }