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

            SetContentView(Resource.Layout.overview);

            //ActionBar.Hide();

            if (Intent.Extras != null && Intent.Extras.ContainsKey(PassWebsiteKey))
            {
                currentWebsite = Config.GetWebsite(currentWebsiteKey = Intent.Extras.GetString(PassWebsiteKey));
            }


            browsingContext = OverviewType.IndexPage;
            analysisModule.ReadIndexPage(UidGenerator(), currentWebsiteKey, refreshingLink = currentWebsite.IndexPageLink, this);   //make the request

            ChangeStatusBarColor(Window, currentWebsite.Color);

            toolbar      = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.overviewToolbar);
            appBarLayout = FindViewById <AppBarLayout>(Resource.Id.overviewAppbar);
            toolbar.SetBackgroundColor(Android.Graphics.Color.ParseColor(currentWebsite.Color));
            appBarLayout.SetBackgroundColor(Android.Graphics.Color.ParseColor(currentWebsite.Color));
            toolbar.Title = currentWebsite.Name;

            swipeRefLayout          = FindViewById <SwipeRefreshLayout>(Resource.Id.swiperefresh);
            swipeRefLayout.Refresh += SwipeRefLayout_Refresh;
            swipeRefLayout.SetColorSchemeColors(new int[] {
                Android.Graphics.Color.ParseColor(currentWebsite.Color).ToArgb()
            });

            drawerLayout = FindViewById <DrawerLayout>(Resource.Id.overviewDrawerLayout);
            navListview  = FindViewById <ListView>(Resource.Id.navigationDrawerListView);
            navData      = new string[currentWebsite.Categories.Length];
            int index = 0;

            foreach (var item in currentWebsite.Categories)
            {
                navData[index++] = item.Name;
            }
            navAdapter             = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, navData);
            navListview.Adapter    = navAdapter;
            navListview.ItemClick += NavListview_ItemClick;

            recyView = FindViewById <RecyclerView>(Resource.Id.overviewRecyclerView);
            recyView.SetLayoutManager(recyLayoutManager = new LinearLayoutManager(this, (int)Orientation.Vertical, false));
            recyView.SetAdapter(adapter = new RecyclerViewAdpater(currentWebsite));
            adapter.OnItemClick        += RecyclerView_OnItemClick;
            adapter.LoadNextPage       += (sender, e) => LoadNextPage();
        }
コード例 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            MyLog.Log(this, nameof(OnCreate) + "...");

            SetContentView(Resource.Layout.artical_layout_v2);
            ActionBar?.Hide();

            #region Grabbing data from bundles
            articalOverview = null;
            Bundle extras = Intent.Extras;
            MyLog.Log(this, "Loading bundle data" + "...");
            if (extras != null && extras.ContainsKey(PassArticalOverviewObj))
            {
                articalOverview = new ArticalOverview(extras.GetBundle(PassArticalOverviewObj));
            }
            else
            {
                Finish();
                return;
            }
            if (extras != null || extras.ContainsKey(PassWebsiteKey))
            {
                currentWebsiteKey = extras.GetString(PassWebsiteKey);
            }
            else
            {
                Finish();
                return;
            }
            if (extras != null || extras.ContainsKey(PassIsOffline))
            {
                isOffline = extras.GetBoolean(PassIsOffline);
            }
            else
            {
                Finish();
                return;
            }
            MyLog.Log(this, "Loading bundle data" + "...Done");
            #endregion

            #region Making request for artical
            if (!isOffline)
            {
                MyLog.Log(this, $"Request artical data online url {articalOverview.LinkOfActualArtical}" + "...");
                analysisModule.ReadArtical(UidGenerator(), currentWebsiteKey, articalOverview, this);  //make the request
                MyLog.Log(this, $"Request artical data online url {articalOverview.LinkOfActualArtical}" + "...Done");
            }

            else
            {
                MyLog.Log(this, $"Requesting artical data offline url{articalOverview.LinkOfActualArtical}" + "...");
                database.GetArtical(UidGenerator(), articalOverview, this);
                MyLog.Log(this, $"Requesting artical data offline url{articalOverview.LinkOfActualArtical}" + "...Done");
            }
            #endregion



            //=================Getting current website===============
            var currentWebsite = Config.GetWebsite(currentWebsiteKey);
            ChangeStatusBarColor(Window, currentWebsite.Color);
            //===============Variable Findings==================
            appBarLayout                = FindViewById <AppBarLayout>(Resource.Id.mainAppbar);
            toolBar                     = FindViewById <SupportToolBar>(Resource.Id.mainToolbar);
            loadingTextView             = FindViewById <TextView>(Resource.Id.articalLoadingTextView);
            fabOfflineButton            = FindViewById <FloatingActionButton>(Resource.Id.articalFab);
            articalContentWebview       = FindViewById <WebView>(Resource.Id.articalContentWebView);
            articalTitleTextview        = FindViewById <TextView>(Resource.Id.articalTitleTextView);
            articalDateTextview         = FindViewById <TextView>(Resource.Id.articalDateTextView);
            articalWebsiteComicTextview = FindViewById <TextView>(Resource.Id.articalWebsiteComicTextView);
            //===============Setup WebView==================
            MyLog.Log(this, "Loading web view" + "...");
            articalContentWebview.Settings.DefaultFontSize                  = 20;
            articalContentWebview.Settings.BuiltInZoomControls              = true;
            articalContentWebview.Settings.JavaScriptEnabled                = true;
            articalContentWebview.Settings.AllowFileAccessFromFileURLs      = true;
            articalContentWebview.Settings.AllowUniversalAccessFromFileURLs = true;
            articalContentWebview.Visibility = ViewStates.Gone;
            MyLog.Log(this, "Loading web view" + "...Done");
            //===============Setup WebView==================

            appBarLayout.SetBackgroundColor(Android.Graphics.Color.ParseColor(currentWebsite.Color));
            //Loading data from artical overview
            toolBar.Title                    = articalOverview.Title ?? "Artical";
            articalTitleTextview.Text        = articalOverview.Title ?? "";
            articalDateTextview.Text         = GetHumanReadableDate(articalOverview.Date) ?? "";
            articalWebsiteComicTextview.Text = currentWebsite.ComicText ?? "";
            //Setting the text for loading
            loadingTextView.Text    = "Loading...";
            loadingTextView.Gravity = GravityFlags.CenterHorizontal;

            fabOfflineButton.Visibility = !isOffline ? ViewStates.Visible : ViewStates.Gone;//determining the visibility of fab as online or offline

            //TODO: Add a support to open the artical in web browser
            fabOfflineButton.Click += FloatingButton_Click;
            MyLog.Log(this, nameof(OnCreate) + "...Done");
        }