This file contains 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
// Intuitive Focus Extension, Kotlin, Android min 19 SDK | |
fun View.accessibilityFullFocus() { | |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) | |
requestFocus() | |
} |
This file contains 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
// Sample using RxJava 1.x, Kotlin | |
var offSwitch = false | |
Observable | |
.interval(0, 100L, TimeUnit.MILLISECONDS) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.takeIf { !offSwitch } | |
.subscribe { | |
// try to focus every 100 milliseconds until the view or any of its children is focused | |
view.accessibilityFullFocus() | |
offSwitch = view.isAccessibilityFocused || view.hasAccessibilityFocusedChild |
This file contains 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
// Kotlin, Android min 19 SDK | |
private enum class Adjustment { | |
DARKEN, | |
LIGHTEN, | |
NONE | |
} | |
fun Context.adjustTextColor(color: Int, isHighContrastEnabled: Boolean): Int { | |
if (isHighContrastEnabled) { |
This file contains 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
import android.app.Activity | |
import android.content.Context | |
import com.google.android.gms.common.api.ApiException | |
import com.google.android.gms.wallet.IsReadyToPayRequest | |
import com.google.android.gms.wallet.PaymentsClient | |
import com.google.android.gms.wallet.Wallet | |
import com.google.android.gms.wallet.WalletConstants | |
import rx.Emitter | |
import rx.Observable |
This file contains 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.instacart.library.persistence; | |
import android.content.Context; | |
import com.fasterxml.jackson.core.type.TypeReference; | |
import java.io.IOException; | |
import java.util.List; | |
public class ILJsonCollectionFile<PAYLOAD> extends ILJsonFile<List<PAYLOAD>> { |
This file contains 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
public abstract class BaseFragment extends Fragment implements ViewableFragment { | |
private boolean mHasViews; | |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
View root = inflater.inflate(getFragmentLayoutId(), null); | |
ButterKnife.inject(this, root); | |
return root | |
} |
This file contains 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
@Override protected void dispatchDraw(Canvas canvas) { | |
super.dispatchDraw(canvas); | |
if (mDragMode && mBitmap != null) { | |
//Log.v("DG", "dispatchDraw matrix " + mMatrix); | |
canvas.drawBitmap(mBitmap, mMatrix, new Paint()); | |
} | |
} |
This file contains 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
/** | |
* 引用不同的数据,会得到不同的地图切片 | |
* 卫星(无地标) WGS-84 一般 GCJ-02 | |
* <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
* 卫星(有地标) GCJ-02 一般 GCJ-02 | |
* <script src="https://ditu.google.cn/maps/api/js?v=3.exp&sensor=false"></script> | |
*/ | |
(function (map) { | |
var Converter = function () { |
This file contains 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
/** | |
* 引用不同的数据,会得到不同的地图切片 | |
* 卫星(无地标) WGS-84 一般 GCJ-02 | |
* <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> | |
* 卫星(有地标) GCJ-02 一般 GCJ-02 | |
* <script src="https://ditu.google.cn/maps/api/js?v=3.exp&sensor=false"></script> | |
*/ | |
(function (map) { | |
var Converter = function () { |
This file contains 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
// Taken from Contacts List example | |
public static int calculateMemCacheSize(float percent) { | |
if (percent < 0.05f || percent > 0.8f) { | |
throw new IllegalArgumentException("setMemCacheSizePercent - percent must be " | |
+ "between 0.05 and 0.8 (inclusive)"); | |
} | |
return Math.round(percent * Runtime.getRuntime().maxMemory() / 1024); | |
} |