@Override protected void onStop() { super.onStop(); /* Implementation of Google Analytics for Android */ if (!(ConstantValues.URL == "http://www.trustripes.com" && ConstantValues.isInDevelopmentTeam(realId))) { EasyTracker.getInstance().activityStop(this); } }
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString("path", finalImagePath); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_pre_snackin); EasyTracker.getInstance().setContext(getApplicationContext()); /* Instantiation of UI widgets */ snackAgainButton = (TextView) findViewById(R.id.presnack_button_again); realSnackInButton = (Button) findViewById(R.id.presnack_button_Snack); backButton = (Button) findViewById(R.id.backButton); image = (ImageView) findViewById(R.id.presnack_imageview_add); ratingBar = (RatingBar) findViewById(R.id.ratingBar); commentBox = (EditText) findViewById(R.id.presnack_edittext_comment); titleName = (TextView) findViewById(R.id.presnack_textview_tittle); sendSnackin = new SendSnackIn(); session = getSharedPreferences(ConstantValues.USER_DATA, MODE_PRIVATE); obtainedCode = getIntent().getStringExtra("BARCODE"); productId = getIntent().getStringExtra("PRODUCT_ID"); productName = getIntent().getStringExtra("PRODUCT_NAME"); productPhoto = getIntent().getStringExtra("PRODUCT_PHOTO"); titleName.setText(productName); ratingBar.setRating(0); ratingValue = "0"; ratingBar.setOnRatingBarChangeListener( new OnRatingBarChangeListener() { public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { ratingBarValueChanged = true; ratingValue = String.valueOf(rating); } }); // loadPhoto = new LoadPhoto(); // if(savedInstanceState != null){ // boolean imageWasLoaded = savedInstanceState.getBoolean("loadingStatus"); // if(imageWasLoaded){ // String path = savedInstanceState.getString("ImagePath"); // if(!path.isEmpty()){ // decodeFile(path, 200, 200); // } // }else{ // imageLoader.DisplayImage(ConstantValues.URL+"/ws/productphoto/"+ productId // +"/thumbnails/"+productPhoto, image, false); // //loadPhoto.execute(); // } // } // else{ // imageLoader.DisplayImage(ConstantValues.URL+"/ws/productphoto/"+ productId // +"/thumbnails/"+productPhoto, image, false); // //loadPhoto.execute(); // } userId = session.getString("user_id", "No user"); /* Instantiation and button event association */ snackAgainButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Log.d("MAIN", "Click en snackAgainButton"); Intent intent = new Intent(getApplicationContext(), CaptureActivity.class); startActivity(intent); finish(); } }); backButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { finish(); } }); realSnackInButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { if (ConstantValues.getConnectionStatus(getApplicationContext())) { sendSnackin.execute(); realSnackInButton.setClickable(false); } else { Toast.makeText( getApplicationContext(), "Looks like you have no connection, please check it and try again", Toast.LENGTH_SHORT) .show(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Pick image from"); LayoutInflater inflater = (LayoutInflater) getSystemService(this.LAYOUT_INFLATER_SERVICE); View new_layout = inflater.inflate(R.layout.pick_photo, null); builder.setView(new_layout); final AlertDialog choosePictureDialog = builder.create(); Button cameraButton = (Button) new_layout.findViewById(R.id.launch_camera_button); Button galleryButton = (Button) new_layout.findViewById(R.id.choose_from_gallery_button); cameraButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile())); startActivityForResult(cameraIntent, CAMERA_RESULT); choosePictureDialog.dismiss(); } }); galleryButton.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, GALLERY_RESULT); choosePictureDialog.dismiss(); } }); // image.setClickable(true); // image.setOnClickListener(new OnClickListener() { // // public void onClick(View v) { // choosePictureDialog.show(); // } // }); imageLoader = new ImageLoader(getApplicationContext(), 16); if (savedInstanceState != null) { String tmp = savedInstanceState.getString("path"); String[] tmpArray = tmp.split("/"); if (tmpArray.length != 8) { decodeFile(tmp, 100, 100); } else { finalImagePath = ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto; imageLoader.DisplayImage(finalImagePath, image, false, false); } } else { finalImagePath = ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto; imageLoader.DisplayImage(finalImagePath, image, false, false); } imgpath = ConstantValues.URL + "/ws/productphoto/" + productId + "/thumbnails/" + productPhoto; developmentSession = getSharedPreferences(ConstantValues.USER_DATA, MODE_PRIVATE); id = developmentSession.getString("user_id", "-1"); realId = Integer.parseInt(id); }