Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void multiImageCaptureFunctionality(String title,final String question_id,String require)
- {
- LinearLayout ll_text = new LinearLayout(this);
- LayoutParams ll_text_params = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- ll_text_params.setMargins(Math.round(49 * multiplier), 0, Math.round(49 * multiplier), 0);
- ll_text.setGravity(Gravity.CENTER_VERTICAL);
- ll_text.setOrientation(LinearLayout.VERTICAL);
- ll_text.setId(Integer.parseInt(question_id));
- methodForGeneratingMultiImage(ll_text, ll_text_params, require,question_id);
- }
- int count_multi=0;
- public void methodForGeneratingMultiImage(final LinearLayout ll_multiImage,final LayoutParams ll_multiImageParams,final String requires,final String question_id)
- {
- final TextView tv_question_text = new TextView(this);
- LayoutParams text_question_params = new LayoutParams(
- Math.round(500*multiplier),
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- text_question_params.setMargins(0, Math.round(38 * multiplier),0, 0);
- tv_question_text.setGravity(Gravity.CENTER_VERTICAL);
- tv_question_text.setId(Integer.parseInt(question_id));
- tv_question_text.setTextSize(16.5f*multiplier);
- if (Constants.ad_status.matches("1")||Constants.ad_status.matches("3")) {
- if (requires.matches("1")) {
- tv_question_text.setText(question_no+". "+getTitleString(question_id, tv_question_text)+" *");
- } else {
- tv_question_text.setText(question_no+". "+getTitleString(question_id, tv_question_text));
- }
- } else {
- if (requires.matches("1")) {
- tv_question_text.setText(""+getTitleString(question_id, tv_question_text)+" *");
- } else {
- tv_question_text.setText(""+getTitleString(question_id, tv_question_text));
- }
- }
- tv_question_text.setTextColor(Color.WHITE);
- tv_question_text.setTypeface(gotham_rounded_bold);
- tv_question_text.setLineSpacing(1.2f, 1.2f);
- final ImageButton bt_image = new ImageButton(this);
- LayoutParams bt_image_params = new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- bt_image_params.setMargins(0, Math.round(23 * multiplier),0, 0);
- bt_image.setId(1+count_multi);
- bt_image.setPadding(5, 0, 5, 0);
- bt_image.setPaddingRelative(15, 0, 15, 0);
- bt_image.setBackgroundDrawable(getResources().getDrawable(
- R.drawable.image_cap_selector));
- final LinearLayout ll_image=new LinearLayout(this);
- LayoutParams ll_image_params=new LayoutParams(
- Math.round(500 * multiplier), Math.round(170 * multiplier));
- ll_image_params.setMargins(0, Math.round(23 * multiplier), 0, 0);
- ll_image.setOrientation(LinearLayout.HORIZONTAL);
- ll_image.setGravity(Gravity.CENTER_VERTICAL);
- ll_image.setVisibility(View.GONE);
- ll_image.setId(161+count_multi);
- final ImageView iv_photo=new ImageView(this);
- LayoutParams iv_photo_params=new LayoutParams(Math.round(200 * multiplier), Math.round(169 * multiplier));
- iv_photo.setBackgroundDrawable(getResources().getDrawable(R.drawable.edittext_bg_with_shadow));
- iv_photo_params.setMargins(Math.round(10.0f), 0, 0, 0);
- iv_photo.setScaleType(ScaleType.FIT_XY);
- iv_photo.setId(34+count_multi);
- final ImageButton ib_delete=new ImageButton(this);
- LayoutParams ib_delete_params=new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
- android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
- ib_delete_params.setMargins(Math.round(10), 0, 0, 0);
- ib_delete.setBackgroundDrawable(getResources().getDrawable(R.drawable.but_delete_selector));
- ib_delete.setBaselineAlignBottom(true);
- ib_delete.setId(249+count_multi);
- ll_image.addView(iv_photo, iv_photo_params);
- ll_image.addView(ib_delete, ib_delete_params);
- File imagesFolder = new File(image_path);
- imagesFolder.mkdirs();
- final String image_name=getRandomStringForImage()+".png";
- final File image = new File(imagesFolder, ""+image_name);
- final String strFile=image.toString();
- final Uri uriSavedImage = Uri.fromFile(image);
- bt_image.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- bt_image.requestFocusFromTouch();
- Intent intent=new Intent("android.media.action.IMAGE_CAPTURE");
- intent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
- startActivity(intent);
- ll_image.setVisibility(View.VISIBLE);
- bt_image.setVisibility(View.GONE);
- Calendar c = Calendar.getInstance();
- System.out.println("Current time => " + c.getTime());
- SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
- formattedDate_question1 = df.format(c.getTime());
- SimpleDateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- formattedDate_user1 = df2.format(c.getTime());
- Constants.endDateAndTime = df2.format(c.getTime());
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
- runOnUiThread( new Runnable() {
- public void run() {
- iv_photo.setBackgroundColor(Color.parseColor(Constants.body_bg_color));
- iv_photo.setImageURI(uriSavedImage);
- iv_photo.setRotation(90);
- Log.d("image", "image="+image+" name="+image_name+" str="+strFile);
- if (count_multi!=4&&count_multi<=4) {
- methodForGeneratingMultiImage(ll_multiImage, ll_multiImageParams, requires,question_id);
- Log.d("eee", ""+count_multi);
- } else {
- }
- }
- });
- }
- }, 10000);
- count_multi++;
- ViewTreeObserver viwob=ll_main.getViewTreeObserver();
- viwob.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- ll_main.getViewTreeObserver().removeGlobalOnLayoutListener(this);
- int height=ll_main.getMeasuredHeight();
- Log.d("rrr", "vidfbsds="+height+" sch="+scrollvalue2);
- if (height<scrollvalue2) {
- rl_footer.setVisibility(View.VISIBLE);
- }else {
- rl_footer.setVisibility(View.GONE);
- }
- }
- });
- }
- });
- ib_delete.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- iv_photo.setBackgroundDrawable(getResources().getDrawable(R.drawable.edittext_bg_with_shadow));
- iv_photo.setImageURI(null);
- ll_image.setVisibility(View.GONE);
- bt_image.setVisibility(View.VISIBLE);
- deleteMultiImageResponse(question_id, image_name);
- ViewTreeObserver viwob=ll_main.getViewTreeObserver();
- viwob.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- ll_main.getViewTreeObserver().removeGlobalOnLayoutListener(this);
- int height=ll_main.getMeasuredHeight();
- Log.d("rrr", "vidfbsds="+height+" sch="+scrollvalue2);
- if (height<scrollvalue2) {
- rl_footer.setVisibility(View.VISIBLE);
- }else {
- rl_footer.setVisibility(View.GONE);
- }
- }
- });
- }
- });
- if (count_multi==0) {
- ll_multiImage.addView(tv_question_text, text_question_params);
- } else {
- }
- ll_multiImage.addView(bt_image, bt_image_params);
- ll_multiImage.addView(ll_image, ll_image_params);
- try {
- ll_main.addView(ll_multiImage, ll_multiImageParams);
- } catch (Exception e) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement