mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-11-04 00:33:55 +01:00 
			
		
		
		
	Convert CommonsDaggerContentProvider to kotlin
This commit is contained in:
		
							parent
							
								
									834013c6c2
								
							
						
					
					
						commit
						76d598cafa
					
				
					 2 changed files with 20 additions and 32 deletions
				
			
		| 
						 | 
					@ -1,32 +0,0 @@
 | 
				
			||||||
package fr.free.nrw.commons.di;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import android.content.ContentProvider;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import dagger.android.AndroidInjector;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public abstract class CommonsDaggerContentProvider extends ContentProvider {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public CommonsDaggerContentProvider() {
 | 
					 | 
				
			||||||
        super();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    @Override
 | 
					 | 
				
			||||||
    public boolean onCreate() {
 | 
					 | 
				
			||||||
        inject();
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private void inject() {
 | 
					 | 
				
			||||||
        ApplicationlessInjection injection = ApplicationlessInjection.getInstance(getContext());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        AndroidInjector<ContentProvider> serviceInjector = injection.contentProviderInjector();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (serviceInjector == null) {
 | 
					 | 
				
			||||||
            throw new NullPointerException("ApplicationlessInjection.contentProviderInjector() returned null");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        serviceInjector.inject(this);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					package fr.free.nrw.commons.di
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import android.content.ContentProvider
 | 
				
			||||||
 | 
					import fr.free.nrw.commons.di.ApplicationlessInjection.Companion.getInstance
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					abstract class CommonsDaggerContentProvider : ContentProvider() {
 | 
				
			||||||
 | 
					    override fun onCreate(): Boolean {
 | 
				
			||||||
 | 
					        inject()
 | 
				
			||||||
 | 
					        return true
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private fun inject() {
 | 
				
			||||||
 | 
					        val injection = getInstance(context!!)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        val serviceInjector = injection.contentProviderInjector()
 | 
				
			||||||
 | 
					            ?: throw NullPointerException("ApplicationlessInjection.contentProviderInjector() returned null")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        serviceInjector.inject(this)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue