private async void OnListItemDisappearing(object sender, ItemVisibilityEventArgs e) { // Experimental - Hiding and showing the FAB correctly is dependent on the objects in the list being unique var list = sender as Xamarin.Forms.ListView; if (list == null) { return; } await Task.Run(() => { var items = list.ItemsSource as IList; if (items != null) { var index = items.IndexOf(e.Item); if (index < appearingListItemIndex && index >= 0) { appearingListItemIndex = index; Device.BeginInvokeOnMainThread(async() => { fab.Hide(); await Task.Delay(1000); fab.Show(); }); } else { appearingListItemIndex = index; } } }); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { CallListViewModel = new CallListViewModel(); var rootView = inflater.Inflate(Resource.Layout.fragment_call, container, false); recycler = rootView.FindViewById <RecyclerView>(Resource.Id.recycleCallHistory); fabAddCall = rootView.FindViewById <FloatingActionButton>(Resource.Id.fabCall); swipeRefresh = rootView.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefresh); InitSwipeRefreshLayout(swipeRefresh); recycler.HasFixedSize = true; recycler.SetLayoutManager(new GridLayoutManager(this.Context, 2)); recycler.SetItemAnimator(new DefaultItemAnimator()); Adapter = new CallListAdapter(Activity, CallListViewModel); recycler.SetAdapter(Adapter); InitRecyclerScrollListener(recycler, (e) => { if (e && fabAddCall.IsShown) { fabAddCall.Hide(); } else if (!e && !fabAddCall.IsShown) { fabAddCall.Show(); } }); return(rootView); }
private void InitFAB() { fab = (FloatingActionButton)FindViewById(Resource.Id.floatingActionButton); fab.Hide(); fab.Click += Fab_Click; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); SetContentView(Resource.Layout.PageProfile); _imageView = FindViewById <ImageView>(Resource.Id.imageView); _editFloatingButton = FindViewById <FloatingActionButton>(Resource.Id.fab); _recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); //_uploadButton = FindViewById<ImageButton>(Resource.Id.button1); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetTitle(Resource.String.profile_title); SupportActionBar.SetDisplayHomeAsUpEnabled(true); _editFloatingButton.Click += _editButton_Click; //Binding _nameBinding = this.SetBinding(() => Vm.Model.Name, () => SupportActionBar.Title); _profilePicBinding = this.SetBinding(() => Vm.Model.ProfilePicUrl, () => ProfilePicUrl); RecyclerView.SetLayoutManager(new LinearLayoutManager(this)); RecyclerView.SetAdapter(new ProfileAdapter <Achievement>(Vm, Vm.Model.Achievements)); //_uploadButton.Click += UploadButtonOnClick; //Hide as not implemented _editFloatingButton.Hide(); }
// Выполняется каждый раз, когда меняется страница в ViewPager private void ViewPager_PageSelected(object sender, ViewPager.PageSelectedEventArgs e) { // Показать/скрыть спиннер при смене страницы switch (e.Position) { case 0: SupportActionBar.SetTitle(Resource.String.tab_item_chat_actionbar); fab.Hide(); break; case 1: SupportActionBar.SetTitle(Resource.String.tab_item_select_set); fab.Show(); break; case 2: SupportActionBar.SetTitle(Resource.String.tab_item_edit_set); fab.Show(); break; default: break; } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); manager = SupportFragmentManager; ft = manager.BeginTransaction(); // Create your application here SetContentView(Resource.Layout.Navigation_2); fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Hide(); fragment = new HomeFragment(); ft.Replace(Resource.Id.frame, fragment).Commit(); // ft.Show(fragment); drawerlayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); nav_view = FindViewById <NavigationView>(Resource.Id.nav_view); Toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(Toolbar); drawertoggle = new MyActionBar(this, drawerlayout, Resource.String.drawer_open, Resource.String.drawer_close); drawerlayout.AddDrawerListener(drawertoggle); nav_view.NavigationItemSelected += NavigationView_NavigationItemSelected; SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); drawertoggle.SyncState(); }
public static void SetDrawableImageSafe(this FloatingActionButton button, Drawable drawable) { var wasHiddenBeforeChange = button.IsOrWillBeHidden; button.Hide(); button.SetImageDrawable(drawable); button.Show(new FabVisibilityListener(() => { button.ImageMatrix.SetScale(1, 1); })); if (wasHiddenBeforeChange) { button.Hide(); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { if (dy != 0 && _fab.IsShown) { _fab.Hide(); } }
void OnStartNewConversationClick(object sender, EventArgs e) { selectFriend.Visibility = ViewStates.Visible; fab.Hide(); if (viewModel.Friends.Count == 0) { viewModel.ExecuteLoadFriendsCommand(false); } }
// show or hide the fab private void toggleFab() { if (navItemIndex == 0) { fab.Show(); } else { fab.Hide(); } }
public void OnPageSelected(int position) { if (position == 2) { fab.Show(); } else { fab.Hide(); } }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { base.OnScrolled(recyclerView, dx, dy); if (dy > 0 && fab.IsShown) { fab.Hide(); } else if (dy < 0 && !fab.IsShown) { fab.Show(); } }
private void ListView_Scroll(object sender, AbsListView.ScrollEventArgs e) { if (e.FirstVisibleItem > mPreviousVisibleItem) { fab.Hide(true); } else if (e.FirstVisibleItem < mPreviousVisibleItem) { fab.Show(true); } mPreviousVisibleItem = e.FirstVisibleItem; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.dean_view_group); grouplistView = FindViewById <ListView>(Resource.Id.dean_group_viewList); grouplist = new List <Group>(); grouplist = DataBaseHelper.GetListOfGroup(); groupAdapter = new GroupAdapter(this, grouplist); grouplistView.Adapter = groupAdapter; grouplistView.ItemClick += GrouplistView_ItemClick; FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab_add_group); fab.Hide(); }
protected override void OnViewModelSet() { System.Diagnostics.Debug.WriteLine("EditItemActivity.OnViewModelSet()"); SetContentView(Resource.Layout.activity_edit_item); // Status Bar Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds); if (IsThereAnAppToTakePictures()) { cameraFab = FindViewById <FloatingActionButton>(Resource.Id.activity_edit_item_fab_photo); cameraFab.Click -= CameraFab_Click; cameraFab.Click += CameraFab_Click; } else { cameraFab.Hide(); } imageView = FindViewById <ImageViewAsync>(Resource.Id.editItem_imageView); imageView.SetColorFilter(Color.ParseColor(Resources.GetString(Resource.Color.accent))); imageOverlay = FindViewById <RelativeLayout>(Resource.Id.edititem_relativelayout_imageoverlay); deleteImageButton = FindViewById <ImageButton>(Resource.Id.edititem_imagebutton_deletephoto); if (!string.IsNullOrEmpty(ViewModel.Item.ImageFilename)) { imageFile = new Java.IO.File(AndroidHelper._dir, ViewModel.Item.ImageFilename); // Clear placeholder imageView.SetColorFilter(null); imageView.SetImageDrawable(null); LoadImage(); } datePurchasedEditText = FindViewById <TextInputEditText>(Resource.Id.editItem_editText_date_purchased); // Auto completion setup - more work than its worth in mvvm. The one time Android makes it easier... var locationACTV = FindViewById <AutoCompleteTextView>(Resource.Id.activity_edit_item_autocompletetextview_location); var categoryACTV = FindViewById <AutoCompleteTextView>(Resource.Id.activity_edit_item_autocompletetextview_category); var locAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, ViewModel.Locations); var catAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, ViewModel.Categories); locationACTV.Adapter = locAdapter; categoryACTV.Adapter = catAdapter; }
public override void OnScrolled(RecyclerView recyclerView, int dx, int dy) { if (!_canScroll.Invoke()) { return; } if (dy < 0 && !_fab.IsShown) { _fab.Show(); } else if (dy > 0 && _fab.IsShown) { _fab.Hide(); } }
private void PageChanged(object sender, ViewPager.PageSelectedEventArgs e) { _lastSelected?.OnUnselect(); int position = e.Position; if (_floatingActionButton.IsShown) { _floatingActionButton.Hide(); } Fragment current = SupportFragmentManager.Fragments[position]; (current as IFabDecorator)?.Decorate(_floatingActionButton); (_lastSelected = current as ISelectable)?.OnSelect(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SimpleActivity); SetSupportActionBar(FindViewById <Toolbar>(Resource.Id.simpleActivityToolBar)); FAB = (FloatingActionButton)FindViewById(Resource.Id.simpleActivityFAB); FAB.Hide(); FM = SupportFragmentManager; var ft = FM.BeginTransaction(); var fragString = Intent.GetStringExtra(Constants.KEY_FRAGMENT_TYPE); var longId = Intent.GetLongExtra(Constants.EXTRA_LONG_ID, -1); switch (fragString) { case "FanReact.LoginPage": lpFragment = new LoginPage().CreateFragment(this); lft = FragmentManager.BeginTransaction(); lft.AddToBackStack(null); lft.Replace(Resource.Id.simpleActivityContent, lpFragment, "Login Page"); lft.Commit(); return; case "FanReact.SecondPage": lpFragment = new SecondPage().CreateFragment(this); lft = FragmentManager.BeginTransaction(); lft.AddToBackStack(null); lft.Replace(Resource.Id.simpleActivityContent, lpFragment, "Second Page"); lft.Commit(); return; case Constants.FRAG_TYPE_ALL_PROGRAMS: //GoToAllProgramsPage(longId); lpFragment = new AllProgramsPage(longId).CreateFragment(this); lft = FragmentManager.BeginTransaction(); lft.AddToBackStack(null); lft.Replace(Resource.Id.simpleActivityContent, lpFragment, Constants.FRAG_TYPE_ALL_PROGRAMS); lft.Commit(); return; } }
public override void OnNestedScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) { // dyconsumed: user initiates movement on the y-axis and it happens on screen // dyunconsumed: user initiates movement on the y-axis but it doesn't happen on screen, for example, downwards movement at the bottom end of the list. // dy > 0: user swiping up, so screen in scrolling down // dy < 0: user swiping down, so screen is scrolling up base.OnNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); BottomNavigationView childView = child.JavaCast <BottomNavigationView>(); if (dyUnconsumed > 0 || dyConsumed > 0) { this.SlideDown(childView); } else if (dyUnconsumed < 0 || dyConsumed < 0) { this.SlideUp(childView); } // define our own behavior IList <View> dependencies = coordinatorLayout.GetDependencies(childView); foreach (View view in dependencies) { if (view is FloatingActionButton) { FloatingActionButton floatingActionButtonView = view.JavaCast <FloatingActionButton>(); if (dyUnconsumed > 0 || dyConsumed > 0) { floatingActionButtonView.Hide(); } else if (dyUnconsumed < 0 || dyConsumed < 0) { floatingActionButtonView.Show(); } } } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); mainRecycler = FindViewById <RecyclerView>(Resource.Id.main_recycler); emptyRoot = FindViewById <ConstraintLayout>(Resource.Id.rv_empty_view); swipe_container = FindViewById <SwipeRefreshLayout>(Resource.Id.main_refresher); addPostFab = FindViewById <FloatingActionButton>(Resource.Id.post_fab); var appbar = FindViewById <AppBarLayout>(Resource.Id.activity_main_appbar); var toolbar = appbar.FindViewById <Toolbar>(Resource.Id.main_toolbar); SetSupportActionBar(toolbar); addPostFab.Click += AddPostFab_Click; mainRecycler.AddOnScrollListener(new OnscrollListener( onScrolled: (r, dx, dy) => { if (dy > 0) { addPostFab.Hide(); } else if (dy < 0) { addPostFab.Show(); } })); DividerItemDecoration decoration = new DividerItemDecoration(mainRecycler.Context, DividerItemDecoration.Vertical); mainRecycler.AddItemDecoration(decoration); posts = new List <Post>(); profileParcelable.WriteTOParcelFailed += ProfileParcelable_WriteTOParcelFailed; new SlydepayPayment(this).InitCredentials("*****@*****.**", "J33899SJS8EJDJDJJ"); await GetUserFromFireAsync(); postEventListener.FetchPost(); postEventListener.OnPostRetrieved += PostEventListener_OnPostRetrieved; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (EngineService.EngineInstance.ChatListViewModel == null) { EngineService.EngineInstance.ChatListViewModel = new ChatListViewModel(); } ChatListViewModel = EngineService.EngineInstance.ChatListViewModel; var rootView = inflater.Inflate(Resource.Layout.fragment_chat, container, false); recycler = rootView.FindViewById <RecyclerView>(Resource.Id.recycleChatHistory); fabAdd = rootView.FindViewById <FloatingActionButton>(Resource.Id.fabAddChat); swipeRefresh = rootView.FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefresh); InitSwipeRefreshLayout(swipeRefresh); recycler.HasFixedSize = true; recycler.SetLayoutManager(new LinearLayoutManager(this.Context, LinearLayoutManager.Vertical, false)); recycler.SetItemAnimator(new DefaultItemAnimator()); Adapter = new ChatListAdapter(Activity, ChatListViewModel); recycler.SetAdapter(Adapter); InitRecyclerScrollListener(recycler, (e) => { if (e && fabAdd.IsShown) { fabAdd.Hide(); } else if (!e && !fabAdd.IsShown) { fabAdd.Show(); } }); fabAdd.Click += (sender, e) => { ParentActivity.SetTabAndFragment(MainActivity.FRAGMENT_TYPE.FRAGMENT_CONTACT); }; return(rootView); }
public void Hide(bool animate = true) { fab.Hide(animate); }
private void ToggleProfile(bool enabled) { // Show or hide buttons if (enabled) { // Show map, hide user fabUser.Hide(); fabMap.Show(); } else { // Hide map, show user fabMap.Hide(); fabUser.Show(); } // Hide battle info battleInfo.State = BottomSheetBehavior.StateHidden; // Starting/ending point var centerX = fabUser.Left + fabUser.Width / 2; var centerY = fabUser.Top + fabUser.Height / 2; // Button radius var radius = (float)Math.Sqrt(centerX * centerX + centerY * centerY); var animator = ViewAnimationUtils.CreateCircularReveal(profileView, centerX, centerY, enabled ? 0f : radius, enabled ? radius : 0f); // Hide or show view if (enabled) { profileView.Visibility = ViewStates.Visible; } else { animator.AnimationEnd += (o, eventArgs) => profileView.Visibility = ViewStates.Invisible; } // Update values on opening profile if (enabled) { // Check profile stat views if (profileStats == null) { TextView FindTextView(int id) => mainView.FindViewById <TextView>(id); profileStats = new Dictionary <string, TextView> { { "hp", FindTextView(Resource.Id.text_profile_hp) }, { "attack", FindTextView(Resource.Id.text_profile_attack) }, { "evasion", FindTextView(Resource.Id.text_profile_evasion) }, { "level", FindTextView(Resource.Id.text_profile_level_info) }, { "armor", FindTextView(Resource.Id.text_profile_armor) } }; } // Check companion info views if (companionInfos == null) { ImageView FindImageView(int id) => profileView.FindViewById <ImageView>(id); companionInfos = new[] { FindImageView(Resource.Id.text_companion_type_1), FindImageView(Resource.Id.text_companion_type_2), FindImageView(Resource.Id.text_companion_type_3) }; } var user = AccountManager.CurrentUser; // Set stats profileStats["hp"].Text = $"{user.HealthPercentage}%"; profileStats["attack"].Text = $"{user.Attack}"; profileStats["evasion"].Text = $"{user.Evasion * 100}%"; profileStats["level"].Text = $"Level {user.Level} ({user.ExperienceToNextLevel} xp to next level)"; profileStats["armor"].Text = $"{user.Armor}"; // Set companion info for (var i = 0; i < companionInfos.Length; i++) { companionInfos[i].SetImageDrawable(AssetLoader.GetCompanionTypeDrawable(Resources, user.EquippedCompanions[i].Type)); } // Update collected companions count profileView.FindViewById <TextView>(Resource.Id.text_companions_collected).Text = $"{AccountManager.CurrentUser.UniqueCompanionCount}/{CompanionManager.CompanionCount} collected"; } else { AccountManager.SaveUserProgress(); } animator.Start(); }
public void Hide() { _floatingButton.Hide(); }
private async void ConnectButton_Click(object sender, EventArgs e) { BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter; if (adapter == null) { throw new Exception("No Bluetooth adapter found."); } if (!adapter.IsEnabled) { throw new Exception("Bluetooth adapter is not enabled."); } BluetoothDevice device = (from bd in adapter.BondedDevices where bd.Name == "HC-06" //**************bluetoothdevice name********************//TODO// select bd).FirstOrDefault(); if (device == null) { throw new Exception("Named device not found."); } if (_socket == null) { _socket = device.CreateRfcommSocketToServiceRecord(UUID.FromString("00001101-0000-1000-8000-00805f9b34fb")); await _socket.ConnectAsync(); connectButton.SetImageResource(Android.Resource.Drawable.IcPopupSync); RunOnUiThread((Action)(async() => { while (true) { await _socket.InputStream.ReadAsync(buffer, 0, buffer.Length); if (received_data == 0) { received_data = 1; } if (buffer[0] >= 0) { receive_buffer[receive_buffer_counter] = buffer[0]; // (byte)nextByte; //Load them in the received_buffer array. } //Search for the start signature in the received data stream. if (receive_byte_previous == 'J' && receive_buffer[receive_buffer_counter] == 'B') { receive_buffer_counter = 0; //Reset the receive_buffer_counter counter if the start signature if found. receive_start_detect++; //Increment the receive_start_detect to check for a full data stream reception. if (receive_start_detect >= 2) { get_data(); latLongJMCdrone = new LatLng(-l_lat_gps / 1000000.0, -l_lon_gps / 1000000.0); if (start == 0) { wayPointArray[0] = latLongJMCdrone; } if (home_gps_set == 0 && number_used_sats > minSats && start == 2) { home_gps_set = 1; home_lat_gps = l_lat_gps; home_lon_gps = l_lon_gps; homeLatLong = new LatLng(-home_lat_gps / 1000000.0, -home_lon_gps / 1000000.0); wayPointArray[0] = homeLatLong; } if (home_gps_set == 1 && start == 0) { home_gps_set = 0; } if (fixCameraHomePoint / fixCameraHomePointDivisor != 1 || boolDragEnd || floatingButton2_clicked || floatingButton3_clicked || floatingButton4_clicked || number_used_sats == 0 || flight_mode >= 5) { mapFragment.GetMapAsync(this);//update Map } if (number_used_sats == 0) { Toast.MakeText(this, "No GPS signal", ToastLength.Long).Show(); progressBar1.SetProgress(1 + myRandowInt.Next(2, 5), false); fixCameraHomePointDivisor = 1; fixCameraHomePoint = 2; } if (number_used_sats > 0 && number_used_sats <= minSats) { progressBar1.SetProgress(number_used_sats * 7 + myRandowInt.Next(0, 5), false); fixCameraHomePoint = 6; } if (number_used_sats > minSats) { fixCameraHomePoint = 7; progressBar1.SetProgress(80 + myRandowInt.Next(5, 20), false); } if (flight_mode == 1) { bluetoothData1.Text = "1-Auto level"; } if (flight_mode == 2) { bluetoothData1.Text = "2-Altitude hold"; } if (flight_mode == 3) { bluetoothData1.Text = "3-GPS hold"; } if (flight_mode == 4) { bluetoothData1.Text = "4-RTH active"; } if (flight_mode == 5) { bluetoothData1.Text = "5-RTH I"; //5-RTH Increase altitude } if (flight_mode == 6) { bluetoothData1.Text = "6-RTH R"; //6-RTH Returning to home position } if (flight_mode == 7) { bluetoothData1.Text = "7-RTH L"; //7-RTH Landing } if (flight_mode == 8) { bluetoothData1.Text = "8-RTH F"; //8-RTH finished } if (flight_mode == 9) { bluetoothData1.Text = "9-Fly waypoint"; } bluetoothData2.Text = (this.latLongJMCdrone.Latitude).ToString(); bluetoothData3.Text = (this.latLongJMCdrone.Longitude).ToString(); bluetoothData4.Text = number_used_sats.ToString(); bluetoothData5.Text = start.ToString(); bluetoothData6.Text = actual_compass_heading.ToString(); bluetoothData7.Text = battery_voltage.ToString(); bluetoothData8.Text = los_distance.ToString("0.") + " m"; fixCameraHomePointDivisor = fixCameraHomePoint; } } else { //If there is no start signature detected. receive_byte_previous = receive_buffer[receive_buffer_counter]; //Safe the current received byte for the next loop. receive_buffer_counter++; //Increment the receive_buffer_counter variable. if (receive_buffer_counter > 48) { receive_buffer_counter = 0; //Reset the receive_buffer_counter variable when it becomes larger than 38. } } if (flight_mode == 9) { fixWayPoint = true; } if (flight_mode == 3 && fixWayPoint == false) { await _socket.OutputStream.WriteAsync(send_buffer, 0, 13); } if (start == 2 && flight_mode == 3 && flyWayPointCounter <= addWayPointCounter + 1 && floatingButton3_clicked && fixWayPoint) { int latitude; int longitude; fixWayPoint = false; flyWayPointCounter++; floatingButton1.Hide(); floatingButton2.Hide(); floatingButton3.Hide(); floatingButton4.Hide(); if (flyWayPointCounter == addWayPointCounter + 1) { // +1 para retornar a origem !!!! floatingButton3_clicked = false; flyWayPointCounter = 0; floatingButton1.Show(); floatingButton2.Show(); floatingButton3.Show(); floatingButton4.Show(); latitude = (int)(homeLatLong.Latitude * 1000000.0); if (latitude < 0) { latitude *= -1; // deve ser um valor positivo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } longitude = (int)(homeLatLong.Longitude * 1000000.0); if (longitude > 0) { longitude *= -1; // deve ser um valor negativo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } } else { latitude = (int)(wayPointArray[flyWayPointCounter].Latitude * 1000000.0); if (latitude < 0) { latitude *= -1; // deve ser um valor positivo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } longitude = (int)(wayPointArray[flyWayPointCounter].Longitude * 1000000.0); if (longitude > 0) { longitude *= -1; // deve ser um valor negativo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } } send_buffer[0] = (byte)'W'; send_buffer[1] = (byte)'P'; send_buffer[5] = (byte)(latitude >> 24); send_buffer[4] = (byte)(latitude >> 16); send_buffer[3] = (byte)(latitude >> 8); send_buffer[2] = (byte)latitude; send_buffer[9] = (byte)(longitude >> 24); send_buffer[8] = (byte)(longitude >> 16); send_buffer[7] = (byte)(longitude >> 8); send_buffer[6] = (byte)longitude; send_buffer[10] = (byte)'-'; check_byte = 0; for (temp_byte = 2; temp_byte <= 10; temp_byte++) { check_byte ^= send_buffer[temp_byte]; } send_buffer[11] = check_byte; await _socket.OutputStream.WriteAsync(send_buffer, 0, 13); } } })); } }
public void OnClick(object sender, EventArgs args) { ReplaceFragment(new NavigationFragment()); restartNavigationFab.Hide(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.main_activity); // Setup toolbar Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); toolbar.SetTitle(Resource.String.applicationname); // Set toolbar title here if (toolbar != null) { SetSupportActionBar(toolbar); //SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(false); } // Setup FloatingActionButton click FloatingActionButton navigateToCreateInvoicesActivityFloatingActionButton = FindViewById <FloatingActionButton>(Resource.Id.floatingactionbutton_navigatetoinvoicescreateviewmodel); navigateToCreateInvoicesActivityFloatingActionButton.Click += delegate { Intent intent = new Intent(this, typeof(InvoicesCreateActivity)); StartActivity(intent); }; // Setup BottomNavigationView clicks BottomNavigationView bottomNavigationView = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation); bottomNavigationView.NavigationItemSelected += (sender, e) => { Android.Support.V4.App.FragmentTransaction fragmentTransaction = this.SupportFragmentManager.BeginTransaction(); fragmentTransaction.SetCustomAnimations(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out); switch (e.Item.ItemId) { case Resource.Id.bottomnavigationview_invoices: InvoicesFragment invoicesFragment = new InvoicesFragment(); fragmentTransaction.Replace(Resource.Id.main_container, invoicesFragment); fragmentTransaction.Commit(); // show the floating action button navigateToCreateInvoicesActivityFloatingActionButton.Show(); break; case Resource.Id.bottomnavigationview_configuration: ConfigurationFragment configurationFragment = new ConfigurationFragment(); fragmentTransaction.Replace(Resource.Id.main_container, configurationFragment); fragmentTransaction.Commit(); // hide the floating action button navigateToCreateInvoicesActivityFloatingActionButton.Hide(); break; } }; // OnCreate only run once when this activity is created. So let's set the default // fragment to show by 'clicking' on the bottomnavigationview_invoices button. View bottomNavigationViewInvoicesButton = bottomNavigationView.FindViewById(Resource.Id.bottomnavigationview_invoices); bottomNavigationViewInvoicesButton.PerformClick(); }
protected async override void OnResume() { base.OnResume(); var portInfo = Intent.GetParcelableExtra(EXTRA_TAG) as UsbSerialPortInfo; int vendorId = portInfo.VendorId; int deviceId = portInfo.DeviceId; int portNumber = portInfo.PortNumber; var drivers = await FindAllDriversAsync(usbManager); var driver = drivers.Where((d) => d.Device.VendorId == vendorId && d.Device.DeviceId == deviceId).FirstOrDefault(); if (driver == null) { throw new Exception("Driver specified in extra tag not found."); } port = driver.Ports[portNumber]; if (port == null) { bluetoothData1.Text = "No serial device."; return; } serialIoManager = new SerialInputOutputManager(port) { //BaudRate = 115200, BaudRate = 9600, DataBits = 8, StopBits = StopBits.One, Parity = Parity.None, }; serialIoManager.DataReceived += (sender, e) => { RunOnUiThread(() => { UpdateReceivedData(e.Data); if (received_data == 0) { received_data = 1; } if (buffer[0] >= 0) { receive_buffer[receive_buffer_counter] = buffer[0]; // (byte)nextByte; //Load them in the received_buffer array. } //Search for the start signature in the received data stream. if (receive_byte_previous == 'J' && receive_buffer[receive_buffer_counter] == 'B') { receive_buffer_counter = 0; //Reset the receive_buffer_counter counter if the start signature if found. receive_start_detect++; //Increment the receive_start_detect to check for a full data stream reception. if (receive_start_detect >= 2) { Set_data(); latLongJMCdrone = new LatLng(-l_lat_gps / 1000000.0, -l_lon_gps / 1000000.0); if (start == 0) { wayPointArray[0] = latLongJMCdrone; } if (home_gps_set == 0 && number_used_sats > minSats && start == 2) { home_gps_set = 1; home_lat_gps = l_lat_gps; home_lon_gps = l_lon_gps; homeLatLong = new LatLng(-home_lat_gps / 1000000.0, -home_lon_gps / 1000000.0); wayPointArray[0] = homeLatLong; } if (home_gps_set == 1 && start == 0) { home_gps_set = 0; } if (fixCameraHomePoint / fixCameraHomePointDivisor != 1 || boolDragEnd || floatingButton2_clicked || floatingButton3_clicked || floatingButton4_clicked || number_used_sats == 0 || flight_mode >= 5) { mapFragment.GetMapAsync(this);//update Map } if (number_used_sats == 0) { Toast.MakeText(this, "No GPS signal", ToastLength.Long).Show(); progressBar1.SetProgress(1 + myRandowInt.Next(2, 5), false); fixCameraHomePointDivisor = 1; fixCameraHomePoint = 2; } if (number_used_sats > 0 && number_used_sats <= minSats) { progressBar1.SetProgress(number_used_sats * 7 + myRandowInt.Next(0, 5), false); fixCameraHomePoint = 6; } if (number_used_sats > minSats) { fixCameraHomePoint = 7; progressBar1.SetProgress(80 + myRandowInt.Next(5, 20), false); } if (flight_mode == 1) { bluetoothData1.Text = "1-Auto level"; } if (flight_mode == 2) { bluetoothData1.Text = "2-Altitude hold"; } if (flight_mode == 3) { bluetoothData1.Text = "3-GPS hold"; } if (flight_mode == 4) { bluetoothData1.Text = "4-RTH active"; } if (flight_mode == 5) { bluetoothData1.Text = "5-RTH I"; //5-RTH Increase altitude } if (flight_mode == 6) { bluetoothData1.Text = "6-RTH R"; //6-RTH Returning to home position } if (flight_mode == 7) { bluetoothData1.Text = "7-RTH L"; //7-RTH Landing } if (flight_mode == 8) { bluetoothData1.Text = "8-RTH F"; //8-RTH finished } if (flight_mode == 9) { bluetoothData1.Text = "9-Fly waypoint"; } bluetoothData2.Text = (latLongJMCdrone.Latitude).ToString(); bluetoothData3.Text = (latLongJMCdrone.Longitude).ToString(); bluetoothData4.Text = number_used_sats.ToString(); bluetoothData5.Text = start.ToString(); bluetoothData6.Text = actual_compass_heading.ToString(); bluetoothData7.Text = battery_voltage.ToString(); bluetoothData8.Text = los_distance.ToString("0.") + " m"; fixCameraHomePointDivisor = fixCameraHomePoint; } } else { //If there is no start signature detected. receive_byte_previous = receive_buffer[receive_buffer_counter]; //Safe the current received byte for the next loop. receive_buffer_counter++; //Increment the receive_buffer_counter variable. if (receive_buffer_counter > 48) { receive_buffer_counter = 0; //Reset the receive_buffer_counter variable when it becomes larger than 38. } } if (flight_mode == 9) { fixWayPoint = true; } if (flight_mode == 3 && fixWayPoint == false) { WriteData(send_buffer); } if (start == 2 && flight_mode == 3 && flyWayPointCounter <= addWayPointCounter + 1 && floatingButton3_clicked && fixWayPoint) { int latitude; int longitude; fixWayPoint = false; flyWayPointCounter++; floatingButton1.Hide(); floatingButton2.Hide(); floatingButton3.Hide(); floatingButton4.Hide(); if (flyWayPointCounter == addWayPointCounter + 1) { // +1 para retornar a origem !!!! floatingButton3_clicked = false; flyWayPointCounter = 0; floatingButton1.Show(); floatingButton2.Show(); floatingButton3.Show(); floatingButton4.Show(); latitude = (int)(homeLatLong.Latitude * 1000000.0); if (latitude < 0) { latitude *= -1; // deve ser um valor positivo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } longitude = (int)(homeLatLong.Longitude * 1000000.0); if (longitude > 0) { longitude *= -1; // deve ser um valor negativo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } } else { latitude = (int)(wayPointArray[flyWayPointCounter].Latitude * 1000000.0); if (latitude < 0) { latitude *= -1; // deve ser um valor positivo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } longitude = (int)(wayPointArray[flyWayPointCounter].Longitude * 1000000.0); if (longitude > 0) { longitude *= -1; // deve ser um valor negativo// nao sei porque //deve ser por causa do sketch translatebyte do codigo arduino!!!! } } send_buffer[0] = (byte)'W'; send_buffer[1] = (byte)'P'; send_buffer[5] = (byte)(latitude >> 24); send_buffer[4] = (byte)(latitude >> 16); send_buffer[3] = (byte)(latitude >> 8); send_buffer[2] = (byte)latitude; send_buffer[9] = (byte)(longitude >> 24); send_buffer[8] = (byte)(longitude >> 16); send_buffer[7] = (byte)(longitude >> 8); send_buffer[6] = (byte)longitude; send_buffer[10] = (byte)'-'; check_byte = 0; for (temp_byte = 2; temp_byte <= 10; temp_byte++) { check_byte ^= send_buffer[temp_byte]; } send_buffer[11] = check_byte; WriteData(send_buffer); } }); }; serialIoManager.ErrorReceived += (sender, e) => { RunOnUiThread(() => { var intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); }); }; try { serialIoManager.Open(usbManager); } catch (Java.IO.IOException e) { bluetoothData1.Text = "Error opening device: " + e.Message; return; } }
/* * The initial state when there is no active conversation. */ void setCallAction() { callActionFab.SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.ic_call_white_24px)); callActionFab.Show(); callActionFab.Click += (sender, e) => { showCallDialog(); }; switchCameraActionFab.Show(); switchCameraActionFab.Click += (sender, e) => { if (cameraCapturer != null) { cameraCapturer.SwitchCamera(); } }; localVideoActionFab.Show(); localVideoActionFab.Click += (sender, e) => { /* * Enable/disable local video track */ pauseVideo = !pauseVideo; if (conversation != null) { var videoTrackList = conversation.LocalMedia.LocalVideoTracks; if (videoTrackList.Count > 0) { var videoTrack = videoTrackList[0]; videoTrack.Enable(!pauseVideo); } else { Android.Util.Log.Warn(TAG, "LocalVideoTrack is not present, unable to pause"); } } if (pauseVideo) { switchCameraActionFab.Hide(); localVideoActionFab.SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.ic_videocam_off_red_24px)); } else { switchCameraActionFab.Show(); localVideoActionFab.SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.ic_videocam_green_24px)); } }; muteActionFab.Show(); muteActionFab.Click += (sender, e) => { /* * Mute/unmute microphone */ muteMicrophone = !muteMicrophone; if (conversation != null) { conversation.LocalMedia.Mute(muteMicrophone); } if (muteMicrophone) { muteActionFab.SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.ic_mic_off_red_24px)); } else { muteActionFab.SetImageDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.ic_mic_green_24px)); } }; speakerActionFab.Hide(); }
/// <summary> /// Hide! /// </summary> /// <param name="animate"></param> public void Hide(bool animate = true) => fab?.Hide(animate);