Example #1
0
 /**
  * The Location Manager manages location providers. This code searches for the best provider of
  * data (GPS, WiFi/cell phone tower lookup, some other mechanism) and finds the last known
  * location.
  */
 private void getLocation() {
   final Bundle bundle = getArguments();
   if (bundle != null) {
     latitude = bundle.getDouble(INTENT_KEY_LATITUDE, 0.0);
     longitude = bundle.getDouble(INTENT_KEY_LONGITUDE, 0.0);
   }
 }
  @Override
  protected void onHandleIntent(Intent intent) {
    Bundle b = intent.getExtras();
    latitude = b.getDouble("latitude");
    longitude = b.getDouble("longitude");
    timeStamp = b.getString("timeStamp");
    deviceId = b.getString("deviceId");

    Cursor cursor =
        getContentResolver()
            .query(LocationContract.UserLocationDetails.CONTENT_URI, null, null, null, null);
    if (!(cursor.moveToFirst()) || (cursor.getCount() == 0)) {
      insertLocationDetailsIntoDb();
      sendLocationDetailsToServer();
      cursor.close();
    } else {
      cursor.moveToLast();
      double previousLat = cursor.getDouble(cursor.getColumnIndex("latitude"));
      double previousLong = cursor.getDouble(cursor.getColumnIndex("longitude"));
      Float distance = distFrom(previousLat, previousLong, latitude, longitude);
      if (distance > 100) {
        insertLocationDetailsIntoDb();
        sendLocationDetailsToServer();
      } else {
        // No uploading required since distance between previous uploaded location and current
        // location is less than 100m
      }
      cursor.close();
    }
  }
        @Override
        public MyLocation createFromParcel(Parcel source) {
          Bundle bundle = source.readBundle();

          return new MyLocation(
              bundle.getDouble(PARCELABLE_LATITUDE), bundle.getDouble(PARCELABLE_LONGITUDE));
        }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_map);
    //      android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar)
    // findViewById(R.id.toolbar);
    //        setSupportActionbar(toolbar);

    Bundle gotLatLong = getIntent().getExtras();
    latitude = gotLatLong.getDouble("camplat");
    longitude = gotLatLong.getDouble("camplong");

    setUpMapIfNeeded();

    new GetAllMarkersTask().execute(new ApiConnector());
    new GetAllPolygonsTask().execute(new PolyConnector());

    mNavigationItems = getResources().getStringArray(R.array.navigation_items);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);

    ObjectDrawerItem[] drawerItem = new ObjectDrawerItem[3];
    drawerItem[0] = new ObjectDrawerItem("Choose Campus");
    drawerItem[1] = new ObjectDrawerItem("Help");
    drawerItem[2] = new ObjectDrawerItem("About Us");

    DrawerItemCustomAdapter adapter =
        new DrawerItemCustomAdapter(this, R.layout.listview_item_row, drawerItem);
    mDrawerList.setAdapter(adapter);

    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  }
