Exemplo n.º 1
0
        public void Update(GetChatsObject.Data user)
        {
            try
            {
                var data = UserList.FirstOrDefault(a => a.User.Id == user.Id);
                if (data != null)
                {
                    data.Id             = user.Id;
                    data.UserOne        = user.UserOne;
                    data.UserTwo        = user.UserTwo;
                    data.Time           = user.Time;
                    data.TextTime       = user.TextTime;
                    data.User           = user.User;
                    user.GetCountSeen   = user.GetCountSeen;
                    data.GetLastMessage = user.GetLastMessage;

                    ActivityContext.RunOnUiThread(() =>
                    {
                        NotifyItemChanged(UserList.IndexOf(data));
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public void Update(GetChatsObject.Data user)
        {
            try
            {
                var data = UserList.FirstOrDefault(a => a.Id == user.Id);
                if (data != null)
                {
                    data.UserId        = user.UserId;
                    data.Username      = user.Username;
                    data.Avatar        = user.Avatar;
                    data.Time          = user.Time;
                    data.Id            = user.Id;
                    data.LastMessage   = user.LastMessage;
                    data.NewMessage    = user.NewMessage;
                    user.UserData.Name = user.UserData.Name;
                    data.TimeText      = user.TimeText;

                    ActivityContext.RunOnUiThread(() =>
                    {
                        NotifyItemChanged(UserList.IndexOf(data));
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        //Event
        public void OnItemClick(View view, GetChatsObject.Data obj, int pos)
        {
            try
            {
                if (MAdapter.GetSelectedItemCount() > 0) // Add Select  New Item
                {
                    EnableActionMode(pos);
                }
                else
                {
                    HomeActivity.GetInstance()?.SetService();

                    if (ToolBar.Visibility != ViewStates.Visible)
                    {
                        ToolBar.Visibility = ViewStates.Visible;
                    }

                    // read the item which removes bold from the row >> event click open ChatBox by user id
                    GetChatsObject.Data item = MAdapter.GetItem(pos);
                    if (item != null)
                    {
                        UserId = item.UserId.ToString();

                        item.NewMessage = 0;
                        Intent intent = new Intent(this, typeof(MessagesBoxActivity));
                        intent.PutExtra("UserId", item.UserId.ToString());
                        intent.PutExtra("TypeChat", "LastChat");
                        intent.PutExtra("UserItem", JsonConvert.SerializeObject(item));

                        // Check if we're running on Android 5.0 or higher
                        if ((int)Build.VERSION.SdkInt < 23)
                        {
                            StartActivity(intent);
                            MAdapter.NotifyItemChanged(pos);
                        }
                        else
                        {
                            //Check to see if any permission in our group is available, if one, then all are
                            if (CheckSelfPermission(Manifest.Permission.ReadExternalStorage) == Permission.Granted &&
                                CheckSelfPermission(Manifest.Permission.WriteExternalStorage) == Permission.Granted)
                            {
                                StartActivity(intent);
                                MAdapter.NotifyItemChanged(pos);
                            }
                            else
                            {
                                new PermissionsController(this).RequestPermission(100);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 4
0
 public void RemoveData(int position, GetChatsObject.Data users)
 {
     try
     {
         Remove(users);
         ResetCurrentItems();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 5
0
 public void Insert(GetChatsObject.Data users)
 {
     try
     {
         UserList.Insert(0, users);
         NotifyItemInserted(0);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 public void Insert(GetChatsObject.Data users)
 {
     try
     {
         UserList.Insert(0, users);
         NotifyItemInserted(UserList.IndexOf(UserList.FirstOrDefault()));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 7
0
 public void Add(GetChatsObject.Data user)
 {
     try
     {
         var check = UserList.FirstOrDefault(a => a.User.Id == user.User.Id);
         if (check == null)
         {
             UserList.Add(user);
             NotifyItemInserted(UserList.IndexOf(UserList.Last()));
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
 public void Remove(GetChatsObject.Data users)
 {
     try
     {
         var index = UserList.IndexOf(UserList.FirstOrDefault(a => a.UserId == users.UserId));
         if (index != -1)
         {
             UserList.Remove(users);
             NotifyItemRemoved(index);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 9
0
 public void Move(GetChatsObject.Data users)
 {
     try
     {
         var data = UserList.FirstOrDefault(a => a.User.Id == users.User.Id);
         if (data != null)
         {
             var index = UserList.IndexOf(data);
             if (index > -1 && index != 0)
             {
                 UserList.Move(index, 0);
                 NotifyItemMoved(index, 0);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemplo n.º 10
0
        public void Initialize(LastChatAdapterViewHolder holder, GetChatsObject.Data item)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, item.User.Avatar, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                string name = Methods.FunString.DecodeString(item.User.Name);
                if (holder.TxtUsername.Text != name)
                {
                    holder.TxtUsername.Text = name;
                }

                string lastMessage = Methods.FunString.DecodeString(item.GetLastMessage.Text);
                if (holder.TxtLastMessages.Text != lastMessage)
                {
                    holder.TxtLastMessages.Text = lastMessage;
                }

                //last seen time
                holder.TxtTimestamp.Text = Methods.Time.ReplaceTime(item.GetLastMessage.TextTime);

                if (Convert.ToInt32(item.GetCountSeen) <= 0)
                {
                    holder.ImageColor.Visibility = ViewStates.Invisible;
                }
                else
                {
                    var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.GetCountSeen, Color.ParseColor(AppSettings.MainColor));
                    holder.ImageColor.SetImageDrawable(drawable);
                    holder.ImageColor.Visibility = ViewStates.Visible;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 11
0
 public void OnItemLongClick(View view, GetChatsObject.Data obj, int pos)
 {
     EnableActionMode(pos);
 }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);

                Window.SetSoftInputMode(SoftInput.AdjustResize);
                base.OnCreate(savedInstanceState);

                if (AppSettings.SetTabDarkTheme)
                {
                    Window.SetBackgroundDrawableResource(Resource.Drawable.chatBackground3_Dark);
                }
                else
                {
                    Window.SetBackgroundDrawableResource(Resource.Drawable.chatBackground3);
                }

                // Set our view from the "MessagesBox_Layout" layout resource
                SetContentView(Resource.Layout.MessagesBox_Layout);

                var data = Intent.GetStringExtra("UserId") ?? "Data not available";
                if (data != "Data not available" && !string.IsNullOrEmpty(data))
                {
                    Userid = data;                                                              // to_id
                }
                var type = Intent.GetStringExtra("TypeChat") ?? "Data not available";
                if (type != "Data not available" && !string.IsNullOrEmpty(type))
                {
                    TypeChat = type;
                    string  json = Intent.GetStringExtra("UserItem");
                    dynamic item;
                    switch (type)
                    {
                    case "LastChat":
                        item = JsonConvert.DeserializeObject <GetChatsObject.Data>(json);
                        if (item != null)
                        {
                            DataUser = item;
                        }
                        break;

                    case "Owner":
                        item = JsonConvert.DeserializeObject <UserDataObject>(json);
                        if (item != null)
                        {
                            UserInfoData = item;
                        }
                        break;
                    }
                }

                //Get Value And Set Toolbar
                InitComponent();
                InitToolbar();
                SetRecyclerViewAdapters();


                //Set Title ToolBar and data chat user
                loadData_ItemUser();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            try
            {
                SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);

                Window.SetSoftInputMode(SoftInput.AdjustResize);
                base.OnCreate(savedInstanceState);

                if (AppSettings.SetTabDarkTheme)
                {
                    Window.SetBackgroundDrawableResource(Resource.Drawable.chatBackground3_Dark);
                }
                else
                {
                    Window.SetBackgroundDrawableResource(Resource.Drawable.chatBackground3);
                }

                // Set our view from the "MessagesBox_Layout" layout resource
                SetContentView(Resource.Layout.MessagesBox_Layout);

                var data = Intent.GetStringExtra("UserId") ?? "Data not available";
                if (data != "Data not available" && !string.IsNullOrEmpty(data))
                {
                    Userid = int.Parse(data);                                                              // to_id
                }
                try
                {
                    var type = Intent.GetStringExtra("TypeChat") ?? "Data not available";
                    if (type != "Data not available" && !string.IsNullOrEmpty(type))
                    {
                        TypeChat = type;
                        string  json = Intent.GetStringExtra("UserItem");
                        dynamic item;
                        switch (type)
                        {
                        case "LastChat":
                            item = JsonConvert.DeserializeObject <GetChatsObject.Data>(json);
                            if (item != null)
                            {
                                DataUser = item;
                            }
                            break;

                        case "comment":
                            item = JsonConvert.DeserializeObject <CommentObject>(json);
                            if (item != null)
                            {
                                UserInfoComment = item;
                            }
                            break;

                        case "following":
                        case "followers":
                        case "suggestion":
                        case "search":
                        case "Notification":
                        case "new":
                        case "NewsFeedPost":
                        case "OneSignalNotification":
                        case "UserData":
                            item = JsonConvert.DeserializeObject <UserDataObject>(json);
                            if (item != null)
                            {
                                UserInfoData = item;
                            }
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                //Get Value And Set Toolbar
                InitComponent();
                InitToolbar();
                SetRecyclerViewAdapters();

                var emojisIcon = new EmojIconActions(this, RootView, EmojiconEditTextView, ChatEmojiImage);
                emojisIcon.ShowEmojIcon();

                //Set Title ToolBar and data chat user
                loadData_ItemUser();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }