App

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

- File List
- File Members

ColorLayerSettingsFragment.java
Go to the documentation of this file.
1 package mhr.app.fragments.layers;
2
3 import mhr.app.AppMainActivity;
4 import mhr.app.R;
5 import mhr.appandroid.adapters.APDImagePresentation;
6 import mhr.appandroid.views.colorpicker.ColorPickerView;
7
8 import mhr.appcore.blending.BlendMode;
9
10 import mhr.appcore.image.layers.ColorLayerSpecificPresentation;
11 import mhr.appcore.image.layers.LayerSpecificPresentation;
12 import mhr.appcore.image.layers.RasterLayerSpecificPresentation;
13
14 import android.app.Activity;
15 import android.app.Fragment;
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.ArrayAdapter;
22 import android.widget.Button;
23 import android.widget.Spinner;
24 import android.widget.Toast;
25
29 public class ColorLayerSettingsFragment extends LayerSettingsFragment implements OnClickListener {
30
31
32 //===== INTERFACES, CLASSES, ENUMS ==========================================================================================================//
33 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
34 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
35
36 //===== FIELDS ==============================================================================================================================//
37 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
38 protected Spinner blendModeSp;
39 protected ColorPickerView colorPicker;
40
41 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
42
43 //===== CONSTRUCTORS, DESTRUCTORS, RELATED METHODS ==========================================================================================//
44 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
48 protected View initView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
49 root = inflater.inflate(R.layout.fragment_color_layer_settings, container, false);
50 blendModeSp = (Spinner) root.findViewById(R.id.ColorLayerBlendModeSp);
51 ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(activity, R.array.BlendModeNames, android.R.layout.simple_spinner_item);
52 adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
53 blendModeSp.setAdapter(adapter);
54
55 colorPicker = (ColorPickerView) root.findViewById(R.id.ColorLayerColorPicker);
56 return root;
57 }
58 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
59
60 //===== METHODS =============================================================================================================================//
61 //----- NON-PUBLIC --------------------------------------------------------------------------------------------------------------------------//
62 @Override
63 protected void updateFromPresentation(LayerSpecificPresentation pres) {
64 ColorLayerSpecificPresentation p = (ColorLayerSpecificPresentation) pres;
65 blendModeSp.setSelection(p.mode.getValue());
66 colorPicker.setNativeState(p.color);
67 }
68 @Override
69 protected void updatePresentation(LayerSpecificPresentation pres) {
70 ColorLayerSpecificPresentation p = (ColorLayerSpecificPresentation) pres;
71 p.mode = BlendMode.fromValue(blendModeSp.getSelectedItemPosition());
72 p.color = colorPicker.getNativeNewColor();
73 }
74
75 //----- PUBLIC ------------------------------------------------------------------------------------------------------------------------------//
76
77 //===== CALLBACKS ===========================================================================================================================//
78 @Override
79 public void onClick(View v) {
80 switch (v.getId()) {
81 default:
82 super.onClick(v);
83 break;
84 }
85 }
86
87 //----- LIFE CYCLE --------------------------------------------------------------------------------------------------------------------------//
88
89 // @Override
90 // public void onAttach(Activity activity) {
91 // super.onAttach(activity);
92 // /*
93 // * called once the fragment is associated with its activity.
94 // */
95 // }
96
97 // @Override
98 // public void onCreate(Bundle savedInstanceState) {
99 // super.onCreate(savedInstanceState);
100 // /*
101 // * called to do initial creation of the fragment.
102 // *
103 // * The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want
104 // * to retain when the fragment is paused or stopped, then resumed.
105 // */
106 // }
107
108 // @Override
109 // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
110 // return super.onCreateView(inflater, container, savedInstanceState);
111 // /*
112 // * creates and returns the view hierarchy associated with the fragment.
113 // *
114 // * 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
115 // * 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.
116 // *
117 // * Zde začíná životní cyklus při návratu z backstacku
118 // */
119 // }
120
121 // @Override
122 // public void onActivityCreated(Bundle savedInstanceState) {
123 // super.onActivityCreated(savedInstanceState);
124 // /*
125 // * tells the fragment that its activity has completed its own Activity.onCreate().
126 // */
127 // }
128
129 // @Override // Vyžaduje API 17
130 // public void onViewStateRestored(Bundle savedInstanceState) {
131 // super.onViewStateRestored(savedInstanceState);
132 // /*
133 // * tells the fragment that all of the saved state of its view hierarchy has been restored.
134 // */
135 // }
136
137 // @Override
138 // public void onStart() {
139 // super.onStart();
140 // /*
141 // * makes the fragment visible to the user (based on its containing activity being started).
142 // */
143 // }
144 //
145 // @Override
146 // public void onResume() {
147 // super.onResume();
148 // /*
149 // * makes the fragment interacting with the user (based on its containing activity being resumed).
150 // */
151 // }
152
153 // @Override
154 // public void onPause() {
155 // super.onPause();
156 // /*
157 // * 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.
158 // *
159 // * 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).
160 // * 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).
161 // */
162 // }
163
164 // @Override
165 // public void onStop() {
166 // super.onStop();
167 // /*
168 // * 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.
169 // */
170 // }
171
172 // @Override
173 // public void onDestroyView() {
174 // super.onDestroyView();
175 // /*
176 // * allows the fragment to clean up resources associated with its View.
177 // *
178 // * Zde končí životní cyklus při umístění do backstacku
179 // */
180 // }
181
182 // @Override
183 // public void onDestroy() {
184 // super.onDestroy();
185 // /*
186 // * called to do final cleanup of the fragment's state.
187 // */
188 // }
189
190 // @Override
191 // public void onDetach() {
192 // super.onDetach();
193 // /*
194 // * called immediately prior to the fragment no longer being associated with its activity.
195 // */
196 // }
197 }