protected override void OnCreate(Bundle bundle) { db = new DataBaseWrapper(this.Resources); if ((setting = db.Table <Setting> ().FirstOrDefault()) == null) { db.Insert(setting = new Setting()); } StartupTheme = setting.Theme; SetTheme(setting.Theme); base.OnCreate(bundle); new UpdateChecker(this, db, setting); // Check if the application knows a user. User user = db.Table <User>().FirstOrDefault(); if (user != null && user.user != null) { initializeAuthenticated(user); } else { initializeNotAuthenticated(); } }
private void moreMessages() { OnBind(); visibleMessages += 10; var x = db.Table <Message> (); if (x.Where(q => q.conversation == conversation).Count() < visibleMessages) { new Thread(async() => { while (!await network.UpdateHistory(db, user, chat, visibleMessages)) { await network.Authenticate(db, user); } RunOnUiThread(() => { if (isUnbound()) { return; } UpdateMessages(user); }); }).Start(); } else { UpdateMessages(user); } InvalidateOptionsMenu(); }
public async void OnUpdateRequested() { User user = db.Table <User>().FirstOrDefault(); if (user != null && user.user != null) { RunOnUiThread(() => ShowChats(user)); } }
private string getLatestTime(DataBaseWrapper db) { var x = db.Table <Chat>(); string latest_conversation = x.OrderByDescending(e => e.time).First <Chat>().conversation; var y = db.Table <Message>(); Message tmp = y.Where(q => q.conversation == latest_conversation).OrderBy(e => e.time).Last <Message>(); string lastid = String.Format("\"time\":\"{0}\"", tmp.time); return(lastid); }
public async Task <int> UpdateNotifications() { if (db != null && network != null && user != null) { var events = db.Table <Event> (); foreach (var x in events) { await HandleEvent(db, network, user, x); db.Delete <Event> (x.id); } } return(0); }
protected override void OnCreate(Bundle bundle) { db = new DataBaseWrapper(this.Resources); if ((setting = db.Table <Setting> ().FirstOrDefault()) == null) { db.Insert(setting = new Setting()); } SetTheme(setting.Theme); base.OnCreate(bundle); network = new AsyncNetwork(); db = new DataBaseWrapper(this.Resources); user = db.Table <User>().FirstOrDefault(); if (setting.FontSize == Setting.Size.large) { SetContentView(Resource.Layout.SettingsLarge); } else { SetContentView(Resource.Layout.Settings); } InitializeView(); }
protected override void OnCreate(Bundle bundle) { db = new DataBaseWrapper(this.Resources); if ((setting = db.Table <Setting> ().FirstOrDefault()) == null) { db.Insert(setting = new Setting()); } SetTheme(setting.Theme); base.OnCreate(bundle); if (Intent.ActionSend == Intent.Action) { if (Intent.GetStringExtra(Intent.ExtraText) != null) { textShare = Intent.GetStringExtra(Intent.ExtraText); } else { var uriString = Intent.GetParcelableExtra(Intent.ExtraStream).ToString(); var uri = Android.Net.Uri.Parse(uriString); if (uri != null) { fileset.Add(uri); } } } else if (Intent.ActionSendMultiple == Intent.Action) { var uris = Intent.GetParcelableArrayListExtra(Intent.ExtraStream); if (uris != null) { foreach (var uri in uris) { fileset.Add(Android.Net.Uri.Parse(uri.ToString())); } } } // Check if the application knows a user. User user = db.Table <User>().FirstOrDefault(); if (user != null && user.user != null) { initializeAuthenticated(user); } }
public async void OnUpdateRequested() { User user = db.Table <User>().FirstOrDefault(); if (user != null && user.user != null) { RunOnUiThread(() => { if (isUnbound()) { return; } ShowChats(user); }); } }
protected override void OnCreate(Bundle bundle) { db = new DataBaseWrapper(this.Resources); if ((setting = db.Table <Setting> ().FirstOrDefault()) == null) { db.Insert(setting = new Setting()); } StartupTheme = setting.Theme; SetTheme(setting.Theme); base.OnCreate(bundle); SetContentView(Resource.Layout.ChatActivity); conversation = Intent.GetStringExtra("conversation"); chat = db.Get <Chat> (conversation); visibleMessages = chat.VisibleMessages; if (visibleMessages <= 0) { visibleMessages = setting.VisibleMessages; } if (visibleMessages <= 0) { visibleMessages = 30; } Title = SmileyTools.GetSmiledTextUTF(chat.name); ActionBar.SetDisplayHomeAsUpEnabled(true); ActionBar.SetIcon(Resource.Drawable.Icon); user = db.Table <User>().FirstOrDefault(); Button send = FindViewById <Button>(Resource.Id.send); send.Click += delegate { TextView message = FindViewById <TextView>(Resource.Id.message); var msg = message.Text; message.Text = ""; if (msg.Equals("")) { return; } LinearLayout messageList = FindViewById <LinearLayout>(Resource.Id.messageLayout); AddMessage(messageList, new Message() { time = "sending", author = "Du", nick = user.user, text = msg, conversation = this.conversation }); ScrollView scrollView = FindViewById <ScrollView>(Resource.Id.messageScrollView); scrollView.FullScroll(FocusSearchDirection.Down); scrollView.Post(() => scrollView.FullScroll(FocusSearchDirection.Down)); OnBind(); new Thread(async() => { while (!await network.SendMessage(db, user, chat, msg)) { await network.Authenticate(db, user); } }).Start(); }; Button smiley = FindViewById <Button>(Resource.Id.smile); smiley.Click += delegate { // TODO implement smiley stuff... }; }
public void DoWork() { db = new DataBaseWrapper(Resources); network = new AsyncNetwork(); network.SetBackgroundService(this); user = db.Table <User>().FirstOrDefault(); var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService); if (user != null && user.user != null) { var t = new Thread(async() => { while (true) { Setting.Frequency f = db.Table <Setting>().FirstOrDefault().Synchronisation; if (f != Setting.Frequency.wlan || connectivityManager.GetNetworkInfo(ConnectivityType.Wifi).GetState() == NetworkInfo.State.Connected) { while (!await network.UpdateEvents(db, user)) { await network.Authenticate(db, user); } } // Wifi connection gets normal updates, other networks get 4 times worse update time. if (connectivityManager.GetNetworkInfo(ConnectivityType.Wifi).GetState() == NetworkInfo.State.Connected) { connectivityMode = 1; } else { connectivityMode = 4; } switch (f) { case Setting.Frequency.often: Mode = 1; break; case Setting.Frequency.normal: Mode = 2; break; case Setting.Frequency.rare: Mode = 4; break; case Setting.Frequency.wlan: Mode = 2; break; } Thread.Sleep(UpdateInterval * Mode * connectivityMode); if (UpdateInterval < 12000) { UpdateInterval += 1000; } else if (UpdateInterval < 30000) { UpdateInterval += 2000; } else { UpdateInterval = 60000; } } } ); t.Start(); } else { StopSelf(); } }