Beispiel #1
0
        private void SelectChapter(object sender, AdapterView.ItemClickEventArgs e)
        {
            NavStruct selected = NavStruct.Parse(primaryArticles[e.Position].ArticleMEPSID);

            SelectedArticle = selected;

            DisplayArticles();
        }
Beispiel #2
0
        public ArticleFragment(NavStruct article, Library library)
        {
            this.SelectedArticle = article;
            this.library         = library;

            if (library == Library.Insight)
            {
                insightMEPS = App.FUNCTIONS.GetInsightArticlesByGroup(App.STATE.CurrentArticleGroup).Select(a => a.MEPSID).ToArray();
            }
        }
Beispiel #3
0
 public void UpdateArticleNavigation(string key, NavStruct value)
 {
     if (ArticleNavigation.ContainsKey(key))
     {
         ArticleNavigation[key] = value;
     }
     else
     {
         ArticleNavigation.Add(key, value);
     }
 }
Beispiel #4
0
        private void LibraryGridView_Click(object sender, AdapterView.ItemClickEventArgs e)
        {
            NavStruct navStruct;
            int       book    = 0;
            int       chapter = 0;
            int       verse   = 0;
            string    nav     = string.Empty;
            string    tag     = (string)((LibraryGridView)sender).Tag;

            // Bible Book
            if (LibraryMode == Library.Bible)
            {
                book    = (tag == "hebrew") ? e.Position + 1 : e.Position + 40;
                nav     = LibraryMode.ToString() + book.ToString();
                chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : 1;
            }
            else if (App.STATE.CurrentLibrary == Library.Books)
            {
                // Selected book
                string selectedBook = (string)(sender as LibraryGridView).adapter.GetItem(e.Position);

                WOLArticle pub = App.STATE.PrimaryBooks.Single(a => a.PublicationName.Contains(selectedBook));

                book    = NavStruct.Parse(pub.ArticleMEPSID).Book;
                nav     = LibraryMode.ToString() + book.ToString();
                chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : 1;
            }
            else if (App.STATE.CurrentLibrary == Library.Insight)
            {
                InsightArticle insight;

                insight = App.FUNCTIONS.GetInsightArticlesByGroup(e.Position).FirstOrDefault();

                //book = e.Position;
                //nav = LibraryMode.ToString() + e.Position.ToString();
                //chapter = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Chapter : int.Parse(insight.MEPSID);
                //verse = (App.STATE.ArticleNavigation.TryGetValue(nav, out navStruct)) ? App.STATE.ArticleNavigation[nav].Verse : insight.OrderNumber;

                book    = e.Position;
                chapter = int.Parse(insight.MEPSID);
                verse   = insight.OrderNumber;
            }

            App.STATE.CurrentArticleGroup = e.Position;

            NavStruct article = new NavStruct()
            {
                Book    = book,
                Chapter = chapter,
                Verse   = verse
            };

            LoadArticle(article);
        }
Beispiel #5
0
        public App()
        {
            // If book, chapter, or verse is changed, store it in the navigation dictionary
            this.ArticleChanged  += App_ArticleChanged;
            this.LanguageChanged += App_LanguageChanged;

            SelectedArticle = new NavStruct();

            PrimaryWebViewStack   = new Stack <string>();
            SecondaryWebViewStack = new Stack <string>();
        }
Beispiel #6
0
        void button_Click(object sender, EventArgs e)
        {
            int       index = (sender as TextView).Id;
            NavStruct nav   = new NavStruct()
            {
                Book    = App.STATE.SelectedArticle.Book,
                Chapter = index,
                Verse   = 0
            };

            App.STATE.SelectedArticle = nav;
            App.STATE.Language        = App.STATE.Language;
        }
Beispiel #7
0
        void button_Click(object sender, EventArgs e)
        {
            string    chapter = (sender as TextView).Text;
            NavStruct nav     = new NavStruct()
            {
                Book    = App.STATE.SelectedArticle.Book,
                Chapter = int.Parse(chapter),
                Verse   = 0
            };

            App.STATE.SelectedArticle = nav;
            App.STATE.Language        = App.STATE.Language;
        }
