Exemplo n.º 1
0
 public void ClearItems()
 {
     CoreUtility.ExecuteMethod("ClearItems", delegate()
     {
         this.Items.Clear();
     });
 }
Exemplo n.º 2
0
        public override void OnMessageReceived(RemoteMessage message)
        {
            CoreUtility.ExecuteMethod("OnMessageReceived", delegate()
            {
                // Shape like previous version of GCM for ease
                Bundle messageIntent = new Bundle();
                if (message.Data != null)
                {
                    foreach (string key in message.Data.Keys)
                    {
                        messageIntent.PutString(key, message.Data[key]);
                    }
                }

                PushNotification notification = PushNotificationProcessor.ExtractPushNotification(messageIntent);
                if (notification != null)
                {
                    notification.Alert += "!";
                    v7.NotificationCompat.Builder builder = PushNotificationProcessor.GenerateNotification(this, notification, messageIntent);
                    if (builder != null)
                    {
                        int uniqueID = (int)DateTime.UtcNow.ToUnixSeconds(); // will work until 2038
                        NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
                        notificationManager.Notify(uniqueID, builder.Build());
                    }
                }
            });
        }
Exemplo n.º 3
0
 public static void SetStyleSpan(this SpannableString spannableString, string allText, string styleText, TypefaceStyle style, Color textColor, Typeface typeFace = null, float typeFaceSize = 0)
 {
     CoreUtility.ExecuteMethod("SetStyleSpan", delegate()
     {
         int ix = allText.IndexOf(styleText);
         while (ix >= 0)
         {
             spannableString.SetSpan(new StyleSpan(style), ix, ix + styleText.Length, SpanTypes.ExclusiveExclusive);
             if (textColor != Color.Transparent)
             {
                 spannableString.SetSpan(new ForegroundColorSpan(textColor), ix, ix + styleText.Length, SpanTypes.ExclusiveExclusive);
             }
             if (typeFace != null)
             {
                 spannableString.SetSpan(new CustomTypefaceSpan(typeFace, typeFaceSize), ix, ix + styleText.Length, SpanTypes.ExclusiveExclusive);
             }
             int nextIndex = allText.Substring(ix + styleText.Length).IndexOf(styleText);
             if (nextIndex >= 0)
             {
                 ix = nextIndex + (ix + styleText.Length);
             }
             else
             {
                 ix = -1; // break out
             }
         }
     });
 }
Exemplo n.º 4
0
 public void OnScrollStateChanged(AbsListView listView, ScrollState scrollState)
 {
     CoreUtility.ExecuteMethod("OnScrollStateChanged", delegate()
     {
         if (this.ViewModel != null)
         {
             if (this.ViewModel.HasMoreData)
             {
                 if (listView.LastVisiblePosition >= listView.Count - 1 - this.ViewModel.ScrollThresholdCount)
                 {
                     Container.Track.LogTrace("Getting more data");
                     this.ViewModel.DoGetMoreData(); // it has its own built-in skip mechanism
                 }
             }
             int topRowVerticalPosition = 0;
             if (this.ListView != null && this.ListView.ChildCount > 0)
             {
                 topRowVerticalPosition = this.ListView.GetChildAt(0).Top;
             }
             if (this.RefreshLayout != null)
             {
                 this.RefreshLayout.Enabled = (topRowVerticalPosition >= 0);
             }
         }
     });
 }
Exemplo n.º 5
0
 public void RecentSet(BaseUIViewController controller)
 {
     CoreUtility.ExecuteMethod("RecentClearIfMatch", delegate()
     {
         RecentController = controller;
     });
 }
