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
| 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
| import android.content.Context | |
| import com.android.volley.Request | |
| import com.android.volley.RequestQueue | |
| import com.android.volley.toolbox.Volley | |
| /** | |
| * Singleton | |
| */ | |
| class HttpRequestQueue constructor(context: Context) { |
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 org.json.JSONObject | |
| abstract class HttpResponse { | |
| companion object { | |
| const val HEADER_KEY = "header" | |
| const val RESPONSE_KEY = "response" | |
| } | |
| internal abstract fun parseJson(json: JSONObject): HttpResponse | |
| } |
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.Response | |
| import com.android.volley.VolleyError | |
| import com.android.volley.toolbox.JsonObjectRequest | |
| import com.example.koheiando.twittervolleysample.TvsApplication | |
| import kotlinx.coroutines.suspendCancellableCoroutine | |
| import org.json.JSONObject | |
| import kotlin.coroutines.resume | |
| import kotlin.coroutines.resumeWithException |
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 io.repro.android.Repro | |
| class ReproTrigger { | |
| companion object { | |
| private var instance: ReproTrigger? = null | |
| fun getInstance(): ReproTrigger { | |
| if (instance == null) | |
| instance = ReproTrigger() | |
| return instance!! | |
| } |
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.app.Application | |
| import android.util.Log | |
| import io.repro.android.Repro | |
| import org.xmlpull.v1.XmlPullParser | |
| import java.lang.Exception | |
| class ReproApplication : Application() { | |
| companion object { | |
| private const val REPRO_TOKEN_KEY = "repro_sdk_token" | |
| } |
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 NotDialogFragment : Fragment() { | |
| private var reserveDismiss = false // resume時にこのdialogを閉じる | |
| private var reserveShow = false // resume時に表示 | |
| private lateinit var dialogMain: LinearLayout | |
| override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
| return inflater?.inflate(R.layout.fragment_load, container, false)?.apply { | |
| dialogMain = findViewById<FrameLayout>(R.id.dialog_main_layout).also { | |
| it.visibility = View.GONE |
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
| 'use strict'; | |
| var p = console.log; | |
| var FS = require('fs'); | |
| // fs appendFile Promise wrapper | |
| function write(path, data){ | |
| return new Promise((res, rej) => FS.appendFile(path, data, err => | |
| err ? rej(err) : res(p(data, 'is done!')) | |
| )); |