Example #5
0
  @Override
  public void run() {
    // TODO Auto-generated method stub
    try {
      btnBackMap = (Button) findViewById(R.id.btnBackMap);
      btnDirection = (Button) findViewById(R.id.btnDirection);
      // Get intent and receive data from the parent activity
      Intent intent = getIntent();
      Bundle bundle = intent.getExtras();
      respectLocation = (PlaceModel) bundle.getSerializable("currentplace");
      curLAT = bundle.getDouble("currentLatitude");
      curLNG = bundle.getDouble("currentLongitude");

      // Set the coordinate for from-point
      if (fromLocation == null) {
        fromLocation = new PlaceModel();
        fromLocation.setLat(curLAT);
        fromLocation.setLng(curLNG);
      }

      // zoom to current place
      zoomToCurrentPlace();
      // draw place
      drawPlace();

      // buttonOnClick, button Zoom on map
      setButtonClick();
      map.setBuiltInZoomControls(true);
      map.invalidate();
    } catch (Exception e) {
    }
    handler.sendEmptyMessage(0);
  }
        @Override
        public void onReceive(Context context, Intent intent) {
          // Get Bundles
          Bundle extras = intent.getExtras();
          // Unwrap bundle object
          runTemp = extras.getDouble(TempService.TEMPKEY); // Hopfully get the temp.
          double runRoc = extras.getDouble(TempService.ROCKEY); // Hopfully get the RoC.
          long currentTime = extras.getLong(TempService.TIMEKEY); // Hopfully get the time.
          int currentPower = extras.getInt(TempService.POWERKEY); // Hopfully get the Power.
          double wantedRoC = extras.getDouble(TempService.WROCKEY); // Desired RoC

          if (currentPower != tempBar.getProgress()) {
            tempBar.setProgress(currentPower);
            sendMessage("A" + String.format("%04d", currentPower));
          }

          if (runTemp > maxTempValue) {
            maxTempValue = runTemp;
            dispMaxT.setText("Max Temp: " + String.format("%5.2f", runTemp));
          }
          liveGraphXYSeries.add(currentTime / 10000, runTemp);
          mChartView.repaint();

          dispRunTime.setText(
              "Time: "
                  + String.format(
                      "%d:%02d",
                      TimeUnit.MILLISECONDS.toMinutes(currentTime),
                      TimeUnit.MILLISECONDS.toSeconds(currentTime)
                          - TimeUnit.MINUTES.toSeconds(
                              TimeUnit.MILLISECONDS.toMinutes(currentTime))));
          dispTemp.setText("Temp: " + String.format("%5.2f", runTemp));
          dispRoc.setText("Roc: " + String.format("%5.2f", runRoc) + "/min");
          dispWRoC.setText("Target RoC: " + String.format("%5.2f", wantedRoC));
        }
Example #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); // Always call the superclass first
    setContentView(R.layout.activity_main);

    txt = (TextView) findViewById(R.id.textView);

    // peidab actionbar-i riba üleval, kus on rakenduse nimi kirjas
    // getActionBar().hide(); --> see ei toiminud, styles.xml-is pidi muutma
    // parent="Theme.AppCompat.Light.NoActionBar" lõpu ära

    // Check whether we're recreating a previously destroyed instance
    if (savedInstanceState != null) {
      // Restore value of members from saved state
      nrEkraanil = savedInstanceState.getString("nrEkraanil");
      esimNr = savedInstanceState.getDouble("esimNr");
      misTehe = savedInstanceState.getString("misTehe");
      teineNr = savedInstanceState.getDouble("teineNr");
      arvutuseVastus = savedInstanceState.getDouble("arvutuseVastus");
      kasTeine = savedInstanceState.getBoolean("kasTeine");
      kasVordusOlnud = savedInstanceState.getBoolean("kasVordunud");
      txt.setText(savedInstanceState.getString("txtView"));
    } else {
      // Probably initialize members with default values for a new instance
    }
  }
Example #8
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gmap);

    Bundle blat = getIntent().getExtras();
    Bundle blng = getIntent().getExtras();

    double lat = blat.getDouble("Plat");
    double lng = blng.getDouble("Plng");

    Log.v(TAG, Double.toString(lat));
    Log.v(TAG, Double.toString(lng));
    // TODO Auto-generated method stub
    init(lat, lng);
    OnKeyListener on_KeyEvent =
        new View.OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            // TODO Auto-generated method stub
            if (event.getAction() == KeyEvent.ACTION_DOWN) {
              if (keyCode == KeyEvent.KEYCODE_BACK) {
                finish();
              }
            }
            return false;
          }
        };
  }
