App
CreateImagePopUpFragment.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.adapters.APDBitmap;
6 import mhr.appandroid.views.LabelledSeekBar;
7 import mhr.appandroid.views.LabelledSeekBar.LabelledSBChangeListener;
8 import mhr.appcore.commands.core.ResizeImageCommand;
9 import mhr.appcore.commands.core.ResizeImageCommand.ResizeAction;
10 import mhr.appcore.interpolators.InterpolatorType;
11 import android.app.Activity;
12 import android.app.Fragment;
13 import android.graphics.Bitmap;
14 import android.graphics.Bitmap.Config;
15 import android.graphics.Canvas;
16 import android.os.Bundle;
17 import android.view.LayoutInflater;
18 import android.view.View;
19 import android.view.View.OnClickListener;
20 import android.view.ViewGroup;
21 import android.widget.Button;
22 import android.widget.RadioGroup;
23 import android.widget.RatingBar;
24 import android.widget.ToggleButton;
25 
29 public class CreateImagePopUpFragment extends Fragment implements OnClickListener {
30 
31  //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
32  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
33  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
34 
35  //===== FIELDS ==============================================================================================================================//
36  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
37  protected View root;
39  protected boolean firstCreated = true;
40 
43 
44  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
45 
46  //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
47  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
55  protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
56  root = inflater.inflate(R.layout.fragment_new_image_popup, container, false);
57 
58  nWidth = (LabelledSeekBar) root.findViewById(R.id.WidthValueLSB);
59  nHeight = (LabelledSeekBar) root.findViewById(R.id.HeightValueLSB);
60 
61  root.findViewById(R.id.CreateImageBtn).setOnClickListener(this);
62  root.findViewById(R.id.CancelBtn).setOnClickListener(this);
63 
64  firstCreated = false;
65 
66  return root;
67  }
68 
69  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
70 
71  //===== METHODS =============================================================================================================================//
72  //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
73  //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
74 
75  //===== CALLBACKS ===========================================================================================================================//
76  @Override
77  public void onClick(View v) {
78  int id = v.getId();
79 
80  switch (id) {
81  case R.id.CreateImageBtn:
82  Bitmap tmp = Bitmap.createBitmap((int) nWidth.getProgress(), (int)nHeight.getProgress(), Config.ARGB_8888);
83  Canvas c = new Canvas(tmp);
84  c.drawColor(0xFFFFFFFF);
88  break;
89  case R.id.CancelBtn:
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 
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  }
166 
167  @Override
168  public void onPause() {
169  super.onPause();
170  /*
171  * 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.
172  *
173  * 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).
174  * 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).
175  */
176  }
177 
178  // @Override
179  // public void onStop() {
180  // super.onStop();
181  // /*
182  // * 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.
183  // */
184  // }
185 
186  // @Override
187  // public void onDestroyView() {
188  // super.onDestroyView();
189  // /*
190  // * allows the fragment to clean up resources associated with its View.
191  // *
192  // * Zde končí životní cyklus při umístění do backstacku
193  // */
194  // }
195 
196  // @Override
197  // public void onDestroy() {
198  // super.onDestroy();
199  // /*
200  // * called to do final cleanup of the fragment's state.
201  // */
202  // }
203 
204  // @Override
205  // public void onDetach() {
206  // super.onDetach();
207  // /*
208  // * called immediately prior to the fragment no longer being associated with its activity.
209  // */
210  // }
211 }