• 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.internal.telephony.uicc.euicc.async;
18 
19 import android.telephony.Rlog;
20 
21 /**
22  * Class to deliver the returned value from an asynchronous call. Either {@link #onResult(Result)}
23  * or {@link #onException(Throwable)} will be called. You can create an anonymous subclass and
24  * override these methods to handle the result or the throwable from an asynchronous call, for
25  * example:
26  *
27  * <pre>
28  *     doSomethingAsync(
29  *             new AsyncResultCallback&lt;Result&gt;() {
30  *                 void onResult(Result r) {
31  *                     Log.i("Got the result: %s", r.toString());
32  *                 }
33  *
34  *                 void onException(Throwable e) {...}
35  *             });
36  * <pre>
37  *
38  * @param <Result> The returned value of the asynchronous call.
39  * @hide
40  */
41 public abstract class AsyncResultCallback<Result> {
42 
43     private static final String LOG_TAG = "AsyncResultCallback";
44 
45     /** This will be called when the result is returned. */
onResult(Result result)46     public abstract void onResult(Result result);
47 
48     /** This will be called when any exception is thrown. */
onException(Throwable e)49     public void onException(Throwable e) {
50         Rlog.e(LOG_TAG, "Error in onException", e);
51     }
52 }
53