Esempio n. 1
0
  private void startUpload(int index) {
    if (NavigineApp.Navigation == null) return;

    String userHash = NavigineApp.Settings.getString("user_hash", "");
    if (userHash.length() == 0) return;

    LocationInfo info = mInfoList.get(index);
    String location = new String(info.title);
    Log.d(TAG, String.format(Locale.ENGLISH, "Start upload: %s", location));

    synchronized (mLoaderMap) {
      if (!mLoaderMap.containsKey(location)) {
        LoaderState loader = new LoaderState();
        loader.location = location;
        loader.type = UPLOAD;
        loader.id = LocationLoader.startLocationUploader(location, info.archiveFile, true);
        mLoaderMap.put(location, loader);
      }
    }
    mAdapter.updateList();
  }
Esempio n. 2
0
  private void updateLocationLoaders() {
    if (NavigineApp.Navigation == null) return;

    long timeNow = DateTimeUtils.currentTimeMillis();
    mUpdateLocationLoadersTime = timeNow;

    synchronized (mLoaderMap) {
      Iterator<Map.Entry<String, LoaderState>> iter = mLoaderMap.entrySet().iterator();
      while (iter.hasNext()) {
        Map.Entry<String, LoaderState> entry = iter.next();

        LoaderState loader = entry.getValue();
        if (loader.state < 100) {
          loader.timeLabel = timeNow;
          if (loader.type == DOWNLOAD) loader.state = LocationLoader.checkLocationLoader(loader.id);
          if (loader.type == UPLOAD) loader.state = LocationLoader.checkLocationUploader(loader.id);
        } else if (loader.state == 100) {
          String archivePath = NavigineApp.Navigation.getArchivePath();
          String locationFile =
              LocationLoader.getLocationFile(NavigineApp.AppContext, loader.location);
          if (archivePath != null && archivePath.equals(locationFile)) {
            Log.d(TAG, "Reloading archive " + archivePath);
            if (NavigineApp.Navigation.loadArchive(archivePath)) {
              SharedPreferences.Editor editor = NavigineApp.Settings.edit();
              editor.putString("map_file", archivePath);
              editor.commit();
            }
          }
          if (loader.type == DOWNLOAD) LocationLoader.stopLocationLoader(loader.id);
          if (loader.type == UPLOAD) LocationLoader.stopLocationUploader(loader.id);
          iter.remove();
        } else {
          // Load failed
          if (Math.abs(timeNow - loader.timeLabel) > 5000) {
            if (loader.type == DOWNLOAD) LocationLoader.stopLocationLoader(loader.id);
            if (loader.type == UPLOAD) LocationLoader.stopLocationUploader(loader.id);
            iter.remove();
          }
        }
      }
    }
    updateLocalVersions();
    mAdapter.updateList();
  }
Esempio n. 3
0
  public void ClickEven(View v) {
    Log.d(
        "getUserPasslocalstorage",
        sharedPref.getString("User", "") + ".." + sharedPref.getString("Pass", ""));
    if (StatusSwithc) {
      if (map.car_ID.getText().toString().equals("")
          || map.Drivername.getText().toString().equals("")
          || map.Ordername.getText().toString().equals("")
          || map.Password.getText().toString().equals("")) {
        if (map.car_ID.getText().toString().equals("")) {
          map.car_ID.setError("set plate NO");
        } else {
          map.car_ID.setError(null);
        }
        if (map.Drivername.getText().toString().equals("")) {
          map.Drivername.setError("set drivername");
        } else {
          map.Drivername.setError(null);
        }
        if (map.Ordername.getText().toString().equals("")) {
          map.Ordername.setError("set ordername");
        } else {
          map.Ordername.setError(null);
        }
        if (map.Password.getText().toString().equals("")) {
          map.Password.setError("set password");
        } else {
          map.Password.setError(null);
        }
      } else {
        if (map.Ordername.getText().toString().equals(ordername)
            && map.Password.getText().toString().equals(password)) {
          StatusSwithc = false;
          map.stopLocation();
          map.setvisible();
          map.textMsg.setText("Sleepmode");
          map.login.setText("Login");
          callSyncGet(map.Location_onResume, drivername, ordername, password, Statuspage);
          Statuspage = "1";
          Log.d("Statuspage", Statuspage);
          myMap.clear();

          map.car_ID.setError(null);
          map.Drivername.setError(null);
          map.Ordername.setError(null);
          map.Password.setError(null);
          finish();
        } else {
          if (!map.Password.getText().toString().equals(password)) {
            map.Password.setError("confirm password fail");
            //                    Toast.makeText(MainActivity.this, "password value fail",
            // Toast.LENGTH_SHORT).show();
          } else {
            map.Password.setError(null);
          }
          if (!map.Ordername.getText().toString().equals(ordername)) {
            map.Ordername.setError("confirm ordername fail");
            //                    Toast.makeText(MainActivity.this, "ordername value fail",
            // Toast.LENGTH_SHORT).show();
          } else {
            map.Ordername.setError(null);
          }
        }
      }

    } else {
      plate_no = map.car_ID.getText().toString();
      drivername = map.Drivername.getText().toString();
      ordername = map.Ordername.getText().toString();
      password = map.Password.getText().toString();
      if (plate_no.equals("")
          || !drivername.equals(sharedPref.getString("User", ""))
          || ordername.equals("")
          || !password.equals(sharedPref.getString("Pass", ""))) {
        if (plate_no.equals("")) {
          //                myswitch.setChecked(StatusSwithc);
          map.car_ID.setError("set plate NO.");
        }
        if (!drivername.equals(sharedPref.getString("User", ""))) {
          map.Drivername.setError("set Driver Name.");
        }
        if (ordername.equals("")) {
          map.Ordername.setError("set Order No.");
        }
        if (!password.equals(sharedPref.getString("Pass", ""))) {
          map.Password.setError("password incorrect.");
        }
      } else {
        if (plate_no.length() < 2) {
          map.car_ID.setError("set plate NO > 2 character");
          //                    myswitch.setChecked(StatusSwithc);
        } else if (plate_no.length() > 20) {
          map.car_ID.setError("set plate NO < 20 character");
          //                    myswitch.setChecked(StatusSwithc);
        } else {
          map.hideSoftKeyboard(this);
          StatusSwithc = true;
          map.startLocation();
          map.Enable();
          map.car_ID.setError(null);
          map.Drivername.setError(null);
          map.Ordername.setError(null);
          map.Password.setError(null);
          //                    if(v.getId() == R.id.imageButton){
          //                        myswitch.setChecked(true);
          //                    }
        }
      }
    }
    Log.d("Evenclick", String.valueOf(StatusSwithc));
  }