8package org.skia.viewer;
11import android.content.res.Configuration;
13import androidx.drawerlayout.widget.DrawerLayout;
14import androidx.appcompat.app.ActionBarDrawerToggle;
17import android.view.MenuInflater;
21import android.view.SurfaceHolder;
27 extends Activity implements SurfaceHolder.
Callback, View.OnTouchListener {
28 private static final float FLING_VELOCITY_THRESHOLD = 1000;
30 private DrawerLayout mDrawerLayout;
31 private ActionBarDrawerToggle mDrawerToggle;
32 private ListView mDrawerList;
37 private native
void onSurfaceCreated(
long handle, Surface
surface);
38 private native
void onSurfaceChanged(
long handle, Surface
surface);
39 private native
void onSurfaceDestroyed(
long handle);
40 private native
void onKeyPressed(
long handle,
int keycode);
41 private native
void onTouched(
long handle,
int owner,
int state,
float x,
float y);
42 private native
void onUIStateChanged(
long handle, String stateName, String stateValue);
46 MenuInflater inflater = getMenuInflater();
47 inflater.inflate(
R.menu.title, menu);
55 if (mDrawerToggle !=
null && mDrawerToggle.onOptionsItemSelected(item)) {
59 switch (item.getItemId()) {
60 case R.id.action_left:
61 onKeyPressed(mApplication.
getNativeHandle(), KeyEvent.KEYCODE_SOFT_LEFT);
63 case R.id.action_right:
64 onKeyPressed(mApplication.
getNativeHandle(), KeyEvent.KEYCODE_SOFT_RIGHT);
67 return super.onOptionsItemSelected(item);
72 protected void onCreate(Bundle savedInstanceState) {
73 super.onCreate(savedInstanceState);
74 setContentView(
R.layout.activity_main);
76 SurfaceView surfaceView = (SurfaceView) findViewById(
R.id.surfaceView);
77 surfaceView.getHolder().addCallback(
this);
78 surfaceView.setOnTouchListener(
this);
80 mDrawerLayout = (DrawerLayout) findViewById(
R.id.drawerLayout);
81 if (mDrawerLayout !=
null) {
82 mDrawerToggle =
new ActionBarDrawerToggle(
this, mDrawerLayout,
83 R.string.drawer_open,
R.string.drawer_close);
84 mDrawerLayout.addDrawerListener(mDrawerToggle);
85 getActionBar().setDisplayHomeAsUpEnabled(
true);
86 getActionBar().setHomeButtonEnabled(
true);
89 mDrawerList = (ListView) findViewById(
R.id.leftDrawer);
91 mDrawerList.setAdapter(mStateAdapter);
99 super.onPostCreate(savedInstanceState);
100 if (mDrawerToggle !=
null) {
101 mDrawerToggle.syncState();
107 super.onConfigurationChanged(newConfig);
108 if (mDrawerToggle !=
null) {
109 mDrawerToggle.onConfigurationChanged(newConfig);
142 int count =
event.getPointerCount();
144 final float x =
event.getX(
i);
145 final float y =
event.getY(
i);
146 final int owner =
event.getPointerId(
i);
147 int action =
event.getAction() & MotionEvent.ACTION_MASK;
158 onUIStateChanged(mApplication.
getNativeHandle(), stateName, stateValue);
void setState(String stateJson)
boolean onTouch(View v, MotionEvent event)
void surfaceDestroyed(SurfaceHolder holder)
void onCreate(Bundle savedInstanceState)
void onStateChanged(String stateName, String stateValue)
boolean onCreateOptionsMenu(Menu menu)
void onPostCreate(Bundle savedInstanceState)
void surfaceCreated(SurfaceHolder holder)
void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
boolean onOptionsItemSelected(MenuItem item)
void onConfigurationChanged(Configuration newConfig)
void setState(String stateJson)
void setViewerActivity(ViewerActivity viewerActivity)
uint32_t uint32_t * format
std::function< void(MTLRenderPipelineDescriptor *)> Callback