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
import kotlin.math.ln | |
import kotlin.math.pow | |
fun colorTemperatureToRGB(kelvin: Int): Triple<Float, Float, Float> { | |
val temp = kelvin / 100.0 | |
val red: Double | |
val green: Double | |
val blue: Double |
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
// | |
// at domain layer | |
// | |
class FizzBuzzNumber(private val number: Int) { | |
fun expression(): String { | |
val isMul3 = number % 3 == 0 | |
val isMul5 = number % 5 == 0 | |
return when { |
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
// | |
// https://twitter.com/yanzm/status/1096312798412328970 | |
// | |
//「3の倍数のときは fizz が返る」 | |
//「5の倍数のときは buzz が返る」 | |
//「3の倍数かつ5の倍数のときは fizzbuzz が返る」 | |
//「3の倍数でも5の倍数でもないときはそのままの数字が返る」 | |
// は | |
// ① Entity または ValueObject(Clean Architecture だと Entities に入る)がもつロジックだと思う | |
// ② DomainService (これも Clean Architecture だと Entities に入る)だと思う |
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
// | |
// DroidKaigi 2019 の 「ぼくのかんがえた最強の Usecase の作り方」 https://www.youtube.com/watch?v=bw8bckLSKiM | |
// というセッションで出てきたビジネスロジックの実装を考えてみました。 | |
// | |
// - 設定が有効なら救急の番号には Prefix をつけない | |
// - 設定が有効ならフリーダイアルの番号には Prefix をつけない | |
// - 無視リストの宛先には Prefix をつけない | |
// | |
data class PhoneNumber(private val number: String) { | |
init { |
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 MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val metrics = resources.displayMetrics | |
val widthMeasureSpec = | |
View.MeasureSpec.makeMeasureSpec(metrics.widthPixels, View.MeasureSpec.AT_MOST) |
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
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
final RecyclerView recyclerView = new RecyclerView(this); | |
setContentView(recyclerView); | |
recyclerView.setHasFixedSize(true); |
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
private static final String PREF_SIZE_KEY = "pref_size_key"; | |
public static void saveSize(@NonNull Context context, @Nullable Size size) { | |
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context); | |
final SharedPreferences.Editor editor = pref.edit(); | |
if (size == null) { | |
editor.remove(PREF_SIZE_KEY); | |
} else { | |
editor.putInt(PREF_SIZE_KEY, size.getValue()); | |
} |
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
/** | |
* サイズId値を保持するクラス | |
* <p/> | |
* 値がセットされていない状態を持つ | |
*/ | |
public class SizeId { | |
public static final int VALID_SIZE1 = 1; | |
public static final int VALID_SIZE2 = 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
/** | |
* サイズId値を保持するクラス | |
* <p/> | |
* 値がセットされていない状態を持つ | |
*/ | |
public class ValidatableSize { | |
public static final int VALID_SIZE1 = 1; | |
public static final int VALID_SIZE2 = 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
package net.yanzm.profileapplication; | |
import android.animation.Animator; | |
import android.animation.AnimatorListenerAdapter; | |
import android.animation.AnimatorSet; | |
import android.animation.ObjectAnimator; | |
import android.app.Activity; | |
import android.app.FragmentManager; | |
import android.content.Intent; | |
import android.net.Uri; |
NewerOlder