• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 package com.android.tv.common.dagger;
17 
18 import android.app.Application;
19 import android.content.ContentResolver;
20 import android.content.Context;
21 import android.os.Looper;
22 import com.android.tv.common.dagger.annotations.ApplicationContext;
23 import com.android.tv.common.dagger.annotations.MainLooper;
24 import dagger.Module;
25 import dagger.Provides;
26 
27 /**
28  * Provides application-scope qualifiers for the {@link Application}, the application context, and
29  * the application's main looper.
30  */
31 @Module
32 public final class ApplicationModule {
33     private final Application mApplication;
34 
ApplicationModule(Application application)35     public ApplicationModule(Application application) {
36         mApplication = application;
37     }
38 
39     @Provides
provideApplication()40     Application provideApplication() {
41         return mApplication;
42     }
43 
44     @Provides
45     @ApplicationContext
provideContext()46     Context provideContext() {
47         return mApplication.getApplicationContext();
48     }
49 
50     @Provides
51     @MainLooper
provideMainLooper()52     static Looper provideMainLooper() {
53         return Looper.getMainLooper();
54     }
55 
56     @Provides
provideContentResolver()57     ContentResolver provideContentResolver() {
58         return mApplication.getContentResolver();
59     }
60 }
61