Skip to content

Instantly share code, notes, and snippets.

Toshihiko Arai araemon

Block or report user

Report or block araemon

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View OkHttpClient.kt
class OkHttpClient(_url:String, _body:String? = null):HTTPClient {
override val url: String = _url
override val body:String? = _body
var client = OkHttpClient()
View VerboseHttpClient.kt
class VerboseHttpClient(_url:String, _body:String? = null):HTTPClient {
override val url: String = _url
override val body:String? = _body
private fun isCurrent(): Boolean {
return Thread.currentThread() == getMainLooper().thread
override fun request(): String? {
View HTTPTask.kt
class HTTPTask<T>(activity: T, private val client:HTTPClient) : AsyncTask<Void, Void, String?>() where T : AppCompatActivity, T : HTTPTask.Listener {
interface Listener {
fun didFinishedHTTPTask(result:String?)
var delegate = WeakReference(activity)
override fun doInBackground(vararg params: Void): String? {
return client.request()
View echo.php
$name = $_POST["name"];
$body = $_POST["body"];
if($name && $body) {
echo $name."\n".$body;
} else {
echo "Hello Getter!";
View MainActivity.kt
class MainActivity : AppCompatActivity(), HTTPTask.Listener {
override fun onCreate(savedInstanceState: Bundle?) {
val button1 = findViewById<Button>(
button1.setOnClickListener {
View build.gradle
dependencies {
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation ''
View jojo.json
"stand":"The World"
View MainActivity.kt
package com.apppppp.retrofitsample
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.widget.TextView
import retrofit2.Call
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
View TouchableFragment.kt
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_touchable, container, false)
return view
View TouchableFragment.kt
private var yPrec = 0.0f
override fun onTouch(v: View?, event: MotionEvent?): Boolean {
when (event?.actionMasked) {
MotionEvent.ACTION_DOWN -> {
yPrec = event.getY(0)
MotionEvent.ACTION_MOVE -> {
val dy = yPrec - event.getY(0)
You can’t perform that action at this time.