1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
public class Main extends Activity{
GLSurfaceView surfaceView;
static Model model = null;
InputStream is=null;
GestureDetector aGestureDetector;
GestureDetector aGestureDetector3D;
GestureDetector aNavigatorGestureListener;
ImageView imgView=null;
ImageView recTransparent=null;
MyGLRenderer glRenderer=null;
Renderer3D glRenderer3d=null;
float xFactor;
private ListView lv=null;
View inflatedView;
ScaleGestureDetector mScaleDetector=null;
Context context = null;
WebView webView =null;
NavigatorView aNavigator=null;
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
ArrayAdapter<Information> lvAdapter;
PageWeb pageWeb;
String baseUrl;
private ArrayList<Information> selectedQuestions;
ZoneView zoneView;
LinearLayout LinearLayout1;
MediaPlayer mediaPlayer;
MediasView mediaView;
LinearLayout mediasLayout;
RelativeLayout buttonParentLayout;
Button btnFermer;
VideoView myVideoView;
SurfaceView surfaceView1;
SurfaceHolder surfaceHolder;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
context = this.getBaseContext();
Log.d("DataDirectory",Environment.getDataDirectory().toString());
baseUrl =Environment.getExternalStorageDirectory()+"/Projet";
final String rootPath1= Environment.getExternalStorageDirectory()+"/Projet";
mediasLayout=(LinearLayout) findViewById(R.id.LinearLayout2);
mediasLayout.setVisibility(View.GONE);
final ScrollView ScrollView1 = (ScrollView) findViewById(R.id.ScrollView1);
ScrollView1.setVisibility(View.GONE);
buttonParentLayout = (RelativeLayout) findViewById(R.id.buttonParentLayout);
btnFermer = (Button) findViewById(R.id.button1);
btnFermer.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View arg0, MotionEvent arg1) {
ScrollView1.setVisibility(View.GONE);
return true;
}
});
surfaceView = (GLSurfaceView) this.findViewById(R.id.glSurface);
lv = (ListView) this.findViewById(R.id.listView1);
lvAdapter = new ArrayAdapter<Information>(this,android.R.layout.simple_list_item_1,model.getQuestions());
lv.setAdapter(lvAdapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Object o = lv.getItemAtPosition(position);
Information article =(Information) lv.getItemAtPosition(position);
TextView questionView = new TextView(context);
questionView.setText(article.toString());
TextView reponseView = new TextView(context);
reponseView.setText(article.getINFORMATION());
ArrayList<ImageView> imageViews = new ArrayList<ImageView>();
ArrayList<VideoView> videoViews = new ArrayList<VideoView>();
int nbrImg = article.getMEDIAS().size();
TextView nbrMedias = new TextView(context);
nbrMedias.setText(""+nbrImg);
int nbrimg =0;
int nbrvideo =0;
for (int i=0;i<article.getMEDIAS().size();i++){
Media media = article.getMEDIAS().get(i);
if (media.getMediaType()=="IMAGE") {
nbrimg++;
String imgPath = media.getUri();
String strTab[]=imgPath.split("/");
String newImgPath = rootPath1 + imgPath + "/"+strTab[3];
FileInputStream in;
BufferedInputStream buf;
Log.d("newImgPath 2 : ",newImgPath);
ImageView image = new ImageView(context);
try {
in = new FileInputStream(newImgPath);
buf = new BufferedInputStream(in);
Bitmap bMap = BitmapFactory.decodeStream(buf);
image.setImageBitmap(bMap);
imageViews.add(image);
if (in != null) {
in.close();
}
if (buf != null) {
buf.close();
}
} catch (Exception e) {
Log.e("Error reading file1", e.toString());
}
}
if (media.getMediaType()=="VIDEO") {
nbrvideo++;
String vidPath = media.getUri();
String strTab[]=vidPath.split("/");
String newVidPath = rootPath1 + vidPath + "/"+strTab[3];
Log.d("VideoImgPath : ",newVidPath);
myVideoView = (VideoView)findViewById(R.id.videoView1);
myVideoView.setVideoURI(Uri.parse(newVidPath));
myVideoView.setMediaController(new MediaController(context));
myVideoView.requestFocus();
videoViews.add(myVideoView);
}
}
mediasLayout.removeAllViews();
mediasLayout.removeView(questionView);
mediasLayout.addView(buttonParentLayout);
mediasLayout.addView(questionView);
mediasLayout.addView(reponseView);
for(int i=0;i<imageViews.size();i++) {
ImageView imgView = imageViews.get(i);
mediasLayout.addView(imgView);
}
for(int i=0;i<videoViews.size();i++) {
VideoView videoView=videoViews.get(i);
mediasLayout.addView(videoView);
//videoView.start();
Log.d("VideoViews ","videoViews : "+videoViews.size());
}
mediasLayout.setVisibility(View.VISIBLE);
ScrollView1.setVisibility(View.VISIBLE);
}
});
glRenderer = new MyGLRenderer(this,model);
surfaceView.setRenderer(glRenderer);
aGestureDetector = new GestureDetector(this, new glSurfaceListener(context,model, lv,lvAdapter,webView,aNavigator));
mScaleDetector = new ScaleGestureDetector(this, new glSurfaceListener(context,model,lv,lvAdapter,webView,aNavigator));
} |
Partager