private void MarkMessagesAsRead() { string ownerID = AndroidData.CurrentUser.AccountID.ToString (); Queue<MessageDB> msgQ = new Queue<MessageDB> (); foreach (MessageDB eachMessageDB in ConversationInfo.Messages.Values.Select(s => s.Message) .Where(s => s.MessageRecipientDBList.Count(t => t.AccountGuid == ownerID && !t.IsRead) > 0)) msgQ.Enqueue (eachMessageDB); if (msgQ.Count > 0) { LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted; service.MessageMarkReadAsync (msgQ.Peek ().MessageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, new Guid (AndroidData.ServiceAuthToken), msgQ); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate (savedInstanceState); Window.AddFlags (WindowManagerFlags.KeepScreenOn); SetContentView (Resource.Layout.previewSoundFX); if (MessageReceivedUtil.userFrom != null) { UserDB user = UserDB.ConvertFromUser (MessageReceivedUtil.userFrom); Header.headertext = user.FirstName + " " + user.LastName; MessageReceivedUtil.userFrom = null; } else { if (MessagePlaybackUtil.recipients != null) { for (int i = 0; i < MessagePlaybackUtil.recipients.Count; ++i) { if (MessagePlaybackUtil.recipients [i] != null) { Header.headertext = MessagePlaybackUtil.recipients [i].FirstName + " " + MessagePlaybackUtil.recipients [i].LastName; break; } } //} } else Header.headertext = "Ann Onymouse"; } linView = FindViewById<LinearLayout> (Resource.Id.linearHolder); context = linView.Context; ImageView btns = FindViewById<ImageView> (Resource.Id.imgNewUserHeader); TextView header = FindViewById<TextView> (Resource.Id.txtFirstScreenHeader); RelativeLayout relLayout = FindViewById<RelativeLayout> (Resource.Id.relativeLayout1); ImageHelper.setupTopPanel (btns, header, relLayout, header.Context); Header.fontsize = 36f; ImageHelper.fontSizeInfo (header.Context); header.SetTextSize (Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; parent = linView; //preview = FindViewById<ImageView> (Resource.Id.imgComicon); progress = FindViewById<ProgressBar> (Resource.Id.prgPreview); co = base.Intent.GetIntExtra ("position", 0); counter = MessagePlaybackUtil.messageSteps.Count; dbm = wowZapp.LaffOutOut.Singleton.dbm; isPlaying = false; stepID = Guid.Empty; #if DEBUG System.Diagnostics.Debug.WriteLine ("number of steps = {0}", counter); #endif linView.RemoveAllViewsInLayout (); t = new System.Timers.Timer (); t.Interval = 2500; t.Elapsed += new System.Timers.ElapsedEventHandler (t_Elapsed); increments = 100 / (counter + 1); if (co != 0) { RunOnUiThread (() => progress.Progress = co * increments); increments *= co + co; } if (MessagePlaybackUtil.markAsRead) { ThreadPool.QueueUserWorkItem (delegate { Guid messageID = MessagePlaybackUtil.messageSteps [0].MessageID; LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted; service.MessageMarkReadAsync (messageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, new Guid (AndroidData.ServiceAuthToken), messageID); }); } ImageButton btnPreAdd = FindViewById<ImageButton> (Resource.Id.imgAdd); btnPreAdd.Tag = 1; ImageButton btnBack = FindViewById<ImageButton> (Resource.Id.btnBack); btnBack.Tag = 0; btnBack.Click += delegate { Window.ClearFlags (WindowManagerFlags.KeepScreenOn); Finish (); }; LinearLayout bottom = FindViewById<LinearLayout> (Resource.Id.bottomHolder); ImageButton[] buttons = new ImageButton[2]; buttons [0] = btnBack; buttons [1] = btnPreAdd; ImageHelper.setupButtonsPosition (buttons, bottom, context); if (MessageReceivedUtil.readOnly) btnPreAdd.Visibility = ViewStates.Invisible; else btnPreAdd.Click += delegate { StartActivity (typeof(ComposeMessageChooseContent)); }; #if DEBUG int m = 0; foreach (MessageStep eachMessageStep in MessagePlaybackUtil.messageSteps) System.Diagnostics.Debug.WriteLine ("step {0} = {1}", m++, eachMessageStep.StepType.ToString ()); #endif RunOnUiThread (delegate { PrepareViews (co); }); }
private void AppDelegate_ReceivedMessages(object sender, IncomingMessageEventArgs e) { List <Messages.MessageInfo> messageItems = new List<Messages.MessageInfo>(); Guid me = AndroidData.CurrentUser.AccountID; //RunOnUiThread (delegate { foreach (LOLMessageDelivery.Message eachMessage in e.Messages) { MessageDB msgDB = MessageDB.ConvertFromMessage(eachMessage); UserDB user = msgDB.FromAccountID == me ? UserDB.ConvertFromUser(AndroidData.CurrentUser) : dbm.GetUserWithAccountID(msgDB.FromAccountGuid); if (user == null) { unknownContacts.Add(msgDB.FromAccountID); //Contacts.AddUnknownUser uku = new Contacts.AddUnknownUser (unknowns, context); } Messages.MessageInfo msgInfo = new Messages.MessageInfo(msgDB, user); if (msgInfo != null) { messageItems.Add(msgInfo); } } if (messageItems.Count > 0) { if (message == null) message = new List<MessageDB>(); else message.Clear(); foreach (Messages.MessageInfo eachMessageInfo in messageItems) { this.MessageItems [eachMessageInfo.Message.MessageID] = eachMessageInfo; message.Add(eachMessageInfo.Message); } dbm.InsertOrUpdateMessages(message); messageItem = messageItems [0]; markAsRead = message.Count; current = 0; LOLMessageClient service = new LOLMessageClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint); service.MessageMarkReadCompleted += Service_MessageMarkReadCompleted; service.MessageMarkReadAsync(message [current].MessageID, AndroidData.CurrentUser.AccountID, AndroidData.NewDeviceID, new Guid(AndroidData.ServiceAuthToken), message [current].MessageID); } //}); }