コード例 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.QuestionsActivity);

            list = FindViewById <RecyclerView>(Resource.Id.QuestionsList);
            var lm = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false);

            list.SetLayoutManager(lm);

            adapter             = new QuestionsAdapter();
            adapter.OnSelected += Adapter_OnLeft;
            list.SetAdapter(adapter);
            list.Visibility = ViewStates.Gone;

            title            = FindViewById <TextView>(Resource.Id.Title);
            title.Visibility = ViewStates.Gone;

            //var toolbar = FindViewById<Toolbar>(Resource.Id.Toolbar);
            //toolbar.Title = "I would like to...";

            if (!StateHolder.Instance.User.IsNew)
            {
                OpenActivity();
            }
            else
            {
                GetData();
            }
        }
コード例 #2
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            this.HasOptionsMenu = true;

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

            recyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView);
            var manager = new LinearLayoutManager(this.Activity);

            recyclerView.SetLayoutManager(manager);

            adapter = new QuestionsAdapter();
            adapter.SetOnLoadMoreListener(this);
            recyclerView.SetAdapter(adapter);

            nologinView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.nologin_view, (ViewGroup)recyclerView.Parent, false);
            nologinView.Click += delegate(object sender, EventArgs e)
            {
                StartActivityForResult(new Intent(this.Activity, typeof(LoginActivity)), (int)RequestCode.LoginCode);
            };
            notDataView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.empty_view, (ViewGroup)recyclerView.Parent, false);
            notDataView.Click += delegate(object sender, EventArgs e)
            {
                OnRefresh();
            };
            errorView        = this.Activity.LayoutInflater.Inflate(Resource.Layout.error_view, (ViewGroup)recyclerView.Parent, false);
            errorView.Click += delegate(object sender, EventArgs e)
            {
                OnRefresh();
            };
            recyclerView.Post(async() =>
            {
                if (position < 4)
                {
                    await questionPresenter.GetClientQuestions(position);
                }
                else if (!LoginUtils.Instance(this.Activity).GetLoginStatus())
                {
                    recyclerView.Post(() =>
                    {
                        adapter.SetEmptyView(nologinView);
                    });
                }
            });
        }