Example #1
0
  public void displayImage(int i) {

    String imgPath = locModel.getImages().get(i).toString();

    ImageView iView = (ImageView) findViewById(R.id.imgImageView);

    File imgFile = new File(imgPath);
    if (imgFile.exists()) {
      Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
      iView.setImageBitmap(myBitmap);
    }
  }
Example #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_go_get_me_pick_location);

    Bundle bundle = getIntent().getExtras();
    userId = bundle.getInt("UserId");
    Log.d("User Id", "" + userId);

    srvc = Context.TELEPHONY_SERVICE;
    TelephonyManager manager = (TelephonyManager) getSystemService(srvc);
    IMEI = manager.getDeviceId();

    /*new ThreadRegister().execute(new DatabaseConnection());
    handlerRegister = new Handler() {
    	public void handleMessage(Message myMessage) {
    		result = myMessage.getData().getString("result");
    		if (result.equals("False")) {
    			// CONNECTION PROBLEM
    			//Toast.makeText(getApplicationContext(), result, Toast.LENGTH_SHORT).show();
    		}
    		else {
    			// CONNECTION IS OK
    			userId = Integer.parseInt(result);

    			//Log.d("user ID",""+userId);
    			//Toast.makeText(getApplicationContext(), userId, Toast.LENGTH_SHORT).show();
              	}
    	}
    };*/

    try {
      locModel.LoadLocations(this);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    try {
      locModel.LoadImage(this);
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    displayImage(0);

    btnNext = (Button) findViewById(R.id.btnNext);
    btnPrevious = (Button) findViewById(R.id.btnPrevious);
    btnGo = (Button) findViewById(R.id.btnGo);

    btnNext.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub

            if (i == locModel.getImages().size() - 1) {
              i = 0;
              l = 0;
              displayImage(i);
            } else if (i < locModel.getImages().size()) {
              i++;
              l++;
              displayImage(i);
            }
          }
        });

    btnPrevious.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (i == 0) {
              i = locModel.getImages().size() - 1;
              l = locModel.getImages().size() - 1;
              displayImage(i);
            } else if (i < locModel.getImages().size()) {
              i--;
              l--;
              displayImage(i);
            }
          }
        });

    ((Button) findViewById(R.id.btnHelp))
        .setOnClickListener(
            new Button.OnClickListener() {

              @Override
              public void onClick(View v) {

                Intent helpScreen = new Intent(GoGetMePickLocation.this, HelpScreen.class);
                helpScreen.putExtra("ScreenName", screenName);
                startActivity(helpScreen);
                // ***********Use this please
                // *****START ACTIVITY FOR RESULT CODE
                // http://stackoverflow.com/questions/2497205/how-to-return-a-result-startactivityforresult-from-a-tabhost-activity

              }
            });

    btnGo.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub

            if (i == l) {

              String address = locModel.getLocations().get(i).toString();

              Intent mapStart = new Intent(GoGetMePickLocation.this, GoGetMeDirections.class);
              mapStart.putExtra("DESTINATION", address);
              mapStart.putExtra("UserId", userId);
              startActivity(mapStart);
              Log.d("address firstLine", address);

              // Make intent to google screen, pass values of first line and postcode through
              // pass values of first line and postcode through as extras

              // Toast.makeText(GoGetMePickLocation.this, "firstLine["+firstLine+"]",
              // Toast.LENGTH_SHORT).show();
            }
          }
        });
  }