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
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"
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 SpotDiffCallback(
private val old: List<Spot>,
private val new: List<Spot>
) : DiffUtil.Callback() {
override fun getOldListSize(): Int {
return old.size
}
override fun getNewListSize(): Int {
data class Spot(
val id: Long = counter++,
var name: String,
val distance: String,
val url: String
) {
companion object {
private var counter = 0L
}
}
<?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"
<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"
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'
@nxsyed
nxsyed / CalculateDistance.js
Created February 19, 2019 19:04
Calculating Distance
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({
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++){