private void SelectChapter(object sender, AdapterView.ItemClickEventArgs e) { NavStruct selected = NavStruct.Parse(primaryArticles[e.Position].ArticleMEPSID); SelectedArticle = selected; DisplayArticles(); }
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); }
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); }
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); }
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); }
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(); }
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()); }