protected override void OnResume()
        {
            base.OnResume ();

            int feedID = Intent.GetIntExtra ("FeedID", -1);
            int feedItemID = Intent.GetIntExtra ("FeedItemID", -1);

            if (feedItemID >= 0)
            {
                Button btnNextNewsEntry = FindViewById<Button>(Resource.Id.btnNextNewsEntry);

                List<de.dhoffmann.mono.adfcnewsapp.buslog.feedimport.Rss.RssItem> rssItems = new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().GetActiveFeedItems(false);
                btnNextNewsEntry.Visibility = ViewStates.Gone;

                int? nextFeedID = null;
                int? nextFeedItemID = null;

                if (rssItems != null && rssItems.Count > 1)
                {
                    bool ready = false;
                    for (int nIndex=0; nIndex<rssItems.Count; nIndex++)
                    {
                        if (!ready)
                        {
                            if (rssItems[nIndex].ItemID == feedItemID)
                            {
                                ready = true;
                            }

                            continue;
                        }

                        if (!rssItems[nIndex].IsRead)
                        {
                            nextFeedID = rssItems[nIndex].FeedID;
                            nextFeedItemID = rssItems[nIndex].ItemID;
                            btnNextNewsEntry.Visibility = ViewStates.Visible;
                            break;
                        }
                    }
                }

                new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().MarkItemsAsRead(feedItemID, true);
                de.dhoffmann.mono.adfcnewsapp.buslog.feedimport.Rss.RssFeed rssfeed = new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().GetRssFeed(feedID, feedItemID);

                if (rssfeed.Items.First().PubDate.HasValue)
                {
                    TextView tvNewsDetailDate = FindViewById<TextView>(Resource.Id.tvNewsDetailDate);
                    tvNewsDetailDate.Text = rssfeed.Items.First().PubDate.ToString();
                }

                TextView tvNewsDetailFeedTitle = FindViewById<TextView>(Resource.Id.tvNewsDetailFeedTitle);
                tvNewsDetailFeedTitle.Text = rssfeed.Header.Title;

                TextView tvNewsItemHeadline = FindViewById<TextView>(Resource.Id.tvNewsItemHeadline);
                tvNewsItemHeadline.Text = rssfeed.Items.First().Title;

                TextView tvNewsDetail = FindViewById<TextView>(Resource.Id.tvNewsDetail);
                tvNewsDetail.Text = rssfeed.Items.First().Description;

                url = rssfeed.Items.First().Link;
                description = rssfeed.Items.First().Description;

                Button btnWebsite = FindViewById<Button>(Resource.Id.btnWebsite);
                btnWebsite.Click += delegate(object sender, EventArgs e)
                {
                    Intent intent = new Intent(Android.Content.Intent.ActionView, Android.Net.Uri.Parse(url));

                    StartActivity(intent);
                };

                ImageButton btnShare = FindViewById<ImageButton>(Resource.Id.btnShare);
                btnShare.Click += delegate(object sender, EventArgs e)
                {
                    Intent intent = new Intent(Android.Content.Intent.ActionSend);
                    intent.SetType("text/plain");

                    intent.PutExtra(Android.Content.Intent.ExtraSubject, "Neues vom ADFC");
                    intent.PutExtra(Android.Content.Intent.ExtraText, description + "\n\n\n" + url + "\n\npowered by: ADFC-News für Android\nhttps://play.google.com/store/apps/details?id=de.dhoffmann.mono.adfcnewsapp");

                    StartActivity(Intent.CreateChooser(intent, "Share via"));
                };

                if (nextFeedID.HasValue && nextFeedItemID.HasValue)
                {
                    btnNextNewsEntry.Click += delegate(object sender, EventArgs e)
                    {
                        Intent i = new Android.Content.Intent(this, typeof(NewsDetails));
                        i.PutExtra("FeedID", nextFeedID.Value);
                        i.PutExtra("FeedItemID", nextFeedItemID.Value);

                        StartActivity(i);
                        this.Finish();
                    };
                }
            }
        }
