Skip to content

Instantly share code, notes, and snippets.

View ekosp's full-sized avatar

Eko Setyo Purnomo ekosp

View GitHub Profile
@ekosp
ekosp / gist:c1bc60f71be24c8e0d9b9c532e5c5d3c
Created July 23, 2021 02:22 — forked from liminal/gist:8801401
Using adb over wifi with Android Tether device
# Set up adb to use tcpip port
adb tcpip 5555
# Default device ip when it's used as a portable hotspot
adb connect 192.168.43.1
# List connected devices
adb devices
@ekosp
ekosp / CutCopyPaste.java
Created May 25, 2021 05:44 — forked from guillermomuntaner/CutCopyPaste.java
EditText which notifies of Cut, Copy and Paste events via an attachable listener
import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;
/**
* Original:
* An EditText, which notifies when something was cut/copied/pasted inside it.
* @author Lukas Knuth
* @version 1.0
*
@ekosp
ekosp / haversine.kt
Created March 7, 2021 09:18 — forked from jferrao/haversine.kt
Kotlin implementation of the Haversine formula
class Geo(private val lat: Double, private val lon: Double) {
companion object {
const val earthRadiusKm: Double = 6372.8
}
/**
* Haversine formula. Giving great-circle distances between two points on a sphere from their longitudes and latitudes.
* It is a special case of a more general formula in spherical trigonometry, the law of haversines, relating the
* sides and angles of spherical "triangles".
WEBVTT
00:00:00.000 --> 00:00:02.200
Aku meyakini ada
pembunuh wanita..
00:00:02.240 --> 00:00:03.640
..beroperasi
di skala internasional.
@ekosp
ekosp / ArrayAdapter.java
Created January 16, 2021 23:48
Custom ArrayAdapter AutoCompleteTextView with contains
package com.ilisium.stokgudang.sumberrejo.helper;
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
WEBVTT
1
00:00:34.800 --> 00:00:37.200 line:0 position:20% size:60% align:start
Kau tak punya
pengalaman kerja.
2
00:00:37.320 --> 00:00:40.040 line:0 position:20% size:60% align:start
Tidak, tapi aku
1
00:00:34,800 --> 00:00:37,200
Kau tak punya
pengalaman kerja.
2
00:00:37,320 --> 00:00:40,040
Tidak, tapi aku
baru lulus dari Fordham.
@ekosp
ekosp / fragment.java
Created November 29, 2019 15:41 — forked from atoennis/fragment.java
WebViews automatically persist cookies into a android.webkit.CookieManager. Need to store cookies from a WebView into a java.net.CookieManager? Here's one way to do so.
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String cookieStr = CookieManager.getInstance().getCookie(url); // android.webkit.CookieManager
storeCookies(url, cookieStr);
return super.shouldOverrideUrlLoading(view, url);
}
// Convert cookie string into a list of cookies. Persist cookies in a java.net.CookieStore
@ekosp
ekosp / bottom_stroke.xml
Created November 23, 2019 03:18 — forked from CiTuX/bottom_stroke.xml
Android xml drawable with a bottom stroke
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:top="-6dp"
android:left="-6dp"
android:right="-6dp"
android:bottom="0dp">
<shape android:shape="rectangle">
<solid android:color="#88FFFF00"/>
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(60, TimeUnit.SECONDS)
.readTimeout(60, TimeUnit.SECONDS)
.addNetworkInterceptor(new LoggingInterceptor())
.addInterceptor(new HeaderInterceptor(mContext))
.build();
static class LoggingInterceptor implements Interceptor {