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 java.lang.AssertionError | |
data class Point(val x: Float, val y: Float) | |
fun pointAt(x: Float, y: Float) = Point(x, y) | |
data class Line(val p1: Point, val p2: Point) | |
infix fun Point.to(other: Point) = Line(this, other) |
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) | |
setSupportActionBar(toolbar) | |
fab.setOnClickListener { view -> | |
main() | |
} |
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 androidx.lifecycle.LiveData | |
import androidx.lifecycle.ViewModel | |
import io.reactivex.Flowable | |
import io.reactivex.processors.BehaviorProcessor | |
import io.reactivex.schedulers.Schedulers | |
// | |
// In/Out/State | |
// |
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
// A-D blocking thread | |
fun testA() { | |
println(1) | |
Thread.sleep(1000) | |
println(2) | |
Thread.sleep(1000) | |
println(3) | |
} |
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 LoginFormFragment : Fragment() { | |
companion object { | |
fun newInstance() = LoginFormFragment() | |
} | |
override fun onCreateView( | |
inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle? |
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 judgeBMI(weight: Double, height: Double): String { | |
return when ( | |
val bmi = (height / 100) | |
.let { weight / (it * it) } | |
) { | |
in 0.0..18.5 -> "Low weight $bmi" | |
in 18.5..25.0 -> "Normal (healthy weight)" | |
in 25.0..30.0 -> "Obese Class I" | |
in 30.0..35.0 -> "Obese Class II" |
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 MainActivityFragment : androidx.fragment.app.Fragment() { | |
val viewModel = MainViewModel() | |
override fun onCreateView( | |
inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { | |
val binding = FragmentMainBinding.inflate(inflater) | |
binding.setLifecycleOwner(this) | |
binding.vm = viewModel |
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"?> | |
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> | |
<android.support.v7.widget.CardView | |
android:id="@+id/cardView" | |
xmlns:android="http://schemas.android.com/apk/res/android" |
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
package com.example.oop; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
// abstract class を継承するやり方のデモコード | |
public class Demo { | |
// このコードはデモ用のコードです。書き方についてはチーム単位や会社単位でコーディング規約があると思いますので、 | |
// 製品コードに書くときはそちらを優先してください。 | |
void demo() { |
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
package com.example.calc | |
/* | |
Copyright 2018 Pooh3Mobi@GitHub | |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | |
documentation files (the "Software"), to deal in the Software without restriction, including without limitation | |
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, | |
and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |