Exemple #1
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Id               = Intent.GetIntExtra("id", 0);
            handler          = new Handler();
            answersPresenter = new QuestionAnswersPresenter(this);
            StatusBarCompat.SetOrdinaryToolBar(this);
            dialog = new ProgressDialog(this);
            dialog.SetCancelable(false);

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetNavigationIcon(Resource.Drawable.back_24dp);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            toolbar.SetNavigationOnClickListener(this);
            toolbar.SetOnMenuItemClickListener(this);

            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeResources(Resource.Color.primary);
            swipeRefreshLayout.SetOnRefreshListener(this);

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView);
            recyclerView.SetLayoutManager(new LinearLayoutManager(this));
            adapter = new QuestionAnswersAdapter();
            adapter.SetOnLoadMoreListener(this);
            adapter.User = await SQLiteUtils.Instance().QueryUser();

            adapter.OnDeleteClickListener = this;

            notDataView        = this.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false);
            notDataView.Click += delegate(object sender, EventArgs e)
            {
                OnRefresh();
            };
            errorView        = this.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false);
            errorView.Click += delegate(object sender, EventArgs e)
            {
                OnRefresh();
            };
            recyclerView.SetAdapter(adapter);
            recyclerView.Post(() =>
            {
                swipeRefreshLayout.Refreshing = true;
                OnRefresh();
            });
        }