class IntentImportProcessor {

    @NonNull
    public synchronized Maybe<IntentImportResult> process(@NonNull final Intent intent) {
        return Maybe.fromCallable(() -> {
                    if (intent.hasExtra(INTENT_CONSUMED)) {
                        return null; // We've already consumed this intent so do nothing
                    } else {
                        final Uri uri;
                        if (Intent.ACTION_VIEW.equals(intent.getAction()) && intent.getData() != null) {
                            uri = intent.getData();
                        } else if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.getExtras() != null) {
                            uri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM);
                        } else {
                            uri = null; // This is an invalid one
                        }

                        if (uri != null) {
                            return buildResultFromUri(uri); // Attempt to build our results from it
                        } else {
                            return null;
                        }
                    }
                })
                .doOnSuccess(intentImportResult -> {
                    Logger.debug(IntentImportProcessor.this, "Successfully processed the file {} with uri: {}.", intentImportResult.getFileType(), intentImportResult.getUri());
                    analytics.record(new DefaultDataPointEvent(Events.Intents.ReceivedActionableIntent).addDataPoint(new DataPoint("type", intentImportResult.getFileType())));
                    lastResult.onNext(Optional.of(intentImportResult));
                })
                .subscribeOn(Schedulers.io());
    }

    @Inject public  IntentImportProcessor(@NonNull Context context, @NonNull Analytics analytics);

}