Search in sources :

Example 1 with BaseAsyncTask

use of cz.destil.glasquare.util.BaseAsyncTask in project glasquare by davidvavra.

the class CheckInActivity method checkIn.

private void checkIn() {
    final String venueId = getIntent().getStringExtra(EXTRA_VENUE_ID);
    final Location location = LocationUtils.getLastLocation();
    final String ll = LocationUtils.getLatLon(location);
    int accuracy = (int) location.getAccuracy();
    int altitude = (int) location.getAltitude();
    showProgress(R.string.checking_in);
    showCheckInInfo();
    String broadcast = getBroadcast();
    Api.get().create(CheckIns.class).add(venueId, ll, mShout, broadcast, accuracy, altitude, new Callback<CheckIns.CheckInResponse>() {

        @Override
        public void success(final CheckIns.CheckInResponse checkInResponse, Response response) {
            mCheckInResponse = checkInResponse;
            if (mAddingPhoto) {
                ImageUtils.processPictureWhenReady(CheckInActivity.this, mPhoto, new ImageUtils.OnPictureReadyListener() {

                    @Override
                    public void onPictureReady() {
                        new BaseAsyncTask() {

                            @Override
                            public void inBackground() {
                                ImageUtils.resize(mPhoto);
                            }

                            @Override
                            public void postExecute() {
                                addPhoto();
                            }
                        }.start();
                    }
                });
            } else {
                showCheckInComplete();
            }
        }

        @Override
        public void failure(RetrofitError retrofitError) {
            if (!Auth.handle(CheckInActivity.this, retrofitError)) {
                showError(R.string.error_please_try_again);
            }
        }
    });
}
Also used : Response(retrofit.client.Response) CheckIns(cz.destil.glasquare.api.CheckIns) BaseAsyncTask(cz.destil.glasquare.util.BaseAsyncTask) Location(android.location.Location) RetrofitError(retrofit.RetrofitError)

Example 2 with BaseAsyncTask

use of cz.destil.glasquare.util.BaseAsyncTask in project glasquare by davidvavra.

the class BaseProgressActivity method showGracePeriod.

protected void showGracePeriod(int resourceId, final GracePeriodListener listener) {
    gracePeriodResourceId = resourceId;
    gracePeriodListener = listener;
    vProgressText.setText(resourceId);
    vProgressBar.startProgress(GRACE_PERIOD_DURATION * 1000);
    vProgressBar.setVisibility(View.VISIBLE);
    vProgressText.setVisibility(View.VISIBLE);
    vGracePeriodText.setVisibility(View.VISIBLE);
    mGraceGone = false;
    mMenuItemSelected = false;
    acquireWakeLock();
    graceTask = new BaseAsyncTask() {

        @Override
        public void inBackground() {
            try {
                Thread.sleep(GRACE_PERIOD_DURATION * 1000);
            } catch (InterruptedException e) {
            // ignore
            }
        }

        @Override
        public void postExecute() {
            vGracePeriodText.setVisibility(View.GONE);
            releaseWakeLock();
            mGraceGone = true;
            listener.onGracePeriodCompleted();
        }
    };
    graceTask.start();
}
Also used : BaseAsyncTask(cz.destil.glasquare.util.BaseAsyncTask)

Aggregations

BaseAsyncTask (cz.destil.glasquare.util.BaseAsyncTask)2 Location (android.location.Location)1 CheckIns (cz.destil.glasquare.api.CheckIns)1 RetrofitError (retrofit.RetrofitError)1 Response (retrofit.client.Response)1