Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0
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 getDataSource from '../dataSource'; | |
import { ListingStatus, Property } from '../entities/Property'; | |
import log from '../logger'; | |
import fetch from 'node-fetch'; | |
import { IsNull } from 'typeorm'; | |
//@ts-ignore <- fight me | |
import { google } from 'googleapis'; | |
// Enable the Indexing API here: |
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 2015 Bartosz Lipinski | |
* | |
* 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
// GSON can parse the data. | |
// | |
// Deserialization: | |
// Note there is a bug in GSON 2.3.1 that can cause it to StackOverflow when working with RealmObjects. | |
// To work around this, use the ExclusionStrategy below or downgrade to 1.7.1 | |
// See more here: https://code.google.com/p/google-gson/issues/detail?id=440 | |
// | |
// Serialization: | |
// <Type>RealmProxy objects are created by the Realm annotation processor. They are used to control | |
// access to the actual data instead of storing them in fields and it is therefore them we need to register a |
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
/** | |
* Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
* both of these conditions are already true. If you deployed from the IDE, however, this will | |
* save you from hundreds of power button presses and pattern swiping per day! | |
*/ | |
public static void riseAndShine(Activity activity) { | |
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
PowerManager.WakeLock lock = |
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.graphics.Canvas; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.util.AttributeSet; | |
import android.view.View; |
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 static class HideExtraOnScroll extends RecyclerView.OnScrollListener{ | |
final static Interpolator ACCELERATE = new AccelerateInterpolator(); | |
final static Interpolator DECELERATE = new DecelerateInterpolator(); | |
WeakReference<View> mTarget; | |
HideExtraOnScrollHelper mScrollHelper; | |
boolean isExtraObjectsOutside; |
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 javax.xml.xpath.XPathConstants | |
import javax.xml.xpath.XPathFactory | |
// Set output filename of APK based on version code from manifest when doing release build | |
// Note: This script will add a couple of seconds to the build script build time | |
gradle.projectsEvaluated { | |
preReleaseBuild.doFirst { | |
android.applicationVariants.all { variant -> | |
// Check version number configured in AndroidManifest | |
if (variant.name != "release") return |
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 (C) 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
import com.google.auto.value.AutoValue; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.Target; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
/** | |
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
* <p> |
NewerOlder