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
[~accountid:{{issue.reporter.accountId}}] |
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 'package:intl/intl.dart'; | |
extension DateTimeExtension on DateTime { | |
String toFormattedString({String format = 'yyyy/MM/dd HH:mm'}) { | |
var formatter = DateFormat(format, "ja_JP"); | |
var formatted = formatter.format(this); | |
return formatted; | |
} | |
} |
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
extension JSONDecoder{ | |
static var commonSettingInstance: JSONDecoder { | |
let decoder = JSONDecoder() | |
decoder.keyDecodingStrategy = .convertFromSnakeCase | |
decoder.dateDecodingStrategy = .iso8601 | |
return decoder | |
} | |
} |
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
struct User: Codable { | |
let name: String | |
let age: Int | |
} | |
Alamofire.request("\(endpoint)" | |
method: .get, | |
parameters: nil, | |
encoding: JSONEncoding.default, | |
headers: nil) |
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 android.content.Intent | |
fun Intent.getStringExtra(key: String, default: String): String { | |
return getStringExtra(key) ?: default | |
} | |
// getStringExtra(key, default)のエイリアス | |
fun Intent.getStringExtraWithDefaultValue(key: String, default: String = ""): String { | |
return getStringExtra(key, default) | |
} |
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
fun <T> DialogFragment.getTarget(): T? = (targetFragment ?: context) as? T | |
// 例 | |
class FooDialogFramgment: DialogFragment() { | |
private var listener: FooListener? = null | |
override fun onAttach(context: Context?) { | |
super.onAttach(context) | |
listener = getTarget() | |
} |
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
@BindingAdapter("isBold") | |
fun TextView.setIsBold(isBold: Boolean) { | |
val typeface = if (isBold) Typeface.BOLD else Typeface.NORMAL | |
setTypeface(null, typeface) | |
} | |
@BindingAdapter("textWithUnderline") | |
fun TextView.setTextWithUnderline(text: String) { | |
val spannableString = SpannableString(text) | |
spannableString.setSpan(UnderlineSpan(), 0, text.count(), 0) |
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
@BindingAdapter("isVisible") | |
fun View.setIsVisible(isVisible: Boolean) { | |
visibility = if (isVisible) View.VISIBLE else View.INVISIBLE | |
} | |
@BindingAdapter("isExist") | |
fun View.setIsExist(isExist: Boolean) { | |
visibility = if (isExist) View.VISIBLE else View.GONE | |
} |
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
val Calendar.year: Int get() = get(Calendar.YEAR) | |
val Calendar.month: Int get() = (get(Calendar.MONTH) + 1) | |
val Calendar.day: Int get() = get(Calendar.DAY_OF_MONTH) | |
private val sdf = SimpleDateFormat("yyyy年MM月dd日", Locale.JAPAN) | |
val Calendar.formattedDate: String | |
get() = sdf.format(this.time) |