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 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" |
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 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" |
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 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) { |
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 SpotDiffCallback( | |
private val old: List<Spot>, | |
private val new: List<Spot> | |
) : DiffUtil.Callback() { | |
override fun getOldListSize(): Int { | |
return old.size | |
} | |
override fun getNewListSize(): Int { |
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
data class Spot( | |
val id: Long = counter++, | |
var name: String, | |
val distance: String, | |
val url: String | |
) { | |
companion object { | |
private var counter = 0L | |
} | |
} |
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"?> | |
<!-- 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" |
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
<android.support.v4.widget.DrawerLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/drawer_layout" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<LinearLayout | |
android:orientation="vertical" | |
android:layout_width="match_parent" |
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
dependencies { | |
implementation group: 'com.pubnub', name: 'pubnub-gson', version: '4.20.0' | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | |
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'com.android.support.test:runner:1.0.2' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' |
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
export default (request) => { | |
const kvstore = require('kvstore'); | |
const xhr = require('xhr'); | |
const pubnub = require('pubnub'); | |
const message = JSON.parse(request.message); | |
console.log(message); | |
kvstore.getItem(message[1]).then((value) => { | |
var location = JSON.parse(value); | |
var distanceDelta = distance(message[2], message[3], location.lat, location.long, "K"); | |
pubnub.publish({ |
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
export default (request) => { | |
const kvstore = require('kvstore'); | |
const xhr = require('xhr'); | |
const pubnub = require('pubnub'); | |
const {location, id} = JSON.parse(request.message); | |
var people = []; | |
kvstore.set(id, {lat: location.lat, long: location.long}); | |
kvstore.getKeys().then((keys) => { | |
for(var i=0; i<keys.length;i++){ |
NewerOlder