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
| @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View addReport = inflater
.inflate(R.layout.add_report, container, false);
ListView listView = (ListView) addReport.findViewById(R.id.list);
// listView.addHeaderView(padding);
listView.setDivider(new GradientDrawable(Orientation.LEFT_RIGHT, colors));
listView.setDividerHeight(1);
remplirListOfReport();
ReportAdaptor reportSchedule = new ReportAdaptor(getActivity(),
R.layout.report_item_format, listOfReports);
listView.setAdapter(reportSchedule);
// Inflate the root layout
myInflater = (LayoutInflater) addReport.getContext().getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
uploadFiles = (LinearLayout) addReport.findViewById(R.id.upload_layout);
picture = (Button) addReport.findViewById(R.id.picture);
video = (Button) addReport.findViewById(R.id.video);
vocale = (Button) addReport.findViewById(R.id.vocal);
report = (EditText) addReport.findViewById(R.id.report_text);
picture.setOnClickListener(buttonOnClickListener);
video.setOnClickListener(buttonOnClickListener);
vocale.setOnClickListener(buttonOnClickListener);
return addReport;
}
Button.OnClickListener buttonOnClickListener = new Button.OnClickListener() {
private String fullPathAudio = "";
@Override
public void onClick(View v) {
if (v == picture) {
if(null != getGPSCoordonnee(getActivity())){
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, MEDIA_TYPE_IMAGE);
}
} else if (v == video) {
if(null != getGPSCoordonnee(getActivity())){
Intent intent1 = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
intent1.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set
//the video image quality to high
startActivityForResult(intent1, MEDIA_TYPE_VIDEO);
}
} else if (v == vocale) {
if(null != getGPSCoordonnee(getActivity())){
getOutputMediaFile(MEDIA_TYPE_AUDIO);
fullPathAudio = URL_START_WITH + File.separator + AUDIO_NAME;
vocale.setText("Vocal");
View audioView = myInflater.inflate(R.layout.picture_format,
uploadFiles, false);
description = (TextView) audioView
.findViewById(R.id.picture_text);
imageView = (ImageView) audioView
.findViewById(R.id.picture_image);
edit = (Button) audioView.findViewById(R.id.picture_edit);
date = (TextView) audioView.findViewById(R.id.picture_date);
date.setText(TIME);
description.setText("Audio");
imageView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent2 = new Intent(getActivity(),
ShowVideo.class);
intent2.putExtra("videoName", fullPathAudio);
startActivity(intent2);
}
});
edit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
editPictureNames(description);
}
});
uploadFiles.addView(audioView);
Intent myIntent = new Intent(getActivity(),
AudioRecordingActivity.class);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myIntent.putExtra("path", fullPathAudio);
getActivity().startActivity(myIntent);
}
}
}
}; |
Partager