private async Task GetUserProfileApi() { if (Methods.CheckConnectivity()) { (int respondCode, var respondString) = await RequestsAsync.User.FetchUserData(Userid.ToString()); if (respondCode == 200) { if (respondString is FetchUserDataObject result) { if (result.Data != null) { UserInfoData = result.Data; RunOnUiThread(() => { SupportActionBar.Title = UserInfoData.Name; SupportActionBar.Subtitle = GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(int.Parse(UserInfoData.LastSeen)); LastSeenUser = GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(int.Parse(UserInfoData.LastSeen)); }); } } } else { Methods.DisplayReportResult(this, respondString); } } }
//Send Message type => "right_text" private void OnClick_OfSendButton() { try { UnixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var time2 = UnixTimestamp.ToString(); string timeNow = DateTime.Now.ToString("hh:mm"); if (string.IsNullOrEmpty(EmojiconEditTextView.Text)) { } else { //Here on This function will send Text Messages to the user //remove \n in a string string replacement = Regex.Replace(EmojiconEditTextView.Text, @"\t|\n|\r", ""); if (Methods.CheckConnectivity()) { GetUserMessagesObject.Message message = new GetUserMessagesObject.Message { Id = UnixTimestamp, FromId = int.Parse(UserDetails.UserId), ToId = Userid, Text = replacement, MediaFile = "", MediaType = "", DeletedFs1 = "", DeletedFs2 = "", Seen = "0", Time = time2, Extra = "", TimeText = timeNow, Position = "Right", }; MAdapter.Add(message); UserDataObject userData = ConvertData(); MessageController.SendMessageTask(Userid, EmojiconEditTextView.Text, time2, userData).ConfigureAwait(false); } else { ToastUtils.ShowToast(GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short); } EmojiconEditTextView.Text = ""; } ChatSendButton.Tag = "Text"; ChatSendButton.SetImageResource(Resource.Drawable.SendLetter); } catch (Exception e) { Console.WriteLine(e); } }
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); } }
private UserDataObject ConvertData() { try { UserDataObject userData = null; if (DataUser != null) { userData = new UserDataObject() { UserId = DataUser.UserData.UserId, Username = DataUser.UserData.Username, Email = DataUser.UserData.Email, IpAddress = DataUser.UserData.IpAddress, Fname = DataUser.UserData.Fname, Lname = DataUser.UserData.Lname, Gender = DataUser.UserData.Gender, Language = DataUser.UserData.Language, Avatar = DataUser.UserData.Avatar, Cover = DataUser.UserData.Cover, CountryId = DataUser.UserData.CountryId, About = DataUser.UserData.About, Google = DataUser.UserData.Google, Facebook = DataUser.UserData.Facebook, Twitter = DataUser.UserData.Twitter, Website = DataUser.UserData.Website, Active = DataUser.UserData.Active, Admin = DataUser.UserData.Admin, Verified = DataUser.UserData.Verified, LastSeen = DataUser.UserData.LastSeen, Registered = DataUser.UserData.Registered, IsPro = DataUser.UserData.IsPro, Posts = DataUser.UserData.Posts, PPrivacy = DataUser.UserData.PPrivacy, CPrivacy = DataUser.UserData.CPrivacy, NOnLike = DataUser.UserData.NOnLike, NOnMention = DataUser.UserData.NOnMention, NOnComment = DataUser.UserData.NOnComment, NOnFollow = DataUser.UserData.NOnFollow, StartupAvatar = DataUser.UserData.StartupAvatar, StartupInfo = DataUser.UserData.StartupInfo, StartupFollow = DataUser.UserData.StartupFollow, Src = DataUser.UserData.Src, SearchEngines = DataUser.UserData.SearchEngines, Mode = DataUser.UserData.Mode, Name = DataUser.UserData.Name, Uname = DataUser.UserData.Uname, Url = DataUser.UserData.Url, TimeText = DataUser.UserData.TimeText, IsFollowing = DataUser.UserData.IsFollowing, IsBlocked = DataUser.UserData.IsBlocked, }; } else if (UserInfoData != null) { userData = UserInfoData; } return(userData); } catch (Exception e) { Console.WriteLine(e); return(null); } }