public static WeatherNowFragment NewInstance(Bundle args) { var fragment = new WeatherNowFragment() { Arguments = args }; return(fragment); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); mWearableActionDrawer = FindViewById <WearableActionDrawerView>(Resource.Id.bottom_action_drawer); mWearableActionDrawer.SetOnMenuItemClickListener(this); mWearableActionDrawer.PeekOnScrollDownEnabled = true; mWearableNavigationDrawer = FindViewById <WearableNavigationDrawerView>(Resource.Id.top_nav_drawer); mWearableNavigationDrawer.AddOnItemSelectedListener(this); mWearableNavigationDrawer.PeekOnScrollDownEnabled = true; mNavDrawerAdapter = new NavDrawerAdapter(this); mWearableNavigationDrawer.SetAdapter(mNavDrawerAdapter); mBroadcastReceiver = new LocalBroadcastReceiver(); mBroadcastReceiver.BroadcastReceived += (context, intent) => { if (WearableDataListenerService.ACTION_SHOWSTORELISTING.Equals(intent?.Action)) { var intentAndroid = new Intent(Intent.ActionView) .AddCategory(Intent.CategoryBrowsable) .SetData(WearableHelper.PlayStoreURI); RemoteIntent.StartRemoteActivity(this, intentAndroid, new ConfirmationResultReceiver(this)); } else if (WearableDataListenerService.ACTION_OPENONPHONE.Equals(intent?.Action)) { bool success = (bool)intent?.GetBooleanExtra(WearableDataListenerService.EXTRA_SUCCESS, false); new ConfirmationOverlay() .SetType(success ? ConfirmationOverlay.OpenOnPhoneAnimation : ConfirmationOverlay.FailureAnimation) .ShowOn(this); } }; var filter = new IntentFilter(); filter.AddAction(WearableDataListenerService.ACTION_SHOWSTORELISTING); filter.AddAction(WearableDataListenerService.ACTION_OPENONPHONE); LocalBroadcastManager.GetInstance(this).RegisterReceiver(mBroadcastReceiver, filter); // Create your application here Fragment fragment = FragmentManager.FindFragmentById(Resource.Id.fragment_container); // Check if fragment exists if (fragment == null) { fragment = new WeatherNowFragment(); // Navigate to WeatherNowFragment FragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, fragment, "home") .Commit(); } }
/** * Use this factory method to create a new instance of * this fragment using the provided parameters. * * @param query Weather query. * @param index Location index. * @return A new instance of fragment WeatherNowFragment. */ public static WeatherNowFragment NewInstance(LocationData data) { var fragment = new WeatherNowFragment(); if (data != null) { Bundle args = new Bundle(); args.PutString("data", data.ToJson()); fragment.Arguments = args; } return(fragment); }