Skip to content

Instantly share code, notes, and snippets.

View joyceHong0524's full-sized avatar
๐ŸŽง
working my ass off

JOYCE HONG joyceHong0524

๐ŸŽง
working my ass off
  • YourCode
  • Seoul
View GitHub Profile
fun ViewPager2.setCurrentItemWithDuration(
item: Int,
duration: Long,
interpolator: TimeInterpolator = AccelerateDecelerateInterpolator(),
pagePxWidth: Int = width // Default value taken from getWidth() from ViewPager2 view
) {
val pxToDrag: Int = pagePxWidth * (item - currentItem)
val animator = ValueAnimator.ofInt(0, pxToDrag)
var previousValue = 0
animator.addUpdateListener { valueAnimator ->
@joyceHong0524
joyceHong0524 / ChatRoomActivity.kt
Last active February 21, 2023 12:40
ChatRoomActivity.kt
package com.junga.socketio_android
import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.gson.Gson
import com.junga.socketio_android.model.MessageType
import io.socket.client.IO
@joyceHong0524
joyceHong0524 / app.js
Last active September 9, 2019 10:26
node.js app
/**
* @author Joyce Hong
* @email [email protected]
* @create date 2019-09-02 20:51:10
* @modify date 2019-09-02 20:51:10
* @desc socket.io server !
*/
const express = require('express');
const bodyParser = require('body-parser');
@joyceHong0524
joyceHong0524 / build.gradle
Last active September 9, 2019 11:14
build.gradle(app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.1"
defaultConfig {
@joyceHong0524
joyceHong0524 / MainActivity.kt
Last active July 28, 2019 11:39
socket io android client coding
package com.junga.realtime
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import io.socket.client.IO
import io.socket.client.Socket
import io.socket.emitter.Emitter
import kotlinx.android.synthetic.main.activity_main.*
import org.json.JSONException
@joyceHong0524
joyceHong0524 / build.gradle
Last active July 28, 2019 11:20
Android implementation
//Socket-io client๋ฅผ build.gradle ํŒŒ์ผ์— ์ถ”๊ฐ€ํ•ด ์ค€๋‹ค
dependencies{
implementation('io.socket:socket.io-client:1.0.0') {
exclude group: 'org.json', module: 'json'
}
}
@joyceHong0524
joyceHong0524 / index.js
Last active July 28, 2019 11:12
socket.io chat server
var express = require('express')
var app = express(); // ์ด๋ฒˆ ์˜ˆ์ œ์—์„œ๋Š” express๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
var socketio = require('socket.io');
var server = app.listen(3001,()=>{
console.log('Listening at port number 3001') //ํฌํŠธ๋Š” ์›ํ•˜์‹œ๋Š” ๋ฒˆํ˜ธ๋กœ..
})
//return socket.io server.
var io = socketio.listen(server) // ์ด ๊ณผ์ •์„ ํ†ตํ•ด ์šฐ๋ฆฌ์˜ express ์„œ๋ฒ„๋ฅผ socket io ์„œ๋ฒ„๋กœ ์—…๊ทธ๋ ˆ์ด๋“œ๋ฅผ ์‹œ์ผœ์ค๋‹ˆ๋‹ค.