Exemplo n.º 6
0
        private void init(Context context, IAttributeSet attrs)
        {
            CoreUtility.ExecuteMethod("init", delegate()
            {
                mGestureListener    = new CustomGestureListener(this);
                mDragHelperCallback = new CustomViewDragHelper(this);

                if (attrs != null && context != null)
                {
                    TypedArray a = context.Theme.ObtainStyledAttributes(
                        attrs,
                        Resource.Styleable.SwipeRevealLayout,
                        0, 0
                        );

                    mDragEdge         = a.GetInteger(Resource.Styleable.SwipeRevealLayout_dragEdge, DRAG_EDGE_LEFT);
                    mMinFlingVelocity = a.GetInteger(Resource.Styleable.SwipeRevealLayout_flingVelocity, DEFAULT_MIN_FLING_VELOCITY);
                    mMode             = a.GetInteger(Resource.Styleable.SwipeRevealLayout_mode, MODE_NORMAL);

                    mMinDistRequestDisallowParent = a.GetDimensionPixelSize(
                        Resource.Styleable.SwipeRevealLayout_minDistRequestDisallowParent,
                        dpToPx(DEFAULT_MIN_DIST_REQUEST_DISALLOW_PARENT)
                        );
                }

                mDragHelper = ViewDragHelper.Create(this, 1.0f, mDragHelperCallback);
                mDragHelper.SetEdgeTrackingEnabled(ViewDragHelper.EdgeAll);

                mGestureDetector = new GestureDetectorCompat(context, mGestureListener);
            });
        }
Exemplo n.º 7
0
 public override void DidRegisterUserNotificationSettings(UIApplication application, UIUserNotificationSettings notificationSettings)
 {
     CoreUtility.ExecuteMethod("DidRegisterUserNotificationSettings", delegate()
     {
         application.RegisterForRemoteNotifications(); // second part, first from viewplatform
     });
 }
Exemplo n.º 8
0
        public static void AddUrlsForText(this NSMutableAttributedString attributedString, UIFont font, UIColor linkColor, string allText, string linkText, string destinationUrl)
        {
            CoreUtility.ExecuteMethod("AddUrlsForText", delegate()
            {
                int ix = allText.IndexOf(linkText, StringComparison.OrdinalIgnoreCase);
                while (ix >= 0)
                {
                    NSRange foundRange = new NSRange(ix, linkText.Length);

                    if (foundRange.Location >= 0)
                    {
                        attributedString.SetAttributes(new UIStringAttributes()
                        {
                            Font            = font,
                            ForegroundColor = linkColor
                        }, foundRange);

                        attributedString.AddAttribute(new NSString("handle"), new NSString(destinationUrl), foundRange);
                    }
                    int nextIX = allText.Substring(ix + linkText.Length).IndexOf(linkText, StringComparison.OrdinalIgnoreCase);
                    if (nextIX >= 0)
                    {
                        ix = ix + linkText.Length + nextIX;
                    }
                    else
                    {
                        ix = -1;
                    }
                }
            });
        }
Exemplo n.º 9
0
 public static void ExecuteMethodOnMainThread(this Activity activity, string name, Action method)
 {
     activity.RunOnUiThread(delegate()
     {
         CoreUtility.ExecuteMethod(name, method);
     });
 }
Exemplo n.º 10
0
 protected virtual void InitializeEnvironment()
 {
     CoreUtility.ExecuteMethod("InitializeEnvironment", delegate()
     {
         // nothing yet
     });
 }
