r2cloud | Decode satellite signals on Raspberry PI | Navigation library
kandi X-RAY | r2cloud Summary
Support
Quality
Security
License
Reuse
- Starts Lora observation
- Sends the request to the LORAR
- Converts a LoraFrame to a RawBeacon object
- Stops an observation
- Process the request
- Sets whether the file should be written
- Returns an integer value from a JsonValue
- Returns a list of observations from the user
- Finds the first observation of the specified transmitter
- Updates the dns
- Returns the current location and view
- Submits an action to the server
- Get the status of the devices
- Decode Lpsk data
- Decode a WV file
- Handles POST request
- Adds a time slot with the specified frequency
- Adds a time slot to the current music slot
- Adds the specified time slot to this time slot
- Starts the Sdr server
- Starts the rtl reader
- Handle a GET request
- Returns the status of the SdrManager
- Get the status of the device
- Starts the R2Cloud application
- Post observation
r2cloud Key Features
r2cloud Examples and Code Snippets
Trending Discussions on Navigation
Trending Discussions on Navigation
QUESTION
I have customized back button. when I click on it, the application crashes after a second. here is the code: error log
private var mBackPressed: Long = 0
private val timeInterval = 2000
private fun configBackPress() {
requireActivity().onBackPressedDispatcher.addCallback(this, true) {
when {
mBackPressed + timeInterval > System.currentTimeMillis() -> {
requireActivity().onBackPressedDispatcher.onBackPressed()
}
else -> {
Snackbar.make(
requireActivity().findViewById(android.R.id.content),
getString(R.string.press_once_again_back_button_to_exit),
Snackbar.LENGTH_SHORT
)
.setAnchorView(viewBinding.vSnackBarHelper)
.show()
mBackPressed = System.currentTimeMillis()
}
}
}
}
when the user click two times on back button, the back should work.
ANSWER
Answered 2022-Apr-05 at 07:23before calling requireActivity().onBackPressedDispatcher.onBackPressed()
. you should set isEnabled
to false because if we go through the onBackPressed source code we see:
it looks for active callbacks and if found any calls them and returns. that's what makes the loop.
your code should be:
isEnabled = false
requireActivity().onBackPressedDispatcher.onBackPressed()
QUESTION
I'm using BottomNavigationView
with Navigation Component. When showing fragment is not root fragment, the tab icon is not updated (selected).
Example:
When I switch between Tab Home with Fragment A (which is root fragment) and Tab Star with Fragment B (which is also root fragment) it is working fine.
But when I navigate from Tab Home to another fragment, like fragment A2, and tap on Tab Star and again return to Tab Home, still Tab Star is selected in BottomNavigationView
.
It was working fine with version 2.4.0-alpha05
, This is happening when I updated it to 2.5.0-alpha01
.
build.gradle (app)
implementation "androidx.navigation:navigation-fragment-ktx:2.5.0-alpha01"
implementation "androidx.navigation:navigation-ui-ktx:2.5.0-alpha01"
implementation "androidx.navigation:navigation-dynamic-features-fragment:2.5.0-alpha01"
build.gradle (root)
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.0-alpha01"
Menu:
Am I doing something wrong? or this is bug?
How can I resolve this problem?
ANSWER
Answered 2022-Feb-12 at 06:00Given your navigation graph, there is no way to associate fragmentA2
with your menu item fragmentA
, so fragmentA
is not selected when you return to fragmentA2
. As per this issue:
NavigationUI
has always used the current destination and what graph it is part of as the source of truth for what tab should be selected.This can be seen by calling
navigate()
to go to yourSecondFragment
- even though you haven't used the bottom nav button, the selected tab was changed because the current destination has changed toR.id.frag_second
.So when you
navigate()
toR.id.frag_hint
via your button inHomeFragment
,NavigationUI
receives a callback that the current destination has changed toR.id.frag_hint
. It looks at thatNavDestination
and notes that there's no menu item that matchesR.id.frag_hint
. It then looks at the destination's parent graph - yourR.id.sample
element. There's no menu item that matches that ID either, so
NavigationUI
can't associated that destination with any menu item and therefore simply does nothing. That is true on all versions of Navigation.So what is different when you tap on a bottom navigation item? Well, nothing different from a
NavigationUI
perspective in fact: the exact same code runs and the current destination and what graph it is part of is the source of truth for what tab should be selected. In the Navigation 2.3.5, there was no state saved for each tab, so it only 'worked' because selecting a tab forced the ID of the current destination to match the destination of the menu item you just tapped.So what you're seeing in your sample app is that there's no link between
R.id.frag_hint
and any menu item, which meansNavigationUI
does nothing. If you want to linkR.id.frag_hint
to your Home tab, then that's exactly what a nested navigation graph can be used for.I.e., your navigation graph should instead look like:
And your menu XML should be updated to use android:id="@id/home"
to match your navigation graph.
Now, when you select the Home bottom nav item, the current destination changes to R.id.frag_hint
(as your state was restored due to Navigation 2.4's support for multiple back stacks) and NavigationUI
looks at the ID - R.id.frag_hint
still doesn't match any menu item, but now the parent graph's ID, R.id.home
does match a menu item - your Home menu item, hence, it becomes selected.
The intention that your navigation graph and its structure drives the UI is a key part of how NavigationUI
works and is working as intended (there was a bug on earlier versions of Navigation 2.4 that broke this driving principle, but that has since been fixed in beta02). All of NavigationUI
is built on public APIs specifically so that if you want to use some different logic for which bottom nav item is selected that is independent from your navigation graph structure, you can absolutely do that.
You'll note from the source code that you can call the public onNavDestinationSelected
with your MenuItem
to get the exact same navigate()
logic which retaining your own ability to return any value from the setOnItemSelectedListener
(which is what controls whether the tab becomes selected). Similarly, your own OnDestinationChangedListener
can choose to look at the hierarchy
of a destination to choose whether to change the selected bottom nav item or not.
So your graphs should also be using nested graphs for each tab:
Menu:
QUESTION
I want to know the current route name but inside the navigation js file, I use the useRoute hook in any component and work well, but I get this error when I use useRoute inside navigation.js
Error: Couldn't find a route object. Is your component inside a screen in a navigator?
navigation.js code example,
export default function Navigation() {
const route = useRoute(); // show error >> Error: Couldn't find a route object. Is your component inside a screen in a navigator?
return (
);
}
when I remove useRoute, the Error is gone, But I need to use useRoute or any other way to get current route name inside navigation.js file.
ANSWER
Answered 2022-Mar-22 at 19:33You can pass the navigationContainerRef
from the NavigationContainer
to the Navigation
comomponent to make the navigation
object accessible.
Consider the following code snippet.
import { createNavigationContainerRef } from "@react-navigation/native"
export const navigationRef = createNavigationContainerRef()
const App = () => {
return
}
export default App
Then, inside Navigation
.
export default function Navigation({ navigation }) {
const route = navigation.current?.getCurrentRoute()
return (
);
}
The current route name get then be accessed using route?.name
.
Edit: As jhon antoy correctly pointed out in the comments, this does not update the current route state if we navigate to a different screen. We need to update this ourselves as follows.
export const navigationRef = createNavigationContainerRef();
const App = () => {
const [routeName, setRouteName] = useState();
return (
{
setRouteName(navigationRef.getCurrentRoute().name)
}}
onStateChange={async () => {
const previousRouteName = routeName;
const currentRouteName = navigationRef.getCurrentRoute().name;
console.log("route", currentRouteName)
setRouteName(currentRouteName);
}}
>
);
}
export default App;
Inside Navigation
.
export function Navigation(props) {
const route = props.routeName
console.log(props)
return (
);
}
I have made a snack with some simple navigation buttons.
QUESTION
The main problem is that the menu bar is not displayed in my layout file. I've done a few searches but haven't been able to find a solution or a reason as to why it is behaving this way. Any help would be appreciated. Thanks. my menu file
`
`
XML my layout file
`
`
Where am I doing wrong? I checked some tutorials, and that exactly the process of setting bottom navigation view photo
ANSWER
Answered 2022-Mar-05 at 06:03If you do not use the rules of material design, you should not have a theme that inherits from material design. Find the theme.xml according to the Android version of your studio and change the parent to Theme.AppCompat.Light.DarkActionBar.
QUESTION
I'm using navigation.navigate
to move between screens but I face the following problem.
I call the method to navigate:
const FileCard = ({ fileDetails }: Props) => {
const navigation = useNavigation();
const loadDetails = () => {
console.log(JSON.stringify(fileDetails));
navigation.navigate("FileDetailScreen" as never, {file:
fileDetails} as never)
}
And I would like to connect with this screen:
interface Props {
file: FileInfo
}
const FileDetailScreen = ({ file }: Props) => {
return (
{
(file) ?
Exists
:
Does not exists
}
)
}
But I get "Does not exists" in my screen, so I can't show the information.
How can I fix this problem? Thanks!
EDIT
I call the loadDetails
function here:
{loadDetails(fileInfo)}}
>
// Elements and styles
And this is my stack navigation:
// THE SCREEN
ANSWER
Answered 2022-Feb-27 at 12:26You are passing the props for FileDetailScreen
using the navigation route param props. If you have a screen
const FileDetailScreen = ({ file }: Props) => {
...
}
then file
is a prop of the JSX component, e.g.
const SomeOtherScreen = () => {
return
}
This is different then passing a prop using the route params. If we want to navigate to FileDetailScreen
and pass the file prop using
navigation.navigate("FileDetailScreen" as never, {file: fileDetails} as never)
you are not instantiating a new JSX component, but you are passing route params. We can access them as follows.
const FileDetailScreen = ({file, route}) {
const f = route.params?.file
}
Notice that route
is passed by the Navigator
. Being precise here, we should add this to the props interface of your screen to satisfy TypeScript. This is very well documented here.
Edit: Since it was explicitly requested to solve the TypeScript error, we are going to solve this as well.
- Create a type, e.g.
RootStackParams
where we need to provide the types for all route params.
export type RouteStackParams = {
FileDetailScreen: {
file: FileInfo
}
...
}
Notice that you need to do this for all your routes in order to provide correct types for the TypeScript compiler.
- Create your Stack.Navigator by providing the route param types as follows.
const Stack = createStackNavigator()
Your FileDetailScreen is now correctly typed. Notice as well that this does not effect your runtime behavior, thus your code would work without doing this.
QUESTION
Hello there I'm facing some issues with the navigation between fragments
ok I explain in detail
I have a bottom nav with 4 fragments Home, Following, Notification, and Profile, there is no issue with the bottom navigation on backstack , but now for eg from profile fragment I jumped to a fragment called edit_profile which is not a part of the bottom nav and when press back I want that it should go back to the profile fragment but the backstack is taking me from edit_profile to directly home fragment
here is a recording link
I recently change my project from java to kotlin and I'm a beginner in kotlin
i really like the navigation of Pinterest and Instagram
Note:- All this code is automatically changed to kotlin (with some changes done manually ) , this issue was also with java and not after migrating to kotlin , Also if you want more reference of the code please tell me i will update the question
Code
MainActivity.kt // Bottom Nav
class MainActivity : AppCompatActivity() {
var bottomNavigationView: BottomNavigationView? = null
var integerDeque: Deque = ArrayDeque(3)
var flag = true
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
setContentView(R.layout.activity_main)
val window = this.window
window.statusBarColor = this.resources.getColor(R.color.black)
bottomNavigationView = findViewById(R.id.bottom_navigation_view)
integerDeque.push(R.id.nav_home)
loadFragments(Home_Fragment())
bottomNavigationView!!.selectedItemId = R.id.nav_home
bottomNavigationView!!.setOnNavigationItemSelectedListener(
BottomNavigationView.OnNavigationItemSelectedListener { item: MenuItem ->
val id = item.itemId
if (integerDeque.contains(id)) {
if (id == R.id.nav_home) {
integerDeque.size
if (flag) {
integerDeque.addFirst(R.id.nav_home)
flag = false
}
}
integerDeque.remove(id)
}
integerDeque.push(id)
loadFragments(getFragment(item.itemId))
false
}
)
}
@SuppressLint("NonConstantResourceId")
private fun getFragment(itemId: Int): Fragment {
when (itemId) {
R.id.nav_home -> {
bottomNavigationView!!.menu.getItem(0).isChecked = true
return Home_Fragment()
}
R.id.nav_following -> {
bottomNavigationView!!.menu.getItem(1).isChecked = true
return Following_Fragment()
}
R.id.nav_notification -> {
bottomNavigationView!!.menu.getItem(2).isChecked = true
return Notification_Fragment()
}
R.id.nav_profile -> {
bottomNavigationView!!.menu.getItem(3).isChecked = true
return Profile_Fragment()
}
}
bottomNavigationView!!.menu.getItem(0).isChecked = true
return Home_Fragment()
}
private fun loadFragments(fragment: Fragment?) {
if (fragment != null) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment, fragment.javaClass.simpleName)
.commit()
}
}
override fun onBackPressed() {
integerDeque.pop()
if (!integerDeque.isEmpty()) {
loadFragments(getFragment(integerDeque.peek()))
} else {
finish()
}
}
Edit_Profile.kt // from this fragment i want to go back to the last fragment which should be the profile fragment
class Edit_Profile : Fragment() {
private var profilePhoto: CircleImageView? = null
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_edit_profile, container, false)
profilePhoto = view.findViewById(R.id.circleImageView)
initImageLoader()
setProfileImage()
val imageView = view.findViewById(R.id.backArrow)
imageView.setOnClickListener {
val newCase: Fragment = Profile_Fragment()
assert(fragmentManager != null)
val transaction = requireFragmentManager().beginTransaction()
transaction.replace(R.id.fragment_container, newCase)
transaction.addToBackStack(Profile_Fragment.toString())
transaction.commit()
}
return view
}
Edit
added a part of the transaction from Profile Fragment to Edit Profile
ProfileFragment.kt
editProfileButton!!.setOnClickListener(View.OnClickListener { v: View? ->
val edit_profile: Fragment = Edit_Profile()
requireActivity().getSupportFragmentManager()
.beginTransaction()
.add(R.id.fragment_container, edit_profile,"TAG")
.addToBackStack("TAG")
.commit()
})
ANSWER
Answered 2022-Jan-13 at 10:08Where I add HomeF in main container which includes all bottom nav tab, and all bottom nav tab will open in home container, and those fragment which are not part of bottom nav will open in main container. I generally add(not replace) all the fragments in main container and set add to back stack , so that if user goes from profile (home_container) to something in main container , while backstack we can pop the top fragment and user will be seeing profile.
QUESTION
I've got a top bar with IconButton
for handling back navigation when clicked.
Function passed as callback's implemented like this:
private fun navigateBack(navController: NavController) {
val route = navController.previousBackStackEntry?.destination?.route ?: ""
navController.navigate(route)
}
ANSWER
Answered 2022-Jan-30 at 15:53You can pass your NavController
to your TopAppBar
and use navController.navigateUp()
in the navigation icon.
If you want to show this icon only in some composables you can use a parameter, like canPop
in the following example, and set it true in the composable where you want handle the back button.
if (canPop) {
TopAppBar(
title = { Text(text = title) },
navigationIcon = {
IconButton(onClick = {
navController.navigateUp()
}) {
Icon(Icons.Rounded.ArrowBack, "")
}
},
backgroundColor = MaterialTheme.colors.TopBarColor)
} else {
TopAppBar(
title = { Text(text = title) },
backgroundColor = MaterialTheme.colors.TopBarColor
)
}
Check also popBackStack documentation
Attempts to pop the controller's back stack. Analogous to when the user presses the system Back button when the associated navigation host has focus.
QUESTION
I have picker in my left menu navigation shell that change the main page language,
for example actually the app in English. When I change to French, it change and redirect to main page with French text.
The problem is when I press the back arrow in navigation page, it back to old language (English).
Here the shell navigation
and this is the method that redirects to the main page:
private async void ChangeLange(string lang)
{
...
Routing.RegisterRoute(nameof(Dashboard), typeof(Dashboard));
await Shell.Current.GoToAsync($"{nameof(Dashboard)}");// it redirect but with button back
RemoveStackNavigation ()
// await Shell.Current.GoToAsync("//main"); like this , it dosent refresh the page with
Shell.Current.FlyoutIsPresented = false;
}
here is the MVMM
public string _selectedLang;
public string SelectedLang
{
get
{
return _selectedLang;
}
set
{
if (_selectedLang != value)
{
_selectedLang = value;
OnPropertyChanged("SelectedLang");
ChangeBuilding(value);
}
}
}
I tried to RemoveStackNavigation before make redirection to Dashboard like this :
public static void RemoveStackNavigation()
{
var existingPages = Shell.Current.Navigation.NavigationStack.ToList();
foreach (var page in existingPages)
{
if (page != null)
Shell.Current.Navigation.RemovePage(page);
}
}
ANSWER
Answered 2022-Jan-26 at 06:20The navigation stack of Shell has something special. Clear the navigation stack is not a good choice. We always use Routes to do the navigation for the Shell. You need to know which would generate the stack.
- A route, which defines the path to content that exists as part of the Shell visual hierarchy.
- A page. Pages that don't exist in the Shell visual hierarchy can be pushed onto the navigation stack from anywhere within a Shell application. For example, a details page won't be defined in the Shell visual hierarchy, but can be pushed onto the navigation stack as required.
For more details, please check the MS docs. https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation
When you press the back button, override the back button event and then judge the route to do the navigation would be better. Use the specific route name to go back.
Update:
After compilation the Navigation Bar that we call in Xamarin Forms, turns into the Action Bar for Android during runtime.
Set the toolbar after LoadApplication(new App()); in OnCreate of MainActivity.
AndroidX.AppCompat.Widget.Toolbar toolbar
= this.FindViewById(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
And then overrode OnOptionsItemSelected(). When you press the backbutton on navigation bar, this event would be triggered.
public override bool OnOptionsItemSelected(IMenuItem item)
{
}
QUESTION
I have a screen that makes a call to an api to fetch some data which is then displayed
An issue that I am seeing is that when I navigate away from the screen (I am using react-navigation 6.x) and then go back to it useEffect()
is not being called
From what I have read so far, this is down to the value of userId
not changing (I think i need to do some more reading around the useEffect()
hook to understand better, maybe someone will help clear things up with this question)
import React, {useState, useEffect, useContext} from 'react';
import AppContext from '../../components/AppContext.js';
export const CreateNewEvent = () => {
const globalContext = useContext(AppContext);
const userId = globalContext.userInfo.id;
useEffect(() => {
const body = JSON.stringify({userId});
fetch(eventTypesUrl, {
method: 'POST',
headers: {'Content-Type': 'application/json', Accept: 'application/json'},
body: body,
})
.then(response => response.json())
.then(json => setEventTypeData(json))
.catch(error => console.error(error))
.finally(() => setLoading(false));
}, [userId]);
}
So in my scenario I am on Screen 1 (Here i can create an event which makes a request to get all event types and loads them into a select menu)
When I navigate to Screen 2 (to create an event type) and then back to Screen 1, the useEffect()
hook is not called resulting in being unable to see the event type I have just created (hope that makes sense).. also notice that any data entered in Screen 1 previously still remains
I have come across this post which appears to be what I am dealing with, just a little unsure how to implement with my setup
How can I ensure that Screen 2 makes the api call when i go back and that all previous form data is cleared out?
Thanks
ANSWER
Answered 2022-Jan-07 at 14:44At the core, React Navigation does not rerender the screen when a user navigates back to that screen for performance optimization and avoids unnecessary rerenders.
When required, They provide a useful hook to detect when screen is focused and run some side effects.
Let refactor code as below:
Top-level import
import { useFocusEffect } from "@react-navigation/core";
// Run side effects when screen focused, navigated, or visited
useFocusEffect(
React.useCallback(() => {
const body = JSON.stringify({userId});
fetch(eventTypesUrl, {
method: 'POST',
headers: {'Content-Type': 'application/json', Accept: 'application/json'},
body: body,
})
.then(response => response.json())
.then(json => setEventTypeData(json))
.catch(error => console.error(error))
.finally(() => setLoading(false));
return () => {
// Run somelogisx when user leave screen,
// Cleaning caches or cancelling subscriptions
};
}, [userId]))
Note: React.useCallback
is part of useFocusEffect
API. The React Navigation team trying to optimize screen performance with memoization.
QUESTION
I have a problem when do a call to my composable in the NavGraph
, it is repeating 3 times or sometimes more times. I have looked where I do the call and I don't see any loop or something.
NavGraph
fun NavGraphBuilder.addScheduleDetails(
navController: NavHostController,
userDataViewModel: UserDataViewModel,
titulos: MutableState,
datosViewModel: DatosViewModel,
){
val animationState = mutableStateOf(true)
composable(route = MainDestinations.SCHEDULE_DETAILS_ROUTE+"/{${NavArguments.NOMBRE_HORARIO}}")
{backStackEntry ->
Log.w("Call", "ScheduleDetails")
titulos.value = backStackEntry.arguments?.getString(NavArguments.NOMBRE_HORARIO)!!+" "
val actions = MainActions(navController = navController)
DetallesHorarioScreen(
nombreHorario = backStackEntry.arguments?.getString(NavArguments.NOMBRE_HORARIO),
userDataViewModel = userDataViewModel,
onNavToAddSubject = actions.navigateToAgregarMateria,
datosViewModel = datosViewModel,
animationState = animationState
)
}
}
Prints from LOG
2022-01-06 19:57:01.548 30533-30533/horarios W/Call: ScheduleDetails
2022-01-06 19:57:01.613 30533-30533/horarios W/Call: ScheduleDetails
2022-01-06 19:57:01.987 30533-30533/horarios W/Call: ScheduleDetails
Call to composable(route = MainDestinations.SCHEDULE_DETAILS_ROUTE ...)
Card(
modifier = Modifier
.fillMaxWidth()
.height(80.dp)
.padding(10.dp)
.clickable { onNavToHorario(nombre) }, //Call to navigator
border = BorderStroke(width = 1.dp, color = primaryColorCustom),
shape = RoundedCornerShape(10),
backgroundColor = Color.White,
elevation = 4.dp
) {...}
onNavToHorario()
val actions = MainActions(navController = navController)
(...)
onNavToHorario = actions.navigateToHorario
MainActions()
class MainActions(navController: NavHostController){
val navigateToHorario:(String) -> Unit = {nomHorario: String ->
navController.navigate(route = MainDestinations.SCHEDULE_DETAILS_ROUTE+"/${nomHorario}")
}
}
In other case I had a similar problem and was occasioned for animations but I already delete all animations in NavGraph
but the problem is still
ANSWER
Answered 2022-Jan-07 at 02:45Navigation always crossfades destinations, so each screen will always recompose multiple times. This is expected as per the Thinking in Compose guide:
In some cases, a composable function might run for every frame of a UI animation. If the function performs expensive operations, like reading from device storage, the function can cause UI jank.
You aren't doing anything wrong (you aren't triggering side effects as part of composition), so your code is already fine.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install r2cloud
Install r2cloud
From the image. This is the easiest way to install r2cloud on Raspberry PI. It will require brand new SD card: Download the latest official image Insert SD card into the card reader and flash it. You could use Etcher to do this Insert SD card into the card reader and create file r2cloud.txt in the root directory. This file should contain any random string. This string is a login token. This token will be used during initial setup.
Or from repository binaries: Login via SSH and create r2cloud.txt file in /boot directory. This file should contain any random string. This string is a login token. This token will be used during initial setup. Execute the following commands:
Open https://raspberrypi.local address.
Accept self-signed certificate. This is unique certificate that was generated during installation. Once setup is complete, you could enable proper SSL using Letsencrypt.
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page