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
private enum ActionDrawableState{ | |
BURGER, ARROW | |
} | |
private static void toggleActionBarIcon(ActionDrawableState state, final ActionBarDrawerToggle toggle, boolean animate){ | |
if(animate) { | |
float start = state == ActionDrawableState.ARROW ? 0f : 1.0f; | |
final float end = Math.abs(start - 1); | |
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { | |
ValueAnimator offsetAnimator = ValueAnimator.ofFloat(start, end); | |
offsetAnimator.setDuration(300); |
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.content.Context; | |
import android.content.res.TypedArray; | |
import android.os.Parcelable; | |
import android.support.annotation.NonNull; | |
import android.support.design.widget.CoordinatorLayout; | |
import android.support.v4.view.WindowInsetsCompat; | |
import android.text.TextUtils; | |
import android.util.AttributeSet; | |
import android.view.MotionEvent; |
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
/* | |
* Copyright 2014 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 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 Observable<DiffUtil.DiffResult> getAllStoreProducts(final List<Product> oldData) { | |
return mApi.getAllStores().flatMap(new Func1<List<Store>, Observable<Store>>() { | |
@Override | |
public Observable<Store> call(List<Store> stores) { | |
return Observable.from(stores); | |
} | |
}).flatMap(new Func1<Store, Observable<List<Product>>>() { | |
@Override | |
public Observable<List<Product>> call(Store store) { | |
return mApi.getStoreProducts(store.getStoreId()); |
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.example.androidthings.myproject; | |
import android.os.Handler; | |
import android.os.Looper; | |
import com.google.android.things.pio.Gpio; | |
import com.google.android.things.pio.GpioCallback; | |
import java.io.IOException; |
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 class RecyclerViewClickListener implements RecyclerView.OnItemTouchListener { | |
private final OnItemClickedListener mListener; | |
private final GestureDetector mGestureDetector; | |
public RecyclerViewClickListener(Context context, OnItemClickedListener onItemClickListener) { | |
mListener = onItemClickListener; | |
GestureDetector.OnGestureListener gestureListener = new RecyclerViewGestureListener(); | |
mGestureDetector = new GestureDetector(context, gestureListener); | |
} |
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.arch.lifecycle.ViewModel; | |
import android.arch.lifecycle.ViewModelProvider; | |
import android.arch.lifecycle.ViewModelStore; | |
import android.arch.lifecycle.ViewModelStores; | |
import android.support.annotation.MainThread; | |
import android.support.v4.app.Fragment; | |
import android.support.v4.app.FragmentActivity; | |
import android.util.Log; | |
import java.lang.reflect.InvocationTargetException; |
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 class CameraAvailabilityPreLolipop extends CameraAvailability implements Runnable { | |
private final ActivityManager mActivityManager; | |
private final Handler mHandler; | |
private final PackageManager mPackageManager; | |
private final static Intent CAMERA_INTENT = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
private final List<ResolveInfo> mCameraIntents; | |
private OnCameraReleasedListener mListener; | |
public CameraAvailabilityPreLolipop(Context context) { | |
mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); |
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 class CameraAvailabilityLollipop extends CameraAvailability { | |
private OnCameraReleasedListener mListener; | |
private String mCurrentCamera; | |
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
public CameraAvailabilityLollipop(Context context) { | |
final CameraManager cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE); | |
cameraManager.registerAvailabilityCallback(new CameraManager.AvailabilityCallback() { | |
@Override | |
public void onCameraAvailable(@NonNull String cameraId) { |