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 co.cdmunoz.cryptocurrencyapp.utils | |
import android.support.v7.widget.LinearLayoutManager | |
import android.support.v7.widget.RecyclerView | |
class InfiniteScrollListener( | |
val func: () -> Unit, | |
val layoutManager: LinearLayoutManager) : RecyclerView.OnScrollListener() { |
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 InfiniteScrollListener( | |
val func: () -> Unit, | |
val layoutManager: LinearLayoutManager) : RecyclerView.OnScrollListener() { | |
private var previousTotal = 0 | |
private var loading = true | |
private var visibleThreshold = 2 | |
private var firstVisibleItem = 0 | |
private var visibleItemCount = 0 | |
private var totalItemCount = 0 |
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 Constants { | |
companion object { | |
const val OFFSET = 12 | |
const val LIMIT = 12 | |
const val START_ZERO_VALUE = "0" | |
const val DATABASE_NAME = "cryptocurrencies_db" | |
const val LIST_SCROLLING = 12 | |
} | |
} |
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 CryptocurrenciesActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(layout.activity_cryptocurrencies) | |
initializeRecycler() | |
progressBar.visibility = View.VISIBLE | |
loadData() |
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 InfiniteScrollListener( | |
val func: () -> Unit, | |
val layoutManager: LinearLayoutManager) : RecyclerView.OnScrollListener() { | |
private var previousTotal = 0 | |
private var loading = true | |
private var visibleThreshold = 2 | |
private var firstVisibleItem = 0 | |
private var visibleItemCount = 0 | |
private var totalItemCount = 0 |
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 InfiniteScrollListener( | |
val func: () -> Unit, | |
val layoutManager: LinearLayoutManager) : RecyclerView.OnScrollListener() { | |
private var previousTotal = 0 | |
private var loading = true | |
private var visibleThreshold = 2 | |
private var firstVisibleItem = 0 | |
private var visibleItemCount = 0 | |
private var totalItemCount = 0 |
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="match_parent" | |
android:layout_margin="8dp" | |
tools:context="co.cdmunoz.cryptocurrencyapp.ui.list.CryptocurrenciesActivity" | |
> |
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 CryptocurrenciesAdapter( | |
cryptocurrencies: List<Cryptocurrency>?) : RecyclerView.Adapter<CryptocurrencieViewHolder>() { | |
private var cryptocurrenciesList = ArrayList<Cryptocurrency>() | |
init { | |
this.cryptocurrenciesList = cryptocurrencies as ArrayList<Cryptocurrency> | |
} | |
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): CryptocurrencieViewHolder { |
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"?> | |
<android.support.v7.widget.CardView | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/cryptocurrency_card" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_margin="@dimen/default_4dp" | |
app:cardElevation="@dimen/cardview_default_elevation" |
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
@Module | |
class AppModule(val app: Application) { | |
//...rest of the code | |
@Provides | |
@Singleton | |
fun provideUtils(): Utils = Utils(app) | |
} |