Click here to Skip to main content
15,891,424 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
public class Map extends Activity {
	private NotificationManager nm;
	private int UniqueID = 100;

	private ImageView selectedImage;
	private Bitmap currentImage;
	float xval;
	float yval;
	float xx1, xx2, xx3, yy1, yy2, yy3;
	// TextView width,height;

	JSONObject json;
	// Progress Dialog
	private ProgressDialog pDialog;

	// JSON parser class
	JSONParser jsonParser = new JSONParser();

	private static final String LOGIN_URL = "http://www.digiassistant.comuf.com/get/getbeacon.php"; // change
	// to

	private static final String TAG_SUCCESS = "success";
	private static final String TAG_MESSAGE = "message";

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.map);
		selectedImage = (ImageView) findViewById(R.id.selectedImage);
		nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
		int width = 500;
		int height = 600;
		LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(width,
				height);
		selectedImage.setLayoutParams(parms);

		new AttemptLogin().execute();
		// width=(TextView)findViewById(R.id.t1);
		// height=(TextView)findViewById(R.id.t2);
		// int x= Integer.valueOf((String) width.getText());

		// int x = Integer.parseInt(width.getText().toString());
		// height.setText(""+x);
		// int x=10;
		// int y=5;

		Button openGallery = (Button) findViewById(R.id.opengallery);

		MyCustomPanel view = new MyCustomPanel(this);

		ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
				LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		addContentView(view, params);

		openGallery.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
				photoPickerIntent.setType("image/*");
				startActivityForResult(photoPickerIntent, 1);
			}
		});
	}

	// public void open_gal(View view){
	//
	//
	// Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
	// photoPickerIntent.setType("image/*");
	// startActivityForResult(photoPickerIntent, 1);
	//
	//
	//
	// }

	private class MyCustomPanel extends View {

		public MyCustomPanel(Context context) {
			super(context);

		}

		@Override
		public void draw(Canvas canvas) {

			Paint paint = new Paint();
			paint.setColor(Color.GREEN);
			paint.setStrokeWidth(50);

			paint.setColor(Color.RED);

			// canvas.drawLine(50, 50, 90, 10, paint);
			// canvas.drawCircle(50, 50, 3, paint);

			// if (x > 500 || x<0 || y<120 || y >710 ){

			// Toast.makeText(Map.this,
			// "Outer the Area",Toast.LENGTH_SHORT).show();
			// displayNotification();

			// }
			// else{

			canvas.drawCircle(x, y, 10, paint);
			// }

		}
	}

	// /
	class AttemptLogin extends AsyncTask<string,> {

		/**
		 * Before starting background thread Show Progress Dialog
		 * */
		boolean failure = false;

		@Override
		protected void onPreExecute() {
			super.onPreExecute();
			pDialog = new ProgressDialog(Map.this);
			pDialog.setMessage("Attempt login...");
			pDialog.setIndeterminate(false);
			pDialog.setCancelable(true);
			pDialog.show();
		}

		@Override
		protected String doInBackground(String... args) {
			SharedPreferences sharedpreferences = getSharedPreferences(
					Login.MyPREFERENCES, Context.MODE_PRIVATE);

			String username = sharedpreferences.getString(Login.name, null);

			// Check for success tag
			int success;
			// String username = user.getText().toString();

			try {
				// Building Parameters
				List<namevaluepair> params = new ArrayList<namevaluepair>();
				params.add(new BasicNameValuePair("username", username));

				Log.d("request!", "starting");
				// getting product details by making HTTP request
				json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", params);

				// check your log for json response
				Log.d("Login attempt", json.toString());

				// json success tag
				success = json.getInt(TAG_SUCCESS);
				if (success == 1) {
					Log.d("Login Successful!", json.toString());

					return json.getString(TAG_MESSAGE);
				} else {
					Log.d("Login Failure!", json.getString(TAG_MESSAGE));
					return json.getString(TAG_MESSAGE);

				}
			} catch (JSONException e) {
				e.printStackTrace();
			}

			return null;

		}

		/**
		 * After completing background task Dismiss the progress dialog
		 * **/
		protected void onPostExecute(String file_url) {
			// dismiss the dialog once product deleted
			pDialog.dismiss();
			try {

				JSONArray user = json.getJSONArray("user");
				JSONObject jb = user.getJSONObject(0);
				float xx1 = jb.getLong("xx1");

				float xx2 = jb.getLong("xx2");
				float xx3 = jb.getLong("xx3");
				float yy1 = jb.getLong("yy1");
				float yy2 = jb.getLong("yy2");
				float yy3 = jb.getLong("yy3");

				// displaying all data in textview

				// Getbeacon.this.xx1.setText("" + a);
				// Getbeacon.this.xx2.setText("" + xx2);
				// Getbeacon.this.xx3.setText("" + xx3);
				// Getbeacon.this.yy1.setText("" + yy1);
				// Getbeacon.this.yy2.setText("" + yy2);
				// Getbeacon.this.yy3.setText("" + yy3);

			} catch (Exception e) {
				e.printStackTrace();
			}
			if (file_url != null) {
				Toast.makeText(Map.this, file_url, Toast.LENGTH_LONG).show();
			}

		}



i need to pass the variables xx1 yy1 to draw in canvas, where x and y in drawccircle
() must set with xx1 and yy1

[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 22-Nov-14 21:36pm
v3
Comments
Sergey Alexandrovich Kryukov 23-Nov-14 1:24am    
Not a question. If, by any chance, it was a request for permission, you got it. You can go ahead and pass whatever you want and return whatever you want from a method you want. If you face any problems with that, feel free to ask your question. We will always gladly help you.
—SA
Member 11062532 23-Nov-14 2:47am    
i didnt get what you said
Sergey Alexandrovich Kryukov 23-Nov-14 3:03am    
Which part?
Anyway, you need to ask a question...
—SA
OriginalGriff 23-Nov-14 3:40am    
What he means is:
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
What you have given us is called a code dump - it's your whole (poorly documented) file complete with commented out code - and nothing else. The "question" part isn't obviously relevant to the code since we have no idea what you want to do with xx1 or yy1, or where you want to do it.

So...edit the question, cut out the "dead wood" so we can see the important bits, and explain in English and better detail what problem you are having to someone who has no idea what your project it, much less how you are implementing it!

Help us to help you!

Use the "Improve question" widget to edit your question and provide better information.
Member 11062532 23-Nov-14 5:04am    
i need to send the xx1 yy1 values from the post class to the draw class and draw those points in the canvas

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900