private void updateMark() { if (mMarkAdapter == null) { mMarkAdapter = new BookMarkAdapter(this, new List <BookMark>()); lvMark.Adapter = (mMarkAdapter); lvMark.ItemClick += (sender, e) => { BookMark mark = mMarkAdapter.getData(e.Position); if (mark != null) { mPageWidget.setPosition(new int[] { mark.chapter, mark.startPos, mark.endPos }); hideReadBar(); } else { ToastUtils.showSingleToast("书签无效"); } }; } mMarkAdapter.clear(); mMarkList = Settings.GetBookMarks(bookId); if (mMarkList != null && mMarkList.Count() > 0) { mMarkList.Reverse(); mMarkAdapter.addAll(mMarkList); } }
//############# DON'T MODIFY HERE ############# //========================= Functions ========================= public static async Task SendMessageTask(int userId, string text, string hashId, UserDataObject userData) { try { var(apiStatus, respond) = await RequestsAsync.Messages.SendMessage(userId.ToString(), text, hashId); if (apiStatus == 200) { if (respond is SendMessageObject result) { if (result.data != null) { UpdateLastIdMessage(result.data, userData); } } } else if (apiStatus == 400) { if (respond is ErrorObject error) { var errorText = error.errors.ErrorText; ToastUtils.ShowToast(errorText, ToastLength.Short); } } else if (apiStatus == 404) { var error = respond.ToString(); ToastUtils.ShowToast(error, ToastLength.Short); } } catch (Exception e) { Console.WriteLine(e); } }
/** * 当UncaughtException发生时会转入该函数来处理 */ public void UncaughtException(Thread thread, Throwable ex) { if (!handleException(ex) && mDefaultHandler != null) { //如果用户没有处理则让系统默认的异常处理器来处理 mDefaultHandler.UncaughtException(thread, ex); } else { DownloadBookService.cancel(); // 取消任务 LogUtils.i("取消下载任务"); new Thread(() => { Looper.Prepare(); ToastUtils.showSingleToast("哎呀,程序发生异常啦..."); Looper.Loop(); }).Start(); try { Thread.Sleep(3000); } catch (InterruptedException e) { LogUtils.e("CrashHandler.InterruptedException--->" + e.ToString()); } //退出程序 Process.KillProcess(Process.MyPid()); JavaSystem.Exit(1); } }
/// <summary> /// 后台运行设置 /// </summary> public void BackgroundOperationSetting() { if (IsHuawei()) { GoHuaweiSetting(); } else if (IsXiaomi()) { GoXiaomiSetting(); } else if (IsOPPO()) { GoOPPOSetting(); } else if (IsVIVO()) { GoVIVOSetting(); } else if (IsMeizu()) { GoMeizuSetting(); } else if (IsSamsung()) { GoSamsungSetting(); } else { ToastUtils.ShowSingleToast("没有检测到机型!"); } }
public void netError(int chapter) { hideDialog();//防止因为网络问题而出现dialog不消失 if (Math.Abs(chapter - currentChapter) <= 1) { ToastUtils.showToast(Resource.String.net_error); } }
//Send Message type => "right_text" private void OnClick_OfSendButton() { try { UnixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var time2 = UnixTimestamp.ToString(); string timeNow = DateTime.Now.ToString("hh:mm"); if (string.IsNullOrEmpty(EmojiconEditTextView.Text)) { } else { //Here on This function will send Text Messages to the user //remove \n in a string string replacement = Regex.Replace(EmojiconEditTextView.Text, @"\t|\n|\r", ""); if (Methods.CheckConnectivity()) { GetUserMessagesObject.Message message = new GetUserMessagesObject.Message { Id = UnixTimestamp, FromId = int.Parse(UserDetails.UserId), ToId = Userid, Text = replacement, MediaFile = "", MediaType = "", DeletedFs1 = "", DeletedFs2 = "", Seen = "0", Time = time2, Extra = "", TimeText = timeNow, Position = "Right", }; MAdapter.Add(message); UserDataObject userData = ConvertData(); MessageController.SendMessageTask(Userid, EmojiconEditTextView.Text, time2, userData).ConfigureAwait(false); } else { ToastUtils.ShowToast(GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short); } EmojiconEditTextView.Text = ""; } ChatSendButton.Tag = "Text"; ChatSendButton.SetImageResource(Resource.Drawable.SendLetter); } catch (Exception e) { Console.WriteLine(e); } }
public void onItemClick(int position) { Recommend.RecommendBooks books = mAdapter.getItem(position); if (books.path.EndsWith(Constant.SUFFIX_TXT)) { // TXT new AlertDialog.Builder(this) .SetTitle("提示") .SetMessage(Java.Lang.String.Format(GetString( Resource.String.book_detail_is_joined_the_book_shelf), books.title)) .SetPositiveButton("确定", (sender, e) => { // 拷贝到缓存目录 FileUtils.fileChannelCopy(new File(books.path), new File(FileUtils.getChapterPath(books._id, 1))); // 加入书架 if (CollectionsManager.getInstance().add(books)) { mRecyclerView.showTipViewAndDelayClose(Java.Lang.String.Format(GetString( Resource.String.book_detail_has_joined_the_book_shelf), books.title)); // 通知 EventManager.refreshCollectionList(); } else { mRecyclerView.showTipViewAndDelayClose("书籍已存在"); } var dialog = sender as AlertDialog; dialog?.Dismiss(); }) .SetNegativeButton("取消", (sender, e) => { var dialog = sender as AlertDialog; dialog?.Dismiss(); }) .Show(); } else if (books.path.EndsWith(Constant.SUFFIX_PDF)) { // PDF // TODO: ReadPDFActivity.start(this, books.path); ToastUtils.showSingleToast("等待开发中"); } else if (books.path.EndsWith(Constant.SUFFIX_EPUB)) { // EPub // TODO: ReadEPubActivity.start(this, books.path); ToastUtils.showSingleToast("等待开发中"); } else if (books.path.EndsWith(Constant.SUFFIX_CHM)) { // CHM // TODO: ReadCHMActivity.start(this, books.path); ToastUtils.showSingleToast("等待开发中"); } }
//Get Messages From API private async void GetMessages_API() { try { if (!Methods.CheckConnectivity()) { SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; ToastUtils.ShowToast(GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short); } else { BeforeMessageId = 0; var(apiStatus, respond) = await RequestsAsync.Messages.GetUserMessages(Userid.ToString()); if (apiStatus == 200) { if (respond is GetUserMessagesObject result) { if (result.data.Messages.Count > 0) { MAdapter.MessageList = new ObservableCollection <GetUserMessagesObject.Message>(result.data.Messages.OrderBy(a => a.Time)); MAdapter.BindEnd(); //Insert to DataBase SqLiteDatabase dbDatabase = new SqLiteDatabase(); dbDatabase.InsertOrReplaceMessages(MAdapter.MessageList); dbDatabase.Dispose(); //Scroll Down >> ChatBoxRecylerView.ScrollToPosition(MAdapter.MessageList.Count - 1); SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; } } } else { Methods.DisplayReportResult(this, respond); } SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; } } catch (Exception e) { Console.WriteLine(e); SwipeRefreshLayout.Refreshing = false; SwipeRefreshLayout.Enabled = false; } }
public override bool OnKeyDown([GeneratedEnum] Keycode keyCode, KeyEvent e) { if (keyCode == Keycode.Back && e.Action == KeyEventActions.Down) { //这里解决Popup 弹出后,点击回退健时不能释放Popup问题 Device.BeginInvokeOnMainThread(async() => { if (PopupNavigation.Instance.PopupStack.Count > 0) { await PopupNavigation.Instance.PopAllAsync(); } }); if (!lastBackKeyDownTime.HasValue || (DateTime.Now - lastBackKeyDownTime.Value) > new TimeSpan(0, 0, 2)) { var actionPage = App.Current.MainPage; if (actionPage?.Navigation != null && actionPage?.Navigation?.NavigationStack?.Count != 0) { actionPage = actionPage.Navigation.NavigationStack.Last(); if (null != actionPage) { if (actionPage is MainLayoutPage) { ToastUtils.ShowSingleToast("再按一次退出程序"); lastBackKeyDownTime = DateTime.Now; return(true); } else if (actionPage is LoginPage) { MoveTaskToBack(true); return(false); } else { Device.BeginInvokeOnMainThread(async() => { await actionPage?.Navigation.PopAsync(true); }); } } } } else { //移除Activity AppManager.Instance().ExitApp(); } return(true); } return(base.OnKeyDown(keyCode, e)); }
private void showTagGroup() { if (!mTagList.Any()) { ToastUtils.showToast(GetString(Resource.String.network_error_tips)); return; } Animation mShowAction = new TranslateAnimation(Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, 0.0f, Dimension.RelativeToSelf, -1.0f, Dimension.RelativeToSelf, 0.0f); mShowAction.Duration = (400); rsvTags.StartAnimation(mShowAction); rsvTags.Visibility = ViewStates.Visible; }
void getBookLists(String duration, String sort, int start, int limit, String tag, String gender) { BookApi.Instance.getBookLists(duration, sort, start.ToString(), limit.ToString(), tag, gender) .SubscribeOn(DefaultScheduler.Instance) .ObserveOn(Application.SynchronizationContext) .Subscribe(data => { showBookList(data.bookLists, start == 0 ? true : false); if (data.bookLists == null || !data.bookLists.Any()) { ToastUtils.showSingleToast("暂无相关书单"); } }, e => { LogUtils.e("GirlBookDiscussionFragment", e.ToString()); showError(); }, () => { LogUtils.i("GirlBookDiscussionFragment", "complete"); complete(); }); }
public void onClickJoinCollection() { if (!isJoinedCollections) { if (recommendBooks != null) { CollectionsManager.getInstance().add(recommendBooks); ToastUtils.showToast(Java.Lang.String.Format(GetString( Resource.String.book_detail_has_joined_the_book_shelf), recommendBooks.title)); initCollection(false); } } else { CollectionsManager.getInstance().remove(recommendBooks._id); ToastUtils.showToast(Java.Lang.String.Format(GetString( Resource.String.book_detail_has_remove_the_book_shelf), recommendBooks.title)); initCollection(true); } }
/// <summary> /// 双击退出 /// </summary> /// <param name="e"></param> /// <returns></returns> public override bool DispatchKeyEvent(KeyEvent e) { if (e.Action == KeyEventActions.Down && e.KeyCode == Keycode.Back) { if (Java.Lang.JavaSystem.CurrentTimeMillis() - currentBackPressedTime > BACK_PRESSED_INTERVAL) { currentBackPressedTime = Java.Lang.JavaSystem.CurrentTimeMillis(); ToastUtils.showToast(GetString(Resource.String.exit_tips)); return(true); } else { Finish(); // 退出 } } else if (e.KeyCode == Keycode.Menu) { return(true); } return(base.DispatchKeyEvent(e)); }
public void prePage() { BookStatus status = pagefactory.prePage(); if (status == BookStatus.NO_PRE_PAGE) { ToastUtils.showSingleToast("没有上一页啦"); return; } else if (status == BookStatus.LOAD_SUCCESS) { if (isPrepared) { pagefactory.onDraw(mCurrentPageCanvas); pagefactory.onDraw(mNextPageCanvas); PostInvalidate(); } } else { return; } }
/***************Book Mark*****************/ public void addBookMark(object sender, EventArgs e) { int[] readPos = mPageWidget.getReadPos(); BookMark mark = new BookMark(); mark.chapter = readPos[0]; mark.startPos = readPos[1]; mark.endPos = readPos[2]; if (mark.chapter >= 1 && mark.chapter <= mChapterList.Count()) { mark.title = mChapterList[mark.chapter - 1].title; } mark.desc = mPageWidget.getHeadLine(); if (Settings.AddBookMark(bookId, mark)) { ToastUtils.showSingleToast("添加书签成功"); updateMark(); } else { ToastUtils.showSingleToast("书签已存在"); } }
private void syncBookShelf() { List <Recommend.RecommendBooks> list = CollectionsManager.getInstance().getCollectionList(); List <IObservable <BookMixAToc.MixToc> > observables = new List <IObservable <BookMixAToc.MixToc> >(); if (list != null && list.Any()) { foreach (var bean in list) { if (!bean.isFromSD) { IObservable <BookMixAToc.MixToc> fromNetWork = BookApi.Instance.getBookMixAToc(bean._id, "chapters") .Select(s => s.mixToc); observables.Add(fromNetWork); } } } else { ToastUtils.showSingleToast("书架空空如也..."); syncBookShelfCompleted(); return; } Observable.Merge(observables) .SubscribeOn(DefaultScheduler.Instance) .ObserveOn(Application.SynchronizationContext) .Subscribe(data => { String lastChapter = data.chapters[data.chapters.Count() - 1].title; CollectionsManager.getInstance().setLastChapterAndLatelyUpdate(data.book, lastChapter, data.chaptersUpdated); }, e => { LogUtils.e("onError: " + e); showError(); }, () => { syncBookShelfCompleted(); }); }
public void readBook(object sender, EventArgs e) { gone(rlReadAaSet, rlReadMark); ToastUtils.showToast("正在拼命开发中..."); }
/// <summary> /// 相当于toast(message);log(message)。显示信息message并在控制台中输出。参见console.log。 /// </summary> /// <param name="message"></param> /// <param name="toastyType"></param> public void ToastLog(string message) { ToastUtils.showToast(message); PLog(message); }
/// <summary> /// 一个全局的异常处理操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UnhandledExceptionHandler(object sender, RaiseThrowableEventArgs e) { ToastUtils.showSingleLongToast(e.Exception.Message); LogEventDelegates.Instance.OnLog(new LogEventArgs("异常", e.Exception.Message, Xamarin.Forms.Color.Red)); }
public override bool OnOptionsItemSelected(IMenuItem item) { int id = item.ItemId; switch (id) { case Resource.Id.action_search: StartActivity(new Intent(this, typeof(SearchActivity))); break; case Resource.Id.action_login: if (popupWindow == null) { popupWindow = new LoginPopupWindow(this); popupWindow.setLoginTypeListener(this); } popupWindow.ShowAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0); break; case Resource.Id.action_my_message: if (popupWindow == null) { popupWindow = new LoginPopupWindow(this); popupWindow.setLoginTypeListener(this); } popupWindow.ShowAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0); break; case Resource.Id.action_sync_bookshelf: showDialog(); syncBookShelf(); /* if (popupWindow == null) { * popupWindow = new LoginPopupWindow(this); * popupWindow.setLoginTypeListener(this); * } * popupWindow.showAtLocation(mCommonToolbar, GravityFlags.Center, 0, 0);*/ break; case Resource.Id.action_scan_local_book: ScanLocalBookActivity.startActivity(this); break; case Resource.Id.action_wifi_book: // TODO:WifiBookActivity.startActivity(this); ToastUtils.showSingleToast("等待开发中"); break; case Resource.Id.action_feedback: FeedbackActivity.startActivity(this); break; case Resource.Id.action_night_mode: if (SharedPreferencesUtil.getInstance().getBoolean(Constant.ISNIGHT, false)) { SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, false); AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightNo); } else { SharedPreferencesUtil.getInstance().putBoolean(Constant.ISNIGHT, true); AppCompatDelegate.DefaultNightMode = (AppCompatDelegate.ModeNightYes); } Recreate(); break; case Resource.Id.action_settings: SettingActivity.startActivity(this); break; default: break; } return(base.OnOptionsItemSelected(item)); }
public override void OnClick(View widget) { ToastUtils.ShowShortToast("事件触发了 landscapes and nedes"); }
public override bool OnTouchEvent(MotionEvent e) { switch (e.Action) { case MotionEventActions.Down: et = JavaSystem.CurrentTimeMillis(); dx = (int)e.GetX(); dy = (int)e.GetY(); mTouch.X = dx; mTouch.Y = dy; actiondownX = dx; actiondownY = dy; touch_down = 0; pagefactory.onDraw(mCurrentPageCanvas); if (actiondownX >= mScreenWidth / 3 && actiondownX <= mScreenWidth * 2 / 3 && actiondownY >= mScreenHeight / 3 && actiondownY <= mScreenHeight * 2 / 3) { center = true; } else { center = false; calcCornerXY(actiondownX, actiondownY); if (actiondownX < mScreenWidth / 2) // 从左翻 { BookStatus status = pagefactory.prePage(); if (status == BookStatus.NO_PRE_PAGE) { ToastUtils.showSingleToast("没有上一页啦"); return(false); } else if (status == BookStatus.LOAD_SUCCESS) { abortAnimation(); pagefactory.onDraw(mNextPageCanvas); } else { return(false); } } else if (actiondownX >= mScreenWidth / 2) // 从右翻 { BookStatus status = pagefactory.nextPage(); if (status == BookStatus.NO_NEXT_PAGE) { ToastUtils.showSingleToast("没有下一页啦"); return(false); } else if (status == BookStatus.LOAD_SUCCESS) { abortAnimation(); pagefactory.onDraw(mNextPageCanvas); } else { return(false); } } listener.onFlip(); setBitmaps(mCurPageBitmap, mNextPageBitmap); } break; case MotionEventActions.Move: if (center) { break; } int mx = (int)e.GetX(); int my = (int)e.GetY(); cancel = (actiondownX < mScreenWidth / 2 && mx < mTouch.X) || (actiondownX > mScreenWidth / 2 && mx > mTouch.X); mTouch.X = mx; mTouch.Y = my; touch_down = mTouch.X - actiondownX; this.PostInvalidate(); break; case MotionEventActions.Up: case MotionEventActions.Cancel: long t = JavaSystem.CurrentTimeMillis(); int ux = (int)e.GetX(); int uy = (int)e.GetY(); if (center) // ACTION_DOWN的位置在中间,则不响应滑动事件 { resetTouchPoint(); if (System.Math.Abs(ux - actiondownX) < 5 && System.Math.Abs(uy - actiondownY) < 5) { listener.onCenterClick(); return(false); } break; } if ((System.Math.Abs(ux - dx) < 10) && (System.Math.Abs(uy - dy) < 10)) { if ((t - et < 1000)) // 单击 { startAnimation(); } else // 长按 { pagefactory.cancelPage(); restoreAnimation(); } PostInvalidate(); return(true); } if (cancel) { pagefactory.cancelPage(); restoreAnimation(); PostInvalidate(); } else { startAnimation(); PostInvalidate(); } cancel = false; center = false; break; default: break; } return(true); }
private async void MessageUpdater() { try { if (TaskWork == "Working") { TaskWork = "Stop"; if (!Methods.CheckConnectivity()) { SwipeRefreshLayout.Refreshing = false; ToastUtils.ShowToast(GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short); } else { int countList = MAdapter.MessageList.Count; string afterId = MAdapter.MessageList.LastOrDefault()?.Id.ToString() ?? ""; var(apiStatus, respond) = await RequestsAsync.Messages.GetUserMessages(Userid.ToString(), "30", "", afterId); if (apiStatus == 200) { if (respond is GetUserMessagesObject result) { int responseList = result.data.Messages.Count; if (responseList > 0) { if (countList > 0) { foreach (var item in from item in result.data.Messages let check = MAdapter.MessageList.FirstOrDefault(a => a.Id == item.Id) where check == null select item) { MAdapter.Add(item); } } else { MAdapter.MessageList = new ObservableCollection <GetUserMessagesObject.Message>(result.data.Messages); } RunOnUiThread(() => { var lastCountItem = MAdapter.ItemCount; if (countList > 0) { MAdapter.NotifyItemRangeInserted(lastCountItem, MAdapter.MessageList.Count - 1); } else { MAdapter.NotifyDataSetChanged(); } //Insert to DataBase SqLiteDatabase dbDatabase = new SqLiteDatabase(); dbDatabase.InsertOrReplaceMessages(MAdapter.MessageList); dbDatabase.Dispose(); //Scroll Down >> ChatBoxRecylerView.ScrollToPosition(MAdapter.MessageList.Count - 1); var lastMessage = MAdapter.MessageList.LastOrDefault(); if (lastMessage != null) { var dataUser = LastChatActivity.MAdapter.UserList?.FirstOrDefault(a => a.UserId == lastMessage?.FromId); if (dataUser != null) { dataUser.LastMessage = lastMessage.Text; LastChatActivity.MAdapter.Move(dataUser); LastChatActivity.MAdapter.Update(dataUser); } if (AppSettings.RunSoundControl) { Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("Popup_GetMesseges.mp3"); } } }); } } } else { Methods.DisplayReportResult(this, respond); } } TaskWork = "Working"; } } catch (Exception e) { Console.WriteLine(e); } }
private async Task <string> LoadMoreMessagesApi() { try { if (!Methods.CheckConnectivity()) { SwipeRefreshLayout.Refreshing = false; ToastUtils.ShowToast(GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short); } else { var(apiStatus, respond) = await RequestsAsync.Messages.GetUserMessages(Userid.ToString(), "30", FirstMessageId.ToString()).ConfigureAwait(false); if (apiStatus == 200) { if (respond is GetUserMessagesObject result) { if (result.data.Messages.Count > 0) { var listApi = new ObservableCollection <GetUserMessagesObject.Message>(); foreach (var messages in result.data.Messages.OrderBy(a => a.Time)) { GetUserMessagesObject.Message message = new GetUserMessagesObject.Message { Id = messages.Id, FromId = messages.FromId, ToId = messages.ToId, Text = messages.Text, MediaFile = messages.MediaFile, MediaType = messages.MediaType, DeletedFs1 = messages.DeletedFs1, DeletedFs2 = messages.DeletedFs2, Seen = messages.Seen, Time = messages.Time, Extra = messages.Extra, TimeText = messages.TimeText, Position = messages.Position, }; MAdapter.Insert(message, FirstMessageId); listApi.Insert(0, message); SqLiteDatabase dbDatabase = new SqLiteDatabase(); // Insert data user in database dbDatabase.InsertOrReplaceMessages(listApi); dbDatabase.Dispose(); } return("1"); } return("0"); } } else { Methods.DisplayReportResult(this, respond); } } return("0"); } catch (Exception exception) { Console.WriteLine(exception); return("0"); } }
/// <summary> /// 后退 /// </summary> public override void OnBackPressed() { MoveTaskToBack(true); ToastUtils.ShowToast("后台正常运行"); }
public void showError() { ToastUtils.showSingleToast("同步异常"); dismissDialog(); }
/// <summary> /// toast /// </summary> /// <param name="message"></param> public void Toast(string message) { ToastUtils.ShowToast(message); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_item_touch_use); SetBackBtn(); SetTitle("ItemDrag And Swipe"); _recyclerView = FindViewById <RecyclerView>(Resource.Id.rv_list); _recyclerView.SetLayoutManager(new LinearLayoutManager(this)); _data = GenerateData(50); var paint = new Paint(); paint.AntiAlias = true; paint.TextSize = 20; paint.Color = Color.Black; _adapter = new ItemDragAdapter(_data); _adapter.ItemDragStart += (s, e) => { Log.Debug(Tag, "drag start"); var holder = e.ViewHolder as BaseViewHolder; // holder.SetTextColor(Resource.Id.tv, Color.White); }; _adapter.ItemDragMoving += (s, e) => { Log.Debug(Tag, $"move from: {e.Source.AdapterPosition} to: {e.Target.AdapterPosition}"); }; _adapter.ItemDragEnd += (s, e) => { Log.Debug(Tag, "drag end"); var holder = e.ViewHolder as BaseViewHolder; // holder.SetTextColor(Resource.Id.tv, Color.Black); }; _adapter.ItemSwipeStart += (s, e) => { Log.Debug(Tag, "view swiped start: " + e.Pos); var holder = e.ViewHolder as BaseViewHolder; // holder.SetTextColor(Resource.Id.tv, Color.White); }; _adapter.ClearView += (s, e) => { Log.Debug(Tag, "View reset: " + e.Pos); var holder = e.ViewHolder as BaseViewHolder; // holder.SetTextColor(Resource.Id.tv, Color.Black); }; _adapter.ItemSwiped += (s, e) => { Log.Debug(Tag, "View Swiped: " + e.Pos); }; _adapter.ItemSwipeMoving += (s, e) => { e.Canvas.DrawColor(new Color(ContextCompat.GetColor(this, Resource.Color.color_light_blue))); // e.Canvas.DrawText("Just some text", 0, 40, paint); }; _itemDragAndSwipeCallback = new ItemDragAndSwipeCallback(_adapter); _itemTouchHelper = new ItemTouchHelper(_itemDragAndSwipeCallback); _itemTouchHelper.AttachToRecyclerView(_recyclerView); //_itemDragAndSwipeCallback.SetDragMoveFlags(ItemTouchHelper.Left | ItemTouchHelper.Right | ItemTouchHelper.Up | ItemTouchHelper.Down); _itemDragAndSwipeCallback.SetSwipeMoveFlags(ItemTouchHelper.Start | ItemTouchHelper.End); _adapter.EnableSwipeItem(); _adapter.EnableDragItem(_itemTouchHelper); _recyclerView.SetAdapter(_adapter); _adapter.ItemClick += (s, e) => { ToastUtils.ShowShortToast("点击了" + e.Position); }; }