Exemple #1
0
        private void LoadArticlesFromStorehouses()
        {
            string primaryDatabase   = LibraryStorehouse.English;
            string secondaryDatabase = LibraryStorehouse.Chinese;

            // Major important!
            if (!App.STATE.Swapped)
            {
                if (App.STATE.PinyinToggle)
                {
                    secondaryDatabase = LibraryStorehouse.Pinyin;
                }
            }
            else
            {
                primaryDatabase   = LibraryStorehouse.Chinese;
                secondaryDatabase = LibraryStorehouse.English;
                if (App.STATE.PinyinToggle)
                {
                    primaryDatabase = LibraryStorehouse.Pinyin;
                }
            }

            //////////////////////////////////////////////////////////////////////////
            // BIBLE
            //////////////////////////////////////////////////////////////////////////
            if (library == Library.Bible)
            {
                Console.WriteLine("Getting primary . . .");
                primaryArticles = JwStore.QueryArticlesByBibleBook(SelectedArticle, primaryDatabase);
                foreach (var a in primaryArticles)
                {
                    primaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>")));
                }

                Console.WriteLine("Getting secondary . . .");
                secondaryArticles = JwStore.QueryMatchByMEPS(PublicationType.Bible, primaryArticles, secondaryDatabase);
                foreach (var a in secondaryArticles)
                {
                    secondaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>")));
                }

                Console.WriteLine("Getting COMPLETE!");
            }
            //////////////////////////////////////////////////////////////////////////
            // DAILY TEXT
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.DailyText)
            {
                primaryArticles = JwStore.QueryArticlesByPublication(PublicationType.DailyText, primaryDatabase);
                foreach (var a in primaryArticles)
                {
                    primaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>")));
                }

                secondaryArticles = JwStore.QueryMatchByMEPS(PublicationType.DailyText, primaryArticles, secondaryDatabase);
                foreach (var a in secondaryArticles)
                {
                    secondaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>")));
                }
            }
            //////////////////////////////////////////////////////////////////////////
            // INSIGHT VOLUMES
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.Insight)
            {
                string group = "it-" + App.STATE.CurrentArticleGroup.ToString();

                primaryArticles = JwStore.QueryInsightsByGroup(group, primaryDatabase);
                foreach (var a in primaryArticles)
                {
                    primaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>") + "<br/><i>" + a.ArticleLocation + "</i>"));
                }

                secondaryArticles = JwStore.QueryMatchByChapters(PublicationType.Insight, primaryArticles, secondaryDatabase);
                foreach (var a in secondaryArticles)
                {
                    secondaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>") + "<br/><i>" + a.ArticleLocation + "</i>"));
                }
            }
            //////////////////////////////////////////////////////////////////////////
            // BOOKS & PUBLICATIONS
            //////////////////////////////////////////////////////////////////////////
            else if (library == Library.Publications)
            {
                string code = App.FUNCTIONS.GetPublicationCode(SelectedArticle.Book.ToString());

                primaryArticles = JwStore.QueryArticlesByPublication(code, primaryDatabase);
                foreach (var a in primaryArticles)
                {
                    primaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>") + "<br/><i>" + a.ArticleLocation + "</i>"));
                }

                secondaryArticles = JwStore.QueryMatchByChapters(code, primaryArticles, secondaryDatabase);
                foreach (var a in secondaryArticles)
                {
                    secondaryChapters.Add(Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>") + "<br/><i>" + a.ArticleLocation + "</i>"));
                }
            }
        }
        private void ShowChapterPrompt(string storehouse, WOLPublication pub, NavStruct article)
        {
            LayoutInflater       inflater = (LayoutInflater)Activity.GetSystemService(Context.LayoutInflaterService);
            View                 view     = inflater.Inflate(Resource.Layout.DialogChapterSelect, null);
            HeaderFooterGridView gridview = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterSelectGridView);

            gridview.SetSelector(Android.Resource.Color.Transparent);

            List <WOLArticle> articles;
            List <ISpanned>   titles;

            if (LibraryMode == Library.Bible)
            {
                gridview.NumColumns  = -1;
                gridview.StretchMode = StretchMode.NoStretch;

                string bookNumber = article.Book.ToString() + ".";

                articles = JwStore.QueryArticleChapterTitles(PublicationType.Bible, storehouse)
                           .Where(a => a.ArticleNumber.StartsWith(bookNumber)).ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.ToString().Split(new[] { ' ' }).Last())).ToList();
                if (titles.Count == 1)
                {
                    LoadArticle(article);

                    return;
                }
            }
            else if (LibraryMode == Library.Insight)
            {
                gridview.NumColumns  = 2;
                gridview.StretchMode = StretchMode.StretchColumnWidth;

                articles = JwStore.QueryArticleChapterTitles(PublicationType.Insight, storehouse)
                           .Where(i => i.ArticleGroup.Equals(pub.Group))
                           .ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList();
            }
            else
            {
                gridview.NumColumns  = 1;
                gridview.StretchMode = StretchMode.StretchColumnWidth;

                articles = JwStore.QueryArticleChapterTitles(pub.Code, storehouse)
                           .ToList();

                titles = articles.Select(a => Html.FromHtml(a.ArticleTitle.Replace("\n", "<br/>").Split('<')[0] + "<br/><i>" + a.ArticleLocation + "</i>")).ToList();
                if (titles.Count == 1)
                {
                    LoadArticle(article);

                    return;
                }
            }

            MaterialDialog dialog = null;

            gridview.Adapter    = new ArticleButtonAdapter(Activity, titles.ToArray());
            gridview.ItemClick += (s, args) =>
            {
                dialog.Dismiss();

                article = NavStruct.Parse(articles[args.Position].ArticleNumber);
                LoadArticle(article);
            };

            MaterialDialog.Builder popup = new MaterialDialog.Builder(Activity);
            popup.SetCustomView(view, false);
            popup.SetTitle(pub.Name.Replace("\n", "<br/>").Split('<')[0]);
            popup.SetNegativeText("X");

            dialog = popup.Show();
        }