Exemplo n.º 11
0
 public static void SetClickableSpan(this SpannableString spannableString, string allText, string clickableText, Action <CoreClickableSpan, View> onClick, string argument, Color?textColor = null, bool hideUnderline = false)
 {
     CoreUtility.ExecuteMethod("SetClickableSpan", delegate()
     {
         if (!textColor.HasValue)
         {
             textColor = Color.Black;
         }
         int ix = allText.IndexOf(clickableText);
         CoreClickableSpan clickableSpan = new CoreClickableSpan(onClick, argument, clickableText);
         clickableSpan.HideUnderline     = hideUnderline;
         while (ix >= 0)
         {
             spannableString.SetSpan(clickableSpan, ix, ix + clickableText.Length, SpanTypes.ExclusiveExclusive);
             spannableString.SetSpan(new StyleSpan(Android.Graphics.TypefaceStyle.Bold), ix, ix + clickableText.Length, SpanTypes.ExclusiveExclusive);
             spannableString.SetSpan(new ForegroundColorSpan(textColor.Value), ix, ix + clickableText.Length, SpanTypes.ExclusiveExclusive);
             int nextIndex = allText.Substring(ix + clickableText.Length).IndexOf(clickableText);
             if (nextIndex >= 0)
             {
                 ix = nextIndex + (ix + clickableText.Length);
             }
             else
             {
                 ix = -1; // break out
             }
         }
     });
 }
Exemplo n.º 12
0
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     CoreUtility.ExecuteMethod("RowSelected", delegate()
     {
         UITableViewCell cell = tableView.CellAt(indexPath);
         if (this.OnSelectedMethodRaw != null)
         {
             if (!this.DisableRowDeselection)
             {
                 tableView.DeselectRow(indexPath, true); // iOS convention is to remove the highlight
             }
             if (this.OnSelectedMethodRaw != null)
             {
                 this.OnSelectedMethodRaw(indexPath, cell);
             }
         }
         else
         {
             TItem info = this.GetItem(indexPath.Row);
             if (!this.DisableRowDeselection)
             {
                 tableView.DeselectRow(indexPath, true); // iOS convention is to remove the highlight
             }
             if (this.OnSelectedMethod != null)
             {
                 this.OnSelectedMethod(info, cell);
             }
         }
     });
 }
Exemplo n.º 13
0
 protected virtual void InitializeEnvironment()
 {
     CoreUtility.ExecuteMethod("InitializeEnvironment", delegate()
     {
         //TODO:COULD: Any 3rd party bootstrap-like settings
     });
 }
Exemplo n.º 14
0
 public override void ReceiveMemoryWarning(UIApplication application)
 {
     CoreUtility.ExecuteMethod("ReceiveMemoryWarning", delegate()
     {
         Container.Track.LogWarning("ReceivedMemoryWarning");
         Container.ViewPlatform.OnMemoryWarning();
     });
 }
Exemplo n.º 15
0
 protected override void OnAppearing()
 {
     CoreUtility.ExecuteMethod("OnAppearing", delegate()
     {
         base.OnAppearing();
         NavigationPage.SetHasNavigationBar(this, false);
     });
 }
Exemplo n.º 16
0
 protected void OnPickerItemSelected(UIPickerView picker, nint row, nint component, IDPair selectedItem)
 {
     CoreUtility.ExecuteMethod("OnPickerItemSelected", delegate()
     {
         UIView selectedView          = picker.ViewFor(row, component);
         selectedView.BackgroundColor = _colorOfSelectedItem;
     });
 }
Exemplo n.º 17
0
        public override void OnCreate()
        {
            CoreUtility.ExecuteMethod("EscapeApplication.OnCreate", delegate()
            {
                base.OnCreate();

                this.InitializeEnvironment();
            });
        }
Exemplo n.º 18
0
        public override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            CoreUtility.ExecuteMethod("RegisteredForRemoteNotifications", delegate()
            {
                this.DeviceToken = deviceToken;

                Container.StencilApp.PersistPushNotificationToken(deviceToken.ToString());
            });
        }
Exemplo n.º 19
0
 protected void ProcessNotification(UIApplication application, NSDictionary userInfo, Action <UIBackgroundFetchResult> completionHandler)
 {
     CoreUtility.ExecuteMethod("ProcessNotification", delegate()
     {
         bool fromBackground = (application.ApplicationState == UIApplicationState.Inactive || application.ApplicationState == UIApplicationState.Background);
         PushNotificationProcessor processor = new PushNotificationProcessor(this);
         processor.ProcessRemotePushNotification(userInfo, fromBackground, completionHandler);
     });
 }
