Ejemplo n.º 1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            MyLog.Log(this, "Fragments view creating...");

            swipeRefreshLayout          = inflater.Inflate(Resource.Layout.main_offline_list, container, false) as SwipeRefreshLayout;
            swipeRefreshLayout.Refresh += SwipeRefreshLayout_Refresh;
            swipeRefreshLayout.SetColorSchemeColors(new int[] {
                Android.Graphics.Color.ParseColor("#673AB7").ToArgb()
            });

            recyclerView = swipeRefreshLayout.FindViewById <RecyclerView>(Resource.Id.offlineRecyclerView);
            recyclerView.SetLayoutManager(recyLayoutManager = new LinearLayoutManager(this.Context, (int)Orientation.Vertical, false));
            recyclerView.SetAdapter(adapter = new RecyAdapter());
            adapter.OnItemClick            += Adapter_OnItemClick;

            MyLog.Log(this, "requesting db for GetAllOfflineArticalList...");
            MyGlobal.database.GetAllOfflineArticalList(MyGlobal.UidGenerator(), this);
            MyLog.Log(this, "requesting db for GetAllOfflineArticalList...Done");

            MyLog.Log(this, "Fragments view creating...Done");
            return(swipeRefreshLayout);
        }
Ejemplo n.º 2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            MyLog.Log(this, $"OnCreateView...");

            swipeRefLayout            = inflater.Inflate(Resource.Layout.main_offline_list, container, false) as SwipeRefreshLayout;
            swipeRefLayout.Refreshing = true;
            swipeRefLayout.Refresh   += SwipeRefLayout_Refresh;
            swipeRefLayout.SetColorSchemeColors(new int[] {
                Android.Graphics.Color.ParseColor(website.Color).ToArgb()
            });

            recyView = swipeRefLayout.FindViewById <RecyclerView>(Resource.Id.offlineRecyclerView);
            recyView.SetLayoutManager(recyLayoutManager = new LinearLayoutManager(this.Context, (int)Orientation.Vertical, false));
            recyView.SetAdapter(adapter = new RecyclerViewAdpater(website));
            adapter.OnItemClick        += RecyclerView_OnItemClick;
            adapter.LoadNextPage       += (sender, e) => LoadNextPage();
            adapter.OnCategorySelected += OnCategorySelected;

            if (website.Categories == null)
            {
                MyLog.Log(this, $"Requesting index page data from analysisModule url {website.IndexPageLink}...");
                browsingContext = OverviewType.IndexPage;
                analysisModule.ReadIndexPage(refreshingRequestUid = UidGenerator(), websiteKey, website.IndexPageLink, this);
                MyLog.Log(this, $"Requesting index page data from analysisModule url {website.IndexPageLink}...Done");
            }
            else
            {
                MyLog.Log(this, $"Requesting index page data from analysisModule category {website?.Categories[0]?.Link}...");
                browsingContext = OverviewType.Category;
                refreshingLink  = website.Categories[0].Link;
                analysisModule.ReadCategory(refreshingRequestUid = UidGenerator(), websiteKey, website.Categories[0], this);
                MyLog.Log(this, $"Requesting index page data from analysisModule category {website?.Categories[0]?.Link}...Done");
            }

            MyLog.Log(this, $"OnCreateView...Done");
            return(swipeRefLayout);
        }
Ejemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Swipe refresh layout.
            swipeRefreshLayout = (SwipeRefreshLayout)inflater.Inflate(Resource.Layout.NewsFragment, container, false);

            // Recycler view & setup.
            recyclerView = swipeRefreshLayout.FindViewById <RecyclerView>(Resource.Id.newsfragment_recyclerview);
            LinearLayoutManager linearLayoutManager = new LinearLayoutManager(Activity);

            recyclerView.SetLayoutManager(linearLayoutManager);

            // Prepare adapter (an empty one).
            currentAdapter                  = new NewsRecyclerAdapter(Activity);
            currentAdapter.ItemClick       += (o, e) => OnNewsClick(e.ItemPosition);
            currentAdapter.Error           += OnError;
            currentAdapter.ConnectionError += OnConnectionError;
            currentAdapter.NoData          += OnNoData;
            currentAdapter.Loading         += OnLoading;
            currentAdapter.Loaded          += OnLoaded;


            recyclerView.SetAdapter(currentAdapter);

            // Apply scroll listener to recyclerview.
            endlessScrollListener = new RecyclerViewEndlessScrollListener(linearLayoutManager, currentAdapter);
            endlessScrollListener.ThresholdReached += async(o, e) => await currentAdapter.LoadMore();

            endlessScrollListener.Scroll += HandleScroll;

            recyclerView.AddOnScrollListener(endlessScrollListener);

            // swipe refresh layout events setup
            swipeRefreshLayout.Refresh += async(o, e) => await currentAdapter.RefreshNews();

            return(swipeRefreshLayout);
        }