Beispiel #1
0
 public override void OnTick(long millisUntilFinished)
 {
     if (adapter != null)
     {
         if (adapter.CheckTypeStatus())
         {
             adapter.NotifyDataSetChanged();
         }
     }
 }
Beispiel #2
0
            private void InitUIComponents(View rootView)
            {
                mListView = rootView.FindViewById(Resource.Id.list) as ListView;
                TurnOffListViewDecoration(mListView);
                mListView.Adapter = mAdapter;

                mBtnChannel        = rootView.FindViewById(Resource.Id.btn_channel) as ImageButton;
                mBtnChannel.Click += (sender, e) => {
                    if (OnChannelListClicked != null)
                    {
                        OnChannelListClicked(this, new EventArgs());
                    }
                };
                mBtnSend               = rootView.FindViewById(Resource.Id.btn_send) as Button;
                mBtnUpload             = rootView.FindViewById(Resource.Id.btn_upload) as ImageButton;
                mProgressBtnUpload     = rootView.FindViewById(Resource.Id.progress_btn_upload) as ProgressBar;
                mEtxtMessage           = rootView.FindViewById(Resource.Id.etxt_message) as EditText;
                mEtxtMessage.KeyPress += (object sender, View.KeyEventArgs e) => {
                    if (e.KeyCode == Keycode.Enter)
                    {
                        if (e.Event.Action == KeyEventActions.Down)
                        {
                            Send();

                            e.Handled = true;
                        }
                    }
                    else
                    {
                        e.Handled = false;
                    }
                };

                mBtnSend.Enabled = false;
                mBtnSend.Click  += (object sender, EventArgs e) => {
                    Send();
                };

                mEtxtMessage.AfterTextChanged += (object sender, AfterTextChangedEventArgs e) => {
                    mBtnSend.Enabled = e.Editable.Length() > 0 ? true : false;
                    if (e.Editable.Length() > 0)
                    {
                        SendBirdSDK.TypeStart();
                    }
                    else
                    {
                        SendBirdSDK.TypeEnd();
                    }
                };
                mListView.Touch += (object sender, View.TouchEventArgs e) => {
                    Helper.HideKeyboard(this.Activity);
                    e.Handled = false;
                };
                mListView.ScrollStateChanged += (s, args) => {
                    if (args.ScrollState == ScrollState.Idle)
                    {
                        if (args.View.FirstVisiblePosition == 0 && args.View.ChildCount > 0 && args.View.GetChildAt(0).Top == 0)
                        {
                            var mMessageListQuery = SendBirdSDK.QueryMessageList(SendBirdSDK.GetChannelUrl());
                            mMessageListQuery.OnResult += (sender, e) => {
                                mSyncContext.Post(delegate {
                                    foreach (var messageModel in e.Messages)
                                    {
                                        mAdapter.AddMessageModel(messageModel);
                                    }

                                    mAdapter.NotifyDataSetChanged();
                                    mListView.SetSelection(e.Messages.Count);
                                }, null);
                            };
                            mMessageListQuery.Prev(mAdapter.GetMinMessageTimestamp(), 30);                              // Excute Query
                        }
                        else if (args.View.FirstVisiblePosition == args.View.ChildCount - 1 && args.View.ChildCount > 0)
                        {
                            var mMessageListQuery = SendBirdSDK.QueryMessageList(SendBirdSDK.GetChannelUrl());
                            mMessageListQuery.OnResult += (sender, e) => {
                                mSyncContext.Post(delegate {
                                    foreach (var messageModel in e.Messages)
                                    {
                                        mAdapter.AddMessageModel(messageModel);
                                    }

                                    mAdapter.NotifyDataSetChanged();
                                }, null);
                            };
                            mMessageListQuery.Next(mAdapter.GetMaxMessageTimestamp(), 30);                              // Excute Query
                        }
                    }
                };
            }