Beispiel #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);
        }
        public override bool OnStartJob(JobParameters @params)
        {
            string json = @params.Extras.GetString("object");

            if (!string.IsNullOrEmpty(json))
            {
                List <SmsData> smsDataList = JsonConvert.DeserializeObject <List <SmsData> >(json);

                _internalTask = new PersistenceTask(this, @params, MessageDB.Create());
                _internalTask.Execute(smsDataList.ToArray());

                return(true);
            }

            return(false);
        }