private void callOnGlobalLayout(Crouton crouton, View croutonView) { var layoutListener = new GlobalLayoutListener(); layoutListener.OnGlobalLayout(delegate { if (Build.VERSION.SdkInt < BuildVersionCodes.JellyBean) { #pragma warning disable 618 croutonView?.ViewTreeObserver?.RemoveGlobalOnLayoutListener(layoutListener); #pragma warning restore 618 } else { croutonView?.ViewTreeObserver?.RemoveOnGlobalLayoutListener(layoutListener); } if (crouton.GetInAnimation() == null) { return; } croutonView?.StartAnimation(crouton.GetInAnimation()); AnnounceForAccessibilityCompat(crouton.GetActivity(), crouton.DataContext?.ToString() ?? "NULL"); sendMessageDelayed(crouton, REMOVE_CROUTON, crouton.DurationInMilliseconds + crouton.GetInAnimation().Duration); }); }
private static async Task LoadAsync(this ImageView imageView, Options options) { if (imageView.Width == 0 || imageView.Height == 0) { try { var globalLisener = new GlobalLayoutListener(imageView, true); EventHandler handler = null; handler = async(s, e) => { globalLisener.GlobalLayout -= handler; handler = null; globalLisener = null; SetSize(options, imageView); imageView.SetImageBitmap(await DecodeBitmap(options)); }; globalLisener.GlobalLayout += handler; } catch (Exception ex) { Console.WriteLine(ex.Message); } return; } SetSize(options, imageView); imageView.SetImageBitmap(await DecodeBitmap(options)); }
public static void OnLayout(this View view, Action action) { var layoutLisener = new GlobalLayoutListener(view, true); layoutLisener.GlobalLayout += (sender, e) => { action?.Invoke(); layoutLisener = null; }; }
protected void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); this.SetContentView(Resource.Layout.inbox); actionBar = SupportActionBar; ConfigureActionBar(); this.richPushInbox = RichPushManager.Shared().RichPushUser.Inbox; // Set up the inbox fragment this.inbox = (InboxFragment)this.SupportFragmentManager.FindFragmentById(Resource.Id.inbox); this.inbox.ListView.ChoiceMode = ChoiceMode.Single; this.inbox.ListView.SetBackgroundColor(Color.Black); // Set up the message view pager if it exists this.messagePager = (CustomViewPager)this.FindViewById(Resource.Id.message_pager); if (messagePager != null) { messagePager.Adapter = new MessageFragmentAdapter(this.SupportFragmentManager); this.messagePager.PageSelected += (sender, e) => { int position = e.P0; messages [position].MarkRead(); // Highlight the current item you are viewing in the inbox inbox.ListView.SetItemChecked(position, true); // If we are in actionMode, update the menu items if (actionMode != null) { actionMode.Invalidate(); } }; } slidingPaneLayout = (CustomSlidingPaneLayout)FindViewById(Resource.Id.sliding_pane_layout); if (slidingPaneLayout != null) { slidingPaneLayout.SetPanelSlideListener(this); slidingPaneLayout.OpenPane(); GlobalLayoutListener l = null; l = new GlobalLayoutListener(() => { // If sliding pane layout is slidable, set the actionbar to have an up action actionBar.SetDisplayHomeAsUpEnabled(slidingPaneLayout.IsSlideable); slidingPaneLayout.ViewTreeObserver.RemoveGlobalOnLayoutListener(l); }); slidingPaneLayout.ViewTreeObserver.AddOnGlobalLayoutListener(l); } // First create, try to show any messages from the intent if (savedInstanceState == null) { this.SetPendingMessageIdFromIntent(Intent); } }
public GlobalLayoutProvider(Activity activity, GlobalLayoutListener listener) : base(activity) { this._activity = activity; this._listener = listener; ContentView = new LinearLayout(_activity.BaseContext) { LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent) }; Width = 0; // this make sure we don't block touch events Height = ViewGroup.LayoutParams.MatchParent; SetBackgroundDrawable(new ColorDrawable(Color.Transparent)); }
public void OnMapReady(GoogleMap map) { mMap = map; // Hide the zoom controls as the button panel will cover it. mMap.UiSettings.ZoomControlsEnabled = false; // Add lots of markers to the map. AddMarkersToMap(); // Setting an info window adapter allows us to change the both the contents and look of the // info window. mMap.SetInfoWindowAdapter(new CustomInfoWindowAdapter(this)); // Set listeners for marker events. See the bottom of this class for their behavior. mMap.SetOnMarkerClickListener(this); mMap.SetOnInfoWindowClickListener(this); mMap.SetOnMarkerDragListener(this); // Pan to see all markers in view. // Cannot zoom to bounds until the map has a size. View mapView = SupportFragmentManager.FindFragmentById(Resource.Id.map).View; if (mapView.ViewTreeObserver.IsAlive) { GlobalLayoutListener gll = null; gll = new GlobalLayoutListener( delegate { LatLngBounds bounds = new LatLngBounds.Builder() .Include(PERTH) .Include(SYDNEY) .Include(ADELAIDE) .Include(BRISBANE) .Include(MELBOURNE) .Build(); /*if (Build.VERSION.SdkInt < Build.VERSION_CODES.JellyBean)*/ { mapView.ViewTreeObserver.RemoveGlobalOnLayoutListener(gll); } /* else { * mapView.ViewTreeObserver.RemoveOnGlobalLayoutListener (this); * }*/ mMap.MoveCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 50)); }); mapView.ViewTreeObserver.AddOnGlobalLayoutListener(gll); } }
public static void ImageLoaderAsync(this ImageLoader view, string path) { if (!File.Exists(path)) { view.SetImageBitmap(null); return; } if (view.Height > 0 && view.Width > 0) { view.SetImageBitmap(DecodeFromFile(path, view.Width, view.Height)); return; } var lisener = new GlobalLayoutListener(view, true); view.ShowLoading(true); lisener.GlobalLayout += async(sender, e) => view.SetImageBitmap( await DecodeFromFileAsync(path, view.Width, view.Height)); }
/** * @param blurView View which will draw it's blurred underlying content * @param rootView Root View where blurView's underlying content starts drawing. * Can be Activity's root content layout (android.R.id.content) * or some of your custom root layouts. */ public BlockingBlurController(Context context, View blurView, ViewGroup rootView, int overlayColor = TRANSPARENT) { this.rootView = rootView; this.blurView = blurView; this.overlayColor = overlayColor; this.blurAlgorithm = new RenderScriptBlur(context); int measuredWidth = blurView.MeasuredWidth; int measuredHeight = blurView.MeasuredHeight; _preDrawListener = new PreDrawListener(this); _globalLayoutListener = new GlobalLayoutListener(this); if (IsZeroSized(measuredWidth, measuredHeight)) { DeferBitmapCreation(); return; } Init(measuredWidth, measuredHeight); }
private void CallOnGlobalLayout(Crouton crouton, View croutonView) { var layoutListener = new GlobalLayoutListener(); layoutListener.OnGlobalLayout(delegate { if (Build.VERSION.SdkInt < Build.VERSION_CODES.JellyBean) { croutonView.ViewTreeObserver.RemoveGlobalOnLayoutListener(layoutListener); } else { croutonView.ViewTreeObserver.RemoveOnGlobalLayoutListener(layoutListener); } if (crouton.GetInAnimation() != null) { croutonView.StartAnimation(crouton.GetInAnimation()); AnnounceForAccessibilityCompat(crouton.GetActivity(), crouton.DataContext == null ? "NULL" : crouton.DataContext.ToString()); SendMessageDelayed(crouton, REMOVE_CROUTON, crouton.DurationInMilliseconds + crouton.GetInAnimation().Duration); } }); }
private void SetUpMap() { // Hide the zoom controls as the button panel will cover it. mMap.UiSettings.ZoomControlsEnabled = false; // Add lots of markers to the map. AddMarkersToMap(); // Setting an info window adapter allows us to change the both the contents and look of the // info window. mMap.SetInfoWindowAdapter (new CustomInfoWindowAdapter (this)); // Set listeners for marker events. See the bottom of this class for their behavior. mMap.SetOnMarkerClickListener(this); mMap.SetOnInfoWindowClickListener(this); mMap.SetOnMarkerDragListener(this); // Pan to see all markers in view. // Cannot zoom to bounds until the map has a size. View mapView = SupportFragmentManager.FindFragmentById (Resource.Id.map).View; if (mapView.ViewTreeObserver.IsAlive) { GlobalLayoutListener gll = null; gll = new GlobalLayoutListener ( delegate { LatLngBounds bounds = new LatLngBounds.Builder() .Include(PERTH) .Include(SYDNEY) .Include(ADELAIDE) .Include(BRISBANE) .Include(MELBOURNE) .Build (); /*if (Build.VERSION.SdkInt < Build.VERSION_CODES.JellyBean)*/ { mapView.ViewTreeObserver.RemoveGlobalOnLayoutListener (gll); } /* else { mapView.ViewTreeObserver.RemoveOnGlobalLayoutListener (this); }*/ mMap.MoveCamera (CameraUpdateFactory.NewLatLngBounds (bounds, 50)); }); mapView.ViewTreeObserver.AddOnGlobalLayoutListener (gll); } }
protected void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); this.SetContentView (Resource.Layout.inbox); actionBar = SupportActionBar; ConfigureActionBar (); this.richPushInbox = RichPushManager.Shared ().RichPushUser.Inbox; // Set up the inbox fragment this.inbox = (InboxFragment)this.SupportFragmentManager.FindFragmentById (Resource.Id.inbox); this.inbox.ListView.ChoiceMode = ChoiceMode.Single; this.inbox.ListView.SetBackgroundColor (Color.Black); // Set up the message view pager if it exists this.messagePager = (CustomViewPager)this.FindViewById (Resource.Id.message_pager); if (messagePager != null) { messagePager.Adapter = new MessageFragmentAdapter (this.SupportFragmentManager); this.messagePager.PageSelected += (sender, e) => { int position = e.P0; messages [position].MarkRead (); // Highlight the current item you are viewing in the inbox inbox.ListView.SetItemChecked (position, true); // If we are in actionMode, update the menu items if (actionMode != null) { actionMode.Invalidate (); } }; } slidingPaneLayout = (CustomSlidingPaneLayout)FindViewById (Resource.Id.sliding_pane_layout); if (slidingPaneLayout != null) { slidingPaneLayout.SetPanelSlideListener (this); slidingPaneLayout.OpenPane (); GlobalLayoutListener l = null; l = new GlobalLayoutListener (() => { // If sliding pane layout is slidable, set the actionbar to have an up action actionBar.SetDisplayHomeAsUpEnabled (slidingPaneLayout.IsSlideable); slidingPaneLayout.ViewTreeObserver.RemoveGlobalOnLayoutListener (l); }); slidingPaneLayout.ViewTreeObserver.AddOnGlobalLayoutListener (l); } // First create, try to show any messages from the intent if (savedInstanceState == null) { this.SetPendingMessageIdFromIntent (Intent); } }
private void Init() { #if _TRIAL_ try { interstitialAds = new InterstitialAd(this); // initializing interstitial ads mAdView.Visibility = ViewStates.Visible; var adRequest = new Android.Gms.Ads.AdRequest.Builder(); #if DEBUG adRequest.AddTestDevice(Android.Gms.Ads.AdRequest.DeviceIdEmulator); //"TEST_EMULATOR" #endif var build = adRequest.Build(); mAdView.LoadAd(build); #if DEBUG //Test interstitialAds.AdUnitId = "ca-app-pub-3940256099942544/1033173712"; #else interstitialAds.AdUnitId = Resources.GetString(Resource.String.adMob_api_interstitial_key); #endif // loading test ad using adrequest interstitialAds.LoadAd(build); var ThisAdListener = new BigDays.AdListener(this); interstitialAds.AdListener = ThisAdListener; ThisAdListener.AdLoaded += () => { _trialImg.Visibility = ViewStates.Invisible; mAdView.Visibility = ViewStates.Visible; }; } catch { } #endif #if _TRIAL_ _trialImg.Visibility = ViewStates.Visible; _shopping.Visibility = ViewStates.Visible; Intent browserIntent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(Constants.VersionLink)); _trialImg.Click += (sender, e) => { StartActivity(browserIntent); }; _shopping.Click += (sender, e) => { StartActivity(browserIntent); }; #else _trialImg.Visibility = ViewStates.Gone; _shopping.Visibility = ViewStates.Gone; #endif long max_memory = Runtime.GetRuntime().MaxMemory(); long total_memory = Runtime.GetRuntime().TotalMemory(); _BDDB = new DataService(); _BDDB.ConnectToDB("BigDaysNew.db3"); _BDDB.CreateTable(); _BDDB.CheckRepeats(); _BDitems = _BDDB.SelectBDItems(); _ActiveBD = _BDitems.FirstOrDefault(x => x._Active == true); if (_ActiveBD == null) { _ActiveBD = _BDitems.FirstOrDefault(); } var Display = WindowManager.DefaultDisplay; _DisplayHeight = Display.Height; _DisplayWidth = Display.Width; _infoBoxControl.SetOnTouchListener(this); GlobalLayoutListener l = null; l = new GlobalLayoutListener(() => { if (_FirstAppOpen == 0) { RelativeLayout.LayoutParams infoBoxParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent - 30, ViewGroup.LayoutParams.WrapContent); infoBoxParams.LeftMargin = _ActiveBD._PosLeft; infoBoxParams.TopMargin = _ActiveBD._PosTop; if (_ActiveBD._ChangePos) { _infoBoxControl.LayoutParameters = infoBoxParams; } else { RelativeLayout.LayoutParams infoBoxParamsDef = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent - 30, ViewGroup.LayoutParams.WrapContent); infoBoxParamsDef.LeftMargin = 0; infoBoxParamsDef.AddRule(LayoutRules.CenterVertical); _infoBoxControl.LayoutParameters = infoBoxParamsDef; } _FirstAppOpen = 1; } _infoBoxControl.ViewTreeObserver.RemoveGlobalOnLayoutListener(l); }); _infoBoxControl.ViewTreeObserver.AddOnGlobalLayoutListener(l); int _ItemID = Intent.GetIntExtra("ItemID", 0); if (_BDitems.Count > 0) { BitmapHelpers.LoadImages(this, _BDitems); _CurrentItem = _BDDB.GetCurrentItem(); if (_ItemID != 0) { _CurrentItem._ID = _ItemID; } var currentItem = _BDitems.FirstOrDefault(n => n._ID == _CurrentItem._ID); if (currentItem != null) { ShowImage(currentItem); } _infoBoxControl.Visibility = ViewStates.Visible; } else { ShowDefImage(); _infoBoxControl.Visibility = ViewStates.Gone; } if (_infoBoxControl.Visibility != ViewStates.Gone) { _infoBoxControl.Title = _CurrentItem._Name; } var ui_showListButton = FindViewById <ImageButton>(Resource.Id.showListButton); ui_showListButton.Click += (sender, e) => { var IntentListActivity = new Intent(this, typeof(ListActivity)); StartActivityForResult(IntentListActivity, (int)BigDays.Enums.RequestCode.List_BigDays); }; var ui_addBigDaysBtn = FindViewById <ImageButton>(Resource.Id.mainAddBigDays); ui_addBigDaysBtn.Click += (sender, e) => { #if _TRIAL_ if (_BDitems.Count == 1) { AlertDialog.Builder builder; builder = new AlertDialog.Builder(this); builder.SetTitle("Free Version"); builder.SetMessage("You can add only 1 Big Day item in free version. Please purchase full version to enable adding unlimited Big Days items and Facebook share function.\n\nBy clicking \"Buy Now\" you will redirect to Full version (no ad banner) purchase page."); builder.SetCancelable(false); builder.SetPositiveButton("Buy Now", delegate { StartActivity(browserIntent); }); builder.SetNegativeButton("Continue", delegate { }); builder.Show(); } else { var IntentNewBigDaysActivity = new Intent(this, typeof(NewBigDays)); StartActivityForResult(IntentNewBigDaysActivity, (int)Enums.RequestCode.AddNew_BigDay); } #else var IntentNewBigDaysActivity = new Intent(this, typeof(NewBigDays)); StartActivityForResult(IntentNewBigDaysActivity, (int)BigDays.Enums.RequestCode.AddNew_BigDay); #endif }; var ui_Feedback = FindViewById <ImageButton>(Resource.Id.Feedback); ui_Feedback.Click += (sender, e) => { var IntentFeedbackActivity = new Intent(this, typeof(Feedback)); StartActivity(IntentFeedbackActivity); }; _infoBoxControl.EditBigDaysBtn.Click += (sender, e) => { var IntentNewBigDaysActivity = new Intent(this, typeof(NewBigDays)); IntentNewBigDaysActivity.PutExtra("Edit", true); IntentNewBigDaysActivity.PutExtra("ID", _CurrentItem._ID); StartActivityForResult(IntentNewBigDaysActivity, (int)BigDays.Enums.RequestCode.Edit_BigDay); }; _infoBoxControl.ShareBigDaysBtn.Click += (sender, e) => { var IntentShareActivity = new Intent(this, typeof(Share)); IntentShareActivity.PutExtra("ID", _CurrentItem._ID); StartActivity(IntentShareActivity); }; if (_infoBoxControl.Visibility != ViewStates.Gone) { if (_ActiveBD._ChangePos) { RelativeLayout.LayoutParams infoBoxParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent - 30, ViewGroup.LayoutParams.WrapContent); infoBoxParams.LeftMargin = _ActiveBD._PosLeft; infoBoxParams.TopMargin = _ActiveBD._PosTop; _infoBoxControl.LayoutParameters = infoBoxParams; } else { RelativeLayout.LayoutParams infoBoxParamsDef = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent - 30, ViewGroup.LayoutParams.WrapContent); infoBoxParamsDef.LeftMargin = 0; infoBoxParamsDef.AddRule(LayoutRules.CenterVertical); _infoBoxControl.LayoutParameters = infoBoxParamsDef; } } _TimerHandler = new Handler(); UpdateGeneration(); }