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
adb shell am start -a android.intent.action.VIEW -d slice-{contentURI} |
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
override fun onBindSlice(sliceUri: Uri): Slice? { | |
return when { | |
sliceUri.path == "/hello" -> createBasicRowSlice(sliceUri) // path hello'ya eşit olursa basit bir slice oluştur. | |
else->null | |
} | |
} | |
private fun createBasicRowSlice(sliceUri: Uri): Slice { | |
return ListBuilder(context, sliceUri, ListBuilder.INFINITY) | |
.addRow { // satır ekle |
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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.faskn.sliceexample"> | |
<application | |
//.. | |
<provider | |
android:name=".MySliceProvider" |
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
dependencies { | |
// | |
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1' | |
// | |
} | |
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
dependencies { | |
//.. | |
.. | |
//.. | |
} | |
kotlin { | |
experimental { | |
coroutines "enable" | |
} |
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
class ThreadBlockingActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_thread_blocking) | |
GlobalScope.launch(Dispatchers.Main){ | |
Toast.makeText(applicationContext,"10 Saniyelik geri sayım başladı.",Toast.LENGTH_SHORT).show() | |
delay(10000) | |
tv_thread.text = "10 Saniye sonra değişti." | |
} |
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
dependencies { | |
// | |
implementation 'com.squareup.retrofit2:retrofit:2.4.0' | |
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' | |
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2' | |
// | |
} |
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
<uses-permission android:name="android.permission.INTERNET" /> |
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
interface RetrofitService{ | |
@GET("photos") | |
fun getPhotos(): Deferred<Response<List<Photos>>> | |
@GET("posts") | |
fun getPost() : Deferred<Response<List<Posts>>> | |
} |
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
object RetrofitFactory { | |
const val BASE_URL = "https://jsonplaceholder.typicode.com/" | |
fun makeRetrofitService(): RetrofitService { | |
return Retrofit.Builder() | |
.baseUrl(BASE_URL) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(CoroutineCallAdapterFactory()) | |
.build().create(RetrofitService::class.java) |