Example #9
0
 @Override
 protected void onActivityResult(int reqCode, int resultCode, Intent data) {
   super.onActivityResult(reqCode, resultCode, data);
   try {
     if (REQ == reqCode) {
       if (resultCode == Activity.RESULT_OK) {
         Bundle returnNumbers1 = data.getExtras();
         int max = returnNumbers1.getInt("max");
         int min = returnNumbers1.getInt("min");
         int sum = returnNumbers1.getInt("sum");
         txtField1.setText("Max:" + max + " Min:" + min + " Sum:" + sum);
       }
     } else if (REQ2 == reqCode) {
       if (resultCode == Activity.RESULT_OK) {
         Bundle returnNumbers2 = data.getExtras();
         double max = returnNumbers2.getDouble("max");
         double min = returnNumbers2.getDouble("min");
         double sum = returnNumbers2.getDouble("sum");
         txtField2.setText("Max:" + max + " Min:" + min + " Sum:" + sum);
       }
     } else if (REQ3 == reqCode) {
       if (resultCode == Activity.RESULT_OK) {
         Bundle returnNumbers2 = data.getExtras();
         int max = returnNumbers2.getInt("max");
         int min = returnNumbers2.getInt("min");
         int sum = returnNumbers2.getInt("sum");
         txtField3.setText("Max:" + max + " Min:" + min + " Sum:" + sum);
       }
     }
   } catch (Exception e) {
     Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_LONG).show();
   }
 }
