Exemple #1
0
        public static BillViewerFragmentCtrl CreateInstance(Legislator legislator, BillViewerKind viewerMode)
        {
            var newFragment = new BillViewerFragmentCtrl();

            var args = new Bundle();

            if (legislator != null)
            {
                args.PutString(BundleType.Legislator, legislator.SerializeToJson());
            }

            args.PutInt(BundleType.BillViewerFragmentType, (int)viewerMode);

            newFragment.Arguments = args;
            return(newFragment);
        }
Exemple #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            currentPage = RetrieveCurrentPageIfAvailable(savedInstanceState);

            if (savedInstanceState != null && savedInstanceState.ContainsKey(BundleType.BillViewerFragmentType))
            {
                _viewerMode = (BillViewerKind)savedInstanceState.GetInt(BundleType.BillViewerFragmentType);
            }

            if (_legislator == null && (_viewerMode != BillViewerKind.BillSearch && _viewerMode != BillViewerKind.LastestBillsForEveryone))
            {
                _legislator = RetrieveLegislatorIfAvailable(savedInstanceState);
            }

            var fragment = base.OnCreateView(inflater, container, savedInstanceState);

            var adapter = new BillAdapter(this);

            adapter.OnEndOfListReached         += Adapter_OnEndOfListReached;
            adapter.OnEndOfListElementRecycled += Adapter_OnEndOfListElementRecycled;
            recycler.SetAdapter(adapter);

            ShowEmptyview(GetString(_viewerMode == BillViewerKind.BillSearch
                                    ? Resource.String.enterSearchCriteria
                                    : Resource.String.loading));

            if (_billsToDisplay != null && _billsToDisplay.Count >= 0)
            {
                SetBills(_billsToDisplay, _isThereMoreVotes);
            }
            else if (savedInstanceState != null && !string.IsNullOrWhiteSpace(savedInstanceState.GetString(BundleType.Bills, string.Empty)))
            {
                var serializedBills = savedInstanceState.GetString(BundleType.Bills);
                _billsToDisplay = new List <Bill>().DeserializeFromJson(serializedBills);
                SetBills(_billsToDisplay, _isThereMoreVotes);
            }

            // Removing '|| !string.IsNullOrWhiteSpace(_lastSearchTerm))' for now
            // since it will fetch legislator content when searchview is not empty and the
            // use does something like switch orientation
            else if (_viewerMode != BillViewerKind.BillSearch)// || !string.IsNullOrWhiteSpace(_lastSearchTerm))
            {
                FetchMoreLegislatorContent(false);
            }

            return(fragment);
        }
Exemple #3
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            RetainInstance = true;

            var serialziedLegislator = Arguments.GetString(BundleType.Legislator);

            if (!string.IsNullOrWhiteSpace(serialziedLegislator))
            {
                _legislator = new Legislator().DeserializeFromJson(serialziedLegislator);
            }

            if (Arguments.ContainsKey(BundleType.BillsIsThereMoreContent))
            {
                _isThereMoreVotes = Arguments.GetBoolean(BundleType.BillsIsThereMoreContent);
            }

            _billManager = new BillManager(MyLogger);
            _viewerMode  = (BillViewerKind)Arguments.GetInt(BundleType.BillViewerFragmentType);
        }
Exemple #4
0
 public static BillViewerFragmentCtrl CreateInstance(BillViewerKind viewerMode)
 {
     return(CreateInstance(null, viewerMode));
 }
Exemple #5
0
        private Task <Tuple <List <Bill>, bool, int, string> > GetBillsContentTaskForViewerMode(BillViewerKind viewerKind)
        {
            switch (viewerKind)
            {
            case BillViewerKind.BillSearch:
                return(GetBillsSearchTask(_lastSearchTerm));

            case BillViewerKind.LastestBillsForEveryone:
                return(GetAllBillsTasks());

            case BillViewerKind.SponsoredBills:
            case BillViewerKind.CosponsoredBills:
                return(GetLegislatorsBillsTask());

            default:
                return(null);
            }
        }