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 soja0524@gmail.com
* @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 서버로 업그레이드를 시켜줍니다.