Skip to content

Instantly share code, notes, and snippets.

View soulduse's full-sized avatar
💭
🔥

Dave soulduse

💭
🔥
View GitHub Profile
@soulduse
soulduse / Volley.md
Last active August 29, 2015 14:27 — forked from benelog/Volley.md
Volley 설명

안드로이드 개발에서 많은 비중을 차지하는 UI패턴은 ListView에서 여러 이미지를 보여주는 Activity입니다. 전형적인 흐름을 정리하면 아래와 같습니다.

​1. 목록조회 API호출

​2. API를 파싱하고 ListView에 데이터를 보여 줌.

​3. 각 아이템마다의 이미지 주소로 다시 서버를 호출

​4. 이미지를 디코딩하고 ImageView에서 보여줌.

@soulduse
soulduse / JsonHelper.java
Created December 28, 2015 07:57 — forked from codebutler/JsonHelper.java
Convert Android JSONObject/JSONArray to a standard Map/List.
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.*;
public class JsonHelper {
public static Object toJSON(Object object) throws JSONException {
if (object instanceof Map) {
JSONObject json = new JSONObject();
@soulduse
soulduse / MainActivity.java
Last active March 9, 2022 11:18
Android - using GPS in the WebView
package com.dave.webviewgps;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
@soulduse
soulduse / MainActivity.java
Created September 17, 2017 11:04
Android WebView에서 GPS 사용하기 + 마시멜로우 버전 이상일 경우 권한체크 추가
package com.dave.webviewgps;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.webkit.GeolocationPermissions;
@soulduse
soulduse / ApiInterface.kt
Last active May 28, 2020 12:29
Example of usage kotlin-coroutines-retrofit
interface ApiInterface {
@GET("User")
fun getUser(
@Query("user_id") userId: String
): Deferred<User>
}
@soulduse
soulduse / CustomDialog.kt
Last active January 11, 2018 13:52
Dialog Helper with Kotlin
/**
* ex)
* CustomDialog
* .create {
* with { mContext }
* items {
* CustomDialog.Items().apply {
* message = "This is dialog message"
* positiveTitle = "Positive title"
* negativeTitle = "Negative title"
@soulduse
soulduse / CustomDialog.kt
Last active January 11, 2018 13:51
Dialog Helper with Kotlin
/**
* Created by Soulduse on 2018. 1. 11..
*
* ex)
* CustomDialog(CustomDialog.Items().apply {
* this.context = context
* this.message = "message"
* this.positiveTitle = "ok"
* this.negativeTitle = "cancel"
* }).show({
@soulduse
soulduse / SortedAndReversed.kt
Last active January 13, 2018 09:18
Getting longest one in array - Kotlin
val items = arrayOf(
longArrayOf(200, 0),
longArrayOf(95, 5, 95, 5),
longArrayOf(60, 7, 60, 7, 60, 7),
longArrayOf(43, 7, 43, 7, 43, 7, 43, 7),
longArrayOf(32, 8, 32, 8, 32, 8, 32, 8, 32, 8),
longArrayOf(25, 8, 25, 8, 25, 8, 25, 8, 25, 8, 25, 8),
longArrayOf(20, 9, 20, 9, 20, 9, 20, 9, 20, 9, 20, 9, 20, 9),
longArrayOf(16, 9, 16, 9, 16, 9, 16, 9, 16, 9, 16, 9, 16, 9, 16, 9),
longArrayOf(13, 9, 13, 9, 13, 9, 13, 9, 13, 9, 13, 9, 13, 9, 13, 9, 13, 9),
@soulduse
soulduse / GeocoderUtil.kt
Last active February 10, 2018 06:52
Geocoder util with Kotlin
import android.location.Address
import android.location.Geocoder
import java.io.IOException
/**
* Created by soulduse on 2018. 2. 10..
*/
object GeocoderUtil {
fun getAddress(lat: Double, lon: Double): String{
@soulduse
soulduse / ankoExt.kt
Created February 16, 2018 11:18
Anko Extensions
inline fun ViewManager.flexboxLayout(theme: Int = 0, init: FlexboxLayout.() -> Unit) = ankoView(::FlexboxLayout, theme, init)
inline fun ViewManager.swipeRefreshLayout(theme: Int = 0, init: SwipeRefreshLayout.() -> Unit) = ankoView(::SwipeRefreshLayout, theme, init)
inline fun ViewManager.zoomTextView(theme: Int = 0, init: ZoomTextView.() -> Unit) = ankoView(::ZoomTextView, theme, init)
inline fun ViewManager.textView(theme: Int = 0, init: TextView.() -> Unit) = ankoView(::TextView, theme, init)
inline fun ViewManager.imageView(theme: Int = 0, init: ImageView.() -> Unit) = ankoView(::ImageView, theme, init)
inline fun ViewManager.view(theme: Int = 0, init: View.() -> Unit) = ankoView(::View, theme, init)
inline fun ViewManager.button(theme: Int = 0, init: Button.() -> Unit) = ankoView(::Button, theme, init)