Removed all the crazy android-specific dagger junk. Doesn't seem to do

anything useful and is super confusing.
This commit is contained in:
casey langen 2017-08-21 21:15:59 -07:00
parent c4cc06f236
commit 525fed1035
17 changed files with 60 additions and 64 deletions

View File

@ -75,10 +75,7 @@ dependencies {
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
implementation 'com.google.dagger:dagger:2.11'
implementation 'com.google.dagger:dagger-android:2.11'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
kapt 'com.google.dagger:dagger-android-processor:2.11'
kapt 'com.google.dagger:dagger-compiler:2.11'
implementation 'com.neovisionaries:nv-websocket-client:1.31'

View File

@ -51,7 +51,12 @@
</activity>
<activity android:name=".ui.activity.CategoryBrowseActivity"
<activity
android:name=".ui.activity.CategoryBrowseActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".ui.activity.ConnectionsActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />

View File

@ -1,12 +1,8 @@
package io.casey.musikcube.remote
import android.app.Activity
import android.arch.persistence.room.Room
import com.crashlytics.android.Crashlytics
import com.facebook.stetho.Stetho
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import io.casey.musikcube.remote.injection.DaggerMainComponent
import io.casey.musikcube.remote.injection.MainComponent
import io.casey.musikcube.remote.injection.MainModule
@ -14,18 +10,14 @@ import io.casey.musikcube.remote.offline.OfflineDb
import io.casey.musikcube.remote.playback.StreamProxy
import io.casey.musikcube.remote.util.NetworkUtil
import io.fabric.sdk.android.Fabric
import javax.inject.Inject
class Application : android.app.Application(), HasActivityInjector {
@Inject lateinit var activityInjector: DispatchingAndroidInjector<Activity>
class Application : android.app.Application() {
override fun onCreate() {
instance = this
super.onCreate()
mainComponent = DaggerMainComponent.builder().mainModule(MainModule()).build()
mainComponent.inject(this)
if (BuildConfig.DEBUG) {
Stetho.initializeWithDefaults(this)
@ -43,10 +35,6 @@ class Application : android.app.Application(), HasActivityInjector {
"offline").build()
}
override fun activityInjector(): AndroidInjector<Activity> {
return activityInjector
}
companion object {
lateinit var mainComponent: MainComponent

View File

@ -4,7 +4,6 @@ import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.graphics.drawable.Drawable
import android.net.Uri
import android.os.Bundle
import android.os.Handler
@ -19,7 +18,6 @@ import android.widget.CheckBox
import android.widget.CompoundButton
import android.widget.SeekBar
import android.widget.TextView
import dagger.android.AndroidInjection
import io.casey.musikcube.remote.playback.PlaybackService
import io.casey.musikcube.remote.playback.PlaybackState
import io.casey.musikcube.remote.playback.RepeatMode
@ -62,7 +60,7 @@ class MainActivity : WebSocketActivityBase() {
/* end views */
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)

View File

@ -1,30 +0,0 @@
package io.casey.musikcube.remote.injection
import dagger.Module
import dagger.android.ContributesAndroidInjector
import io.casey.musikcube.remote.MainActivity
import io.casey.musikcube.remote.ui.activity.*
@Module
abstract class ActivityModule {
@ContributesAndroidInjector
abstract fun mainActivityInjector(): MainActivity
@ContributesAndroidInjector
abstract fun baseActivityInject(): WebSocketActivityBase
@ContributesAndroidInjector
abstract fun settingsInjector(): SettingsActivity
@ContributesAndroidInjector
abstract fun albumBrowseInject(): AlbumBrowseActivity
@ContributesAndroidInjector
abstract fun categoryBrowseInject(): CategoryBrowseActivity
@ContributesAndroidInjector
abstract fun playQueueInject(): PlayQueueActivity
@ContributesAndroidInjector
abstract fun trackListInject(): TrackListActivity
}

View File

@ -1,19 +1,28 @@
package io.casey.musikcube.remote.injection
import dagger.Component
import dagger.android.AndroidInjectionModule
import dagger.android.AndroidInjector
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.MainActivity
import io.casey.musikcube.remote.offline.OfflineDb
import io.casey.musikcube.remote.playback.RemotePlaybackService
import io.casey.musikcube.remote.playback.StreamingPlaybackService
import io.casey.musikcube.remote.ui.activity.*
import io.casey.musikcube.remote.ui.view.EmptyListView
import io.casey.musikcube.remote.ui.view.MainMetadataView
import javax.inject.Singleton
@Singleton
@Component(modules = arrayOf(AndroidInjectionModule::class, MainModule::class, ActivityModule::class))
interface MainComponent : AndroidInjector<Application> {
@Component(modules = arrayOf(MainModule::class))
interface MainComponent {
/* activities */
fun inject(activity: ConnectionsActivity)
fun inject(activity: MainActivity)
fun inject(activity: WebSocketActivityBase)
fun inject(activity: SettingsActivity)
fun inject(activity: AlbumBrowseActivity)
fun inject(activity: CategoryBrowseActivity)
fun inject(activity: PlayQueueActivity)
fun inject(activity: TrackListActivity)
/* views */
fun inject(view: EmptyListView)
fun inject(view: MainMetadataView)

View File

@ -1,6 +1,5 @@
package io.casey.musikcube.remote.playback
import android.content.Context
import android.os.Handler
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.ui.model.TrackListSlidingWindow

View File

@ -4,6 +4,7 @@ import android.app.*
import android.content.*
import android.graphics.Bitmap
import android.media.AudioManager
import android.os.Build
import android.os.Handler
import android.os.IBinder
import android.os.PowerManager
@ -27,7 +28,6 @@ import io.casey.musikcube.remote.util.Debouncer
import io.casey.musikcube.remote.util.Strings
import io.casey.musikcube.remote.websocket.Prefs
import android.support.v4.app.NotificationCompat.Action as NotifAction
import android.os.Build
/**
* a service used to interact with all of the system media-related components -- notifications,

View File

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.Metadata
import io.casey.musikcube.remote.ui.extension.*
@ -34,6 +35,7 @@ class AlbumBrowseActivity : WebSocketActivityBase(), Filterable {
private lateinit var emptyView: EmptyListView
override fun onCreate(savedInstanceState: Bundle?) {
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
categoryName = intent.getStringExtra(EXTRA_CATEGORY_NAME) ?: ""

View File

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.Metadata
import io.casey.musikcube.remote.ui.extension.*
@ -41,6 +42,8 @@ class CategoryBrowseActivity : WebSocketActivityBase(), Filterable {
private lateinit var emptyView: EmptyListView
override fun onCreate(savedInstanceState: Bundle?) {
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
category = intent.getStringExtra(EXTRA_CATEGORY)

View File

@ -0,0 +1,16 @@
package io.casey.musikcube.remote.ui.activity
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import io.casey.musikcube.remote.Application
/**
* Created by casey on 8/21/2017.
*/
class ConnectionsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Application.mainComponent.inject(this);
super.onCreate(savedInstanceState)
}
}

View File

@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.Metadata
import io.casey.musikcube.remote.playback.PlaybackService
@ -28,6 +29,8 @@ class PlayQueueActivity : WebSocketActivityBase() {
private lateinit var emptyView: EmptyListView
override fun onCreate(savedInstanceState: Bundle?) {
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
playback = playbackService

View File

@ -12,7 +12,7 @@ import android.support.v7.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.widget.*
import dagger.android.AndroidInjection
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.PlayerWrapper
import io.casey.musikcube.remote.playback.StreamProxy
@ -43,7 +43,7 @@ class SettingsActivity : AppCompatActivity() {
@Inject lateinit var wss: WebSocketService
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
prefs = this.getSharedPreferences(Prefs.NAME, Context.MODE_PRIVATE)
setContentView(R.layout.activity_settings)

View File

@ -10,6 +10,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.pluscubed.recyclerfastscroll.RecyclerFastScroller
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.Metadata
import io.casey.musikcube.remote.ui.extension.*
@ -36,6 +37,8 @@ class TrackListActivity : WebSocketActivityBase(), Filterable {
private var adapter = Adapter()
override fun onCreate(savedInstanceState: Bundle?) {
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
val intent = intent

View File

@ -7,12 +7,10 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.KeyEvent
import android.view.MenuItem
import com.uacf.taskrunner.LifecycleDelegate
import com.uacf.taskrunner.Runner
import com.uacf.taskrunner.Task
import dagger.android.AndroidInjection
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.playback.PlaybackService
import io.casey.musikcube.remote.playback.PlaybackServiceFactory
import io.casey.musikcube.remote.websocket.Prefs
@ -26,7 +24,7 @@ abstract class WebSocketActivityBase : AppCompatActivity(), Runner.TaskCallbacks
@Inject lateinit var wss: WebSocketService
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
Application.mainComponent.inject(this)
super.onCreate(savedInstanceState)
volumeControlStream = AudioManager.STREAM_MUSIC
runnerDelegate = LifecycleDelegate(this, this, javaClass, null)

View File

@ -21,7 +21,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.GlideDrawable
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import dagger.android.AndroidInjection
import io.casey.musikcube.remote.Application
import io.casey.musikcube.remote.R
import io.casey.musikcube.remote.playback.*

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>