Skip to content

Instantly share code, notes, and snippets.

View nxsyed's full-sized avatar
👁️‍🗨️
Cory is officially in the house

Syed Ahmed nxsyed

👁️‍🗨️
Cory is officially in the house
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<!-- https://qiita.com/ntsk/items/dac92596742e18470a55 -->
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:foreground="?attr/selectableItemBackground"
data class Spot(
val id: Long = counter++,
var name: String,
val distance: String,
val url: String
) {
companion object {
private var counter = 0L
}
}
class SpotDiffCallback(
private val old: List<Spot>,
private val new: List<Spot>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int {
return old.size
}
override fun getNewListSize(): Int {
class CardStackAdapter(
private var spots: List<Spot> = emptyList()
) : RecyclerView.Adapter<CardStackAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
return ViewHolder(inflater.inflate(R.layout.item_spot, parent, false))
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
class MainActivity : AppCompatActivity(), CardStackListener {
private val cardStackView by lazy { findViewById<CardStackView>(R.id.card_stack_view) }
private val manager by lazy { CardStackLayoutManager(this, this) }
private val adapter by lazy { CardStackAdapter(createSpots("Welcome to Dating Swipe!", "0")) }
private val MY_PERMISSIONS_REQUESTACCESS_COARSE_LOCATION = 1
private lateinit var fusedLocationClient: FusedLocationProviderClient
private val pnConfiguration = PNConfiguration()
init {
pnConfiguration.publishKey = "YOUR-PUB-KEY"
pnConfiguration.subscribeKey = "YOUR-SUB-KEY"
class MainActivity : AppCompatActivity(), CardStackListener {
private val cardStackView by lazy { findViewById<CardStackView>(R.id.card_stack_view) }
private val manager by lazy { CardStackLayoutManager(this, this) }
private val adapter by lazy { CardStackAdapter(createSpots("Welcome to Dating Swipe!", "0")) }
private val MY_PERMISSIONS_REQUESTACCESS_COARSE_LOCATION = 1
private lateinit var fusedLocationClient: FusedLocationProviderClient
private val pnConfiguration = PNConfiguration()
init {
pnConfiguration.publishKey = "YOUR-PUB-KEY"
pnConfiguration.subscribeKey = "YOUR-SUB-KEY"