From 331790403d7cc229f0ae609eb66d9ff6836d9919 Mon Sep 17 00:00:00 2001 From: Maxime Graulich <maxime.graulich@gmail.com> Date: Thu, 4 Jul 2013 07:51:49 +0000 Subject: [PATCH] Fix the black screen issue --- contrib/mobile/Android/res/layout/model.xml | 16 +++---- .../src/org/geuz/onelab/MainActivity.java | 42 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/contrib/mobile/Android/res/layout/model.xml b/contrib/mobile/Android/res/layout/model.xml index 9301369f01..8980316ca9 100644 --- a/contrib/mobile/Android/res/layout/model.xml +++ b/contrib/mobile/Android/res/layout/model.xml @@ -1,34 +1,36 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView - android:id="@+id/icone" + android:id="@+id/icon" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:contentDescription="icone" + android:contentDescription="icon" android:src="@drawable/ic_launcher" /> <LinearLayout android:layout_width="wrap_content" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:orientation="vertical" > <TextView - android:id="@+id/titre" + android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" - android:textColor="#ffffff" /> + android:textColor="#ffffff" + android:textIsSelectable="false" /> <TextView android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="#ffffff" /> + android:textColor="#ffffff" + android:textIsSelectable="false" /> </LinearLayout> diff --git a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java index 49c4d69603..7153b3a390 100644 --- a/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java +++ b/contrib/mobile/Android/src/org/geuz/onelab/MainActivity.java @@ -58,6 +58,7 @@ public class MainActivity extends Activity { private UndragableViewPager pager; private List<Parameter> params = new ArrayList<Parameter>(); private SeparatedListView paramListView; + private boolean compute = false; @Override public void onCreate(Bundle savedInstanceState) { @@ -65,8 +66,7 @@ public class MainActivity extends Activity { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - //this.requestWindowFeature(Window.FEATURE_NO_TITLE); - + LinearLayout layout = new LinearLayout(this); loading = new ProgressDialog(this); layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); @@ -74,7 +74,7 @@ public class MainActivity extends Activity { pager = new UndragableViewPager(this); pager.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); pager.setAdapter(new AdaptedPager()); - pager.setOffscreenPageLimit(3); + pager.setOffscreenPageLimit(2); pager.setCurrentItem(0); layout.addView(pager); dialogBuilder = new AlertDialog.Builder(this); @@ -85,11 +85,11 @@ public class MainActivity extends Activity { Bundle extras = getIntent().getExtras(); if(intent != null && intent.getAction() != null && intent.getAction().equals(Intent.ACTION_VIEW)) { String tmp = intent.getData().getPath(); - pager.setCurrentItem(1); + pager.setCurrentItem(1, true); gmsh.load(tmp); } else if(extras != null) { - pager.setCurrentItem(0); + pager.setCurrentItem(0, true); //extras.getInt("model"); //extras.getString("name"); String tmp = extras.getString("file"); @@ -201,7 +201,6 @@ public class MainActivity extends Activity { case 1: // OpenGL ES view renderer = new GLESRender(gmsh); glView = new mGLSurfaceView(container.getContext(), renderer); - //TODO the glView seems break the ViewPager (black square appear ...) glView.setEGLContextClientVersion(1); glView.setRenderer(renderer); glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); @@ -411,17 +410,17 @@ public class MainActivity extends Activity { reset = new Button(ctx); run.setText("Run"); reset.setText("Reset"); - run.setOnClickListener(new OnClickListener() {public void onClick(View v) { - if(run.getText().equals("Show progress")) - { - loading.show(); - return; + run.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + if(compute) { + loading.show(); + } + else { + new Run().execute(); + pager.setCurrentItem(1, true); + } } - else - new Run().execute(); - - pager.setCurrentItem(1, true); - }}); + }); reset.setOnClickListener(new OnClickListener() {public void onClick(View v) { if(gmsh.onelabCB("reset") == 1){ getAvailableParam(); @@ -469,6 +468,7 @@ public class MainActivity extends Activity { @Override protected void onPreExecute() { + compute = true; loading.setTitle("Please wait"); loading.setButton(DialogInterface.BUTTON_NEUTRAL, "Hide", new DialogInterface.OnClickListener() { @@ -485,7 +485,7 @@ public class MainActivity extends Activity { }); loading.setMessage("..."); loading.show(); - run.setText("Show progress"); + //run.setText("Show progress"); reset.setEnabled(false); super.onPreExecute(); } @@ -498,14 +498,16 @@ public class MainActivity extends Activity { @Override protected void onPostExecute(Integer[] result) { - loading.dismiss(); - run.setText("Run"); Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); v.vibrate(350); - run.setEnabled(true); reset.setEnabled(true); + run.setEnabled(true); + //run.setText("Run"); // TODO this seems break the ViewPager + pager.postInvalidate(); glView.requestRender(); super.onPostExecute(result); + loading.dismiss(); + compute = false; } } -- GitLab