This file contains hidden or 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
| import android.util.Log | |
| import com.android.volley.DefaultRetryPolicy | |
| import com.android.volley.VolleyError | |
| class HttpRetryPolicy(timeoutMs: Int = defaultTimeoutMs, maxRetry: Int = defaultMaxRetryCount) : | |
| DefaultRetryPolicy(timeoutMs, maxRetry, DEFAULT_BACKOFF_MULT) { | |
| companion object { | |
| private const val defaultTimeoutMs = 1000 * 10 | |
| private const val defaultMaxRetryCount = 1 |
This file contains hidden or 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 MainViewModel : ViewModel() { | |
| private val repository = TweetsRepository() | |
| private val searchWords = MutableLiveData<String>() // trigger | |
| // tweet data exposed to Views | |
| val tweetDataResults: LiveData<TweetDataResult> | |
| = Transformations.switchMap(searchWords) { str -> repository.loadTweets(str) } | |
| /** | |
| * search trigger |
This file contains hidden or 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
| fun request(method: Int, url: String, headers: Map<String, String>, jsonRequest: JSONObject?, | |
| successListener: (json: JSONObject) -> Unit, errorListener: (error: Exception) -> Unit) { | |
| val request = object : JsonObjectRequest(method, url, jsonRequest, | |
| Response.Listener<JSONObject> { json -> successListener(json) }, | |
| Response.ErrorListener { e -> errorListener(e) }) { | |
| override fun getHeaders(): Map<String, String> = headers | |
| override fun parseNetworkError(volleyError: VolleyError): VolleyError { | |
| return volleyError.networkResponse?.let { | |
| Log.e("VolleyRequest", volleyError.networkResponse.headers.toString()) |
This file contains hidden or 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
| suspend fun request(method: Int, url: String, headers: Map<String, String>, jsonRequest: JSONObject?): JSONObject { | |
| return suspendCancellableCoroutine { continuation -> | |
| val success = Response.Listener<JSONObject> { response -> continuation.resume(response) } | |
| val error = Response.ErrorListener { error -> continuation.resumeWithException(error) } | |
| val request = object : JsonObjectRequest(method, url, jsonRequest, success, error) { | |
| override fun getHeaders(): Map<String, String> = headers | |
| override fun parseNetworkError(volleyError: VolleyError): VolleyError { | |
| return volleyError.networkResponse?.let { |
This file contains hidden or 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 TestRequest : HttpRequest() { | |
| companion object { | |
| private const val HEADER_AUTHORIZATION_KEY = "Authorization" | |
| private const val QUERY_KEY = "q" | |
| } | |
| override val method: Int = Request.Method.GET | |
| override val url: String = "https://www.testrequestforfun.com" | |
| override val queryParams: Map<String, String> = mapOf(QUERY_KEY to "paramTest") |
This file contains hidden or 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.example.koheiando.reprosample"> | |
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> | |
| <uses-permission android:name="android.permission.INTERNET"/> | |
| <application | |
| android:name=".ReproApplication" | |
| android:allowBackup="true" | |
| android:icon="@mipmap/ic_launcher" |
This file contains hidden or 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 DeepLinkTargetONEActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_deeplink_one) | |
| } | |
| } |
This file contains hidden or 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 DeepLinkTargetTWOActivity : AppCompatActivity() { | |
| companion object { | |
| const val EXTRA_TEXT = "text" | |
| } | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_deeplink_two) | |
| findViewById<TextView>(R.id.tv_to_replace).text = intent.getStringExtra(EXTRA_TEXT) ?: "text not passed" | |
| } |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| } | |
| override fun onResume() { | |
| super.onResume() | |
| Repro.track("main_open") // send tracking |
This file contains hidden or 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 MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContentView(R.layout.activity_main) | |
| } | |
| override fun onResume() { | |
| super.onResume() | |
| Handler().postDelayed({ |