private void InitUIComponents() { mTopBarContainer = FindViewById(Resource.Id.top_bar_container); mTxtChannelUrl = FindViewById(Resource.Id.txt_channel_url) as TextView; mSettingsContainer = FindViewById(Resource.Id.settings_container); mSettingsContainer.Visibility = ViewStates.Gone; mBtnLeave = FindViewById(Resource.Id.btn_leave) as Button; mBtnLeave.Click += (sender, e) => { mSettingsContainer.Visibility = ViewStates.Gone; SendBirdSDK.Leave(SendBirdSDK.GetChannelUrl()); Finish(); }; mBtnClose = FindViewById(Resource.Id.btn_close) as ImageButton; mBtnClose.Click += (object sender, EventArgs e) => { Finish(); }; mBtnSettings = FindViewById(Resource.Id.btn_settings) as ImageButton; mBtnSettings.Click += (sender, e) => { if (mSettingsContainer.Visibility != ViewStates.Visible) { mSettingsContainer.Visibility = ViewStates.Visible; } else { mSettingsContainer.Visibility = ViewStates.Gone; } }; ResizeMenubar(); }
public override View GetView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if (convertView == null) { viewHolder = new ViewHolder(); convertView = mInflater.Inflate(Resource.Layout.SendBirdViewChannel, parent, false); viewHolder.SetView("selected_container", convertView.FindViewById(Resource.Id.selected_container)); viewHolder.GetView("selected_container").Visibility = ViewStates.Gone; viewHolder.SetView("img_thumbnail", convertView.FindViewById(Resource.Id.img_thumbnail)); viewHolder.SetView("txt_topic", convertView.FindViewById(Resource.Id.txt_topic)); viewHolder.SetView("txt_desc", convertView.FindViewById(Resource.Id.txt_desc)); convertView.Tag = viewHolder; } Channel item = this[position]; viewHolder = convertView.Tag as ViewHolder; DisplayUrlImage(viewHolder.GetView <ImageView> ("img_thumbnail"), item.coverUrl); viewHolder.GetView <TextView> ("txt_topic").Text = "#" + item.GetUrlWithoutAppPrefix(); viewHolder.GetView <TextView> ("txt_desc").Text = ("" + item.memberCount + ((item.memberCount <= 1) ? " Member" : " Members")); if (item.url.Equals(SendBirdSDK.GetChannelUrl())) { viewHolder.GetView("selected_container").Visibility = ViewStates.Visible; } else { viewHolder.GetView("selected_container").Visibility = ViewStates.Gone; } return(convertView); }
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 } } }; }
private void InitUIComponents(View rootView) { mListView = rootView.FindViewById(Resource.Id.list_view) 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; mBtnUpload.Click += delegate { Intent intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(intent, "Select Picture"), REQUEST_PICK_IMAGE); }; 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 = true; }; 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 for RunOnUIThread 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 } } }; // Register Cache // Get max available VM memory, exceeding this amount will throw an OutOfMemory exception. // Stored in kilobytes as LruCache takes an int in its constructor. var cacheSize = (int)(Java.Lang.Runtime.GetRuntime().MaxMemory() / 16); mMemoryCache = new ImageUtils.MemoryLimitedLruCache(cacheSize); }