ganghee / android_pattern Goto Github PK
View Code? Open in Web Editor NEWRepository, MVP, MVVM, AAC, Koin
Repository, MVP, MVVM, AAC, Koin
binding = DataBindingUtil.inflate(inflater,R.layout.fragment_upbit,container,false)
fun onPause(){
compositeDisposable.clear()
}
여기에 하는 것이 맞을까?
let, with, apply, run, also 각각의 키워드들을 어떻게 구분하여 사용해야 하는가?
compositeDisposable.add(
jsonApi.getTickers("KRW-BTC, KRW-DASH, KRW-ETH, KRW-NEO, KRW-MTL" +
", KRW-LTC, KRW-STRAT, KRW-XRP, KRW-ETC, KRW-OMG")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ marketList ->
displayData(marketList)
}, {
Toast.makeText(context, it.message, Toast.LENGTH_LONG).show()
})
)
class UpbitHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var coinName: TextView = itemView.tv_coin_name
var tradePrice: TextView = itemView.tv_trade_price
var signedChangeRate: TextView = itemView.tv_signed_change_rate
var accTradePrice24th: TextView = itemView.tv_acc_trade_price_24h
...
}
//색이 바뀌지 않음
if(dataList[position].signed_change_rate > 0){
holder.signed_change_rate.textColor = ContextCompat.getColor(ctx, R.color.diff_up)
}else if (dataList[position].signed_change_rate < 0){
holder.signed_change_rate.textColor = ContextCompat.getColor(ctx, R.color.diff_down)
}else{
holder.signed_change_rate.textColor = ContextCompat.getColor(ctx, R.color.black)
class TickerAdapter(private var ctx: Context, private var dataList: List<TickerResponse>) :
RecyclerView.Adapter<TickerAdapter.Holder>() {
...
}
contract 인터페이스에는 view인터페이스와 presenter인터페이스가 있다.
이러한 인터페이스에 mothod들을 많이 만들어 구체화하는 것이 좋을까?
Fragment갯수가 고정되어있는 경우 FragmentPagerAdapter와 FragmentStatePagerAdapter중 어느것을 써야할까?
android:text="@{item.toAccTradePrice24h}"
를 사용하면 binding 되지 않는다. 이를 어떻게 해결하면 좋을까?
class UpbitHolder(private val binding: RvItemListBinding) : RecyclerView.ViewHolder(binding.root) {
override fun getItem(p0: Int): Fragment {
return when(p0) {
0 -> getKoreanFragment()
1 -> getBitcoinFragment()
2 -> getEthereumFragment()
3 -> getTetherFragment()
}
}
변수를 초기화 할 때
lateinit var sampleAdapter: SampleAdapter
...
sampleAdapter = SampleAdapter(ImageLoaderAdapterViewModel(this,3)
val sampleAdapter: SampleAdapter by lazy {
SampleAdapter(ImageLoaderAdapterViewModel(this, 3))
}
어느 것을 쓰는 게 맞을까?
@SuppressLint("CheckResult")
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
repository.getMarket()
.subscribe { it ->
repository.getTicker(it)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map {
it.filter {TickerResponse ->
TickerResponse.market.split("-")[0] == firstMarket
}
}
.subscribe({
displayData(it)
}, {
})
}
}
private fun displayData(posts: List<TickerResponse>?) {
posts?.let {
val tickerList = mutableListOf<FormatTickers>()
posts.forEach{
tickerList.add(
it.toTicker(requireContext())
)
}
rv_tickers.adapter = TickerAdapter(ctx, tickerList)
rv_tickers.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false)
}
}
ViewPagerAdapter.kt
override fun getItem(p0: Int): Fragment {
return when (p0) {
0 -> UpbitFragment("KRW")
1 -> UpbitFragment("BTC")
2 -> UpbitFragment("ETH")
3 -> UpbitFragment("USDT")
else -> null
}!!
}
class TickerAdapter(private var ctx: Context, private var dataList: List<TickerResponse>) :
RecyclerView.Adapter<TickerAdapter.Holder>() {
...
override fun onBindViewHolder(holder: Holder, position: Int) {
...
}
...
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.