-
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.
Showing
13 changed files
with
161 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.kkkk.di | ||
|
||
import android.content.Context | ||
import com.google.android.gms.wearable.DataClient | ||
import com.google.android.gms.wearable.Wearable | ||
import com.kkkk.presentation.manager.WearableDataManager | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ManagerModule{ | ||
|
||
@Provides | ||
@Singleton | ||
fun provideDataClient(@ApplicationContext context: Context): DataClient { | ||
return Wearable.getDataClient(context) | ||
} | ||
|
||
@Provides | ||
@Singleton | ||
fun provideWearableDataManager(dataClient: DataClient): WearableDataManager { | ||
return WearableDataManager(dataClient) | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
presentation/src/main/java/com/kkkk/presentation/manager/WearableDataManager.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,38 @@ | ||
package com.kkkk.presentation.manager | ||
|
||
import com.google.android.gms.tasks.Task | ||
import com.google.android.gms.wearable.DataClient | ||
import com.google.android.gms.wearable.DataItem | ||
import com.google.android.gms.wearable.PutDataMapRequest | ||
import com.google.android.gms.wearable.PutDataRequest | ||
import timber.log.Timber | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class WearableDataManager @Inject constructor( | ||
private val dataClient: DataClient | ||
) { | ||
|
||
fun sendIntToWearable(path: String, key: String, value: Int): Task<DataItem> { | ||
|
||
Timber.tag("okhttp").d("START SENDING DATA TO WEARABLE") | ||
|
||
val putDataReq: PutDataRequest = PutDataMapRequest.create(path).run { | ||
dataMap.putInt(key, value) | ||
asPutDataRequest().setUrgent() | ||
} | ||
|
||
return dataClient.putDataItem(putDataReq).addOnSuccessListener { dataItem -> | ||
Timber.tag("okhttp").d("SEND DATA TO WEARABLE SUCCESS : ${dataItem.uri}") | ||
}.addOnFailureListener { exception -> | ||
Timber.tag("okhttp").d("SEND DATA TO WEARABLE FAIL : ${exception.message}") | ||
} | ||
} | ||
|
||
companion object { | ||
const val KEY_BPM = "KEY_BPM" | ||
|
||
const val PATH_BPM = "/bpm" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package com.kkkk.stempo.presentation | ||
|
||
import android.app.Application | ||
import com.kkkk.di.BuildConfig | ||
import dagger.hilt.android.HiltAndroidApp | ||
import timber.log.Timber | ||
|
||
@HiltAndroidApp | ||
class MyApp : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
initTimber() | ||
} | ||
|
||
private fun initTimber() { | ||
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) | ||
} | ||
} |
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