I have 3 fragments in my activity A,B,C - android-fragments

I have 3 fragments in my activity A,B,C. The flow is A->B,B->C,C->B, A Back pressed app exit,B back pressed app exit. I have an auto logout feature which took fragment C->A but after that when press back button the fragment A moves to C instead of App exit. i have used the below code to go from C->A Fragment. I want when i come from C->A and press back button the application should be exited.
FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.frameLayout_main, ApplicationConstants.loginFragment);
fragmentTransaction.addToBackStack(null);
//fragmentTransaction.commit();
fragmentTransaction.commitAllowingStateLoss();

Related

How can I set values of switcher in all fragments of a viewpager, by changes one switch in MainActivity

I am developing one android application and it has a tab layout with ViewPager setup. I have totally 8 fragments in the viewpager. Each Fragment holding an RecyclerView. The recyclerview row has one text one switcher and one icon for rename text.
Whenever the activity started it loads 8 fragments with recyclerview data. I have a switcher in the MainActivity, whenever the MainActivity switcher it changes I need to switch all the switches from all 8 fragments and I want to save all in Lists and to send them in server.

JavaFX: When the user touches any button (to click them) in a particular scene, how can I suppress mouse cursor movement?

I have a JavaFX Windows application that contains:
a Teacher screen (JavaFX scene), which exists on the first monitor.
a Student screen, which exists on a second monitor.
On the Student screen there are controls, such as buttons, that the student touches in order to click.
When the student does that (touches a button in order to click it), I don’t want the mouse cursor to move at all from where it resides on the Teacher screen.
How can I accomplish that? Thanks!

How can destination view controller be pushed on to the same navigation controller programatically, Swift

Searching SO, I figured out that there many questions on navigating to a destinationViewController programatically, but none on how the destinationViewController can be pushed (programatically) on to the same navigation controller from which it got triggered.
This is what I have (See Picture of Storyboard)
I have 2 scenes with their respective controllers, appointments (source) and appointmentTimes (destination)
a. Navigation controller is connected to appointments through a segue.
b. appointmentTimes is not connected to appointments through a segue in storyboard (since I would like to navigate to it programatically when a button ('Schedule Appointment') is clicked in appointments scene)
This is what I want (See Picture of Storyboard)
a. When a user clicks a button ('Schedule Appointment') in appointments scene (source) // DONE
b. Some requests are made to the server and on obtaining response, the user is navigated programatically to appointmentTimes scene (destination) // DONE
c. I would like the appointmentTimes scene to be pushed onto the same navigation stack as the appointments scene. This means the user can freely navigate between the two scenes (by clicking 'Schedule Appointment' in appointments scene they can go to appointmentTimes scene, and by clicking back button in appointmentTimes scene they can go back to appointments scene) // HOW CAN I ACHIEVE THIS ??
I figured out that following steps help to achieve the desired outcome of adding the destination scene on to the same navigation stack of the source scene programatically.
Create a manual segue: Go to storyboard, point the mouse on the yellow icon of the source scene (you can find it on top of the scene) and Control + Drag on to the destination scene to create a manual segue.
Give the segue an ID, select the segue and go to the attributes and add a name in the identifier cell.
Call the segue programatically self.performSegue(withIdentifier: "appointment", sender: nil), This will add the destination scene on to the same navigation stack as the source scene.

Fragment Life cycle from onPause to OnResume

In Activity life cycle we can go from OnPause to Onresume directly (this can occur if our activity leaves the foreground but is still visible, i.e. a dialog pop ups). Checking the fragment life cycle diagram: http://developer.android.com/guide/components/fragments.html
When the activity is paused then the fragments respective onPause is called. But at this point when the activity call onResume what state is the fragment in ? What life cycle callback gets called ?
The Fragment lifecycle is tied to the Activity lifecycle. If the Activity is changing the state the Fragment will aswell. Because of that a Fragment has the same major lifecycle components as an Activity like onCreate(), onResume and so on. In addition to these, there are some specific ones like onAttached(), onDetached(), onActivityCreated() etc.
A Fragment is able to draw an UI and is controlled by the Activity. If that wouldn't be the case some strange things could happen. Like the Activity goes into the background but the Fragment is still visible. That's why these two components have to sync their state.
onResume as well, check the official documentation: http://developer.android.com/reference/android/app/Fragment.html#onResume()

How to Kill focus of an MFC button control

I have an MFC button control and I am trying to handle the "OnPressed" event of it by starting a timer on click and making it go through my event in the OnTimer function. This all works fine but the focus remains on the button and if I click outside of the button area, the app carries out the OnPressed event. Any suggestions on how to kill the focus on the button when the mouse is pressed outside of the button area? My code for getting the focus and button ID.
void Dlg::OnTimer(...)
{
CWnd * pFocus = GetFocus();
int btnID = 0;
if (pFocus != NULL && pDialog->IsChild(pFocus))
btnID = pFocus->GetDlgCtrlID();
// Carry on my button pressed activity
Buttonpressed();
}
So basically I am getting the proper button press and I can carry out the desired action using the Buttonpressed() function given above. Now my problem is, once that button is pressed, it gets focus and the focus remains even after I leave the mouse and move out of the area of the button. Because of this behaviour, if I click outside of the button area, the application still thinks that I am in the mouse area and pressing the button. Is there a way I could remove focus after the mouse is moved out of the button area and then bring focus back in again when it is in the button area?
Looking forward to your suggestions.

Resources