Example #10
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // make sure the orientation can't be changed once this activity started
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      sectionName = extras.getString(LibraryConstants.PREFS_KEY_FORM_NAME);
      sectionObjectString = extras.getString(LibraryConstants.PREFS_KEY_FORM_JSON);
      latitude = extras.getDouble(LibraryConstants.LATITUDE);
      longitude = extras.getDouble(LibraryConstants.LONGITUDE);
      elevation = extras.getDouble(LibraryConstants.ELEVATION);
    }

    try {
      if (sectionObjectString == null) {
        sectionObject = TagsManager.getInstance(this).getSectionByName(sectionName);
        // copy the section object, which will be kept around along the activity
        sectionObjectString = sectionObject.toString();
      }

      sectionObject = new JSONObject(sectionObjectString);
      formNames4Section = TagsManager.getFormNames4Section(sectionObject);
    } catch (Exception e) {
      e.printStackTrace();
    }
    setContentView(R.layout.form);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!isGooglePlayServicesAvailable()) {
      finish();
    }

    // Create view
    setContentView(R.layout.activity_home_page);

    // Spinner
    spinner = (ProgressBar) findViewById(R.id.progressBar);
    spinner.bringToFront();
    spinner.setVisibility(View.GONE);

    // Add Maps
    mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mapsActivity = new MapsActivity(getBaseContext(), mapFragment, this);

    // Get Autocomplete textview
    autoCompView = (AutoCompleteTextView) findViewById(R.id.destination);
    autoCompView.setAdapter(new GooglePlacesAutocompleteAdapter(this, R.layout.list_item));
    autoCompView.setOnItemClickListener(this);

    // Add background to Done button
    submitUpdate = (Button) findViewById(R.id.submitUpdate);
    submitUpdate.getBackground().setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY);

    // Set Date TimePicker
    setDateTimePicker();
    // Call the method to call the Maps activity
    // Set the drawer
    setupDrawer();
    addDrawerItems();
    // Get hidden Panel
    hiddenPanel = findViewById(R.id.hidden_panel);

    // Call to get API esults
    apiResults = new GetAPIResults(getBaseContext(), mapFragment, this);

    // Check if there is a savedInstance
    if (savedInstanceState != null && savedInstanceState.getString("parking_listings") != null) {
      saved = true;
      JSONArray parking_listings_array = null;

      try {
        latitude = savedInstanceState.getDouble("lat");
        longitude = savedInstanceState.getDouble("lng");
        parking_listings = savedInstanceState.getString("parking_listings");
        parking_listings_array = new JSONArray(parking_listings);
        mapsActivity.addMapsOnMarker(parking_listings_array, latitude, longitude);
      } catch (JSONException e) {
        e.printStackTrace();
      }
    } else {
      mMap = mapFragment.getMap();
      getCurrentLocationOfUser();
    }
  }
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    // The preferences returned if the request code is what we had given
    // earlier in startSubActivity
    switch (requestCode) {
      case REQUEST_CODE_CAMERA:
        setRequestedOrientation(
            ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); // pull it out of landscape mode
        break;

      case REQUEST_CODE_IMAGE:
        if (resultCode != RESULT_OK) {
          return;
        }
        Uri uri = data.getData();
        Bitmap b = null;
        try {
          b = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
        } catch (FileNotFoundException e) {
          break;
        } catch (IOException e) {
          break;
        }
        ByteArrayOutputStream byteArrayos = new ByteArrayOutputStream();
        try {
          b.compress(CompressFormat.JPEG, 75, byteArrayos);
          byteArrayos.flush();
        } catch (OutOfMemoryError e) {
          break;
        } catch (IOException e) {
          break;
        }
        filename = "android_pic_upload" + randomString() + ".jpg";
        ImageManager.writeImage(byteArrayos.toByteArray(), filename);
        UshahidiService.fileName = filename;
        selectedPhoto.setText(UshahidiService.fileName);
        break;

      case VIEW_MAP:
        if (resultCode != RESULT_OK) {
          return;
        }

        bundle = null;
        extras = data.getExtras();
        if (extras != null) bundle = extras.getBundle("locations");

        if (bundle != null && !bundle.isEmpty()) {
          incidentLocation.setText(bundle.getString("location"));

          AddIncident.latitude = bundle.getDouble("latitude");
          AddIncident.longitude = bundle.getDouble("longitude");
        }
        break;
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (DEBUG) {
      Log.d(TAG, "onCreate(" + savedInstanceState + ")");
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mCelsius = (EditNumber) findViewById(R.id.celsius);
    mFahrenheit = (EditNumber) findViewById(R.id.fahrenheit);

    mCelsius.addTextChangedListener(
        new TemperatureChangeWatcher(mCelsius, mFahrenheit) {

          @Override
          protected double convert(double temp) {
            return TemperatureConverter.celsiusToFahrenheit(temp);
          }
        });

    mFahrenheit.addTextChangedListener(
        new TemperatureChangeWatcher(mFahrenheit, mCelsius) {

          @Override
          protected double convert(double temp) {
            return TemperatureConverter.fahrenheitToCelsius(temp);
          }
        });

    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(CELSIUS_KEY)) {
        final double c = savedInstanceState.getDouble(CELSIUS_KEY);
        final double f = TemperatureConverter.celsiusToFahrenheit(c);
        if (DEBUG) {
          Log.d(TAG, "onCreate: restoring celsius: " + c);
        }
        mCelsius.setNumber(c);
        mFahrenheit.setNumber(f);
      } else if (savedInstanceState.containsKey(FAHRENHEIT_KEY)) {
        final double f = savedInstanceState.getDouble(FAHRENHEIT_KEY);
        final double c = TemperatureConverter.fahrenheitToCelsius(f);
        if (DEBUG) {
          Log.d(TAG, "onCreate: restoring fahrenheit: " + f);
        }
        mFahrenheit.setNumber(f);
        mCelsius.setNumber(c);
      }
    }

    mCelsius.setOnFocusChangeListener(mTemperatureEntryFocusChangeListener);
    mFahrenheit.setOnFocusChangeListener(mTemperatureEntryFocusChangeListener);
  }
  private void initBaiduMap() {
    mapView = (MapView) findViewById(R.id.bmapView);
    baiduMap = mapView.getMap();
    baiduMap.setMaxAndMinZoomLevel(18, 13);
    IntentFilter iFilter = new IntentFilter();
    iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
    iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
    receiver = new BaiduReceiver();
    registerReceiver(receiver, iFilter);

    geoCoder = GeoCoder.newInstance();
    geoCoder.setOnGetGeoCodeResultListener(this);

    Intent intent = getIntent();
    intentType = intent.getStringExtra(TYPE);
    initActionBar(R.string.chat_position);
    if (intentType.equals(TYPE_SELECT)) {
      // 选择发送位置
      // 开启定位图层
      baiduMap.setMyLocationEnabled(true);
      baiduMap.setMyLocationConfigeration(
          new MyLocationConfigeration(MyLocationConfigeration.LocationMode.NORMAL, true, null));
      // 定位初始化
      locClient = new LocationClient(this);
      locClient.registerLocationListener(myListener);
      LocationClientOption option = new LocationClientOption();
      option.setProdName("avosim");
      option.setOpenGps(true);
      option.setCoorType("bd09ll");
      option.setScanSpan(1000);
      option.setOpenGps(true);
      option.setIsNeedAddress(true);
      option.setIgnoreKillProcess(true);
      locClient.setLocOption(option);
      locClient.start();
      if (locClient != null && locClient.isStarted()) {
        locClient.requestLocation();
      }
      if (lastLocation != null) {
        // 显示在地图上
        LatLng ll = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        baiduMap.animateMapStatus(u);
      }
    } else {
      Bundle b = intent.getExtras();
      LatLng latlng = new LatLng(b.getDouble(LATITUDE), b.getDouble(LONGITUDE)); // 维度在前,经度在后
      baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
      OverlayOptions ooA = new MarkerOptions().position(latlng).icon(descriptor).zIndex(9);
      baiduMap.addOverlay(ooA);
    }
  }
 private void parseInput() {
   // parse input
   Intent inputIntent = getIntent();
   if (inputIntent != null) {
     mEditMode = inputIntent.getBooleanExtra("edit-mode", false);
     if (mEditMode) mLocationAlert = inputIntent.getParcelableExtra("data");
     else {
       Bundle extras = inputIntent.getExtras();
       circleRadius = extras.getFloat("Radius");
       circleLatitude = extras.getDouble("Latitude");
       circleLongitude = extras.getDouble("Longitude");
     }
   }
 }
  /**
   * This function is called when a new activty of this class is created.
   *
   * @param savedInstanceState Bundle containing data from a previous instance of an activity
   */
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.seller_change_attributes);

    db = new MyDBHandler(this, null, null, 4);

    nameET = (EditText) findViewById(R.id.changeProductName);
    descriptionET = (EditText) findViewById(R.id.changeDescription);
    quantityET = (EditText) findViewById(R.id.changeQuantity);
    invoicePriceET = (EditText) findViewById(R.id.changeInvoicePrice);
    sellPriceET = (EditText) findViewById(R.id.changeSellPrice);
    submit = (Button) findViewById(R.id.submit);
    goBack = (Button) findViewById(R.id.changeGoBack);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
      id = extras.getInt("id");
      name = extras.getString("name");
      description = extras.getString("description");
      sellPrice = extras.getDouble("sellPrice");
      seller = extras.getString("seller");
      quantity = extras.getInt("quantity");
      invoicePrice = extras.getDouble("invoicePrice");
    }

    nameET.setText(name);
    descriptionET.setText(description);
    sellPriceET.setText(Double.toString(sellPrice));
    invoicePriceET.setText(Double.toString(invoicePrice));
    quantityET.setText(Integer.toString(quantity));

    submit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            updateInventory();
          }
        });

    goBack.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent k = new Intent(SellerChangeAttributes.this, SellerMainPage.class);
            startActivity(k);
          }
        });
  }
