Java Code Examples for androidx.work.Data#getString()

The following examples show how to use androidx.work.Data#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModifyKeywordWorker.java    From lttrs-android with Apache License 2.0 5 votes vote down vote up
public ModifyKeywordWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = getInputData();
    this.threadId = data.getString(THREAD_ID_KEY);
    this.keyword = data.getString(KEYWORD_KEY);
    this.target = data.getBoolean(TARGET_STATE_KEY, false);
}
 
Example 2
Source File: AbstractCreateEmailWorker.java    From lttrs-android with Apache License 2.0 5 votes vote down vote up
AbstractCreateEmailWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = workerParams.getInputData();
    this.identity = data.getString(IDENTITY_KEY);
    final String to = data.getString(TO_KEY);
    this.to = to == null ? Collections.emptyList() : EmailAddressUtil.parse(to);
    final String cc = data.getString(CC_KEY);
    this.cc = cc == null ? Collections.emptyList() : EmailAddressUtil.parse(cc);
    this.subject = data.getString(SUBJECT_KEY);
    this.body = data.getString(BODY_KEY);
    final String[] inReplyTo = data.getStringArray(IN_REPLY_TO_KEY);
    this.inReplyTo = inReplyTo == null ? Collections.emptyList() : Arrays.asList(inReplyTo);
}
 
Example 3
Source File: RemoveFromMailboxWorker.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
public RemoveFromMailboxWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = getInputData();
    this.mailboxId = data.getString(MAILBOX_ID_KEY);
}
 
Example 4
Source File: CopyToMailboxWorker.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
public CopyToMailboxWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = getInputData();
    this.mailboxId = data.getString(MAILBOX_ID_KEY);
}
 
Example 5
Source File: SubmitEmailWorker.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
public SubmitEmailWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = workerParams.getInputData();
    this.emailId = data.getString(EMAIL_ID);
    this.identity = data.getString(IDENTITY_KEY);
}
 
Example 6
Source File: DiscardDraftWorker.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
public DiscardDraftWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = workerParams.getInputData();
    this.emailId = data.getString(DISCARD_ID_KEY);
}
 
Example 7
Source File: AbstractMailboxModificationWorker.java    From lttrs-android with Apache License 2.0 4 votes vote down vote up
AbstractMailboxModificationWorker(@NonNull Context context, @NonNull WorkerParameters workerParams) {
    super(context, workerParams);
    final Data data = getInputData();
    this.threadId = data.getString(THREAD_ID_KEY);
}
 
Example 8
Source File: FlutterUploaderPlugin.java    From flutter_uploader with MIT License 4 votes vote down vote up
@Override
public void onChanged(List<WorkInfo> workInfoList) {
  FlutterUploaderPlugin plugin = this.plugin.get();

  if (plugin == null) {
    return;
  }

  for (WorkInfo info : workInfoList) {
    String id = info.getId().toString();
    if (!plugin.completedTasks.containsKey(id)) {
      if (info.getState().isFinished()) {
        plugin.completedTasks.put(id, true);
        Data outputData = info.getOutputData();

        switch (info.getState()) {
          case FAILED:
            int failedStatus =
                outputData.getInt(UploadWorker.EXTRA_STATUS, UploadStatus.FAILED);
            int statusCode = outputData.getInt(UploadWorker.EXTRA_STATUS_CODE, 500);
            String code = outputData.getString(UploadWorker.EXTRA_ERROR_CODE);
            String errorMessage = outputData.getString(UploadWorker.EXTRA_ERROR_MESSAGE);
            String[] details = outputData.getStringArray(UploadWorker.EXTRA_ERROR_DETAILS);
            plugin.sendFailed(id, failedStatus, statusCode, code, errorMessage, details);
            break;
          case CANCELLED:
            plugin.sendFailed(
                id,
                UploadStatus.CANCELED,
                500,
                "flutter_upload_cancelled",
                "upload has been cancelled",
                null);
            break;
          case SUCCEEDED:
            int status = outputData.getInt(UploadWorker.EXTRA_STATUS, UploadStatus.COMPLETE);
            Map<String, String> headers = null;
            Type type = new TypeToken<Map<String, String>>() {}.getType();
            String headerJson = info.getOutputData().getString(UploadWorker.EXTRA_HEADERS);
            if (headerJson != null) {
              headers = plugin.gson.fromJson(headerJson, type);
            }

            String response = info.getOutputData().getString(UploadWorker.EXTRA_RESPONSE);
            plugin.sendCompleted(id, status, response, headers);
            break;
        }
      }
    }
  }
}