Exemplo n.º 1
0
            public void OnClick(View v)
            {
                int          position     = AdapterPosition;
                UserListItem user         = users[position];
                Intent       returnIntent = new Intent();

                v.Selected = true;
                returnIntent.PutExtra(Application.Context.GetString(Resource.String.ID), user.ID);
                returnIntent.PutExtra(Application.Context.GetString(Resource.String.UserName), user.name);
                activity.SetResult(Result.Ok, returnIntent);
                activity.Finish();
            }
Exemplo n.º 2
0
        public void UpdateAvatarState(UserListItem user)
        {
            try
            {
                using (var db = new SQLiteConnection(dbPath))
                {
                    String StrVal = user.AvatarIsDefault ? "1" : "0";

                    db.Execute("UPDATE UserListItem SET AvatarIsDefault = ? WHERE ID = ?", StrVal, user.ID);
                }
            }
            catch (SQLiteException ex)
            {
                Console.Out.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
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);
        }