Example #17
0
  @Override
  public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mLayersSettings = getArguments().getParcelable(ARG_LAYERS_SETTINGS);

    if (savedInstanceState == null) {
      // FIXME: hardcoded default map position
      mMapCenter =
          mLayersSettings == null
              ? new GeoPoint(48.853307d, 2.348864d)
              : mLayersSettings.boundingBoxE6.getCenter();
      // FIXME: default hardcoded zoom level
      mZoomLevel = 17;
      // as default indoor level
      mIndoorLevel = 0d;

      if (BuildConfig.DEBUG) {
        Log.d(TAG, "default tile size: " + getTileSize());
      }
    } else {
      mMapCenter = savedInstanceState.getParcelable(STATE_MAP_POSITION);
      mZoomLevel = savedInstanceState.getInt(STATE_MAP_ZOOM_LEVEL);
      mIndoorLevel = savedInstanceState.getDouble(STATE_INDOOR_LEVEL);
    }
  }
 /**
  * Overridden to restore instance state when device orientation changes. This method is called
  * automatically if you assign an id to the RangeSeekBar widget using the {@link #setId(int)}
  * method.
  */
 @Override
 protected void onRestoreInstanceState(Parcelable parcel) {
   final Bundle bundle = (Bundle) parcel;
   super.onRestoreInstanceState(bundle.getParcelable("SUPER"));
   normalizedMinValue = bundle.getDouble("MIN");
   normalizedMaxValue = bundle.getDouble("MAX");
 }
