예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            DataUtils.Init();
            _timerHolder = new TimerHolder(UpdateInterval, CheckNewData);

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            FindViewById <TextView>(Resource.Id.btnSettings)
            .Click += (sender, args) => StartSettingsActivity();

            _pingIndicator = FindViewById <ImageView>(Resource.Id.ivPing);
            _tvTitle       = FindViewById <TextView>(Resource.Id.tvTitle);

            _recyclerView  = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            _layoutManager = new LinearLayoutManager(this);
            _recyclerView.SetLayoutManager(_layoutManager);

            _adapter = new MachinesAdapter(_machines);
            _recyclerView.SetAdapter(_adapter);
            _adapter.ItemClicked += StartSelectedMachineActivity;

            _scrollListener = new CustomScrollListener();
            _recyclerView.AddOnScrollListener(_scrollListener);

            InitDataUpdating();
        }
예제 #2
0
        private void StartSettingsActivity()
        {
            _recyclerView.SetAdapter(null);
            _adapter.ItemClicked -= StartSelectedMachineActivity;
            _adapter.Dispose();
            _adapter = null;

            var intent = new Intent(this, typeof(SettingsActivity));

            StartActivity(intent);
        }
예제 #3
0
        protected override void OnStart()
        {
            base.OnStart();

            if (DataManager.LoginImpossible)
            {
                StartUserActivity();
                return;
            }

            if (_recyclerView.GetAdapter() == null)
            {
                _machines.Clear();
                _adapter = new MachinesAdapter(_machines);
                _recyclerView.SetAdapter(_adapter);
                _adapter.ItemClicked += StartSelectedMachineActivity;

                DataManager.SheduleGetMachinesRequest(DataUpdateCallback);
                _lastUpdateTime = DateTime.Now;
            }

            _timerHolder.Start();
        }