예제 #1
0
 private void deleteFetchedCheckin() {
   fetchedAdapter = new ListFetchedCheckinAdapter(this);
   pendingAdapter = new ListPendingCheckinAdapter(this);
   final List<ListCheckinModel> items = fetchedAdapter.fetchedCheckins();
   for (ListCheckinModel checkin : items) {
     new ListCheckinModel().deleteAllFetchedCheckin(checkin.getCheckinId());
   }
   ImageManager.deleteImages(this);
 }
예제 #2
0
  private boolean uploadPendingCheckin() {
    fetchedAdapter = new ListFetchedCheckinAdapter(this);
    pendingAdapter = new ListPendingCheckinAdapter(this);

    List<ListCheckinModel> items = pendingAdapter.pendingCheckin();
    StringBuilder urlBuilder = new StringBuilder(Preferences.domain);
    urlBuilder.append("/api");
    if (items != null) {
      for (ListCheckinModel checkin : items) {
        final HashMap<String, String> mParams = new HashMap<String, String>();
        mParams.put("task", "checkin");
        mParams.put("action", "ci");
        mParams.put("mobileid", Util.IMEI(this));
        mParams.put("lat", checkin.getLocationLatitude());
        mParams.put("lon", checkin.getLocationLongitude());
        mParams.put("message", checkin.getMessage());
        mParams.put("firstname", Preferences.firstname);
        mParams.put("lastname", Preferences.lastname);
        mParams.put("email", Preferences.email);
        final String photo =
            new UploadPhotoAdapter(this).pendingPhotos((int) checkin.getCheckinId());

        // load filenames
        if (!TextUtils.isEmpty(photo)) {
          mParams.put("filename", photo);
        }
        // upload
        try {
          if (new CheckinHttpClient(this).PostFileUpload(urlBuilder.toString(), mParams)) {
            deletePendingCheckin((int) checkin.getDbId());
            return true;
          }
          return false;
        } catch (IOException e) {
          return false;
        }
      }
    }
    return false;
  }