private void InitUIComponents()
        {
            mTopBarContainer = FindViewById(Resource.Id.top_bar_container) as View;
            mTxtChannelUrl   = FindViewById(Resource.Id.txt_channel_url) as TextView;

            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) => {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("SENDBIRD");
                builder.SetMessage("SendBird In App version " + SendBird.CommonVar.VERSION);
                builder.SetPositiveButton("OK", (sender_child, e_child) => {
                });

                var dialog = builder.Create();
                dialog.Show();
            };
            ResizeMenubar();

            // 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);
        }
Exemplo n.º 2
0
        private void InitUIComponents()
        {
            mTopBarContainer = FindViewById(Resource.Id.top_bar_container) as View;
            mTxtChannelUrl   = FindViewById(Resource.Id.txt_channel_url) as TextView;

            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) => {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetTitle("SendBird");
                builder.SetMessage("SendBird In App version " + SendBird.CommonVar.VERSION);
                builder.SetPositiveButton("OK", (sender_child, e_child) => {
                });

                var dialog = builder.Create();
                dialog.Show();
            };
            var maxMemory = (int)(Java.Lang.Runtime.GetRuntime().MaxMemory() / 1024);
            // Use 1/8th of the available memory for this memory cache.
            int cacheSize = maxMemory / 8;

            mMemoryCache = new ImageUtils.MemoryLimitedLruCache(cacheSize);
        }
Exemplo n.º 3
0
        private void InitUIComponents()
        {
            mTopBarContainer = FindViewById(Resource.Id.top_bar_container) as View;
            mTxtChannelUrl   = FindViewById(Resource.Id.txt_channel_url) as TextView;

            mBtnClose        = FindViewById(Resource.Id.btn_close) as ImageButton;
            mBtnClose.Click += (sender, e) => {
                Finish();
            };

            mBtnOK        = FindViewById(Resource.Id.btn_ok) as Button;
            mBtnOK.Click += (sender, e) => {
                if (mSelectedMembers.Count > 0)
                {
                    string[] memberIds = new string[mSelectedMembers.Count];
                    for (var i = 0; i < memberIds.Length; i++)
                    {
                        Console.WriteLine(mSelectedMembers[i].GetId());
                        memberIds[i] = mSelectedMembers[i].GetId();
                    }
                    Intent data = new Intent();
                    data.PutExtra("userIds", memberIds);
                    SetResult(Android.App.Result.Ok, data);
                }
                else
                {
                    SetResult(Android.App.Result.Canceled);
                }
                Finish();
            };

            ResizeMenubar();

            var cacheSize = (int)(Java.Lang.Runtime.GetRuntime().MaxMemory() / 16);

            mMemoryCache = new ImageUtils.MemoryLimitedLruCache(cacheSize);
        }
Exemplo n.º 4
0
            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);
            }