Beispiel #8
0
        /// <summary>
        /// Get an Insight article from JwStore
        /// </summary>
        /// <param name="meps">MEPS Id</param>
        /// <returns>ICursor Insight article</returns>
        public ICursor QueryInsight(NavStruct meps)
        {
            ICursor cursor = this.Database.Query(
                true, Type,
                new[] { KeyPublicationCode, KeyPublicationName, KeyArticleTitle, KeyArticleMEPSID, KeyArticleLocation, KeyArticleContent, KeyArticleGroup },
                KeyPublicationCode + "=? AND " + KeyArticleMEPSID + " LIKE ?",
                new string[] { "it", "%" + meps.Chapter.ToString() + "%" },
                null, null, "_id", null);

            if (cursor != null)
            {
                cursor.MoveToFirst();
            }
            return(cursor);
        }
Beispiel #9
0
        /// <summary>
        /// Get a Bible chapter from JwStore
        /// </summary>
        /// <param name="meps">MEPS Id</param>
        /// <returns>ICursor Bible chapter</returns>
        public ICursor QueryBible(NavStruct meps)
        {
            ICursor cursor = this.Database.Query(
                true, Type,
                new[] { KeyPublicationCode, KeyPublicationName, KeyArticleTitle, KeyArticleMEPSID, KeyArticleLocation, KeyArticleContent, KeyArticleGroup },
                KeyPublicationCode + "=? AND " + KeyArticleMEPSID + "=?",
                new string[] { "nwt", meps.ToString() },
                null, null, "_id", null);

            if (cursor != null)
            {
                cursor.MoveToFirst();
            }
            return(cursor);
        }
Beispiel #10
0
        private void LoadArticle(NavStruct article)
        {
            Fragment fragment = new ArticleFragment(article, LibraryMode);

            fragment.RetainInstance = true;

            FragmentManager     manager     = Activity.SupportFragmentManager;
            FragmentTransaction transaction = manager.BeginTransaction();

            transaction.SetTransition((int)FragmentTransit.FragmentFade);
            transaction.Add(Resource.Id.content_frame, fragment, null);
            transaction.AddToBackStack(null);
            transaction.Commit();

            ((MainLibraryActivity)Activity).stacks[(int)LibraryMode].Push(fragment);
        }
Beispiel #11
0
        private int GetNavigationIndex()
        {
            List <WOLArticle> articles = (App.STATE.Swapped == false) ? primaryArticles : secondaryArticles;

            int index = 0;

            if (library == Library.DailyText)
            {
                index = Array.IndexOf(articles.Select(a => a.ArticleMEPSID).ToArray(), SelectedArticle.ToString());
            }
            else
            {
                index = Array.IndexOf(articles.Select(a => NavStruct.Parse(a.ArticleMEPSID).Chapter.ToString()).ToArray(), SelectedArticle.Chapter.ToString());
            }

            return(index);
        }
Beispiel #12
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            TextView button = new TextView(context);

            button.SetText(chapters[position], TextView.BufferType.Normal);
            button.TextSize = 28;
            button.SetHeight(84);
            button.SetPadding(8, 8, 8, 8);
            button.SetBackgroundResource(Resource.Drawable.metro_button_style);
            button.SetTextColor(Android.Graphics.Color.White);
            button.Gravity = GravityFlags.CenterVertical;
            button.Id      = NavStruct.Parse(articles[position]).Chapter;

            button.Click += button_Click;

            return(button);
        }
Beispiel #13
0
        public ICursor QueryAllInsightsByGroup(NavStruct meps)
        {
            string group = "it-" + meps.Book.ToString();

            ICursor cursor = this.Database.Query(
                true, Type,
                new[] { KeyPublicationCode, KeyPublicationName, KeyArticleTitle, KeyArticleMEPSID, KeyArticleLocation, KeyArticleContent, KeyArticleGroup },
                KeyPublicationCode + "=? AND " + KeyArticleGroup + "=?",
                new string[] { "it", group },
                null, null, "_id", null);

            if (cursor != null)
            {
                cursor.MoveToFirst();
            }
            return(cursor);
        }
Beispiel #14
0
        public void ResetStorehouse()
        {
            JwStore database = new JwStore(Storehouse.Primary);

            database.Open();
            database.DeleteAllTables();
            database.Close();

            database = new JwStore(Storehouse.Secondary);
            database.Open();
            database.DeleteAllTables();
            database.Close();

            PrimaryBibleBooks   = null;
            SecondaryBibleBooks = null;

            PrimaryInsightGroups   = null;
            SecondaryInsightGroups = null;

            PrimaryInsightArticles   = null;
            SecondaryInsightArticles = null;

            PrimaryBooks   = null;
            SecondaryBooks = null;

            PrimaryWebViewStack   = null;
            SecondaryWebViewStack = null;

            SelectedArticle   = new NavStruct();
            Libraries         = null;
            CurrentLibrary    = Library.None;
            CurrentScreenMode = ScreenMode.Duel;
            Swapped           = false;

            ArticleNavigation = new Dictionary <string, NavStruct>();

            App.STATE.PrimaryLanguage   = null;
            App.STATE.SecondaryLanguage = null;
            App.STATE.Language          = "";

            // Clear all preferences
            var prefs = PreferenceManager.GetDefaultSharedPreferences(Context);

            prefs.Edit().Clear().Commit();
        }
