-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing MVP with dagger and koting its too hard men testing CI please squash or ammend
- Loading branch information
mercuriete
committed
Nov 14, 2018
1 parent
c99dd35
commit 78c2eb0
Showing
16 changed files
with
115 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/src/main/java/org/mercuriete/musiciantools/BasePresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.mercuriete.musiciantools | ||
|
||
interface BasePresenter<T> { | ||
|
||
/** | ||
* Binds presenter with a view when resumed. The Presenter will perform initialization here. | ||
* | ||
* @param view the view associated with this presenter | ||
*/ | ||
fun takeView(view: T) | ||
|
||
/** | ||
* Drops the reference to the view when destroyed | ||
*/ | ||
fun dropView() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.mercuriete.musiciantools | ||
|
||
interface BaseView<T> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/mercuriete/musiciantools/bpmcalculator/BPMCalculatorContract.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.mercuriete.musiciantools.bpmcalculator | ||
|
||
import org.mercuriete.musiciantools.BasePresenter | ||
import org.mercuriete.musiciantools.BaseView | ||
|
||
|
||
interface BPMCalculatorContract { | ||
|
||
interface View : BaseView<Presenter> { | ||
fun showBPM(bpm:String) | ||
} | ||
|
||
interface Presenter : BasePresenter<View> { | ||
fun addBeat() | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/mercuriete/musiciantools/bpmcalculator/BPMCalculatorModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.mercuriete.musiciantools.bpmcalculator | ||
|
||
import dagger.Provides | ||
import dagger.Module | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
class BPMCalculatorModule { | ||
|
||
@Provides | ||
fun bpmCalculatorServiceProvider(): BPMCalculatorService { | ||
return BPMCalculatorServiceImpl() | ||
} | ||
|
||
@Singleton | ||
@Provides | ||
fun bpmCalculatorPresenterProvider(bpmCalculatorService: BPMCalculatorService): BPMCalculatorContract.Presenter { | ||
return BPMCalculatorPresenter(bpmCalculatorService) | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/mercuriete/musiciantools/bpmcalculator/BPMCalculatorPresenter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package org.mercuriete.musiciantools.bpmcalculator | ||
|
||
import android.support.annotation.Nullable | ||
import javax.inject.Inject | ||
|
||
class BPMCalculatorPresenter : BPMCalculatorContract.Presenter { | ||
@Nullable | ||
private var bpmCalculatorView: BPMCalculatorContract.View? = null | ||
|
||
private var bpmCalculatorService: BPMCalculatorService | ||
|
||
@Inject | ||
constructor(bpmCalculatorService: BPMCalculatorService) { | ||
this.bpmCalculatorService = bpmCalculatorService | ||
} | ||
|
||
override fun addBeat() { | ||
bpmCalculatorService.beat() | ||
bpmCalculatorView?.showBPM(String.format("%.2f", bpmCalculatorService.getBPM())) | ||
|
||
} | ||
|
||
override fun takeView(view: BPMCalculatorContract.View) { | ||
bpmCalculatorView = view | ||
} | ||
|
||
override fun dropView() { | ||
bpmCalculatorView = null | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...iantools/services/BPMCalculatorService.kt → ...ols/bpmcalculator/BPMCalculatorService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ools/services/BPMCalculatorServiceImpl.kt → ...bpmcalculator/BPMCalculatorServiceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 0 additions & 17 deletions
17
app/src/main/java/org/mercuriete/musiciantools/services/BPMCalculatorModule.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../services/BPMCalculatorServiceUnitTest.kt → ...alculator/BPMCalculatorServiceUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters