public override void OnAttachedToWindow() { Window?.AddFlags(WindowManagerFlags.ShowWhenLocked | WindowManagerFlags.KeepScreenOn | WindowManagerFlags.DismissKeyguard | WindowManagerFlags.TurnScreenOn); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); Methods.App.FullScreenApp(this); Window?.AddFlags(WindowManagerFlags.KeepScreenOn); // Create your application here SetContentView(Resource.Layout.TwilioAudioCallActivityLayout); SensorManager = (SensorManager)GetSystemService(SensorService); Proximity = SensorManager?.GetDefaultSensor(SensorType.Proximity); GlobalContext = MsgTabbedMainActivity.GetInstance(); //Get Value And Set Toolbar InitComponent(); InitTwilioCall(); MsgTabbedMainActivity.RunCall = true; } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); View mContentView = Window?.DecorView; var uiOptions = (int)mContentView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.Fullscreen; newUiOptions |= (int)SystemUiFlags.HideNavigation; mContentView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window?.AddFlags(WindowManagerFlags.Fullscreen); //ScreenOrientation.Portrait >> Make to run your application only in portrait mode //ScreenOrientation.Landscape >> Make to run your application only in LANDSCAPE mode RequestedOrientation = ScreenOrientation.Landscape; // Create your application here SetContentView(Resource.Layout.LocalWebViewLayout); //Get Value And Set Toolbar InitComponent(); InitToolbar(); SetWebView(); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; CrossCurrentActivity.Current.Init(this, savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Window?.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); // https://devblogs.microsoft.com/xamarin/persisting-settings-preferences-mobile-apps-xamarin-essentials/ Rg.Plugins.Popup.Popup.Init(this); // https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started // Remove the status bar and icons from top of screen Window?.AddFlags(WindowManagerFlags.Fullscreen); Window?.ClearFlags(WindowManagerFlags.ForceNotFullscreen); Xamarin.Forms.Forms.Init(this, savedInstanceState); Android: OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); // Create your application here //Set Full screen View mContentView = Window?.DecorView; var uiOptions = (int)mContentView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.Fullscreen; newUiOptions |= (int)SystemUiFlags.HideNavigation; mContentView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window?.AddFlags(WindowManagerFlags.Fullscreen); //newUiOptions |= (int)SystemUiFlags.LowProfile; //newUiOptions |= (int)SystemUiFlags.Immersive; //ScreenOrientation.Portrait >> Make to run your application only in portrait mode //ScreenOrientation.Landscape >> Make to run your application only in LANDSCAPE mode //RequestedOrientation = ScreenOrientation.Landscape; SetContentView(Resource.Layout.FullScreenDialog_Layout); string type = Intent?.GetStringExtra("Type"); if (type == "Movies") { VideoActionsController = new VideoController(this, "FullScreen"); VideoActionsController.PlayFullScreen(); //if (Intent?.GetStringExtra("Downloaded") == "Downloaded") // VideoActionsController.DownloadIcon.SetImageDrawable(GetDrawable(Resource.Drawable.ic_checked_red)); } else if (type == "Post") { FullscreenplayerView = FindViewById <PlayerView>(Resource.Id.player_view2); } } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); var testOptions = new MSTestX.TestOptions(); // You can deploy and launch the app from the ADB shell and parsing intent parameters // Example: // adb install PATH_TO_APK/TestAppRunner.Android-Signed.apk // Launch the app and pass parameters where -n is for starting an intent // The intent should be [AppName]/[Activity Name] // Use --ez for passing boolean, --es for passing a string, --ei for passing int // adb shell am start -n TestAppRunner/TestAppRunner.Android --ez AutoRun true --es TrxReportFile TestReport // Once test run is complete you can copy the report back: // adb exec -out run -as com.mstestx.TestAppRunner cat/data/data/com.mstestx.TestAppRunner/files/TestReport.trx > TestReport.trx testOptions.AutoRun = Intent.GetBooleanExtra("AutoRun", false); string path = Intent.GetStringExtra("ReportFile"); // Or generate a new time-stamped log file path on each run: // if (string.IsNullOrEmpty(path)) // path = "TestAppRunner_" + System.DateTime.Now.ToString("yyyy_MM_dd_HH-mm-ss"); if (!string.IsNullOrEmpty(path)) { path = System.IO.Path.Combine(ApplicationContext.FilesDir.Path, path); testOptions.TrxOutputPath = path + ".trx"; testOptions.ProgressLogPath = path + ".log"; } testOptions.TerminateAfterExecution = testOptions.AutoRun; var testApp = new MSTestX.RunnerApp(testOptions); // Disable screen saver while tests are running testApp.TestRunStarted += (a, testCases) => Window?.AddFlags(WindowManagerFlags.KeepScreenOn); testApp.TestRunCompleted += (a, results) => Window?.ClearFlags(WindowManagerFlags.KeepScreenOn); LoadApplication(testApp); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); View mContentView = Window?.DecorView; var uiOptions = (int)mContentView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.Fullscreen; newUiOptions |= (int)SystemUiFlags.LayoutStable; mContentView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window?.AddFlags(WindowManagerFlags.Fullscreen); // Create your application here SetContentView(Resource.Layout.View_Story_Layout); GlobalContext = TabbedMainActivity.GetInstance(); //Get Value And Set Toolbar InitComponent(); InitToolbar(); if (Intent != null) { UserId = Intent.GetStringExtra("UserId") ?? ""; IndexItem = Intent.GetIntExtra("IndexItem", 0); DataStories = JsonConvert.DeserializeObject <GetUserStoriesObject.StoryObject>(Intent?.GetStringExtra("DataItem") ?? ""); } LoadData(DataStories); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); //Set Full screen View mContentView = Window?.DecorView; var uiOptions = (int)mContentView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.Fullscreen; newUiOptions |= (int)SystemUiFlags.HideNavigation; mContentView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window?.AddFlags(WindowManagerFlags.Fullscreen); // Create your application here SetContentView(Resource.Layout.Login_Layout); Client a = new Client(AppSettings.TripleDesAppServiceProvider); Console.WriteLine(a); //Get Value And Set Toolbar InitComponent(); InitSocialLogins(); GetTimezone(); if (string.IsNullOrEmpty(UserDetails.DeviceId)) { OneSignalNotification.RegisterNotificationDevice(); } } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { Profile.FrameBegin(); _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } Profile.FramePartition("Xamarin.Android.OnCreate"); base.OnCreate(savedInstanceState); Profile.FramePartition("SetSupportActionBar"); AToolbar bar = null; if (_toolbarResource == 0) { ToolbarResource = Resource.Layout.toolbar; } if (_tabLayoutResource == 0) { _tabLayoutResource = Resource.Layout.tabbar; } if (ToolbarResource != 0) { try { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } catch (global::Android.Views.InflateException ie) { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar", ie); } if (bar == null) { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar"); } } else { bar = new AToolbar(this); } SetSupportActionBar(bar); Profile.FramePartition("SetContentView"); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Profile.FramePartition("OnStateChanged"); Microsoft.Maui.Controls.Application.Current = null; _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Profile.FramePartition("Set DrawsSysBarBkgrnds"); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } Profile.FrameEnd(); }
protected override void OnCreate(Bundle savedInstanceState) { OnCreate(savedInstanceState, Resource.Layout.StopActivity); SupportActionBar.SetDisplayHomeAsUpEnabled(true); // Handle bundle parameter Bundle extras = Intent.Extras; if (extras != null && extras.ContainsKey("Stop")) { int stopId = extras.GetInt("Stop"); stop = TramUrWayApplication.GetStop(stopId); } #if DEBUG else { stop = TramUrWayApplication.Lines.SelectMany(l => l.Stops).FirstOrDefault(s => s.Name == "Saint-Lazare"); } #endif if (stop == null) { throw new Exception("Could not find any stop matching the specified id"); } if (extras != null && extras.ContainsKey("Line")) { int lineId = extras.GetInt("Line"); line = TramUrWayApplication.GetLine(lineId); } else { line = stop.Line; } Title = stop.Name; // Change toolbar color Color color = Utils.GetColorForLine(this, line); Color darkColor = new Color(color.R * 2 / 3, color.G * 2 / 3, color.B * 2 / 3); SupportActionBar.SetBackgroundDrawable(new ColorDrawable(color)); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Window.ClearFlags(WindowManagerFlags.TranslucentStatus); Window.SetStatusBarColor(darkColor); } // Refresh widget swipeRefresh = FindViewById <SwipeRefreshLayout>(Resource.Id.StopActivity_SwipeRefresh); swipeRefresh.Refresh += SwipeRefresh_Refresh; swipeRefresh.SetColorSchemeColors(color.ToArgb()); // Initialize UI lineLabel = FindViewById <TextView>(Resource.Id.StopActivity_LineLabel); lineLabel.Text = line.Name; lineLabel.SetTextColor(darkColor); listStopList = FindViewById <RecyclerView>(Resource.Id.StopActivity_LineStopList); listStopList.HasFixedSize = true; listStopList.NestedScrollingEnabled = false; listStopList.SetLayoutManager(new WrapLayoutManager(this)); listStopList.AddItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.Vertical)); otherLabel = FindViewById <TextView>(Resource.Id.StopActivity_OtherLabel); otherLabel.SetTextColor(darkColor); otherStopList = FindViewById <RecyclerView>(Resource.Id.StopActivity_OtherStopList); otherStopList.HasFixedSize = true; otherStopList.NestedScrollingEnabled = false; otherStopList.SetLayoutManager(new WrapLayoutManager(this)); otherStopList.AddItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.Vertical)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(Android.Views.WindowFeatures.NoTitle); SetContentView(Resource.Layout.cropimage); imageView = FindViewById <CropImageView>(Resource.Id.image); showStorageToast(this); Bundle extras = Intent.Extras; if (extras != null) { imagePath = extras.GetString("image-path"); saveUri = getImageUri(imagePath); if (extras.GetString(MediaStore.ExtraOutput) != null) { saveUri = getImageUri(extras.GetString(MediaStore.ExtraOutput)); } bitmap = getBitmap(imagePath); aspectX = extras.GetInt("aspectX"); aspectY = extras.GetInt("aspectY"); outputX = extras.GetInt("outputX"); outputY = extras.GetInt("outputY"); scale = extras.GetBoolean("scale", true); scaleUp = extras.GetBoolean("scaleUpIfNeeded", true); if (extras.GetString("outputFormat") != null) { outputFormat = Bitmap.CompressFormat.ValueOf(extras.GetString("outputFormat")); } } if (bitmap == null) { Finish(); return; } Window.AddFlags(WindowManagerFlags.Fullscreen); FindViewById <Button>(Resource.Id.discard).Click += (sender, e) => { SetResult(Result.Canceled); Finish(); }; FindViewById <Button>(Resource.Id.save).Click += (sender, e) => { onSaveClicked(); }; FindViewById <Button>(Resource.Id.rotateLeft).Click += (o, e) => { bitmap = Util.rotateImage(bitmap, -90); RotateBitmap rotateBitmap = new RotateBitmap(bitmap); imageView.SetImageRotateBitmapResetBase(rotateBitmap, true); addHighlightView(); }; FindViewById <Button>(Resource.Id.rotateRight).Click += (o, e) => { bitmap = Util.rotateImage(bitmap, 90); RotateBitmap rotateBitmap = new RotateBitmap(bitmap); imageView.SetImageRotateBitmapResetBase(rotateBitmap, true); addHighlightView(); }; imageView.SetImageBitmapResetBase(bitmap, true); addHighlightView(); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetTheme(AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base); View mContentView = Window.DecorView; var uiOptions = (int)mContentView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.LayoutStable; newUiOptions |= (int)SystemUiFlags.LayoutFullscreen; mContentView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; Window.AddFlags(WindowManagerFlags.Fullscreen); // Create your application here SetContentView(Resource.Layout.UserProfile_Layout); NamePage = Intent.GetStringExtra("NamePage") ?? string.Empty; SUserId = Intent.GetStringExtra("UserId") ?? string.Empty; var userObject = Intent.GetStringExtra("UserObject"); if (!string.IsNullOrEmpty(userObject)) { try { if (NamePage == "Chat") { if (AppSettings.LastChatSystem == SystemApiGetLastChat.New) { UserData = JsonConvert.DeserializeObject <UserDataObject>(userObject); } else if (AppSettings.LastChatSystem == SystemApiGetLastChat.Old) { UserData = JsonConvert.DeserializeObject <GetUsersListObject.User>(userObject); } else { UserData = JsonConvert.DeserializeObject <UserDataObject>(userObject); } } else { UserData = JsonConvert.DeserializeObject <UserDataObject>(userObject); } } catch (Exception e) { Console.WriteLine(e); } } //Get Value And Set Toolbar InitComponent(); InitToolbar(); SetRecyclerViewAdapters(); MAdView = FindViewById <AdView>(Resource.Id.adView); AdsGoogle.InitAdView(MAdView, null); //Get Data User if (UserData != null) { LoadDataUser(UserData); } GetFiles(); StartApiService(); AdsGoogle.Ad_Interstitial(this); } catch (Exception e) { Console.WriteLine(e); } }
protected override void OnCreate(Bundle savedInstanceState) { var alarmIntent = new Intent(this, typeof(LockAlarmReceiver)); _lockAlarmPendingIntent = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); var clearClipboardIntent = new Intent(this, typeof(ClearClipboardAlarmReceiver)); _clearClipboardPendingIntent = PendingIntent.GetBroadcast(this, 0, clearClipboardIntent, PendingIntentFlags.UpdateCurrent); var policy = new StrictMode.ThreadPolicy.Builder().PermitAll().Build(); StrictMode.SetThreadPolicy(policy); _deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"); _messagingService = ServiceContainer.Resolve <IMessagingService>("messagingService"); _broadcasterService = ServiceContainer.Resolve <IBroadcasterService>("broadcasterService"); _userService = ServiceContainer.Resolve <IUserService>("userService"); _appIdService = ServiceContainer.Resolve <IAppIdService>("appIdService"); _storageService = ServiceContainer.Resolve <IStorageService>("storageService"); _stateService = ServiceContainer.Resolve <IStateService>("stateService"); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; UpdateTheme(ThemeManager.GetTheme(true)); base.OnCreate(savedInstanceState); if (!CoreHelpers.InDebugMode()) { Window.AddFlags(Android.Views.WindowManagerFlags.Secure); } #if !FDROID var hockeyAppListener = new HockeyAppCrashManagerListener(_appIdService, _userService); var hockeyAppTask = hockeyAppListener.InitAsync(); HockeyApp.Android.CrashManager.Register(this, HockeyAppId, hockeyAppListener); #endif Xamarin.Essentials.Platform.Init(this, savedInstanceState); Xamarin.Forms.Forms.Init(this, savedInstanceState); _appOptions = GetOptions(); LoadApplication(new App.App(_appOptions)); _broadcasterService.Subscribe(_activityKey, (message) => { if (message.Command == "scheduleLockTimer") { var lockOptionMinutes = (int)message.Data; var lockOptionMs = lockOptionMinutes * 60000; var triggerMs = Java.Lang.JavaSystem.CurrentTimeMillis() + lockOptionMs + 10; var alarmManager = GetSystemService(AlarmService) as AlarmManager; alarmManager.Set(AlarmType.RtcWakeup, triggerMs, _lockAlarmPendingIntent); } else if (message.Command == "cancelLockTimer") { var alarmManager = GetSystemService(AlarmService) as AlarmManager; alarmManager.Cancel(_lockAlarmPendingIntent); } else if (message.Command == "finishMainActivity") { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => Finish()); } else if (message.Command == "listenYubiKeyOTP") { ListenYubiKey((bool)message.Data); } else if (message.Command == "updatedTheme") { RestartApp(); } else if (message.Command == "exit") { ExitApp(); } else if (message.Command == "copiedToClipboard") { var task = ClearClipboardAlarmAsync(message.Data as Tuple <string, int?, bool>); } }); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (Bootlegger.BootleggerClient.CurrentEvent == null) { Finish(); return; } CurrentEvent = Bootlegger.BootleggerClient.CurrentEvent; SetTheme(Resource.Style.Theme_Normal); SetContentView(Resource.Layout.Review); //AndHUD.Shared.Show(this, Resources.GetString(Resource.String.loading), -1, MaskType.Black, null, null, true); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); Window.ClearFlags(WindowManagerFlags.TranslucentStatus); if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { // add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); // finally change the color Window.SetStatusBarColor(new Color(ContextCompat.GetColor(this, Android.Resource.Color.Transparent))); } //FindViewById<TextView>(Resource.Id.customTitle).Text = CurrentEvent.name; FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetTitle(CurrentEvent.name); FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetExpandedTitleTextAppearance(Resource.Style.ExpandedAppBar); Typeface font = ResourcesCompat.GetFont(this, Resource.Font.montserratregular); FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).CollapsedTitleTypeface = font; FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).ExpandedTitleTypeface = font; FindViewById <AppBarLayout>(Resource.Id.appbar).SetExpanded(false, false); //if (!string.IsNullOrEmpty(CurrentEvent.iconbackground) && !WhiteLabelConfig.REDUCE_BANDWIDTH) // Picasso.With(this).Load(CurrentEvent.iconbackground).CenterCrop().Fit().MemoryPolicy(MemoryPolicy.NoCache, MemoryPolicy.NoStore).Tag(this).Into(FindViewById<ImageView>(Resource.Id.defaultback), new Action(() => // { // var bitmap = ((BitmapDrawable)FindViewById<ImageView>(Resource.Id.defaultback).Drawable).Bitmap; // Palette palette = Palette.From(bitmap).Generate(); // int vibrant = palette.GetLightVibrantColor(0); // if (vibrant == 0) // vibrant = palette.GetMutedColor(0); // int dark = palette.GetVibrantColor(0); // if (dark == 0) // dark = palette.GetLightMutedColor(0); // //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(vibrant); // //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark); // }), null); //else //{ //Picasso.With(this).Load(Resource.Drawable.user_back).CenterCrop().Fit().Into(FindViewById<ImageView>(Resource.Id.defaultback)); //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetContentScrimColor(Color.Transparent); //FindViewById<CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar).SetStatusBarScrimColor(dark); //} FindViewById <TextView>(Resource.Id.organisedby).Text = CurrentEvent.organisedby; Picasso.With(this).Load(CurrentEvent.organiserprofile.Replace("sz=50", "")).Tag(this).Fit().Transform(new CircleTransform()).Into(FindViewById <ImageView>(Resource.Id.imgGravatar)); FindViewById <TextView>(Resource.Id.contributors).Text = Java.Lang.String.Format("%d", CurrentEvent.numberofcontributors); FindViewById <TextView>(Resource.Id.contributions).Text = Java.Lang.String.Format("%d", CurrentEvent.numberofclips); _pager = FindViewById <ViewPager>(Resource.Id.tabpager); capture = FindViewById <FloatingActionButton>(Resource.Id.capture); newedit = FindViewById <FloatingActionButton>(Resource.Id.newedit); newtag = FindViewById <FloatingActionButton>(Resource.Id.newtag); capture.Click += CaptureClick; newedit.Click += Review_Click; newtag.Click += Newtag_Click; var dip16 = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, 16, Resources.DisplayMetrics); capture.LayoutParameters = new CoordinatorLayout.LayoutParams(capture.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, capture, 0, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; newtag.LayoutParameters = new CoordinatorLayout.LayoutParams(newtag.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, newtag, 1, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; newedit.LayoutParameters = new CoordinatorLayout.LayoutParams(newedit.LayoutParameters) { Behavior = new MyFABAwareScrollingViewBehavior(this, newedit, 2, _pager), Gravity = (int)(GravityFlags.End | GravityFlags.Right | GravityFlags.Bottom), MarginEnd = dip16, BottomMargin = dip16 }; _tabs = FindViewById <Android.Support.Design.Widget.TabLayout>(Resource.Id.tabs); _tabs.TabGravity = 0; _tabs.TabMode = 1; _adapter = new ReviewPageAdapter(SupportFragmentManager, this); _pager.Adapter = _adapter; if (savedInstanceState == null) { myclips = new MyClipsFragment(this); myclips.OnPreview += Myclips_OnPreview; myclips.OnRefresh += Myclips_OnRefresh; myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate; myclips.OnStartUpload += Myclips_OnStartUpload; myedits = new MyEditsFragment(); myedits.OnOpenEdit += Myedits_OnOpenEdit; myedits.OnPreview += Myedits_OnPreview; myingest = new AllClipsFragment(AllClipsFragment.ClipViewMode.LIST); myingest.OnPreview += Myingest_OnPreview; } else { myclips = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":0") as MyClipsFragment; myclips.OnPreview += Myclips_OnPreview; myclips.OnRefresh += Myclips_OnRefresh; myclips.OnEventInfoUpdate += Myclips_OnEventInfoUpdate; myclips.OnStartUpload += Myclips_OnStartUpload; myingest = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":1") as AllClipsFragment; myingest.ChooserMode = AllClipsFragment.ClipViewMode.LIST; myingest.OnPreview += Myingest_OnPreview; myedits = SupportFragmentManager.FindFragmentByTag("android:switcher:" + Resource.Id.tabpager + ":2") as MyEditsFragment; if (myedits == null) { myedits = new MyEditsFragment(); } myedits.OnOpenEdit += Myedits_OnOpenEdit; myedits.OnPreview += Myedits_OnPreview; } //myedits.Reattach(); _adapter.AddTab(GetString(Resource.String.videos), myclips, ReviewPageAdapter.TabType.CLIPS); _adapter.AddTab(GetString(Resource.String.tagging), myingest, ReviewPageAdapter.TabType.INGEST); _adapter.AddTab(GetString(Resource.String.edits), myedits, ReviewPageAdapter.TabType.EDITS); _pager.Post(() => { _tabs.SetupWithViewPager(_pager); }); _pager.PageSelected += _pager_PageSelected; if (Intent?.GetBooleanExtra("needsperms", false) ?? false) { LoginFuncs.ShowError(this, new NeedsPermissionsException()); } }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; Resources.DisplayMetrics.ScaledDensity = 2;//告诉android不要把自己大小单位缩放 //double systemDensity = DeviceDisplay.MainDisplayInfo.Density; //Resources.DisplayMetrics.Density = (float)systemDensity / 2.55F; //var temp = Resources.DisplayMetrics; //var device = DeviceDisplay.MainDisplayInfo; App.ScreenWidth = Resources.DisplayMetrics.WidthPixels; App.ScreenHeight = Resources.DisplayMetrics.HeightPixels; if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat) { //透明状态栏 //Window.AddFlags(WindowManagerFlags.TranslucentStatus); Window.SetStatusBarColor(Android.Graphics.Color.LightGray); //不遮挡导航栏 Window.AddFlags(WindowManagerFlags.ForceNotFullscreen); } Rg.Plugins.Popup.Popup.Init(this, savedInstanceState); //弹出框 CarouselViewRenderer.Init(); //轮播图 CachedImageRenderer.Init(true); //支付宝 MessagingCenter.Subscribe <object, string>(this, "Pay", (sender, sign) => { try { //Func<string, string> test = Pay; //IAsyncResult asyncResult = test.BeginInvoke(sign, null, null); //string result = test.EndInvoke(asyncResult); // //Console.WriteLine(result); //Status = ""; Thread the = new Thread(new ParameterizedThreadStart(Pay)); the.Start(sign); //the.Join(); //Console.WriteLine(Pay(sign)); //Task<string> task = new Task<string>(async () => await Pay(sign)); //var result = await Pay(sign); //task.Wait(); //task.RunSynchronously(); //Console.WriteLine(result); //PayDelegate payDelegate = Pay; //Task<string> task = Task<string>.Factory.FromAsync(payDelegate.BeginInvoke(sign, Callback, "a delegate asynchronous call"), payDelegate.EndInvoke); //Task<string> task = Task<string>.Factory.FromAsync(payDelegate.BeginInvoke, payDelegate.EndInvoke, sign, "a delegate asynchronous call"); //task.ContinueWith(t => MessagingCenter.Send(new object(), "PaySuccess", t.Result)); } catch (ThreadAbortException) { MessagingCenter.Send(new object(), "PaySuccess", Status); } }); //微信相关 //注册 MessagingCenter.Subscribe <object>(this, "Register", d => { var result = RegToWx(); // MessagingCenter.Send(new object(), "Registered", result);//广播注册的结果 }); MessagingCenter.Subscribe <object>(this, "Login", d => { // send oauth request SendAuth.Req req = new SendAuth.Req(); req.Scope = "snsapi_userinfo"; req.State = "wechat_sdk_demo_test"; bool result = wxApi.SendReq(req); }); //分享小程序给朋友 MessagingCenter.Subscribe <object, string>(this, "ShareMiniProgramToFriend", (sender, arg) => { WXMiniProgramObject miniProgramObj = new WXMiniProgramObject(); miniProgramObj.WebpageUrl = "http://www.qq.com"; // 兼容低版本的网页链接 miniProgramObj.MiniprogramType = WXMiniProgramObject.MiniptogramTypeRelease; // 正式版:0,测试版:1,体验版:2 miniProgramObj.UserName = "******"; // 小程序原始id miniProgramObj.Path = "/pages/media"; //小程序页面路径;对于小游戏,可以只传入 query 部分,来实现传参效果,如:传入 "?foo=bar" WXMediaMessage msg = new WXMediaMessage(miniProgramObj); msg.Title = "小程序消息Title"; // 小程序消息title msg.Description = "小程序消息Desc"; // 小程序消息desc //msg.ThumbData = getThumb(); // 小程序消息封面图片,小于128k SendMessageToWX.Req req = new SendMessageToWX.Req { //Transaction = DateTime.Now.ToFileTimeUtc().ToString(), Message = msg, Scene = SendMessageToWX.Req.WXSceneSession // 目前只支持会话 }; wxApi.SendReq(req); }); //分享文字给朋友 MessagingCenter.Subscribe <object, string>(this, "ShareToFriend", (sender, arg) => { WXTextObject textObj = new WXTextObject { Text = arg }; //定义wx文本对象 WXMediaMessage msg = new WXMediaMessage { MyMediaObject = textObj, Description = arg }; //定义wxmsg对象 SendMessageToWX.Req req = new SendMessageToWX.Req() { Transaction = DateTime.Now.ToFileTimeUtc().ToString(), Message = msg, Scene = SendMessageToWX.Req.WXSceneSession//分享到对话 }; wxApi.SendReq(req); }); //分享文字到朋友圈 MessagingCenter.Subscribe <object, string>(this, "ShareToTimeline", (sender, arg) => { WXTextObject textObj = new WXTextObject { Text = arg }; //定义wx文本对象 WXMediaMessage msg = new WXMediaMessage { MyMediaObject = textObj, Description = arg }; //定义wxmsg对象 SendMessageToWX.Req req = new SendMessageToWX.Req() { Transaction = DateTime.Now.ToFileTimeUtc().ToString(), Message = msg, Scene = SendMessageToWX.Req.WXSceneTimeline//分享到朋友圈 }; wxApi.SendReq(req); }); /* * //分享网页给朋友 * MessagingCenter.Subscribe<object, string>(this, "ShareToFriend", (sender, arg) => * { * //初始化一个WXWebpageObject,填写url * WXWebpageObject webpage = new WXWebpageObject(); * webpage.WebpageUrl = "网页url"; * * //用 WXWebpageObject 对象初始化一个 WXMediaMessage 对象 * WXMediaMessage msg = new WXMediaMessage(webpage); * msg.Title = "网页标题 "; * msg.Description = "网页描述"; * Bitmap thumbBmp = BitmapFactory.decodeResource(getResources(), R.drawable.send_music_thumb); * msg.ThumbData = Util.bmpToByteArray(thumbBmp, true); * * //构造一个Req * SendMessageToWX.Req req = new SendMessageToWX.Req(); * req.Transaction = buildTransaction("webpage"); * req.Message = msg; * req.Scene = mTargetScene; * req.UserOpenId = getOpenId(); * * //调用api接口,发送数据到微信 * wxApi.sendReq(req); * });*/ base.OnCreate(savedInstanceState); Instance = this; Platform.Init(this, savedInstanceState); // add this line to your code, it may also be called: bundle Forms.Init(this, savedInstanceState); LoadApplication(new App()); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); FacebookSdk.SdkInitialize(this.ApplicationContext); SetContentView(Resource.Layout.Login); txtUserName = FindViewById <EditText>(Resource.Id.etEmailPhone); txtPassword = FindViewById <EditText>(Resource.Id.etPassword); txtForgotUsername = FindViewById <EditText>(Resource.Id.etForgotUsername); btnLogIn = FindViewById <Button>(Resource.Id.btnLogin); GoogleApiClient.Builder builder = new GoogleApiClient.Builder(this); builder.AddConnectionCallbacks(this); builder.AddOnConnectionFailedListener(this); builder.AddApi(PlusClass.API); builder.AddScope(new Scope(Scopes.PlusLogin)); mGoogleApiClient = builder.Build(); mGoogleApiClient.Connect(); if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Window.SetStatusBarColor(new Android.Graphics.Color(ContextCompat.GetColor(this, Resource.Color.primaryDark))); } ISharedPreferences prefs = Application.Context.GetSharedPreferences("WeClip", FileCreationMode.Private); var FromUserScreen = Intent.GetStringExtra("FromUserName"); if (!string.IsNullOrEmpty(FromUserScreen)) { var prefEditor = prefs.Edit(); prefEditor.PutBoolean("RegisterEmail", false); prefEditor.PutBoolean("RegisterPhone", false); prefEditor.Commit(); } bool RegisterEmail = prefs.GetBoolean("RegisterEmail", false); bool RegisterPhone = prefs.GetBoolean("RegisterPhone", false); llayoutSignIn = FindViewById <LinearLayout>(Resource.Id.llayoutSignIn); llayoutSignUpOptions = FindViewById <LinearLayout>(Resource.Id.llayoutSignUpOptions); llayoutForgotPassword = FindViewById <LinearLayout>(Resource.Id.llayoutForgot); btnSignUpWsocial = FindViewById <TextView>(Resource.Id.btnSignUpWsocial); btnSignUpWsocial.Click += BtnSignUpWsocial_Click; btnSignInView = FindViewById <TextView>(Resource.Id.btnSignInView); btnSignInView.Click += BtnSignInView_Click; btnForgotPassword = FindViewById <TextView>(Resource.Id.btnForgotPassword); btnForgotPassword.Click += BtnForgotPassword_Click; btnsignInInForgotPassword = FindViewById <TextView>(Resource.Id.tvSigninInForgotPassword); btnsignInInForgotPassword.Click += BtnSigninForgotPassword_Click; btnSignupWithEmail = FindViewById <Button>(Resource.Id.btnSignUpWithEmail); btnSignupWithPhone = FindViewById <Button>(Resource.Id.btnSignUpWithPhone); btnSignupWithGoogle = FindViewById <Button>(Resource.Id.btnGPlus); btnSignUpWithFacebook = FindViewById <Button>(Resource.Id.btnFacebook); btnSumitForgotPassword = FindViewById <Button>(Resource.Id.btnSubmitForgotPassword); mcallBackManager = CallbackManagerFactory.Create(); btnSignupWithPhone.Visibility = ViewStates.Gone; LoginManager.Instance.RegisterCallback(mcallBackManager, this); btnSignupWithEmail.Click += btnSignupWithEmail_Click; btnSignupWithPhone.Click += BtnSignupWithPhone_Click; btnSignupWithGoogle.Click += BtnSignupWithGoogle_Click; btnSignUpWithFacebook.Click += BtnSignUpWithFacebook_Click; btnSumitForgotPassword.Click += BtnSumitForgotPassword_Click; btnLogIn.Click += BtnLogIn_Click; if (RegisterEmail == true) { SignUpView(); } } catch (Java.Lang.Exception ex) { new CrashReportAsync("LoginActivity", "OnCreate", ex.Message + ex.StackTrace).Execute(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.cropimage); _imageView = FindViewById <CropImageView>(Resource.Id.image); ShowStorageToast(this); var extras = Intent.Extras; if (extras != null) { _imagePath = extras.GetString("image-path"); _saveUri = GetImageUri(_imagePath); if (extras.GetString(MediaStore.ExtraOutput) != null) { _saveUri = GetImageUri(extras.GetString(MediaStore.ExtraOutput)); } _bitmap = GetBitmap(_imagePath); _aspectX = extras.GetInt("aspectX"); _aspectY = extras.GetInt("aspectY"); _outputX = extras.GetInt("outputX"); _outputY = extras.GetInt("outputY"); _scale = extras.GetBoolean("scale", true); _scaleUp = extras.GetBoolean("scaleUpIfNeeded", true); if (extras.GetString("outputFormat") != null) { _outputFormat = Bitmap.CompressFormat.ValueOf(extras.GetString("outputFormat")); } } if (_bitmap == null) { Finish(); //raise event MediaCroped?.Invoke(this, new XViewEventArgs(nameof(MediaCroped), null)); return; } Window.AddFlags(WindowManagerFlags.Fullscreen); FindViewById <Button>(Resource.Id.discard).Click += (sender, e) => { OnDisCardClick(); }; FindViewById <Button>(Resource.Id.save).Click += (sender, e) => { OnSaveClicked(); }; FindViewById <Button>(Resource.Id.rotateLeft).Click += (o, e) => { _bitmap = Util.RotateImage(_bitmap, -90); var rotateBitmap = new RotateBitmap(_bitmap); _imageView.SetImageRotateBitmapResetBase(rotateBitmap, true); AddHighlightView(); }; FindViewById <Button>(Resource.Id.rotateRight).Click += (o, e) => { _bitmap = Util.RotateImage(_bitmap, 90); var rotateBitmap = new RotateBitmap(_bitmap); _imageView.SetImageRotateBitmapResetBase(rotateBitmap, true); AddHighlightView(); }; _imageView.SetImageBitmapResetBase(_bitmap, true); AddHighlightView(); }
protected override void OnCreate(Bundle savedInstanceState) { try { if ((int)Build.VERSION.SdkInt >= 23) { Window.AddFlags(WindowManagerFlags.LayoutNoLimits); Window.AddFlags(WindowManagerFlags.TranslucentNavigation); } base.OnCreate(savedInstanceState); IMethods.IApp.FullScreenApp(this); var view = MyContextWrapper.GetContentView(this, Settings.Lang, Resource.Layout.EventView_Layout); if (view != null) { SetContentView(view); } else { SetContentView(Resource.Layout.EventView_Layout); } News_Empty = (LinearLayout)FindViewById(Resource.Id.News_LinerEmpty); News_Icon = (TextView)FindViewById(Resource.Id.News_icon); Txt_News_Empty = (TextView)FindViewById(Resource.Id.Txt_LabelEmpty); Txt_News_start = (TextView)FindViewById(Resource.Id.Txt_LabelStart); Btn_Reload = (Button)FindViewById(Resource.Id.reloadPage_Button); IMethods.Set_TextViewIcon("2", News_Icon, "\uf119"); News_Empty.Visibility = ViewStates.Gone; Txt_Name = FindViewById <TextView>(Resource.Id.tvName_ptwo); IconGoing = FindViewById <TextView>(Resource.Id.IconGoing); Txt_Going = FindViewById <TextView>(Resource.Id.GoingTextview); IconInterested = FindViewById <TextView>(Resource.Id.IconInterested); Txt_Interested = FindViewById <TextView>(Resource.Id.InterestedTextview); Txt_StartDate = FindViewById <TextView>(Resource.Id.txtStartDate); Txt_EndDate = FindViewById <TextView>(Resource.Id.txtEndDate); IconLocation = FindViewById <TextView>(Resource.Id.IconLocation); Txt_Location = FindViewById <TextView>(Resource.Id.LocationTextview); Txt_Description = FindViewById <TextView>(Resource.Id.tv_aboutdescUser); HybirdView = (WebView)FindViewById(Resource.Id.hybirdview); ImageEventCover = FindViewById <ImageViewAsync>(Resource.Id.EventCover); IconBack = FindViewById <ImageView>(Resource.Id.back); Btn_Go = FindViewById <Button>(Resource.Id.ButtonGoing); Btn_Intersted = FindViewById <Button>(Resource.Id.ButtonIntersted); FloatingActionButtonView = FindViewById <FloatingActionButton>(Resource.Id.floatingActionButtonView); IMethods.Set_TextViewIcon("1", IconGoing, IonIcons_Fonts.IosPeople); IMethods.Set_TextViewIcon("1", IconInterested, IonIcons_Fonts.AndroidStar); IMethods.Set_TextViewIcon("1", IconLocation, IonIcons_Fonts.Location); var mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.map); mapFragment.GetMapAsync(this); //Set to event id to load the news feed HybridController = new HybirdViewController(this, HybirdView, null); Get_Data_Event(); } catch (Exception e) { Crashes.TrackError(e); } }
void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { Profile.FrameBegin(); _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } Profile.FramePartition("Xamarin.Android.OnCreate"); base.OnCreate(savedInstanceState); Profile.FramePartition("SetSupportActionBar"); AToolbar bar; if (ToolbarResource != 0) { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); if (bar == null) { throw new InvalidOperationException("ToolbarResource must be set to a Android.Support.V7.Widget.Toolbar"); } } else { bar = new AToolbar(this); } SetSupportActionBar(bar); Profile.FramePartition("SetContentView"); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Profile.FramePartition("OnStateChanged"); Xamarin.Forms.Application.ClearCurrent(); _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); Profile.FramePartition("Forms.IsLollipopOrNewer"); if (Forms.IsLollipopOrNewer) { // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Profile.FramePartition("Set DrawsSysBarBkgrnds"); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } } if (Forms.IsLollipopOrNewer) { // Listen for the device going into power save mode so we can handle animations being disabled Profile.FramePartition("Allocate PowerSaveModeReceiver"); _powerSaveModeBroadcastReceiver = new PowerSaveModeBroadcastReceiver(); } ContextExtensions.SetDesignerContext(_layout); Profile.FrameEnd(); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); if (Intent != null && InstanceAlreadyStarted && (Intent.Action == Intent.ActionView || Intent.Action == Intent.ActionSend)) { HandleImportFile(Intent); Finish(); return; } Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState); Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity = this; _config = new DVBTTelevizorConfiguration(); #if DEBUG _config.ShowServiceMenu = true; _config.ScanEPG = true; _config.EnableLogging = true; //_config.AutoInitAfterStart = false; #endif InitLogging(); _loggingService.Info("DVBTTelevizor starting"); // workaround for not using FileProvider (necessary for file sharing): // https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder(); StrictMode.SetVmPolicy(builder.Build()); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); // prevent sleep: Window window = (Forms.Context as Activity).Window; window.AddFlags(WindowManagerFlags.KeepScreenOn); // https://stackoverflow.com/questions/39248138/how-to-hide-bottom-bar-of-android-back-home-in-xamarin-forms _defaultUiOptions = (int)Window.DecorView.SystemUiVisibility; _fullscreenUiOptions = _defaultUiOptions; _fullscreenUiOptions |= (int)SystemUiFlags.LowProfile; _fullscreenUiOptions |= (int)SystemUiFlags.Fullscreen; _fullscreenUiOptions |= (int)SystemUiFlags.HideNavigation; _fullscreenUiOptions |= (int)SystemUiFlags.ImmersiveSticky; if (_config.Fullscreen) { SetFullScreen(true); } try { UsbManager manager = (UsbManager)GetSystemService(Context.UsbService); var usbReciever = new USBBroadcastReceiverSystem(); var intentFilter = new IntentFilter(UsbManager.ActionUsbDeviceAttached); var intentFilter2 = new IntentFilter(UsbManager.ActionUsbDeviceDetached); RegisterReceiver(usbReciever, intentFilter); RegisterReceiver(usbReciever, intentFilter2); usbReciever.UsbAttachedOrDetached += CheckIfUsbAttachedOrDetached; } catch (Exception ex) { _loggingService.Error(ex, "Error while initializing UsbManager"); } #if TestingDVBTDriverManager _driverManager = new TestingDVBTDriverManager(); #else _driverManager = new DVBTDriverManager(_loggingService, _config); #endif _notificationHelper = new NotificationHelper(this); _app = new App(_loggingService, _config, _driverManager); LoadApplication(_app); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_Init, (message) => { InitDriver(); }); MessagingCenter.Subscribe <SettingsPage>(this, BaseViewModel.MSG_CheckBatterySettings, (sender) => { try { var pm = (PowerManager)Android.App.Application.Context.GetSystemService(Context.PowerService); bool ignoring = pm.IsIgnoringBatteryOptimizations(AppInfo.PackageName); if (!ignoring) { MessagingCenter.Send <string>(string.Empty, BaseViewModel.MSG_RequestBatterySettings); } } catch (Exception ex) { _loggingService.Error(ex); } }); MessagingCenter.Subscribe <SettingsPage>(this, BaseViewModel.MSG_SetBatterySettings, (sender) => { try { var intent = new Intent(); intent.SetAction(Android.Provider.Settings.ActionIgnoreBatteryOptimizationSettings); intent.SetFlags(ActivityFlags.NewTask); Android.App.Application.Context.StartActivity(intent); } catch (Exception ex) { _loggingService.Error(ex); } }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_ToastMessage, (message) => { ShowToastMessage(message); }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_LongToastMessage, (message) => { ShowToastMessage(message, 8000); }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_EnableFullScreen, (msg) => { SetFullScreen(true); }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_DisableFullScreen, (msg) => { SetFullScreen(false); }); MessagingCenter.Subscribe <MainPage, PlayStreamInfo>(this, BaseViewModel.MSG_PlayInBackgroundNotification, (sender, playStreamInfo) => { Device.BeginInvokeOnMainThread(() => { Task.Run(async() => await ShowPlayingNotification(playStreamInfo)); }); }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_StopPlayInBackgroundNotification, (sender) => { Device.BeginInvokeOnMainThread(() => { StopPlayingNotification(); }); }); MessagingCenter.Subscribe <string>(this, BaseViewModel.MSG_ShareFile, (fileName) => { Device.BeginInvokeOnMainThread(() => { Task.Run(async() => await ShareFile(fileName)); }); }); InstanceAlreadyStarted = true; if (Intent != null && InstanceAlreadyStarted && (Intent.Action == Intent.ActionView || Intent.Action == Intent.ActionSend)) { HandleImportFile(Intent); } }
protected override void OnCreate(Bundle savedInstanceState) { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); Window.SetStatusBarColor(Color.White.ToAndroid()); Window.SetNavigationBarColor(Color.White.ToAndroid()); } base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); Forms.SetFlags("CollectionView_Experimental"); Forms.Init(this, savedInstanceState); /** * Subscribe to the "AuthenticatePhone" message, and start/handle firebase phone authentication */ MessagingCenter.Subscribe <FirebaseAuthFunctions, string>(this, "AuthenticatePhone", (sender, phoneNumber) => { var phoneVerificationCallbacks = new PhoneAuthOnVerificationStateChangedCallbacks(); phoneVerificationCallbacks.CodeSent += PhoneVerificationCodeSent; phoneVerificationCallbacks.VerificationCompleted += PhoneVerificationCompleted; phoneVerificationCallbacks.VerificationFailed += PhoneVerificationFailed; PhoneAuthProvider.GetInstance(Auth).VerifyPhoneNumber(phoneNumber, 30, TimeUnit.Seconds, this, phoneVerificationCallbacks); }); MessagingCenter.Subscribe <SignupPage>(this, "showingSocialOptions", (sender) => { InitFirebaseAuth(); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.SetStatusBarColor(Android.Graphics.Color.ParseColor("#E81945")); Window.SetNavigationBarColor(Android.Graphics.Color.ParseColor("#191919")); Window.DecorView.SystemUiVisibility = StatusBarVisibility.Visible; } }); MessagingCenter.Subscribe <ContinueSignup>(this, "RequestLocation", (sender) => { if (Build.VERSION.SdkInt >= BuildVersionCodes.M) { string lastPermission = ""; foreach (string permission in PermissionsLocation) { if (ContextCompat.CheckSelfPermission(this, permission) != (int)Permission.Granted) { if (ActivityCompat.ShouldShowRequestPermissionRationale(this, lastPermission)) { Android.Views.View layout = FindViewById(Android.Resource.Id.Content); Snackbar .Make(layout, "Allow location access or manually select your preferred Country and State", Snackbar.LengthLong) .SetAction("OK", v => ActivityCompat.RequestPermissions(this, PermissionsLocation, RequestLocationId)) .Show(); } else { ActivityCompat.RequestPermissions(this, PermissionsLocation, RequestLocationId); } break; } } } }); Window.SetBackgroundDrawable(new ColorDrawable(Color.White.ToAndroid())); App app = new App(); LoadApplication(app); }
void OnCreate( Bundle savedInstanceState, ActivationFlags flags) { Profile.FrameBegin(); _activityCreated = true; if (!AllowFragmentRestore) { // Remove the automatically persisted fragment structure; we don't need them // because we're rebuilding everything from scratch. This saves a bit of memory // and prevents loading errors from child fragment managers savedInstanceState?.Remove("android:support:fragments"); } Profile.FramePartition("Xamarin.Android.OnCreate"); base.OnCreate(savedInstanceState); Profile.FramePartition("SetSupportActionBar"); AToolbar bar = null; if (ToolbarResource == 0) { ToolbarResource = Resource.Layout.Toolbar; } if (TabLayoutResource == 0) { TabLayoutResource = Resource.Layout.Tabbar; } if (ToolbarResource != 0) { try { bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } catch (global::Android.Views.InflateException ie) { if ((ie.Cause is Java.Lang.ClassNotFoundException || ie.Cause.Cause is Java.Lang.ClassNotFoundException) && ie.Message.Contains("Error inflating class android.support.v7.widget.Toolbar")) { Internals.Log.Warning(nameof(FormsAppCompatActivity), "Toolbar layout needs to be updated from android.support.v7.widget.Toolbar to androidx.appcompat.widget.Toolbar. " + "Tabbar layout need to be updated from android.support.design.widget.TabLayout to com.google.android.material.tabs.TabLayout. " + "Or if you haven't made any changes to the default Toolbar and Tabbar layouts they can just be deleted."); ToolbarResource = Resource.Layout.FallbackToolbarDoNotUse; TabLayoutResource = Resource.Layout.FallbackTabbarDoNotUse; bar = LayoutInflater.Inflate(ToolbarResource, null).JavaCast <AToolbar>(); } else { throw; } } if (bar == null) { throw new InvalidOperationException("ToolbarResource must be set to a androidx.appcompat.widget.Toolbar"); } } else { bar = new AToolbar(this); } SetSupportActionBar(bar); Profile.FramePartition("SetContentView"); _layout = new ARelativeLayout(BaseContext); SetContentView(_layout); Profile.FramePartition("OnStateChanged"); Xamarin.Forms.Application.ClearCurrent(); _previousState = _currentState; _currentState = AndroidApplicationLifecycleState.OnCreate; OnStateChanged(); Profile.FramePartition("Forms.IsLollipopOrNewer"); if (Forms.IsLollipopOrNewer) { // Allow for the status bar color to be changed if ((flags & ActivationFlags.DisableSetStatusBarColor) == 0) { Profile.FramePartition("Set DrawsSysBarBkgrnds"); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } } if (Forms.IsLollipopOrNewer) { // Listen for the device going into power save mode so we can handle animations being disabled Profile.FramePartition("Allocate PowerSaveModeReceiver"); _powerSaveModeBroadcastReceiver = new PowerSaveModeBroadcastReceiver(); } ContextExtensions.SetDesignerContext(_layout); Profile.FrameEnd(); }
/// <inheritdoc /> protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); var testOptions = GenerateTestOptions(); // Launch the test app testApp = new RunnerApp(testOptions); // Disable screen saver while tests are running testApp.TestRunStarted += (a, testCases) => { OnTestRunStarted(testCases); RunOnUiThread(() => Window?.AddFlags(WindowManagerFlags.KeepScreenOn)); }; testApp.TestRunCompleted += (a, results) => { OnTestRunCompleted(results); RunOnUiThread(() => Window?.ClearFlags(WindowManagerFlags.KeepScreenOn)); }; testApp.TestsDiscovered += (a, testCases) => OnTestsDiscovered(testCases); LoadApplication(testApp); }
protected override void OnCreate(Bundle savedInstanceState) { Console.Error.WriteLine("--------------------------- Creating activity ---------------------------"); base.OnCreate(savedInstanceState); _activityResultWait = new ManualResetEvent(false); _facebookCallbackManager = CallbackManagerFactory.Create(); _serviceBindWait = new ManualResetEvent(false); Window.AddFlags(global::Android.Views.WindowManagerFlags.DismissKeyguard); Window.AddFlags(global::Android.Views.WindowManagerFlags.ShowWhenLocked); Window.AddFlags(global::Android.Views.WindowManagerFlags.TurnScreenOn); Forms.Init(this, savedInstanceState); FormsMaps.Init(this, savedInstanceState); MapExtendRenderer.Init(this, savedInstanceState); CrossCurrentActivity.Current.Activity = this; #if UNIT_TESTING Forms.ViewInitialized += (sender, e) => { if (!string.IsNullOrWhiteSpace(e.View.StyleId)) { e.NativeView.ContentDescription = e.View.StyleId; } }; #endif _app = new App(); LoadApplication(_app); MobileBarcodeScanner.Initialize(Application); _serviceConnection = new AndroidSensusServiceConnection(); _serviceConnection.ServiceConnected += (o, e) => { // it's happened that the service is created / started after the service helper is disposed: https://insights.xamarin.com/app/Sensus-Production/issues/46 // binding to the service in such a situation can result in a null service helper within the binder. if the service helper was disposed, then the goal is // to close down sensus. so finish the activity. if (e.Binder.SensusServiceHelper == null) { Finish(); return; } if (e.Binder.SensusServiceHelper.BarcodeScanner == null) { try { e.Binder.SensusServiceHelper.BarcodeScanner = new MobileBarcodeScanner(); } catch (Exception ex) { e.Binder.SensusServiceHelper.Logger.Log("Failed to create barcode scanner: " + ex.Message, LoggingLevel.Normal, GetType()); } } // tell the service to finish this activity when it is stopped e.Binder.ServiceStopAction = Finish; // signal the activity that the service has been bound _serviceBindWait.Set(); // if we're unit testing, try to load and run the unit testing protocol from the embedded assets #if UNIT_TESTING using (Stream protocolFile = Assets.Open("UnitTestingProtocol.json")) { Protocol.RunUnitTestingProtocol(protocolFile); } #endif }; // the following is fired if the process hosting the service crashes or is killed. _serviceConnection.ServiceDisconnected += (o, e) => { Toast.MakeText(this, "The Sensus service has crashed.", ToastLength.Long); DisconnectFromService(); Finish(); }; OpenIntentAsync(Intent); }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.TwilioCommingVideoCallLayout); Window.AddFlags(WindowManagerFlags.KeepScreenOn); SensorManager = (SensorManager)GetSystemService(SensorService); Proximity = SensorManager.GetDefaultSensor(SensorType.Proximity); CallActivity = this; var dataCallId = Intent?.GetStringExtra("CallID") ?? ""; if (!string.IsNullOrEmpty(dataCallId)) { CallType = Intent?.GetStringExtra("type"); switch (CallType) { case "Twilio_video_call": case "Twilio_audio_call": CallId = dataCallId; UserId = Intent?.GetStringExtra("UserID"); Avatar = Intent?.GetStringExtra("avatar"); Name = Intent?.GetStringExtra("name"); FromId = Intent?.GetStringExtra("from_id"); Active = Intent?.GetStringExtra("active"); Time = Intent?.GetStringExtra("time"); Status = Intent?.GetStringExtra("status"); RoomName = Intent?.GetStringExtra("room_name"); TwilioAccessToken = Intent?.GetStringExtra("access_token"); TwilioAccessTokenUser2 = Intent?.GetStringExtra("access_token_2"); break; case "Agora_video_call_recieve": case "Agora_audio_call_recieve": CallId = dataCallId; UserId = Intent?.GetStringExtra("UserID"); Avatar = Intent?.GetStringExtra("avatar"); Name = Intent?.GetStringExtra("name"); FromId = Intent?.GetStringExtra("from_id"); Active = Intent?.GetStringExtra("active"); Time = Intent?.GetStringExtra("time"); Status = Intent?.GetStringExtra("status"); RoomName = Intent?.GetStringExtra("room_name"); break; } } UserNameTextView = FindViewById <TextView>(Resource.Id.UsernameTextView); TypeCallTextView = FindViewById <TextView>(Resource.Id.TypecallTextView); UserImageView = FindViewById <ImageView>(Resource.Id.UserImageView); GradientPreView = FindViewById <View>(Resource.Id.gradientPreloaderView); AcceptCallButton = FindViewById <CircleButton>(Resource.Id.accept_call_button); RejectCallButton = FindViewById <CircleButton>(Resource.Id.end_call_button); MessageCallButton = FindViewById <CircleButton>(Resource.Id.message_call_button); StartAnimatedBackground(); AcceptCallButton.Click += AcceptCallButton_Click; RejectCallButton.Click += RejectCallButton_Click; MessageCallButton.Click += MessageCallButton_Click; if (!string.IsNullOrEmpty(Name)) { UserNameTextView.Text = Name; } if (!string.IsNullOrEmpty(Avatar)) { GlideImageLoader.LoadImage(this, Avatar, UserImageView, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); } if (CallType == "Twilio_video_call" || CallType == "Agora_video_call_recieve") { TypeCallTextView.Text = GetText(Resource.String.Lbl_Video_call); } else { TypeCallTextView.Text = GetText(Resource.String.Lbl_Voice_call); } Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("mystic_call.mp3"); Vibrator = (Vibrator)GetSystemService(VibratorService); var vibrate = new long[] { 1000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000 }; // Vibrate for 500 milliseconds Vibrator.Vibrate(VibrationEffect.CreateWaveform(vibrate, 3)); } catch (Exception e) { Methods.DisplayReportResultTrack(e); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.MainLibraryActivity); Window.AddFlags(WindowManagerFlags.KeepScreenOn); //Window.SetBackgroundDrawableResource(Resource.Color.storehouse_blue); Color c = Resources.GetColor(Resource.Color.storehouse_blue); Drawable b = Resources.GetDrawable(Resource.Drawable.app_background); b.SetColorFilter(c, PorterDuff.Mode.Multiply); //Window.SetBackgroundDrawable(b); Window.SetBackgroundDrawableResource(Resource.Color.storehouse_blue); App.STATE.Activity = this; SupportActionBar.SetHomeButtonEnabled(true); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetDisplayShowHomeEnabled(true); //SupportActionBar.SetIcon(Resource.Drawable.Icon); App.STATE.SetActionBarTitle(SupportActionBar, "JW Chinese"); list = FindViewById <ListView>(Resource.Id.left_drawer); nav = FindViewById <ListView>(Resource.Id.nav_drawer); list.ItemClick += (sender, args) => SelectLibrary(args.Position); // Set background of NavigationDrawer Color color = Resources.GetColor(Resource.Color.storehouse_blue); Drawable background = Resources.GetDrawable(Resource.Drawable.blue_bg); background.SetColorFilter(color, PorterDuff.Mode.Multiply); list.SetBackgroundDrawable(background); App.FUNCTIONS.SetActionBarDrawable(this); drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); toggle = new MyActionBarDrawerToggle(this, drawer, Resource.String.drawer_open, Resource.String.drawer_close); toggle.DrawerClosed += delegate { SetActionBarArrow(); SupportInvalidateOptionsMenu(); }; toggle.DrawerOpened += delegate { toggle.DrawerIndicatorEnabled = true; SupportInvalidateOptionsMenu(); }; drawer.SetDrawerListener(toggle); SupportFragmentManager.BackStackChanged += SupportFragmentManager_BackStackChanged; // Add stacks for each LibraryMode section stacks.Add((int)Library.Bible, new Stack <Fragment>()); stacks.Add((int)Library.Insight, new Stack <Fragment>()); stacks.Add((int)Library.DailyText, new Stack <Fragment>()); stacks.Add((int)Library.Publications, new Stack <Fragment>()); App.STATE.LoadUserPreferences(); App.STATE.LanguageChanged += STATE_LanguageChanged; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var nearestTrainColor = Intent.GetIntExtra("nearestTrainColor", -1); if (nearestTrainColor > 0) { Window window = Window; View decorView = Window.DecorView; var uiOptions = (int)decorView.SystemUiVisibility; var newUiOptions = uiOptions; newUiOptions |= (int)SystemUiFlags.LowProfile; newUiOptions |= (int)SystemUiFlags.HideNavigation; newUiOptions |= (int)SystemUiFlags.Immersive; if (isFullscreen) { //window.AddFlags (WindowManagerFlags.Fullscreen); //window.SetFlags (WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); newUiOptions |= (int)SystemUiFlags.Fullscreen; } window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); window.SetStatusBarColor(Color.ParseColor(Resources.GetString(nearestTrainColor))); decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions; decorView.SetBackgroundResource(nearestTrainColor); } SetContentView(Resource.Layout.Detail); Button ButtonClose = FindViewById <Button>(Resource.Id.DetailClose); ButtonClose.Click += (sender, e) => Finish(); LinearLayout detailView = FindViewById <LinearLayout>(Resource.Id.DetailInfo); List <View> detailLabels = MainActivity.GetViewsByTag(detailView, "detail"); List <View> timeLabels = MainActivity.GetViewsByTag(detailView, "time"); List <View> points = MainActivity.GetViewsByTag(detailView, "point"); var nearestTrain = Intent.GetStringExtra("nearestTrain"); if (nearestTrain != null) { Train train = Newtonsoft.Json.JsonConvert.DeserializeObject <Train>(nearestTrain); if (detailLabels.Count > 0 && train != null) { TextView DetailRouteId = FindViewById <TextView>(Resource.Id.DetailRouteId); DetailRouteId.Text = train.route_id; int t = 0; foreach (TextView detailLabel in detailLabels) { switch (t) { case 0: detailLabel.Text = "TO: " + train.trip_headsign; break; case 1: detailLabel.Text = train.stop_name; break; case 2: detailLabel.Text = train.TimeString(); break; } t++; } } } else { Console.WriteLine("Detail: Json error!!"); } var fartherTrains = Intent.GetStringExtra("fartherTrains"); if (fartherTrains != null) { Console.WriteLine("Detail: has Farther Trains"); List <Train> trains = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Train> >(fartherTrains); int i = 0; int ce = 0; if (timeLabels.Count > 0 && trains != null && trains.Count > 0) { foreach (TextView timeLabel in timeLabels) { timeLabel.Text = ""; if (i < trains.Count) { Train fartherTrain = trains[i]; timeLabel.Text = fartherTrain.TimeString(); points[i + ce].Visibility = ViewStates.Visible; points[i + ce + 1].Visibility = ViewStates.Visible; } else { points[i + ce].Visibility = ViewStates.Invisible; points[i + ce + 1].Visibility = ViewStates.Invisible; } i++; ce++; } } else { Console.WriteLine("Detail: no Farther Trains"); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); title = Intent.GetStringExtra("Title") ?? ""; message = Intent.GetStringExtra("Message") ?? ""; stacktrace = Intent.GetStringExtra("Stacktrace") ?? ""; log = Intent.GetStringExtra("Log") ?? ""; string exceptionData = Intent.GetStringExtra("ExceptionData"); if (string.IsNullOrEmpty(exceptionData)) { exceptionData = "Cannot receive information about this failure.<br><br><small>If you have any issues, report it to developers.<br><a href=\"https://github.com/deathkiller/jazz2\">https://github.com/deathkiller/jazz2</a></small>"; } else { exceptionData += "<br><br><small>This report was sent to developers to help resolve it.<br><a href=\"https://github.com/deathkiller/jazz2\">https://github.com/deathkiller/jazz2</a></small>"; } try { View decorView = Window.DecorView; decorView.SystemUiVisibility |= (StatusBarVisibility)SystemUiFlags.LayoutStable; decorView.SystemUiVisibility |= (StatusBarVisibility)SystemUiFlags.LayoutFullscreen; Window.ClearFlags(WindowManagerFlags.TranslucentStatus); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { Window.SetStatusBarColor(new Color(0x30000000)); Window.SetNavigationBarColor(new Color(unchecked ((int)0xff000000))); } if (Build.VERSION.SdkInt >= BuildVersionCodes.P) { Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; } } catch { // Nothing to do... } SetContentView(Resource.Layout.activity_info); backgroundVideo = FindViewById <VideoView>(Resource.Id.background_video); backgroundVideo.SetVideoURI(global::Android.Net.Uri.Parse("android.resource://" + PackageName + "/raw/logo")); backgroundVideo.Prepared += OnVideoViewPrepared; backgroundVideo.Start(); Button closeButton = FindViewById <Button>(Resource.Id.retry_button); closeButton.Visibility = ViewStates.Gone; TextView versionView = FindViewById <TextView>(Resource.Id.version); versionView.Text = "v" + App.AssemblyVersion; TextView headerView = FindViewById <TextView>(Resource.Id.header); headerView.Text = "Application has exited unexpectedly"; TextView contentView = FindViewById <TextView>(Resource.Id.content); contentView.MovementMethod = LinkMovementMethod.Instance; if (Build.VERSION.SdkInt >= BuildVersionCodes.N) { contentView.TextFormatted = Html.FromHtml(exceptionData, FromHtmlOptions.ModeLegacy); } else { contentView.TextFormatted = Html.FromHtml(exceptionData); } // Send report if (!string.IsNullOrEmpty(title)) { new Task(SendReportAsync).Start(); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_route_filter); if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop) { Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); } var intent = Intent; var toolbar = (Toolbar)FindViewById(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); ISet <Route> routes = new HashSet <Route> (); //Init the available routes foreach (var route in RouteManager.GetRoutes()) { routes.Add(route); } ISet <string> activeTags = new HashSet <string> (); var tags = intent.GetStringArrayExtra(IntentActiveTags); foreach (var tag in tags) { activeTags.Add(tag); } //There will be duplicates in the route set so we have to remove them var uniqueTags = new Dictionary <string, RouteTagHolder> (); foreach (var route in routes) { foreach (var tag in route.RouteTags) { if (!uniqueTags.ContainsKey(tag.Tag)) { uniqueTags.Add(tag.Tag, new RouteTagHolder(activeTags.Contains(tag.Tag), tag)); } } } // Add tags var listView = (ListView)FindViewById(Resource.Id.routeFilterTagList); ArrayAdapter <RouteTagHolder> adapter = new RouteTagArrayAdapter(ApplicationContext, new List <RouteTagHolder> (uniqueTags.Values)); listView.Adapter = adapter; // Add buttons var closeWithoutSave = (Button)FindViewById(Resource.Id.routeFilterCloseWithoutSaveButton); var closeWithSave = (Button)FindViewById(Resource.Id.routeFilterCloseWithSaveButton); closeWithoutSave.SetOnClickListener(new CloseWithoutSaveOnClickListener(this)); closeWithSave.SetOnClickListener(new CloseWithSaveOnClickListener(this, adapter)); }