2018-01-14 22:47:42 +01:00
|
|
|
package jp.juggler.subwaytooter.util
|
|
|
|
|
|
|
|
import android.view.ViewManager
|
2021-11-08 12:05:03 +01:00
|
|
|
import androidx.appcompat.view.ContextThemeWrapper
|
2021-11-18 18:09:22 +01:00
|
|
|
import androidx.appcompat.widget.AppCompatButton
|
2019-10-05 14:28:04 +02:00
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
2021-11-08 12:05:03 +01:00
|
|
|
import com.google.android.flexbox.FlexboxLayout
|
2019-10-05 14:28:04 +02:00
|
|
|
import com.omadahealth.github.swipyrefreshlayout.library.SwipyRefreshLayout
|
2021-11-08 12:05:03 +01:00
|
|
|
import jp.juggler.subwaytooter.R
|
2019-10-05 14:28:04 +02:00
|
|
|
import jp.juggler.subwaytooter.view.*
|
2018-01-14 22:47:42 +01:00
|
|
|
import org.jetbrains.anko.custom.ankoView
|
|
|
|
|
|
|
|
// Anko Layout中にカスタムビューを指定する為に拡張関数を定義する
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.myNetworkImageView(init: MyNetworkImageView.() -> Unit): MyNetworkImageView {
|
|
|
|
return ankoView({ MyNetworkImageView(it) }, theme = 0, init = init)
|
2018-01-14 22:47:42 +01:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.myTextView(init: MyTextView.() -> Unit): MyTextView {
|
|
|
|
return ankoView({ MyTextView(it) }, theme = 0, init = init)
|
2018-01-14 22:47:42 +01:00
|
|
|
}
|
2021-11-08 12:05:03 +01:00
|
|
|
|
2021-11-08 11:04:30 +01:00
|
|
|
inline fun ViewManager.myEditText(init: MyEditText.() -> Unit): MyEditText {
|
|
|
|
return ankoView({ MyEditText(it) }, theme = 0, init = init)
|
|
|
|
}
|
2021-11-08 12:05:03 +01:00
|
|
|
|
2021-11-18 18:09:22 +01:00
|
|
|
inline fun ViewManager.compatButton(init: AppCompatButton.() -> Unit): AppCompatButton {
|
|
|
|
return ankoView({ AppCompatButton(it) }, theme = 0, init = init)
|
2021-11-08 11:04:30 +01:00
|
|
|
}
|
2018-01-14 22:47:42 +01:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.trendTagHistoryView(init: TagHistoryView.() -> Unit): TagHistoryView {
|
|
|
|
return ankoView({ TagHistoryView(it) }, theme = 0, init = init)
|
2018-05-30 07:18:45 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.blurhashView(init: BlurhashView.() -> Unit): BlurhashView {
|
|
|
|
return ankoView({ BlurhashView(it) }, theme = 0, init = init)
|
2019-05-05 06:41:13 +02:00
|
|
|
}
|
2019-10-05 14:28:04 +02:00
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.maxHeightScrollView(init: MaxHeightScrollView.() -> Unit): MaxHeightScrollView {
|
|
|
|
return ankoView({ MaxHeightScrollView(it) }, theme = 0, init = init)
|
2019-10-05 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.swipyRefreshLayout(init: SwipyRefreshLayout.() -> Unit): SwipyRefreshLayout {
|
|
|
|
return ankoView({ SwipyRefreshLayout(it) }, theme = 0, init = init)
|
2019-10-05 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.recyclerView(init: RecyclerView.() -> Unit): RecyclerView {
|
|
|
|
return ankoView({
|
|
|
|
RecyclerView(ContextThemeWrapper(it, R.style.recycler_view_with_scroll_bar))
|
|
|
|
}, theme = 0, init = init)
|
2019-10-05 14:28:04 +02:00
|
|
|
}
|
|
|
|
|
2021-06-20 15:12:25 +02:00
|
|
|
inline fun ViewManager.flexboxLayout(init: FlexboxLayout.() -> Unit): FlexboxLayout {
|
|
|
|
return ankoView({ FlexboxLayout(it) }, theme = 0, init = init)
|
2021-05-21 10:20:14 +02:00
|
|
|
}
|