Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            _noMessageTextView = FindViewById <TextView>(Resource.Id.emptyText);
            _recyclerView      = FindViewById <RecyclerView>(Resource.Id.recyclerView);

            _recyclerView.ChildViewAdded   += (sender, args) => { _noMessageTextView.Visibility = ViewStates.Gone; };
            _recyclerView.ChildViewRemoved += (sender, args) => { if (_recyclerView.ChildCount == 0)
                                                                  {
                                                                      _noMessageTextView.Visibility = ViewStates.Visible;
                                                                  }
            };

            _db = MessageDB.Create();

            _messageViewerAdapter = new MessageViewerAdapter(_db.GetMessageDataSource());

            _recyclerView.SetAdapter(_messageViewerAdapter);
            _recyclerView.SetLayoutManager(new LinearLayoutManager(this));

            _handler = new Handler(x => {
                OnDataSourceUpdated(x);
            });

            _dataSourceUpdateListener = new DataSourceUpdateListener(_handler);
        }