private Tweet NewTweet(Android.Database.ICursor cursor) { var j = JsonValue.Parse (cursor.GetString (1)); Tweet twt = new Tweet (j); return (twt); }
public long AddTweet(Tweet tweet) { var values = new ContentValues (); values.Put ("Source", tweet.SourceString); return twtHelp.WritableDatabase.Insert ("Tweet", null, values); }
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 (); } }