Example #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_map);
    /* ActionBar items */
    try {
      getActionBar().setHomeButtonEnabled(true);
      getActionBar().setDisplayHomeAsUpEnabled(true);
    } catch (NullPointerException e) {
      Toast.makeText(this, "Something went wrong. Try again.", Toast.LENGTH_SHORT).show();
    }
    ICON_HEIGHT = getResources().getDimensionPixelSize(R.dimen.mapIconHeight);

    // Toast.makeText(this, "onCreate", Toast.LENGTH_SHORT).show();
    FragmentManager fm = getFragmentManager();
    /* Obtain a reference to the UI element */
    MapFragment frag = (MapFragment) fm.findFragmentById(R.id.overworld);

    /* Obtain a reference to GoogleMap object associated with the fragment */
    worldMap = frag.getMap();
    mapClient = new LocationClient(this, this, this);
    mapClient = new LocationClient(this, this, this);
    ePrefs = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean infoShown = ePrefs.getBoolean(infoDialoguePref, false);

    if (!infoShown) {
      String title = "Map Gallery";
      String text = getResources().getString(R.string.mapInfo);
      new AlertDialog.Builder(this)
          .setTitle(title)
          .setMessage(text)
          .setPositiveButton(
              android.R.string.ok,
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              })
          .show();
      SharedPreferences.Editor editor = ePrefs.edit();
      editor.putBoolean(infoDialoguePref, true);
      editor.commit();
    }

    if (savedInstanceState != null) {
      zoomlevel = savedInstanceState.getFloat("zoom");
      loaded = savedInstanceState.getBoolean("loaded");
      currentLat = savedInstanceState.getDouble("lat");
      currentLng = savedInstanceState.getDouble("lng");
      fileToReload = savedInstanceState.getString("redo");

      dataRestorer =
          new DataRestorer(
              savedInstanceState.getStringArrayList("allFiles"),
              savedInstanceState.getParcelableArrayList("allBitmaps"),
              savedInstanceState.getFloatArray("allLat"),
              savedInstanceState.getFloatArray("allLng"));
    }
  }
