Skip to content

Instantly share code, notes, and snippets.

View Elvis10ten's full-sized avatar

Elvis Chidera Elvis10ten

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/donateFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mobymagic.shazamclone.donate.DonateActivity" />
package com.mobymagic.shazamclone.discover
import com.mobymagic.shazamclone.BasePresenter
import com.mobymagic.shazamclone.BaseView
import com.mobymagic.shazamclone.data.identify.Song
interface DiscoverContract {
interface View: BaseView<Presenter> {
// Show/hide progress view
package com.mobymagic.shazamclone
interface BasePresenter<in V> {
// This method is called by the View on the presenter when it is active
fun takeView(view: V)
// This method is called by the View when it is no longer active
fun dropView()
package com.mobymagic.shazamclone
// Well, we would call this one just a marker interface
interface BaseView<P> {
}
package com.mobymagic.shazamclone.discover
import com.mobymagic.shazamclone.data.identify.Song
import com.mobymagic.shazamclone.data.identify.SongIdentifyService
class DiscoverPresenter(private val songIdentifyService: SongIdentifyService): DiscoverContract.Presenter {
override fun takeView(view: DiscoverContract.View) {
}
package com.mobymagic.shazamclone.discover
import com.mobymagic.shazamclone.data.identify.Song
import com.mobymagic.shazamclone.data.identify.SongIdentifyService
import com.nhaarman.mockito_kotlin.argumentCaptor
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.verify
import org.junit.After
import org.junit.Before
import org.junit.Test
package com.mobymagic.shazamclone.data.identify
// A class that will hold information about the song that was identified/discovered. For now, it will have no properties. In future parts,
// we will update this class to include properties.
class Song {
}
package com.mobymagic.shazamclone.data.identify
interface SongIdentifyService {
// Called to start identifying/discovering the song that is currently playing
fun startIdentication(callback: SongIdentificationCallback)
// Called to stop identifying/discovering song
fun stopIdentification()
package com.mobymagic.shazamclone.discover
import com.mobymagic.shazamclone.data.identify.Song
import com.mobymagic.shazamclone.data.identify.SongIdentifyService
class DiscoverPresenter(private val songIdentifyService: SongIdentifyService): DiscoverContract.Presenter,
SongIdentifyService.SongIdentificationCallback {
private var mDiscoverView: DiscoverContract.View? = null
override fun takeView(view: DiscoverContract.View) {
import android.os.Bundle
import android.support.v4.app.Fragment
import android.support.v7.app.AlertDialog
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.mobymagic.shazamclone.R
import com.mobymagic.shazamclone.data.identify.Song
import com.mobymagic.shazamclone.di.Injection