Exemple #3
0
        public void InitializeLayoutParadigm(View view)
        {
            // Set views
            primaryWebview   = view.FindViewById <ObservableWebView>(Resource.Id.primaryWebView);
            secondaryWebview = view.FindViewById <ObservableWebView>(Resource.Id.secondaryWebView);
            flipper          = view.FindViewById <ViewFlipper>(Resource.Id.view_flipper);
            gridViewTitle    = view.FindViewById <TextView>(Resource.Id.chapterTitle);
            gridView         = view.FindViewById <HeaderFooterGridView>(Resource.Id.chapterGridView);

            LayoutInflater layoutInflater = LayoutInflater.From(Activity);
            View           footerView     = layoutInflater.Inflate(Resource.Layout.FooterWebView, null);

            gridViewFooterWebview = footerView.FindViewById <ObservableWebView>(Resource.Id.footerWebView);

            // ViewFlipper animations
            flipper.SetInAnimation(Activity, Resource.Animation.push_down_in_no_alpha);
            flipper.SetOutAnimation(Activity, Resource.Animation.push_down_out_no_alpha);

            // Style views
            Typeface face = Typeface.CreateFromAsset(Activity.Assets, "fonts/Roboto-Regular.ttf");

            gridViewTitle.SetTypeface(face, TypefaceStyle.Normal);

            // WebView setup
            InitializeWebView(primaryWebview);
            InitializeWebView(secondaryWebview);
            InitializeWebView(gridViewFooterWebview);

            primaryWebview.Tag   = "primary";
            secondaryWebview.Tag = "secondary";

            ((LinearLayout)primaryWebview.Parent).LayoutParameters = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.MatchParent,
                App.STATE.WebviewWeights[0]);
            ((LinearLayout)secondaryWebview.Parent).LayoutParameters = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MatchParent,
                LinearLayout.LayoutParams.MatchParent,
                App.STATE.WebviewWeights[1]);

            if (App.STATE.WebviewWeights[0] == 0)
            {
                primaryWebview.IsDeflated = true;
            }
            if (App.STATE.WebviewWeights[1] == 0)
            {
                secondaryWebview.IsDeflated = true;
            }

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
            {
                gridView.ChoiceMode = ChoiceMode.Single;
            }

            gridView.ItemClick += SelectChapter;

            if (library == Library.Bible)
            {
                gridView.DoSetHeight = false;

                gridViewTitle.Click += text_Click;
                gridViewTitle.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_outline, 0, 0, 0);

                // Set Bible book outline
                NavStruct outline = new NavStruct()
                {
                    Book    = 0,
                    Chapter = SelectedArticle.Book,
                    Verse   = 0
                };
                OutlineContents = JwStore.QueryArticle("outline", outline, LibraryStorehouse.English).ArticleContent;
                gridView.AddFooterView(footerView);
                gridViewFooterWebview.LoadDataWithBaseURL("file:///android_asset/", OutlineContents, "text/html", "utf-8", null);
            }
        }