Example #20
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.findlocation);
    Log.i(TAG, "After View");
    btnSearch = (Button) findViewById(R.id.btnSearch);
    userText = (EditText) findViewById(R.id.edtxtLocation);
    Log.i(TAG, "After Fields");
    // showing the map
    mapv = (MapView) findViewById(R.id.mapvew);
    // getting values from bundle instance
    Bundle b = getIntent().getExtras();
    // double lat = Double.parseDouble("31.5497222");
    // double lng = Double.parseDouble("74.3436111");
    double lat = b.getDouble("lat");
    double lng = b.getDouble("lng");

    gp = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));

    mapv.getController().setCenter(gp);
    // mapv.getController().setZoom(13);
    mapv.getController().animateTo(gp);

    gc = new Geocoder(this);
    Log.i(TAG, "B4 Listener");
    btnSearch.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (userText.length() == 0) {
              // Toast.makeText(getBaseContext(), "Enter Location !", Toast.LENGTH_LONG).show();
              AlertMessage2Show("Enter Location Name To Search");
            } else {
              String locn = userText.getText().toString();
              try {
                List<Address> addressList = gc.getFromLocationName(locn, 5);
                if (addressList != null && addressList.size() > 0) {

                  double lat = addressList.get(0).getLatitude();
                  double lng = addressList.get(0).getLongitude();
                  Toast.makeText(
                          getBaseContext(),
                          "New Latitude : " + lat + " && Longitude : " + lng,
                          Toast.LENGTH_LONG)
                      .show();
                  gp = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
                  mapv.getController().animateTo(gp);
                } else {

                  AlertMessage2Show("No Location Found !");
                }
              } catch (IOException e) {
                e.printStackTrace();
              }
            }
          }
        });
  }
 /** Gets the longitude of the address. */
 public Double getLongitude() {
   if (data.containsKey(KEY_LONGITUDE)) {
     return data.getDouble(KEY_LONGITUDE);
   } else {
     return null;
   }
 }
  public QueryStore(Bundle bundle) {
    name = bundle.getString("QueryStore_name");
    // radius = bundle.getInt("QueryStore_radius");
    lat = bundle.getDouble("QueryStore_lat");
    lon = bundle.getDouble("QueryStore_lon");

    debug = bundle.getBoolean("QueryStore_debug");

    // Restore cookie list from 2 arrays

    // viewStateMap = new HashMap<String,String>();

    // ArrayList<String> names = bundle.getStringArrayList("QueryStore_viewStateMap_names");
    // ArrayList<String> values = bundle.getStringArrayList("QueryStore_viewStateMap_values");

    // for (int i=0; i<names.size(); i++) {
    //    viewStateMap.put(names.get(i), values.get(i));
    // }

    //        // Retrieve cache type filter
    //
    //        cacheTypeList = new CacheTypeList(bundle.getString("QueryStore_cacheType"));
    //
    //        // Retrieve container type filter
    //
    //        containerTypeList = new
    // ContainerTypeList(bundle.getString("QueryStore_containerType"));
    //
    //        difficultyFilter = new OneToFiveFilter(bundle.getString("QueryStore_difficulty"));
    //        terrainFilter = new OneToFiveFilter(bundle.getString("QueryStore_terrain"));
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
    Bundle data = intent.getExtras();

    numPDUsReceived++;

    if (numPDUsReceived == 1) {
      // Add packet type + time stamp
      buffer.put((byte) 0x03); // Type
      buffer.put((byte) data.getInt("usli.smd.payload.hour")); // Hour
      buffer.put((byte) data.getInt("usli.smd.payload.minute")); // Minute
      buffer.put((byte) data.getInt("usli.smd.payload.second")); // Second
    }

    // Add data
    buffer.putDouble(data.getDouble("usli.smd.payload.latitude")); // Latitude
    buffer.putDouble(data.getDouble("usli.smd.payload.longitude")); // Longitude
    buffer.putShort(data.getShort("usli.smd.payload.pressure1")); // Pressure
    buffer.putShort(data.getShort("usli.smd.payload.temperature1")); // Temperature
    buffer.putShort(data.getShort("usli.smd.payload.humidity1")); // Humidity
    buffer.putShort(data.getShort("usli.smd.payload.solarIrradiance1")); // Solar Irradiance
    buffer.putShort(data.getShort("usli.smd.payload.uvRadiation1")); // UV Radiation

    if (numPDUsReceived == numPDUs) {
      String message = "";
      message += data.getInt("usli.smd.payload.hour");
      message += ":" + data.getInt("usli.smd.payload.minute");
      message += ":" + data.getInt("usli.smd.payload.second");
      message += ";" + data.getDouble("usli.smd.payload.latitude");
      message += "," + data.getDouble("usli.smd.payload.longitude");
      message += "," + data.getFloat("usli.smd.payload.bearing");
      message += "," + data.getInt("usli.smd.payload.signal");
      // message += "," + data.getFloat("usli.smd.payload.accelX");
      // message += "," + data.getFloat("usli.smd.payload.accelY");
      // message += "," + data.getFloat("usli.smd.payload.accelZ");
      // Send byte[] to SMSSender
      SMSDataPacket.putExtra("destination", 0);
      SMSDataPacket.putExtra("message", message);
      startService(SMSDataPacket);

      // Reset service
      numPDUsReceived = 0;
      buffer.clear();
    }

    return START_STICKY;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    setUpMapIfNeeded();

    Bundle extras = getIntent().getExtras();
    double latitude = extras.getDouble("latitude");
    double longitude = extras.getDouble("longitude");

    LatLng latLng = new LatLng(latitude, longitude);

    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17));

    MarkerOptions mOpt = new MarkerOptions().title("Você está aqui").position(latLng);
    mMap.addMarker(mOpt);
  }
 /**
  * Overridden to restore instance state when device orientation changes. This method is called
  * automatically if you assign an id to the RangeSeekBar widget using the {@link #setId(int)}
  * method.
  */
 @Override
 protected void onRestoreInstanceState(Parcelable parcel) {
   final Bundle bundle = (Bundle) parcel;
   super.onRestoreInstanceState(bundle.getParcelable("SUPER"));
   normalizedMinValue = bundle.getDouble("MIN");
   normalizedMaxValue = bundle.getDouble("MAX");
   mValueProcessor = (RangeSeekBarValueProcessor) bundle.getSerializable("VALUE_PROCESSOR");
 }
  public String summarizeValue(Context context, Bundle bundle) {
    double powerX = bundle.getDouble("POWER_X");
    double powerY = bundle.getDouble("POWER_Y");
    double powerZ = bundle.getDouble("POWER_Z");

    double freqX = bundle.getDouble("FREQ_X");
    double freqY = bundle.getDouble("FREQ_Y");
    double freqZ = bundle.getDouble("FREQ_Z");

    return String.format(
        context.getResources().getString(R.string.summary_frequency_statistics_feature),
        freqX,
        freqY,
        freqZ,
        powerX,
        powerY,
        powerZ);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_final_exam_prep);

    if (savedInstanceState == null) {
      inchStoredValue = 0.0;
      cmStoredValue = 0.0;
    } else {
      inchStoredValue = savedInstanceState.getDouble(inchesS);
      cmStoredValue = savedInstanceState.getDouble(cmsS);
    }

    inchesValue = (EditText) findViewById(R.id.inchesEditText);
    inchesValue.addTextChangedListener(inchesValueTextWatcher);

    cmsValue = (EditText) findViewById(R.id.cmEditText);
  }
  @Override
  public void onViewStateRestored(Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);

    if (savedInstanceState != null) {
      if (savedInstanceState.containsKey(KEY_SAVED_LOCATION_LAT)
          && savedInstanceState.containsKey(KEY_SAVED_LOCATION_LNG)) {
        savedLocation =
            new LatLng(
                savedInstanceState.getDouble(KEY_SAVED_LOCATION_LAT),
                savedInstanceState.getDouble(KEY_SAVED_LOCATION_LNG));
      }

      if (savedInstanceState.containsKey(KEY_SAVED_LOCATION_ZOOM)) {
        savedZoon = savedInstanceState.getDouble(KEY_SAVED_LOCATION_ZOOM);
      }
    }
  }
Example #29
0
 @Override
 protected void onRestoreInstanceState(Parcelable state) {
   Bundle bundle = (Bundle) state;
   super.onRestoreInstanceState(bundle.getParcelable("parcelable"));
   tpSlPrice = bundle.getInt("tpSlPrice");
   minPriceUnit = bundle.getDouble("minPriceUnit");
   priceView.setText(bundle.getString("price"));
   toggleButton.setToggle(bundle.getBoolean("isSwitchOn"));
   setViewEnabled(toggleButton.isToggleOn());
 }
Example #30
0
  public static Album unBundleAlbum(Bundle albumBundle) {
    Album album = new Album();
    album.setId(albumBundle.getInt(ALBUM_ID));
    album.setGenre(albumBundle.getString(ALBUM_GENRE));
    album.setArtist(albumBundle.getString(ALBUM_ARTIST));
    album.setTitle(albumBundle.getString(ALBUM_TITLE));
    album.setPrice(albumBundle.getDouble(ALBUM_PRICE));

    return album;
  }