App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

NavigationToolSettingsFragment.java
Go to the documentation of this file.
1 package mhr.app.fragments.toolbox;
2
3 import mhr.app.AppMainActivity;
4 import mhr.app.R;
5 import mhr.appandroid.displayer.DisplayerTouchNavigator;
6 import android.app.Activity;
7 import android.app.Fragment;
8 import android.os.Bundle;
9 import android.view.LayoutInflater;
10 import android.view.View;
11 import android.view.View.OnClickListener;
12 import android.view.ViewGroup;
13 import android.widget.Toast;
14
18 public class NavigationToolSettingsFragment extends Fragment implements OnClickListener {
19
20 //===================================================================================================================================================//
21 //===== PUBLIC ==============================================================================================================================//
22 //----- interface a třídy -------------------------------------------------------------------------------------------------------------------//
23 //----- pole --------------------------------------------------------------------------------------------------------------------------------//
24 //----- acesory a primitivní metody ---------------------------------------------------------------------------------------------------------//
25 //----- konstruktory ------------------------------------------------------------------------------------------------------------------------//
26 //----- destruktory -------------------------------------------------------------------------------------------------------------------------//
27 //----- metody ------------------------------------------------------------------------------------------------------------------------------//
28
29 //===================================================================================================================================================//
30 //===== LIFE CYCLE ==========================================================================================================================//
31
32 @Override
33 public void onAttach(Activity activity) {
34 super.onAttach(activity);
35 this.activity = (AppMainActivity) getActivity();
36 if (navig == null) { // instance bude cachovana
37 navig = new DisplayerTouchNavigator(this.activity.getBitmapDisplayer(), this.activity);
38 }
39
40 /*
41 * called once the fragment is associated with its activity.
42 */
43 }
44
45 @Override
46 public void onCreate(Bundle savedInstanceState) {
47 super.onCreate(savedInstanceState);
48 /*
49 * called to do initial creation of the fragment.
50 *
51 * The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want
52 * to retain when the fragment is paused or stopped, then resumed.
53 */
54 }
55
56 @Override
57 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
58 /*
59 * creates and returns the view hierarchy associated with the fragment.
60 *
61 * The system calls this when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a
62 * View from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI.
63 *
64 * Zde začíná životní cyklus při návratu z backstacku
65 */
66 View v = inflater.inflate(R.layout.fragment_navigation_tool_settings, container, false);
67 root = v;
68 root.findViewById(R.id.CenterAndFitBtn).setOnClickListener(this);
69 root.findViewById(R.id.CenterAndResetZoomBtn).setOnClickListener(this);
70 return v;
71 }
72
73 @Override
74 public void onActivityCreated(Bundle savedInstanceState) {
75 super.onActivityCreated(savedInstanceState);
76 /*
77 * tells the fragment that its activity has completed its own Activity.onCreate().
78 */
79 }
80
81 //@Override // Vyžaduje API 17
82 //public void onViewStateRestored(Bundle savedInstanceState) {
83 // super.onViewStateRestored(savedInstanceState);
84 // /*
85 // * tells the fragment that all of the saved state of its view hierarchy has been restored.
86 // */
87 //}
88
89 @Override
90 public void onStart() {
91 super.onStart();
92 /*
93 * makes the fragment visible to the user (based on its containing activity being started).
94 */
95 }
96
97 @Override
98 public void onResume() {
99 super.onResume();
100 /*
101 * makes the fragment interacting with the user (based on its containing activity being resumed).
102 */
103 activity.setCanvasOnTouchListener(navig);
104 }
105
106 @Override
107 public void onPause() {
108 super.onPause();
109 /*
110 * fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.
111 *
112 * The system calls this method as the first indication that the user is leaving the fragment (though it does not always mean the fragment is being destroyed).
113 * This is usually where you should commit any changes that should be persisted beyond the current user session (because the user might not come back).
114 */
115 }
116
117 @Override
118 public void onStop() {
119 super.onStop();
120 /*
121 * fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.
122 */
123 }
124
125 @Override
126 public void onDestroyView() {
127 super.onDestroyView();
128 /*
129 * allows the fragment to clean up resources associated with its View.
130 *
131 * Zde končí životní cyklus při umístění do backstacku
132 */
133 }
134
135 @Override
136 public void onDestroy() {
137 super.onDestroy();
138 /*
139 * called to do final cleanup of the fragment's state.
140 */
141 }
142
143 @Override
144 public void onDetach() {
145 super.onDetach();
146 /*
147 * called immediately prior to the fragment no longer being associated with its activity.
148 */
149 }
150
151 //===================================================================================================================================================//
152 //===== NON-PUBLIC ==========================================================================================================================//
153 //----- interface a třídy -------------------------------------------------------------------------------------------------------------------//
154 //----- pole --------------------------------------------------------------------------------------------------------------------------------//
155 protected View root;
156 protected AppMainActivity activity;
157 protected DisplayerTouchNavigator navig = null;
158 //----- acesory a primitivní metody ---------------------------------------------------------------------------------------------------------//
159 //----- konstruktory ------------------------------------------------------------------------------------------------------------------------//
160 //----- destruktory -------------------------------------------------------------------------------------------------------------------------//
161 //----- metody ------------------------------------------------------------------------------------------------------------------------------//
162 @Override
163 public void onClick(View v) {
164 int id = v.getId();
165 switch (id) {
166 case R.id.CenterAndFitBtn:
167 activity.getBitmapDisplayer().centerAndFit();
168 break;
169 case R.id.CenterAndResetZoomBtn:
170 activity.getBitmapDisplayer().centerAndResetZoom();
171 break;
172 default:
173 break;
174 }
175 }
176
177 //===================================================================================================================================================//
178 //===== DEPRECATED ==========================================================================================================================//
179 }