Exemplo n.º 20
0
 protected void Self_RefreshRequested(object sender, EventArgs e)
 {
     CoreUtility.ExecuteMethod("Self_RefreshRequested", delegate()
     {
         if (OnRefreshRequested != null)
         {
             this.OnRefreshRequested();
         }
     });
 }
Exemplo n.º 21
0
 public virtual void AppendItems(IEnumerable <TItem> items)
 {
     CoreUtility.ExecuteMethod("AppendItems", delegate()
     {
         foreach (var item in items)
         {
             this.Items.Add(item);
         }
     });
 }
Exemplo n.º 22
0
 public void RecentClearIfMatch(BaseUIViewController controller)
 {
     CoreUtility.ExecuteMethod("RecentClearIfMatch", delegate()
     {
         if (RecentController == controller)
         {
             RecentController = null;
         }
     });
 }
 public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
 {
     CoreUtility.ExecuteMethod("RowSelected", delegate()
     {
         if (selectedElementCallback != null)
         {
             selectedElementCallback(indexPath.Row);
         }
     });
 }
Exemplo n.º 24
0
 public virtual void LaunchMain(UIViewAnimationOptions transition = UIViewAnimationOptions.TransitionFlipFromLeft)
 {
     CoreUtility.ExecuteMethod("LaunchMain", delegate()
     {
         UIViewController firstController     = this.MainStoryboard.InstantiateViewController(MainController.IDENTIFIER);
         UINavigationController navController = new UINavigationController(firstController);
         navController.NavigationBarHidden    = true;
         this.ChangeRootViewController(navController, transition);
     });
 }
Exemplo n.º 25
0
 private void Initialize()
 {
     CoreUtility.ExecuteMethod("Initialize", delegate()
     {
         this.Refresh += Self_RefreshRequested;
         this.SetColorSchemeColors(Resource.Color.refresh_color1,
                                   Resource.Color.refresh_color2,
                                   Resource.Color.refresh_color3,
                                   Resource.Color.refresh_color4);
     });
 }
Exemplo n.º 26
0
 public static void RemoveRefreshControl(this UITableViewController tableViewController, UIRefreshControl control, EventHandler handler)
 {
     CoreUtility.ExecuteMethod("RemoveRefreshControl", delegate()
     {
         control.RemoveTarget(handler, UIControlEvent.ValueChanged);
         if (tableViewController.RefreshControl == control)
         {
             tableViewController.RefreshControl = null;
         }
     });
 }
Exemplo n.º 27
0
        public override void OnCreate()
        {
            CoreUtility.ExecuteMethod("StencilApplication.OnCreate", delegate()
            {
                base.OnCreate();

                this.InitializeEnvironment();

                Container.StencilApp.OnAppActivated();
            });
        }
Exemplo n.º 28
0
        public override void OnActivated(UIApplication application)
        {
            CoreUtility.ExecuteMethod("OnActivated", delegate()
            {
                // Restart any tasks that were paused (or not yet started) while the application was inactive.
                // If the application was previously in the background, optionally refresh the user interface.

                Container.Track.LogTrace("OnActivated");
                Container.StencilApp.OnAppActivated();
            });
        }
Exemplo n.º 29
0
 public virtual void ClearItems()
 {
     CoreUtility.ExecuteMethod("ClearItems", delegate()
     {
         if (this.Items == null)
         {
             return;
         }
         this.Items.Clear();
     });
 }
Exemplo n.º 30
0
 public virtual void EnqueueReusableCustomView(UIView view, string identifier)
 {
     CoreUtility.ExecuteMethod("EnqueueReusableCustomView", delegate()
     {
         if (!this.CachedCustomViews.ContainsKey(identifier))
         {
             this.CachedCustomViews[identifier] = new List <UIView>();
         }
         this.CachedCustomViews[identifier].Add(view);
     });
 }