Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
org.skia.viewer.StateAdapter Class Reference
Inheritance diagram for org.skia.viewer.StateAdapter:

Public Member Functions

 StateAdapter (ViewerActivity viewerActivity)
 
void setState (String stateJson)
 
int getCount ()
 
Object getItem (int position)
 
long getItemId (int position)
 
View getView (int position, View convertView, ViewGroup parent)
 
void onItemSelected (AdapterView<?> parent, View view, int position, long id)
 
void onNothingSelected (AdapterView<?> parent)
 

Detailed Description

Definition at line 34 of file StateAdapter.java.

Constructor & Destructor Documentation

◆ StateAdapter()

org.skia.viewer.StateAdapter.StateAdapter ( ViewerActivity  viewerActivity)
inline

Definition at line 48 of file StateAdapter.java.

48 {
49 mViewerActivity = viewerActivity;
50 try {
51 mStateJson = new JSONArray("[{\"name\": \"Please\", " +
52 "\"value\": \"Initialize\", \"options\": []}]");
53 } catch (JSONException e) {
54 e.printStackTrace();
55 }
56 }

Member Function Documentation

◆ getCount()

int org.skia.viewer.StateAdapter.getCount ( )
inline

Definition at line 73 of file StateAdapter.java.

73 {
74 return 1;
75 }

◆ getItem()

Object org.skia.viewer.StateAdapter.getItem ( int  position)
inline

Definition at line 78 of file StateAdapter.java.

78 {
79 return null;
80 }

◆ getItemId()

long org.skia.viewer.StateAdapter.getItemId ( int  position)
inline

Definition at line 83 of file StateAdapter.java.

83 {
84 return 0;
85 }

◆ getView()

View org.skia.viewer.StateAdapter.getView ( int  position,
View  convertView,
ViewGroup  parent 
)
inline

Definition at line 88 of file StateAdapter.java.

88 {
89 switch (position) {
90 case 0: {
91 if (mLayout == null) {
92 mLayout = new LinearLayout(mViewerActivity);
93 mLayout.setOrientation(LinearLayout.VERTICAL);
94 updateDrawer();
95 }
96 return mLayout;
97 }
98 default: {
99 return null;
100 }
101 }
102 }

◆ onItemSelected()

void org.skia.viewer.StateAdapter.onItemSelected ( AdapterView<?>  parent,
View  view,
int  position,
long  id 
)
inline

Definition at line 192 of file StateAdapter.java.

192 {
193 if (view == null) {
194 return;
195 }
196 View stateItem = (View) parent.getParent();
197 String stateName = ((TextView) stateItem.findViewById(R.id.nameText)).getText().toString();
198 String stateValue = ((TextView) view).getText().toString();
199 if (!stateValue.equals(stateItem.getTag(R.integer.value_tag_key))) {
200 stateItem.setTag(null); // Reset the tag to let updateDrawer update this item view.
201 mViewerActivity.onStateChanged(stateName, stateValue);
202 }
203
204 // Due to the current Android limitation, we're required to recreate the SurfaceView for
205 // switching to/from the Raster backend.
206 // (Although we can switch between GPU backend without recreating the SurfaceView.)
207 final Object oldValue = stateItem.getTag(R.integer.value_tag_key);
208 if (stateName.equals(BACKEND_STATE_NAME)
209 && oldValue != null && !stateValue.equals(oldValue)) {
210 LinearLayout mainLayout = (LinearLayout) mViewerActivity.findViewById(R.id.mainLayout);
211 mainLayout.removeAllViews();
212 SurfaceView surfaceView = new SurfaceView(mViewerActivity);
213 surfaceView.setId(R.id.surfaceView);
214 surfaceView.getHolder().addCallback(mViewerActivity);
215 surfaceView.setOnTouchListener(mViewerActivity);
216 mainLayout.addView(surfaceView);
217 }
218 }
void onStateChanged(String stateName, String stateValue)
#define R(r)

◆ onNothingSelected()

void org.skia.viewer.StateAdapter.onNothingSelected ( AdapterView<?>  parent)
inline

Definition at line 221 of file StateAdapter.java.

221 {
222 // do nothing
223 }

◆ setState()

void org.skia.viewer.StateAdapter.setState ( String  stateJson)
inline

Definition at line 58 of file StateAdapter.java.

58 {
59 try {
60 mStateJson = new JSONArray(stateJson);
61 if (mLayout != null) {
62 updateDrawer();
63 } else {
64 notifyDataSetChanged();
65 }
66 } catch (JSONException e) {
67 e.printStackTrace();
68 }
69 }

The documentation for this class was generated from the following file: