Exemple #1
0
 internal PublicChatRoomAndroidImpl(AndroidJavaObject chatRoomJavaObject) : base(chatRoomJavaObject)
 {
     if (chatRoomJavaObject.GetSimpleClassName() != "PublicChatRoom")
     {
         Debug.LogError("Current AndroidJavaObject is not public chat room but is: " + chatRoomJavaObject.GetSimpleClassName());
     }
 }
 public static System.DateTime DateTimeFromJavaUtilDate(AndroidJavaObject javaDate)
 {
     if (javaDate.GetSimpleClassName() != "Date")
     {
         throw new System.InvalidOperationException("Trying to convert to DateTime failed. This java object is not java date");
     }
     using (var simpleDateFormat = new AndroidJavaObject("java.text.SimpleDateFormat", ParseUtils.TimestampFormat))
     {
         string dateText = simpleDateFormat.Call <string>("format", javaDate);
         return(ParseUtils.ParseTimestamp(dateText));
     }
 }
        public static User UserFromJavaObj(AndroidJavaObject javaObjUser)
        {
            if (javaObjUser.GetSimpleClassName() != "User")
            {
                throw new System.InvalidOperationException("Trying to convert to user failed. This java object is not user");
            }

            var serializedUser = javaObjUser.Call <string>("serialize");

            javaObjUser.Dispose();
            return(new User(new JSONObject(serializedUser)));
        }
        public static IPrivateChatRoom PrivateChatRoomFromJavaObject(AndroidJavaObject roomAJO)
        {
            if (roomAJO == null)
            {
                Debug.LogError("Private chat room AndroidJavaObject is null");
            }

            if (roomAJO.GetSimpleClassName() != "PrivateChatRoom")
            {
                Debug.LogError("This AndroidJavaObject is not private chat room!");
            }

            return(new PrivateChatRoomAndroidImpl(roomAJO));
        }