Beispiel #15
0
        public static List <WOLArticle> ToInsightList(this ICursor cursor, string[] groupArticles)
        {
            cursor.MoveToFirst();
            List <WOLArticle> articles = new List <WOLArticle>();

            for (bool haveRow = cursor.MoveToFirst(); haveRow; haveRow = cursor.MoveToNext())
            {
                if (groupArticles.Contains(NavStruct.Parse(cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleMEPSID))).Chapter.ToString()))
                {
                    articles.Add(new WOLArticle()
                    {
                        ArticleContent  = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleContent)),
                        ArticleLocation = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleLocation)),
                        ArticleMEPSID   = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleMEPSID)),
                        ArticleTitle    = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyArticleTitle)),
                        PublicationCode = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyPublicationCode)),
                        PublicationName = cursor.GetString(cursor.GetColumnIndex(JwStore.KeyPublicationName))
                    });
                }
            }

            return(articles);
        }
Beispiel #16
0
        public void ChangeArticle(int offset)
        {
            Console.WriteLine(Enum.GetName(typeof(Library), library));

            int currentIndex = Array.IndexOf(primaryArticles.Select(a => a.ArticleMEPSID).ToArray(), SelectedArticle.ToString());
            int index        = currentIndex + offset;
            int last         = primaryArticles.Count - 1;

            if (index > last)
            {
                index = 0;
            }
            else if (index < 0)
            {
                index = last;
            }

            NavStruct nav = NavStruct.Parse(primaryArticles[index].ArticleMEPSID);

            SelectedArticle = nav;

            DisplayArticles();
        }
Beispiel #17
0
 public ArticleChangedArgs(NavStruct selectedArticle)
 {
     this.selectedArticle = selectedArticle;
 }
        private void SelectLibrary(Library library)
        {
            if (IsFinishing)
            {
                return;
            }

            App.STATE.CurrentLibrary = library;
            string tag = Enum.GetName(typeof(Library), library);

            FragmentTransaction transaction = SupportFragmentManager.BeginTransaction();

            transaction.SetTransition((int)FragmentTransit.FragmentFade);
            Fragment fragment = SupportFragmentManager.FindFragmentByTag(tag);

            if (App.STATE.CanTranslate())
            {
                if (fragment == null)
                {
                    if (App.STATE.CurrentLibrary == Library.DailyText)
                    {
                        string date = App.FUNCTIONS.FormatDateTime(DateTime.Now);

                        fragment = new ArticleFragment(NavStruct.Parse(date), library);
                        fragment.RetainInstance = true;
                    }
                    //else if (App.STATE.CurrentLibrary == Library.Insight)
                    //{
                    //    fragment = new InsightLibraryFragment();
                    //    fragment.RetainInstance = true;
                    //}
                    else
                    {
                        fragment = new LibraryFragment();
                        fragment.RetainInstance = true;
                    }

                    if (SelectedFragment != null)
                    {
                        transaction.Detach(SelectedFragment);
                    }
                    transaction.Add(Resource.Id.content_frame, fragment, tag);
                    transaction.Commit();
                }
                else
                {
                    transaction.Detach(SelectedFragment);
                    transaction.Attach(fragment);
                    transaction.Commit();
                }

                SelectedFragment = fragment;

                int index = App.STATE.Libraries.IndexOf(library);
                list.SetItemChecked(index, true);
                list.SetSelection(index);

                drawer.CloseDrawer(list);
            }
            else
            {
                // Temporary HACK
                SupportFragmentManager.PopBackStack(null, (int)PopBackStackFlags.Inclusive);

                SelectedFragment = null;
                transaction.Replace(Resource.Id.content_frame, new Fragment()).Commit();
                RunOnUiThread(() =>
                {
                    list.Adapter = null;
                });
            }

            Console.WriteLine("Current LibraryMode is " + App.STATE.CurrentLibrary.ToString());
        }