This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void PauseAnimation() | |
| { | |
| var pausedTime = Layer.ConvertTimeFromLayer(CAAnimation.CurrentMediaTime(), null); | |
| Layer.Speed = 0.0f; | |
| Layer.TimeOffset = pausedTime; | |
| } | |
| void ResumeAnimation() | |
| { | |
| var pausedTime = Layer.TimeOffset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // first, separate your drawing code from your animation code. | |
| // this way you can call animations without instantiating new objects | |
| func drawLine() { | |
| let path = UIBezierPath() | |
| // draw your path with no position translation.. move the layer | |
| path.moveToPoint(CGPointMake(view.bounds.width, 0)) | |
| path.addLineToPoint(CGPointMake(0, 0)) | |
| pathLayer.frame = path.bounds | |
| // this line sets the position of the layer appropriately | |
| pathLayer.position = view.bounds.width - pathLayer.bounds.width / 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public DateTime ConvertNsDateToDateTime(NSDate date) | |
| { | |
| DateTime newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); | |
| return newDate.AddSeconds(date.SecondsSinceReferenceDate); | |
| } | |
| public NSDate ConvertDateTimeToNSDate(DateTime date) | |
| { | |
| DateTime newDate = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0)); | |
| return NSDate.FromTimeIntervalSinceReferenceDate((date - newDate).TotalSeconds); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // -------------------------------------- | |
| // ANDROID | |
| // -------------------------------------- | |
| var id = Android.OS.Build.Serial; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CrossConnectivity.Current.ConnectivityChanged += async (sender, args) => | |
| { | |
| try | |
| { | |
| GlobalVariables.Instance.IsNetworkReachable = args.IsConnected; | |
| if (GlobalVariables.Instance.IsNetworkReachable) | |
| { | |
| // stuff here that needs to be done when connectivity restored | |
| // (e.g. updating list of purchases for in-app purchases/billing | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Android | |
| Vibrator vibrator = (Vibrator) this.ApplicationContext.GetSystemService(Context.VibratorService); | |
| // iOS | |
| SystemSound.Vibrate.PlayAlertSound(); | |
| // Windows Phone | |
| VibrateController testVibrateController = VibrateController.Default; | |
| vibrate.Start(TimeSpan.FromMilliseconds(1000)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // listen to keyboards events | |
| NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, OnKeyboardNotification); | |
| NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, OnKeyboardNotification); | |
| // reposition the view | |
| void OnKeyboardNotification(NSNotification notification) { | |
| var visible = notification.Name == UIKeyboard.WillShowNotification; | |
| var location = _origin.Location; | |
| if (visible) { | |
| var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var refreshControl: UIRefreshControl! | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| refreshControl = UIRefreshControl() | |
| refreshControl.attributedTitle = NSAttributedString(string: "Pull to refresh") | |
| refreshControl.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged) | |
| tableView.addSubview(refreshControl) // not required when using UITableViewController | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var typeInfo = GetType ().GetTypeInfo (); | |
| var myAttr = typeInfo.CustomAttributes.FirstOrDefault (_ => _.AttributeType == typeof (MyAttribute)); | |
| Value = myAttr?.ConstructorArguments.First ().Value as string; |