Search in sources :

Example 16 with ResultReceiver

use of android.os.ResultReceiver in project easy by MehdiBenmesa.

the class RendezVousService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        switch(intent.getAction()) {
            case GET_RENDEZVOUS_TEACHER:
                final ResultReceiver receiverTeacher = intent.getParcelableExtra(DATA_RECEIVER);
                final String rdvState = intent.getParcelableExtra("rdvState");
                final Bundle bundleTeacher = new Bundle();
                receiverTeacher.send(STATUS_RUNNING, Bundle.EMPTY);
                try {
                    getRendezVousByTeacher(rdvState, new IRendezVous() {

                        @Override
                        public void onDataRecieved(JSONArray object) {
                            bundleTeacher.putString("action", GET_RENDEZVOUS_TEACHER);
                            bundleTeacher.putSerializable("result", object.toString());
                            receiverTeacher.send(STATUS_FINISHED, bundleTeacher);
                        }
                    });
                } catch (Exception e) {
                    /* Sending error message back to activity */
                    bundleTeacher.putString(Intent.EXTRA_TEXT, e.toString());
                    receiverTeacher.send(STATUS_ERROR, bundleTeacher);
                }
                break;
            case GET_RENDEZVOUS_STUDENT:
                final ResultReceiver receiverStudent = intent.getParcelableExtra(DATA_RECEIVER);
                final String rdv = intent.getParcelableExtra("rdvState");
                final Bundle bundleStudent = new Bundle();
                receiverStudent.send(STATUS_RUNNING, Bundle.EMPTY);
                try {
                    getRendeVousByStudent(rdv, new IRendezVous() {

                        @Override
                        public void onDataRecieved(JSONArray object) {
                            bundleStudent.putString("action", GET_RENDEZVOUS_STUDENT);
                            bundleStudent.putSerializable("result", object.toString());
                            receiverStudent.send(STATUS_FINISHED, bundleStudent);
                        }
                    });
                } catch (Exception e) {
                    /* Sending error message back to activity */
                    bundleStudent.putString(Intent.EXTRA_TEXT, e.toString());
                    receiverStudent.send(STATUS_ERROR, bundleStudent);
                }
                break;
            case GET_RENDEZVOUS_MANAGER:
                final ResultReceiver receiverTeachers = intent.getParcelableExtra(DATA_RECEIVER);
                final Bundle bundleTeachers = new Bundle();
                receiverTeachers.send(STATUS_RUNNING, Bundle.EMPTY);
                try {
                    getRendezvousByManager(new IRendezVous() {

                        @Override
                        public void onDataRecieved(JSONArray object) {
                            bundleTeachers.putString("action", GET_RENDEZVOUS_MANAGER);
                            bundleTeachers.putSerializable("result", object.toString());
                            receiverTeachers.send(STATUS_FINISHED, bundleTeachers);
                        }
                    });
                } catch (Exception e) {
                    /* Sending error message back to activity */
                    bundleTeachers.putString(Intent.EXTRA_TEXT, e.toString());
                    receiverTeachers.send(STATUS_ERROR, bundleTeachers);
                }
                break;
        }
        this.stopSelf();
    }
}
Also used : Bundle(android.os.Bundle) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) ResultReceiver(android.os.ResultReceiver)

Example 17 with ResultReceiver

use of android.os.ResultReceiver in project easy by MehdiBenmesa.

the class GroupService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    if (intent != null) {
        switch(intent.getAction()) {
            case GET_GROUP_MODULE_TEACHER:
                String moduleId = intent.getStringExtra("moduleId");
                final ResultReceiver receiverTeacher = intent.getParcelableExtra(DATA_RECEIVER);
                final Bundle bundleTeacher = new Bundle();
                receiverTeacher.send(STATUS_RUNNING, Bundle.EMPTY);
                try {
                    getGroupsByModuleByTeacher(new IGroupe() {

                        @Override
                        public void onDataRecieved(JSONArray object) {
                            bundleTeacher.putString("action", GET_GROUP_MODULE_TEACHER);
                            bundleTeacher.putSerializable("result", object.toString());
                            receiverTeacher.send(STATUS_FINISHED, bundleTeacher);
                        }
                    }, moduleId);
                } catch (Exception e) {
                    /* Sending error message back to activity */
                    bundleTeacher.putString(Intent.EXTRA_TEXT, e.toString());
                    receiverTeacher.send(STATUS_ERROR, bundleTeacher);
                }
                break;
        }
        this.stopSelf();
    }
}
Also used : Bundle(android.os.Bundle) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) IOException(java.io.IOException) ResultReceiver(android.os.ResultReceiver)

Example 18 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by ResurrectionRemix.

the class Tethering method runUiTetherProvisioningAndEnable.

