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