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
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 -> |
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
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 |
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
/** | |
* @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'); |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
android { | |
compileSdkVersion 29 | |
buildToolsVersion "29.0.1" | |
defaultConfig { |
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
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 |
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
//Socket-io client๋ฅผ build.gradle ํ์ผ์ ์ถ๊ฐํด ์ค๋ค | |
dependencies{ | |
implementation('io.socket:socket.io-client:1.0.0') { | |
exclude group: 'org.json', module: 'json' | |
} | |
} |
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
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 ์๋ฒ๋ก ์ ๊ทธ๋ ์ด๋๋ฅผ ์์ผ์ค๋๋ค. |