• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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 com.android.dialer.common.concurrent;
18 
19 import android.app.FragmentManager;
20 import android.support.annotation.NonNull;
21 import com.android.dialer.common.concurrent.DialerExecutor.Worker;
22 
23 /**
24  * Factory interface for creating {@link DialerExecutor} objects.
25  *
26  * <p>Factory instances may be used instead of the static methods in {@link DialerExecutors} in
27  * order to improve testability.
28  *
29  * @see DialerExecutors
30  */
31 public interface DialerExecutorFactory {
32 
33   /**
34    * Must be called from onCreate of your activity or fragment.
35    *
36    * @param taskId used for the headless fragment ID and task ID
37    * @param worker a function executed on a worker thread which accepts an {@link InputT} and
38    *     returns an {@link OutputT}. It should ideally not be an inner class of your (meaning it
39    *     should not be a lambda, anonymous, or non-static) but it can be a static nested class. The
40    *     static nested class should not contain any reference to UI, including any activity or
41    *     fragment or activity context, though it may reference some threadsafe system objects such
42    *     as the application context.
43    */
44   @NonNull
createUiTaskBuilder( @onNull FragmentManager fragmentManager, @NonNull String taskId, @NonNull Worker<InputT, OutputT> worker)45   <InputT, OutputT> DialerExecutor.Builder<InputT, OutputT> createUiTaskBuilder(
46       @NonNull FragmentManager fragmentManager,
47       @NonNull String taskId,
48       @NonNull Worker<InputT, OutputT> worker);
49 
50   /**
51    * Create a task from a non-UI context.
52    *
53    * @param worker a function executed on a worker thread which accepts an {@link InputT} and
54    *     returns an {@link OutputT}. It should ideally not be an inner class of your (meaning it
55    *     should not be a lambda, anonymous, or non-static) but it can be a static nested class. The
56    *     static nested class should not contain any reference to UI, including any activity or
57    *     fragment or activity context, though it may reference some threadsafe system objects such
58    *     as the application context.
59    */
60   @NonNull
createNonUiTaskBuilder( @onNull Worker<InputT, OutputT> worker)61   <InputT, OutputT> DialerExecutor.Builder<InputT, OutputT> createNonUiTaskBuilder(
62       @NonNull Worker<InputT, OutputT> worker);
63 }
64