private void runUiTetherProvisioningAndEnable(int type, ResultReceiver receiver) {
    ResultReceiver proxyReceiver = getProxyReceiver(type, receiver);
    sendUiTetherProvisionIntent(type, proxyReceiver);
}
Also used : ResultReceiver(android.os.ResultReceiver)

Example 19 with ResultReceiver

use of android.os.ResultReceiver in project android_frameworks_base by ResurrectionRemix.

the class ActivityTransitionState method enterReady.

public void enterReady(Activity activity) {
    if (mEnterActivityOptions == null || mIsEnterTriggered) {
        return;
    }
    mIsEnterTriggered = true;
    mHasExited = false;
    ArrayList<String> sharedElementNames = mEnterActivityOptions.getSharedElementNames();
    ResultReceiver resultReceiver = mEnterActivityOptions.getResultReceiver();
    if (mEnterActivityOptions.isReturning()) {
        restoreExitedViews();
        activity.getWindow().getDecorView().setVisibility(View.VISIBLE);
    }
    mEnterTransitionCoordinator = new EnterTransitionCoordinator(activity, resultReceiver, sharedElementNames, mEnterActivityOptions.isReturning(), mEnterActivityOptions.isCrossTask());
    if (mEnterActivityOptions.isCrossTask()) {
        mExitingFrom = new ArrayList<>(mEnterActivityOptions.getSharedElementNames());
        mExitingTo = new ArrayList<>(mEnterActivityOptions.getSharedElementNames());
    }
    if (!mIsEnterPostponed) {
        startEnter();
    }
}
Also used : ResultReceiver(android.os.ResultReceiver)

Example 20 with ResultReceiver

use of android.os.ResultReceiver in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TetherService method onStartCommand.

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent.hasExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE)) {
        int type = intent.getIntExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE, ConnectivityManager.TETHERING_INVALID);
        ResultReceiver callback = intent.getParcelableExtra(ConnectivityManager.EXTRA_PROVISION_CALLBACK);
        if (callback != null) {
            List<ResultReceiver> callbacksForType = mPendingCallbacks.get(type);
            if (callbacksForType != null) {
                callbacksForType.add(callback);
            } else {
                // Invalid tether type. Just ignore this request and report failure.
                callback.send(ConnectivityManager.TETHER_ERROR_UNKNOWN_IFACE, null);
                stopSelf();
                return START_NOT_STICKY;
            }
        }
        if (!mCurrentTethers.contains(type)) {
            if (DEBUG)
                Log.d(TAG, "Adding tether " + type);
            mCurrentTethers.add(type);
        }
    }
    if (intent.hasExtra(ConnectivityManager.EXTRA_REM_TETHER_TYPE)) {
        if (!mInProvisionCheck) {
            int type = intent.getIntExtra(ConnectivityManager.EXTRA_REM_TETHER_TYPE, ConnectivityManager.TETHERING_INVALID);
            int index = mCurrentTethers.indexOf(type);
            if (DEBUG)
                Log.d(TAG, "Removing tether " + type + ", index " + index);
            if (index >= 0) {
                removeTypeAtIndex(index);
            }
            cancelAlarmIfNecessary();
        } else {
            if (DEBUG)
                Log.d(TAG, "Don't cancel alarm during provisioning");
        }
    }
    // type.
    if (intent.getBooleanExtra(ConnectivityManager.EXTRA_SET_ALARM, false) && mCurrentTethers.size() == 1) {
        scheduleAlarm();
    }
    if (intent.getBooleanExtra(ConnectivityManager.EXTRA_RUN_PROVISION, false)) {
        startProvisioning(mCurrentTypeIndex);
    } else if (!mInProvisionCheck) {
        // If we aren't running any provisioning, no reason to stay alive.
        if (DEBUG)
            Log.d(TAG, "Stopping self.  startid: " + startId);
        stopSelf();
        return START_NOT_STICKY;
    }
    // the check.
    return START_REDELIVER_INTENT;
}
Also used : ResultReceiver(android.os.ResultReceiver)

Aggregations

ResultReceiver (android.os.ResultReceiver)70 Bundle (android.os.Bundle)38 RemoteException (android.os.RemoteException)11 Handler (android.os.Handler)9 HandlerThread (android.os.HandlerThread)6 OnSharedElementsReadyListener (android.app.SharedElementCallback.OnSharedElementsReadyListener)5 Intent (android.content.Intent)5 Parcel (android.os.Parcel)5 Parcelable (android.os.Parcelable)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 JSONArray (org.json.JSONArray)5 JSONException (org.json.JSONException)5 ParcelFileDescriptor (android.os.ParcelFileDescriptor)4 File (java.io.File)4 SharedPreferences (android.content.SharedPreferences)3 IOException (java.io.IOException)3 Point (android.graphics.Point)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 IResultReceiver (com.android.internal.os.IResultReceiver)2 JSONObject (org.json.JSONObject)2