Exemplo n.º 1
0
        private String OrganizeMessageString(HistoryListItem value, String name)
        {
            String result = String.Empty;

            if (value.message.Contains("sent"))
            {
                result = name + " " + value.message;
            }
            else
            {
                result = value.message;
            }

            return(result);
        }
Exemplo n.º 2
0
        protected override Java.Lang.Void RunInBackground(params object[] @params)
        {
            if (@params[0].GetType() == typeof(HistoryListItem))
            {
                HistoryListItem historyItem = @params[0] as HistoryListItem;
                UsersDatabase   db          = new UsersDatabase();
                UserListItem    user        = db.GetUserByID(historyItem.fromUserID);

                try
                {
                    byte[] data = OperationWithBitmap.Retrieve(context, user.ID);

                    if (data == null)
                    {
                        Bitmap curImage = OperationWithBitmap.GetFromUrl(user.url);
                        //user.AvatarIsDefault = OperationWithBitmap.isDefault(curImage);
                        //if (!user.AvatarIsDefault)
                        //{
                        historyItem.image = curImage;
                        //}
                        var bitmapData = OperationWithBitmap.ConvertToByteArray(historyItem.image);
                        OperationWithBitmap.Cache(context, bitmapData, historyItem.ID);
                    }
                    else
                    {
                        //if (!user.AvatarIsDefault)
                        historyItem.image = OperationWithBitmap.ConvertFromByteArray(data);
                    }
                }
                catch (Exception e) { Console.Out.WriteLine(e.Message); }
            }
            else if (@params[0].GetType() == typeof(UserListItem))
            {
                UserListItem user            = @params[0] as UserListItem;
                bool         AvatarIsDefault = user.AvatarIsDefault;
                try
                {
                    byte[] data = OperationWithBitmap.Retrieve(context, user.ID);

                    if (data == null)
                    {
                        Bitmap curImage = OperationWithBitmap.GetFromUrl(user.url);
                        //user.AvatarIsDefault = OperationWithBitmap.isDefault(curImage);
                        //if (!user.AvatarIsDefault)
                        //{
                        user.image = curImage;
                        //    UsersDatabase db = new UsersDatabase();
                        //    db.UpdateAvatarState(user);
                        //}
                        var bitmapData = OperationWithBitmap.ConvertToByteArray(user.image);
                        OperationWithBitmap.Cache(context, bitmapData, user.ID);
                    }
                    else
                    {
                        //if (!user.AvatarIsDefault)
                        user.image = OperationWithBitmap.ConvertFromByteArray(data);
                    }
                }
                catch (Exception e) { Console.Out.WriteLine(e.Message); }
            }
            else
            {
                throw new Exception("Wrong ItemList type.");
            }
            return(null);
        }