Beispiel #2
0
        protected override void OnResume()
        {
            base.OnResume();

            int feedID     = Intent.GetIntExtra("FeedID", -1);
            int feedItemID = Intent.GetIntExtra("FeedItemID", -1);

            if (feedItemID >= 0)
            {
                Button btnNextNewsEntry = FindViewById <Button>(Resource.Id.btnNextNewsEntry);

                List <de.dhoffmann.mono.adfcnewsapp.buslog.feedimport.Rss.RssItem> rssItems = new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().GetActiveFeedItems(true);
                btnNextNewsEntry.Visibility = ViewStates.Gone;

                if (rssItems != null && rssItems.Count > 1)
                {
                    for (int nIndex = 0; nIndex < rssItems.Count - 1; nIndex++)
                    {
                        if (rssItems[nIndex].ItemID == feedItemID)
                        {
                            btnNextNewsEntry.Visibility = ViewStates.Visible;
                            break;
                        }
                    }
                }

                new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().MarkItemsAsRead(feedItemID, true);

                de.dhoffmann.mono.adfcnewsapp.buslog.feedimport.Rss.RssFeed rssfeed = new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().GetRssFeed(feedID, feedItemID);

                if (rssfeed.Items.First().PubDate.HasValue)
                {
                    TextView tvNewsDetailDate = FindViewById <TextView>(Resource.Id.tvNewsDetailDate);
                    tvNewsDetailDate.Text = rssfeed.Items.First().PubDate.ToString();
                }

                TextView tvNewsDetailFeedTitle = FindViewById <TextView>(Resource.Id.tvNewsDetailFeedTitle);
                tvNewsDetailFeedTitle.Text = rssfeed.Header.Title;

                TextView tvNewsItemHeadline = FindViewById <TextView>(Resource.Id.tvNewsItemHeadline);
                tvNewsItemHeadline.Text = rssfeed.Items.First().Title;

                TextView tvNewsDetail = FindViewById <TextView>(Resource.Id.tvNewsDetail);
                tvNewsDetail.Text = rssfeed.Items.First().Description;

                url         = rssfeed.Items.First().Link;
                description = rssfeed.Items.First().Description;

                Button btnWebsite = FindViewById <Button>(Resource.Id.btnWebsite);
                btnWebsite.Click += delegate(object sender, EventArgs e)
                {
                    Intent intent = new Intent(Android.Content.Intent.ActionView, Android.Net.Uri.Parse(url));

                    StartActivity(intent);
                };

                Button btnShare = FindViewById <Button>(Resource.Id.btnShare);
                btnShare.Click += delegate(object sender, EventArgs e)
                {
                    Intent intent = new Intent(Android.Content.Intent.ActionSend);
                    intent.SetType("text/plain");

                    intent.PutExtra(Android.Content.Intent.ExtraSubject, "Neues vom ADFC");
                    intent.PutExtra(Android.Content.Intent.ExtraText, description + "\n\n\n" + url + "\n\npowered by: ADFC-News für Android\nhttps://play.google.com/store/apps/details?id=de.dhoffmann.mono.adfcnewsapp");

                    StartActivity(Intent.CreateChooser(intent, "Share via"));
                };

                btnNextNewsEntry.Click += delegate(object sender, EventArgs e)
                {
                    rssItems = new de.dhoffmann.mono.adfcnewsapp.buslog.database.Rss().GetActiveFeedItems(false);

                    if (rssItems != null && rssItems.Count > 1)
                    {
                        for (int nIndex = 1; nIndex < rssItems.Count; nIndex++)
                        {
                            if (rssItems[nIndex - 1].ItemID == feedItemID)
                            {
                                Intent i = new Android.Content.Intent(this, typeof(NewsDetails));
                                i.PutExtra("FeedID", rssItems[nIndex].FeedID);
                                i.PutExtra("FeedItemID", rssItems[nIndex].ItemID);

                                StartActivity(i);
                                this.Finish();
                                break;
                            }
                        }
                    }
                };
            }
        }