1 /*
2  * Copyright 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package androidx.work;
18 
19 import android.content.Context;
20 
21 import com.google.common.util.concurrent.ListenableFuture;
22 
23 import org.jspecify.annotations.NonNull;
24 
25 import java.util.UUID;
26 
27 /**
28  * Updates progress for a {@link androidx.work.ListenableWorker}.
29  */
30 public interface ProgressUpdater {
31 
32     /**
33      * @param context The application {@link Context}.
34      * @param id      The {@link UUID} identifying the {@link ListenableWorker}
35      * @param data    The progress {@link Data}
36      * @return The {@link ListenableFuture} which resolves after progress is persisted.
37      * <p>
38      * Cancelling this {@link ListenableFuture} does not cancel the writes to the database
39      * to update progress.
40      */
updateProgress( @onNull Context context, @NonNull UUID id, @NonNull Data data)41     @NonNull ListenableFuture<Void> updateProgress(
42             @NonNull Context context,
43             @NonNull UUID id,
44             @NonNull Data data);
45 }
46