Skip to content
Snippets Groups Projects
Commit 964f024c authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Android: show progress informations

parent a831aa9f
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
......
...@@ -69,6 +69,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO ...@@ -69,6 +69,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO
getFragmentManager().beginTransaction().add(R.id.model_fragment, _modelFragment).commit(); getFragmentManager().beginTransaction().add(R.id.model_fragment, _modelFragment).commit();
} }
} }
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu); super.onCreateOptionsMenu(menu);
...@@ -164,7 +165,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO ...@@ -164,7 +165,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO
protected void onPostExecute(Integer[] result) { protected void onPostExecute(Integer[] result) {
//(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350); //(Vibrator) getSystemService(Context.VIBRATOR_SERVICE).vibrate(350);
_runStopMenuItem.setTitle(R.string.menu_run); _runStopMenuItem.setTitle(R.string.menu_run);
//loading.dismiss(); if(_modelFragment != null) _modelFragment.hideProgress();
_compute = false; _compute = false;
super.onPostExecute(result); super.onPostExecute(result);
} }
...@@ -208,8 +209,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO ...@@ -208,8 +209,7 @@ public class MainActivity extends Activity implements OptionsDisplayFragment.OnO
if(_optionsFragment != null) _optionsFragment.refresh(); if(_optionsFragment != null) _optionsFragment.refresh();
break; break;
case 2: // we get a message for loading case 2: // we get a message for loading
/*String loadingMessage =(String) msg.obj; if(_modelFragment != null) _modelFragment.showProgress((String) msg.obj);
loading.setMessage(loadingMessage);*/
break; break;
case 3: // we get a progress for loading case 3: // we get a progress for loading
//loading.setProgress(msg.arg1); //loading.setProgress(msg.arg1);
......
...@@ -7,11 +7,14 @@ import android.view.LayoutInflater; ...@@ -7,11 +7,14 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class ModelFragment extends Fragment{ public class ModelFragment extends Fragment{
Gmsh _gmsh; Gmsh _gmsh;
mGLSurfaceView _glView; mGLSurfaceView _glView;
TextView _progress;
public static ModelFragment newInstance(Gmsh g) { public static ModelFragment newInstance(Gmsh g) {
ModelFragment fragment = new ModelFragment(); ModelFragment fragment = new ModelFragment();
...@@ -34,7 +37,7 @@ public class ModelFragment extends Fragment{ ...@@ -34,7 +37,7 @@ public class ModelFragment extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_model, container, false); View rootView = inflater.inflate(R.layout.fragment_model, container, false);
LinearLayout glViewLayout = (LinearLayout)rootView.findViewById(R.id.glViewLayout); RelativeLayout glViewLayout = (RelativeLayout)rootView.findViewById(R.id.glViewLayout);
GLESRender renderer = new GLESRender(_gmsh); GLESRender renderer = new GLESRender(_gmsh);
_glView = new mGLSurfaceView(glViewLayout.getContext(), renderer); _glView = new mGLSurfaceView(glViewLayout.getContext(), renderer);
_glView.setEGLContextClientVersion(1); _glView.setEGLContextClientVersion(1);
...@@ -42,9 +45,25 @@ public class ModelFragment extends Fragment{ ...@@ -42,9 +45,25 @@ public class ModelFragment extends Fragment{
_glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY); _glView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
_glView.requestRender(); _glView.requestRender();
glViewLayout.addView(_glView); glViewLayout.addView(_glView);
_progress = new TextView(container.getContext());
_progress.setAlpha(0);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
_progress.setPadding(10, 0, 10, 10);
_progress.setLayoutParams(layoutParams);
glViewLayout.addView(_progress);
return rootView; return rootView;
} }
public void showProgress(String progress) {
_progress.setAlpha(1);
_progress.setText(progress);
}
public void hideProgress() {
_progress.setAlpha(0);
_progress.setText("");
}
public void requestRender() { public void requestRender() {
_glView.requestRender(); _glView.requestRender();
} }
......
...@@ -6,6 +6,7 @@ import android.app.Activity; ...@@ -6,6 +6,7 @@ import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -110,7 +111,7 @@ public class OptionsDisplayFragment extends Fragment{ ...@@ -110,7 +111,7 @@ public class OptionsDisplayFragment extends Fragment{
} }
}); });
Button button = new Button(_listView.getContext()); Button button = new Button(_listView.getContext());
button.setText("More options"); button.setText("More options >");
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { public void onClick(View v) {
Intent intent = new Intent(getActivity(), PostProcessingActivity.class); Intent intent = new Intent(getActivity(), PostProcessingActivity.class);
...@@ -121,6 +122,7 @@ public class OptionsDisplayFragment extends Fragment{ ...@@ -121,6 +122,7 @@ public class OptionsDisplayFragment extends Fragment{
}); });
button.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); button.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
button.setBackgroundColor(Color.TRANSPARENT); button.setBackgroundColor(Color.TRANSPARENT);
button.setGravity(Gravity.RIGHT);
layout.addView(checkbox); layout.addView(checkbox);
layout.addView(button); layout.addView(button);
_listView.addItem("Result", layout); _listView.addItem("Result", layout);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment