protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.fav_list);

            listView = FindViewById<ListView> (Resource.Id.fav_list);
            List<Tweet> allFavTweets = new List<Tweet> ();

            try {
                var dbT = new TweetCommands (this);
                allFavTweets = dbT.GetAllTweets ();

            } catch (System.Exception sysExc) {
                Console.Error.WriteLine ("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
            }

            if (allFavTweets.Count > 0) {
                try {
                        listAdapter = new MyListAdapter (this, allFavTweets);
                        listView.Adapter = listAdapter;
                        listView.ItemClick += ListClick;

                } catch (WebException we) {
                    Console.Error.WriteLine ("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine ("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            } else {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof (Activity1));
                Finish ();
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.fav_list);

            listView = FindViewById <ListView> (Resource.Id.fav_list);
            List <Tweet> allFavTweets = new List <Tweet> ();

            try {
                var dbT = new TweetCommands(this);
                allFavTweets = dbT.GetAllTweets();
            } catch (System.Exception sysExc) {
                Console.Error.WriteLine("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
            }

            if (allFavTweets.Count > 0)
            {
                try {
                    listAdapter         = new MyListAdapter(this, allFavTweets);
                    listView.Adapter    = listAdapter;
                    listView.ItemClick += ListClick;
                } catch (WebException we) {
                    Console.Error.WriteLine("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            }
            else
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof(Activity1));
                Finish();
            }
        }
예제 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.list);
            sourceString = Intent.GetStringExtra(SOURCE) ?? "error";
            listView     = FindViewById <ListView> (Resource.Id.list);
            Console.WriteLine(sourceString);
            if (sourceString != null && !sourceString.Equals("error"))
            {
                try {
                    var          result = JsonValue.Parse(sourceString);
                    List <Tweet> tweets = new List <Tweet> ();
                    //TODO count issue continued

                    /* result.Count is not always 5?
                     */
                    Console.WriteLine(result.Count.ToString());

                    for (int i = 0; i < result.Count; i++)
                    {
                        Tweet tweet = new Tweet(result [i]);
                        tweets.Add(tweet);
                    }
                    if (tweets.Count > 0)
                    {
                        listAdapter = new MyListAdapter(this, tweets);
                        //TODO Header issue
                        // not really had time to look at this, but currently your content is only a list view...
                        // ping me if it is not solved, another meeting awaits...

                        /* I wanted to make a static header, so I only have to load the profileimage and name once
                         * But i can't get it to show anything and it scrolls with rest of the list.
                         */
                        Bitmap    bm    = listAdapter.GetHeaderInfo();
                        ViewGroup vg    = FindViewById <LinearLayout> (Resource.Id.mainll);
                        View      v     = this.LayoutInflater.Inflate(Resource.Layout.list_header, vg, false) as LinearLayout;
                        ImageView image = v.FindViewById(Resource.Id.imageView1) as ImageView;
                        image.SetImageBitmap(bm);
                        listView.AddHeaderView(v);
                        listView.Adapter = listAdapter;

                        listView.ItemClick += ListClick;
                    }
                } catch (WebException we) {
                    Console.Error.WriteLine("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            }
            else
            {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof(Activity1));
                Finish();
            }
        }
예제 #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.list);
            sourceString = Intent.GetStringExtra(SOURCE) ?? "error";
            listView = FindViewById<ListView> (Resource.Id.list);
            Console.WriteLine (sourceString);
            if (sourceString != null && !sourceString.Equals ("error")) {
                try {

                    var result = JsonValue.Parse (sourceString);
                    List<Tweet> tweets = new List<Tweet> ();
                    //TODO count issue continued
                    /* result.Count is not always 5?
                 	 */
                    Console.WriteLine (result.Count.ToString ());

                    for (int i = 0; i<result.Count; i++) {

                        Tweet tweet = new Tweet (result [i]);
                        tweets.Add (tweet);
                    }
                    if (tweets.Count > 0) {
                        listAdapter = new MyListAdapter (this, tweets);
                        //TODO Header issue
                        // not really had time to look at this, but currently your content is only a list view...
                        // ping me if it is not solved, another meeting awaits...
                        /* I wanted to make a static header, so I only have to load the profileimage and name once
                         * But i can't get it to show anything and it scrolls with rest of the list.
                         */
                        Bitmap bm = listAdapter.GetHeaderInfo ();
                        ViewGroup vg = FindViewById<LinearLayout> (Resource.Id.mainll);
                        View v = this.LayoutInflater.Inflate (Resource.Layout.list_header, vg, false)as LinearLayout;
                        ImageView image = v.FindViewById (Resource.Id.imageView1) as ImageView;
                        image.SetImageBitmap (bm);
                        listView.AddHeaderView (v);
                        listView.Adapter = listAdapter;

                        listView.ItemClick += ListClick;

                    }
                } catch (WebException we) {
                    Console.Error.WriteLine ("WebException : " + we.Message);
                } catch (System.Exception sysExc) {
                    Console.Error.WriteLine ("System.Exception : " + sysExc.Message + "\n" + sysExc.StackTrace);
                }
            } else {
                Toast.MakeText(this, "Something went wrong", ToastLength.Short).Show();
                StartActivity(typeof (Activity1));
                Finish ();
            }
        }