App

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

- File List
- File Members

FilterToolSettingsFragment.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.app.fragments.toolbox.filters.DifferenceOfGaussianSharpenPopUpFragment;
6 import mhr.app.fragments.toolbox.filters.GaussianBlurPopUpFragment;
7 import mhr.app.fragments.toolbox.filters.GaussianSharpenPopUpFragment;
8 import mhr.app.fragments.toolbox.filters.LaplaceSharpenPopUpFragment;
9 import mhr.app.fragments.toolbox.filters.LaplacianOfGaussianSharpenPopUpFragment;
10 import mhr.app.fragments.toolbox.transforms.ProjectiveTransformPopUpFragment;
11 import mhr.appandroid.displayer.DisplayerTouchNavigator;
12 import android.app.Activity;
13 import android.app.Fragment;
14 import android.os.Bundle;
15 import android.view.LayoutInflater;
16 import android.view.View;
17 import android.view.View.OnClickListener;
18 import android.view.ViewGroup;
19 import android.widget.Button;
20
24 public class FilterToolSettingsFragment extends Fragment implements OnClickListener {
25
26 //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
27 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
28 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
29
30 //===== FIELDS ==============================================================================================================================//
31 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
32 protected View root;
33 protected AppMainActivity activity;
34 protected boolean firstCreated = true;
35
36 protected DisplayerTouchNavigator navig = null;
37
38 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
39
40 //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
41 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
49 protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
50 root = inflater.inflate(R.layout.fragment_filter_tool_settings, container, false);
51 ((Button) root.findViewById(R.id.GaussianBlurBtn)).setOnClickListener(this);
52 ((Button) root.findViewById(R.id.LaplaceSharpenBtn)).setOnClickListener(this);
53 ((Button) root.findViewById(R.id.GaussianSharpenBtn)).setOnClickListener(this);
54 ((Button) root.findViewById(R.id.LaplacianOfGaussianSharpenBtn)).setOnClickListener(this);
55 ((Button) root.findViewById(R.id.DifferenceOfGaussianSharpenBtn)).setOnClickListener(this);
56
57
58
59 firstCreated = false;
60
61 return root;
62 }
63
64 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
65
66 //===== METHODS =============================================================================================================================//
67 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
68 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
69
70 //===== CALLBACKS ===========================================================================================================================//
71 @Override
72 public void onClick(View v) {
73 int id = v.getId();
74 switch (id) {
75 case R.id.GaussianBlurBtn:
76 activity.showDialog(new GaussianBlurPopUpFragment());
77 break;
78 case R.id.LaplaceSharpenBtn:
79 activity.showDialog(new LaplaceSharpenPopUpFragment());
80 break;
81 case R.id.GaussianSharpenBtn:
82 activity.showDialog(new GaussianSharpenPopUpFragment());
83 break;
84 case R.id.LaplacianOfGaussianSharpenBtn:
85 activity.showDialog(new LaplacianOfGaussianSharpenPopUpFragment());
86 break;
87 case R.id.DifferenceOfGaussianSharpenBtn:
88 activity.showDialog(new DifferenceOfGaussianSharpenPopUpFragment());
89 break;
90 default:
91 break;
92 }
93 }
94
95 //----- LIFE CYCLE --------------------------------------------------------------------------------------------------------------------------//
96
97 @Override
98 public void onAttach(Activity activity) {
99 super.onAttach(activity);
100 /*
101 * called once the fragment is associated with its activity.
102 */
103 this.activity = (AppMainActivity) activity;
104
105 if (navig == null) { // instance bude cachovana
106 navig = new DisplayerTouchNavigator(this.activity.getBitmapDisplayer(), this.activity);
107 }
108 }
109
110 // @Override
111 // public void onCreate(Bundle savedInstanceState) {
112 // super.onCreate(savedInstanceState);
113 // /*
114 // * called to do initial creation of the fragment.
115 // *
116 // * The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want
117 // * to retain when the fragment is paused or stopped, then resumed.
118 // */
119 // }
120
121 @Override
122 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
123 /*
124 * creates and returns the view hierarchy associated with the fragment.
125 *
126 * 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
127 * 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.
128 *
129 * Zde začíná životní cyklus při návratu z backstacku
130 */
131 if (firstCreated) {
132 firstCreated = false;
133 return initView(inflater, container, savedInstanceState);
134 } else {
135 return root;
136 }
137 }
138
139 // @Override
140 // public void onActivityCreated(Bundle savedInstanceState) {
141 // super.onActivityCreated(savedInstanceState);
142 // /*
143 // * tells the fragment that its activity has completed its own Activity.onCreate().
144 // */
145 // }
146
147 // @Override // Vyžaduje API 17
148 // public void onViewStateRestored(Bundle savedInstanceState) {
149 // super.onViewStateRestored(savedInstanceState);
150 // /*
151 // * tells the fragment that all of the saved state of its view hierarchy has been restored.
152 // */
153 // }
154
155 // @Override
156 // public void onStart() {
157 // super.onStart();
158 // /*
159 // * makes the fragment visible to the user (based on its containing activity being started).
160 // */
161 // }
162
163 @Override
164 public void onResume() {
165 super.onResume();
166 /*
167 * makes the fragment interacting with the user (based on its containing activity being resumed).
168 */
169
170 activity.setCanvasOnTouchListener(navig);
171
172 //
173 // activity.setCanvasOnTouchListener(null);
174 // guiHolder = activity.getGuiOverCanvas();
175 //
176 // guiHolder.removeAllViews();
177 //
178 // p = new ProjectiveTransformPicker(activity);
179 // p.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
180 //
181 // guiHolder.addView(p);
182 // guiHolder.setVisibility(View.VISIBLE);
183 }
184
185 @Override
186 public void onPause() {
187 super.onPause();
188 /*
189 * 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.
190 *
191 * 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).
192 * 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).
193 */
194 activity.dismissDialog();
195 // guiHolder.removeAllViews();
196 // guiHolder.setVisibility(View.GONE);
197 }
198
199 // @Override
200 // public void onStop() {
201 // super.onStop();
202 // /*
203 // * 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.
204 // */
205 // }
206
207 // @Override
208 // public void onDestroyView() {
209 // super.onDestroyView();
210 // /*
211 // * allows the fragment to clean up resources associated with its View.
212 // *
213 // * Zde končí životní cyklus při umístění do backstacku
214 // */
215 // }
216
217 // @Override
218 // public void onDestroy() {
219 // super.onDestroy();
220 // /*
221 // * called to do final cleanup of the fragment's state.
222 // */
223 // }
224
225 // @Override
226 // public void onDetach() {
227 // super.onDetach();
228 // /*
229 // * called immediately prior to the fragment no longer being associated with its activity.
230 // */
231 // }
232 }