private async void CheckClassRoomsResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); roomsList = JsonConvert.DeserializeObject <List <RoomModel> >(strContent); if (roomsList.Count > 0) { classRoomId = roomsList[0].RoomId; BindClassRooms(roomsList); } else { UILabel lblRemark = new UILabel() { Frame = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 250, View.Bounds.Width, 40), Text = "No rooms found!", Font = UIFont.FromName("Futura-Medium", 15f), TextColor = UIColor.White, BackgroundColor = UIColor.Clear, LineBreakMode = UILineBreakMode.WordWrap, Lines = 1, TextAlignment = UITextAlignment.Center }; View.AddSubviews(lblRemark); loadingOverlay.Hide(); } } else { IOSUtil.ShowMessage("No rooms found!", loadingOverlay, this); } }
public async void GetConsumptionDetails(ConsumptionFor currentConsumption, int Id) { InvokeOnMainThread(() => { // Added for showing loading screen var bounds = UIScreen.MainScreen.Bounds; // show the loading overlay on the UI thread using the correct orientation sizing loadingOverlay = new LoadingOverlay(bounds); View.Add(loadingOverlay); }); string url = GetConsumptionURL(currentConsumption); if (Id != 0) { url = url + "/" + Convert.ToString(Id); } var responseConsumption = await InvokeApi.Invoke(url, string.Empty, HttpMethod.Get, PreferenceHandler.GetToken(), IOSUtil.CurrentStage); if (responseConsumption.StatusCode == HttpStatusCode.OK) { GetConsumptionResponse(responseConsumption); } else if (responseConsumption.StatusCode == HttpStatusCode.BadRequest || responseConsumption.StatusCode == HttpStatusCode.Unauthorized) { await IOSUtil.RefreshToken(this, loadingOverlay); } }
private async void GetConsumptionResponse(HttpResponseMessage responseConsumption) { if (responseConsumption != null && responseConsumption.StatusCode == System.Net.HttpStatusCode.OK && responseConsumption.Content != null) { string strContent = await responseConsumption.Content.ReadAsStringAsync(); List <ConsumptionModel> consumptions = GetConsumptionModels(strContent); if (consumptions.Count > 0) { SetConsumptions(consumptions); } else { IOSUtil.ShowMessage("No " + CurrentConsumption.ToString() + " found!", loadingOverlay, this); switch (CurrentConsumption) { case ConsumptionFor.Buildings: CurrentConsumption = ConsumptionFor.Premises; break; case ConsumptionFor.Meters: CurrentConsumption = ConsumptionFor.Buildings; break; } } } else { await IOSUtil.RefreshToken(this, loadingOverlay); } }
private async void submitFeedbackResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); GeneralResponseModel response = JsonConvert.DeserializeObject <GeneralResponseModel>(strContent); if (response.Status_Code == Constants.STATUS_CODE_SUCCESS) { var ThankYouViewController = Storyboard.InstantiateViewController("ThankYouViewController") as ThankYouViewController; ThankYouViewController.NavigationItem.SetHidesBackButton(true, false); NavigationController.PushViewController(ThankYouViewController, true); loadingOverlay.Hide(); } else { IOSUtil.ShowMessage("Failed to submit feedback, please try again!", loadingOverlay, this); } } else { IOSUtil.ShowMessage("Failed to submit feedback, please try again!", loadingOverlay, this); } }
private async void getRecommendationsListResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); JArray array = JArray.Parse(strContent); lstRecommendations = array.ToObject <List <AlertModel> >(); if (lstRecommendations.Count > 0) { GetRecommendations(lstRecommendations); } else { UILabel lblRemark = new UILabel() { Frame = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 70, View.Bounds.Width, 40), Text = "No recommendations found!", Font = UIFont.FromName("Futura-Medium", 15f), TextColor = UIColor.White, BackgroundColor = UIColor.FromRGB(0, 102, 153), LineBreakMode = UILineBreakMode.WordWrap, Lines = 1, TextAlignment = UITextAlignment.Center }; View.AddSubviews(lblRemark); loadingOverlay.Hide(); } } else { IOSUtil.ShowMessage("Please try again later !", loadingOverlay, this); } }
public async void CheckAlertsResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); List <AlertModel> alertsList = JsonConvert.DeserializeObject <List <AlertModel> >(strContent); if (alertsList.Count > 0) { BindAlerts(alertsList); } else { UILabel lblRemark = new UILabel() { Frame = new CGRect(0, this.NavigationController.NavigationBar.Bounds.Bottom + 20, View.Bounds.Width, 40), Text = "No alerts found!", Font = UIFont.FromName("Futura-Medium", 15f), TextColor = UIColor.White, BackgroundColor = UIColor.FromRGB(0, 102, 153), LineBreakMode = UILineBreakMode.WordWrap, Lines = 1, TextAlignment = UITextAlignment.Center }; View.AddSubviews(lblRemark); } } else { IOSUtil.ShowMessage("No Alerts.", loadingOverlay, this); } }
public static void ShowAlertView(string title, string content) { #if UNITY_IPHONE IOSUtil.showAlertView(title, content); #elif UNITY_ANDROID #endif }
private async void GetMeterReportsResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { Console.WriteLine(restResponse.Content.ToString()); string strContent = await restResponse.Content.ReadAsStringAsync(); meterReports = JsonConvert.DeserializeObject <MeterReports>(strContent); if (meterReports != null) { GetAccessToken(); } else { Console.WriteLine("GetMeterReportsResponse() Failed"); IOSUtil.ShowAlert("Reports are not available"); String body = "<html><body>Failed to load reports for <b>" + meterName + ".</b></body></html>"; showContentOnWebView(body); } } else { Console.WriteLine("GetMeterReportsResponse() Failed"); IOSUtil.ShowAlert("Failed to load reports"); String body = "<html><body>Failed to load reports for <b>" + meterName + ".</b></body></html>"; showContentOnWebView(body); } }
public override void ViewDidLoad() { base.ViewDidLoad(); webView = new UIWebView(View.Bounds); webView.ScalesPageToFit = false; if (meterSerialNumber == null) { showErrorMessage(); } else { String body = "<html><body>Loading reports for <b>" + meterName + "...</b></body></html>"; View.AddSubview(webView); showContentOnWebView(body); //var preferenceHandler = new PreferenceHandler(); int userId = PreferenceHandler.GetUserDetails().UserId; if (userId != -1) { getMeterReports(userId, meterSerialNumber); } else { IOSUtil.ShowAlert("Invalid Email. Please Login Again !"); } } }
public void OnPurchaseFailed(Product product, PurchaseFailureReason p) { Debug.Log(string.Format("IAP::OnPurchaseFailed PurchaseFailureReason:{0}", p)); int purchaseType = 0; string udid = ""; #if UNITY_IOS || UNITY_IPHONE purchaseType = 1; //Apple Store EPlatformType.EPlatformType_AppStore udid = IOSUtil.iosGetOpenUDID(); #elif UNITY_ANDROID purchaseType = 2; //Google Play EPlatformType.EPlatformType_GooglePlay udid = AndroidUtil.GetOpenUDID(); #endif var transactionID = product.transactionID; var pid = product.definition.id; //Write cache FileBilling.Instance.ReadFile(); FileBilling.CReceiptInfo entry = new FileBilling.CReceiptInfo(); entry.RoleId = _roleId; entry.ProductId = pid; entry.BillingType = purchaseType; entry.IsSucceed = false; entry.TransactionId = transactionID; FileBilling.Instance.Update(purchaseType, entry); FileBilling.Instance.WriteFile(); PostVerifyData(_roleId, _roleId, purchaseType, pid, transactionID, udid, "", "", false, false); // Callback PURCHASE_INFO info = new PURCHASE_INFO(); info.iBillingType = purchaseType; info.strTransactionId = product.transactionID; _fnPurchaseCallback(false, info); }
public static void OpenUrl(string url) { #if UNITY_IOS IOSUtil.iosOpenUrl(url); #elif UNITY_ANDROID AndroidUtil.OpenUrl(url); #endif }
public static void RequestCameraPermission() { #if UNITY_IOS IOSUtil.RequestPermission((int)IOSUtil.PermissionType.PermissionCamera); #elif UNITY_ANDROID AndroidUtil.RequestPermission(AndroidUtil.CODE_CAMERA); #else #endif }
public static void RequestRecordAudioPermission() { #if UNITY_IOS IOSUtil.RequestPermission((int)IOSUtil.PermissionType.PermissionMicrophone); #elif UNITY_ANDROID AndroidUtil.RequestPermission(AndroidUtil.CODE_RECORD_AUDIO); #else #endif }
public static void RequestPhotoPermission() { #if UNITY_IOS IOSUtil.RequestPermission((int)IOSUtil.PermissionType.PermissionPhotoLibrary); #elif UNITY_ANDROID AndroidUtil.RequestPermission(AndroidUtil.CODE_WRITE_EXTERNAL_STORAGE); #else #endif }
public static bool HasCameraPermission() { #if UNITY_IOS return(IOSUtil.HasPermission((int)IOSUtil.PermissionType.PermissionCamera)); #elif UNITY_ANDROID return(AndroidUtil.HasPermission(AndroidUtil.CODE_CAMERA)); #else return(true); #endif }
public static bool HasRecordAudioPermission() { #if UNITY_IOS return(IOSUtil.HasPermission((int)IOSUtil.PermissionType.PermissionMicrophone)); #elif UNITY_ANDROID return(AndroidUtil.HasPermission(AndroidUtil.CODE_RECORD_AUDIO)); #else return(true); #endif }
public static bool HasPhotoPermission() { #if UNITY_IOS return(IOSUtil.HasPermission((int)IOSUtil.PermissionType.PermissionPhotoLibrary)); #elif UNITY_ANDROID return(AndroidUtil.HasPermission(AndroidUtil.CODE_WRITE_EXTERNAL_STORAGE)); #else return(true); #endif }
public static int OpenCamera(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; #if UNITY_ANDROID AndroidUtil.OpenCamera(); #elif UNITY_IPHONE IOSUtil.iosOpenCamera(true); #endif return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
// 复制到粘贴板 public static void CopyTextToClipboard(string str) { #if UNITY_IOS IOSUtil.iosCopyTextToClipboard(str); #elif UNITY_ANDROID AndroidUtil.CopyTextToClipboard(str); #else TextEditor t = new TextEditor(); t.text = str; t.OnFocus(); t.Copy(); #endif }
private async void CheckClassRoomsResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); List <ClassRoomModel> classRoomsList = JsonConvert.DeserializeObject <List <ClassRoomModel> >(strContent); BindClassRooms(classRoomsList); } else { IOSUtil.ShowMessage("No Class Rooms", loadingOverlay, this); } }
void CheckUpgradeGame() { EventDispatcher.Instance.Dispatch <string>(EventConstant.UPDATE_TIP, ""); EventDispatcher.Instance.Dispatch <string, Action>(EventConstant.SHOW_ALERT, "需要更新到最新版本才能进入游戏,点击下载!", delegate() { CheckUpgradeGame(); #if UNITY_IOS IOSUtil.GotoAppStore(); #elif UNITY_ANDROID AndroidJavaClassUtil.Call("DownLoadAPK", sLastConfig.GetValue("game", "apk")); #endif }); }
public static int OpenPhoto(IntPtr L) { int count = LuaDLL.lua_gettop(L); const int nRet = 0; #if UNITY_ANDROID AndroidUtil.OpenPhoto(); #elif UNITY_IPHONE IOSUtil.iosOpenPhotoAlbums(false); #elif UNITY_STANDALONE_WIN OpenFileName.OpenPhoto(); #endif return(GameUtilWrap.CheckReturnNum(L, count, nRet)); }
private async void GetCurrentUserResponse(HttpResponseMessage responseUser) { if (responseUser != null && responseUser.StatusCode == System.Net.HttpStatusCode.OK && responseUser.Content != null) { string strContent = await responseUser.Content.ReadAsStringAsync(); UserDetails user = JsonConvert.DeserializeObject <UserDetails>(strContent); PreferenceHandler.SaveUserDetails(user); ShowDashboard(user); } else { IOSUtil.ShowMessage("User details not found", loadingOverlay, this); } }
// UDID public static string GetOpenUDID() { string udid = string.Empty; #if UNITY_IOS udid = IOSUtil.iosGetOpenUDID(); #elif UNITY_ANDROID udid = AndroidUtil.GetOpenUDID(); #endif if (string.IsNullOrEmpty(udid)) { udid = SystemInfo.deviceUniqueIdentifier; } return(udid); }
public static string GetLastPlatformName() { #if UNITY_IOS && !UNITY_EDITOR string customPlatform = IOSUtil.GetCustomPlatform(); if (customPlatform.Length > 0) { return(customPlatform); } #endif TextAsset textAsset = Resources.Load("Platform/config") as TextAsset; string name = textAsset.text.Trim(); Resources.UnloadAsset(textAsset); return(name); }
private void BtnSubmit_TouchUpInside(object sender, EventArgs e) { // Added for showing loading screen var bounds = UIScreen.MainScreen.Bounds; // show the loading overlay on the UI thread using the correct orientation sizing loadingOverlay = new LoadingOverlay(bounds); View.Add(loadingOverlay); if (SelectedAnswer > 0) { submitFeedback(userdetail.UserId); } else { IOSUtil.ShowMessage("Please select an option", loadingOverlay, this); } }
private async void GetInsightDataResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == System.Net.HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); InsightDataModel response = JsonConvert.DeserializeObject <InsightDataModel>(strContent); GenerateInsightsHeader(response); } else if (restResponse.StatusCode == HttpStatusCode.Unauthorized) { await IOSUtil.RefreshToken(this, loadingOverlay); } else { HideOverlay(); } }
private async void getQuestionListResponse(HttpResponseMessage restResponse) { if (restResponse != null && restResponse.StatusCode == HttpStatusCode.OK && restResponse.Content != null) { string strContent = await restResponse.Content.ReadAsStringAsync(); JArray array = JArray.Parse(strContent); questionList = array.ToObject <List <QuestionModel> >(); } else if (restResponse.StatusCode == System.Net.HttpStatusCode.Unauthorized) { await IOSUtil.RefreshToken(this, loadingOverlay); //await GetQuestionList(); } else { IOSUtil.ShowAlert("Error Occured"); } }
private void WebView_LoadError(object sender, UIWebErrorArgs e) { var URL = (NSObject)e.Error.UserInfo.Values[2]; string req = URL.ToString(); if (req.Contains("id_token=")) { string token = Common.FunGetValuefromQueryString(req, "id_token"); PreferenceHandler.SetToken(token); } else { IOSUtil.ShowAlert("Failed to change password.Please try again later."); } var ViewController = (ViewController)Storyboard.InstantiateViewController("ViewController"); ViewController.NavigationItem.SetHidesBackButton(true, false); NavController.PushViewController(ViewController, false); SidebarController.MenuWidth = 0; SidebarController.CloseMenu(); }
public void InitIPAndPort(string ip, int port) { mIP = ip; mPort = port; #if UNITY_IOS && !UNITY_EDITOR string IPv6 = IOSUtil.GetIPv6(ip); string[] ipList = IPv6.Split('&'); mIP = ipList[0]; if (ipList[1] == "ipv6") { mAddressFamily = AddressFamily.InterNetworkV6; } #endif mHasConnectSuccess = false; SetConnectStatus(NetStatus.reconnect, "InitIPAndPort"); }