This file contains hidden or 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
| /** | |
| * This is the implementation Haversine Distance Algorithm between two places | |
| * @author ananth | |
| * R = earth’s radius (mean radius = 6,371km) | |
| Δlat = lat2− lat1 | |
| Δlong = long2− long1 | |
| a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) | |
| c = 2.atan2(√a, √(1−a)) | |
| d = R.c | |
| * |
This file contains hidden or 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 com.androidfu.nowplaying.app.util.Log; | |
| import com.androidfu.nowplaying.app.util.Preconditions; | |
| import com.jakewharton.byteunits.DecimalByteUnit; | |
| import com.squareup.okhttp.Cache; | |
| import com.squareup.okhttp.OkHttpClient; | |
| import java.io.File; | |
| import java.io.IOException; |
This file contains hidden or 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.androidfu.nowplaying.app.api; | |
| import android.content.Context; | |
| import com.androidfu.nowplaying.app.util.Log; | |
| import com.androidfu.nowplaying.app.util.Preconditions; | |
| import com.jakewharton.byteunits.DecimalByteUnit; | |
| import com.squareup.okhttp.Cache; | |
| import com.squareup.okhttp.OkHttpClient; |
This file contains hidden or 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
| <receiver | |
| android:name=".DownloadBroadcastReceiver" | |
| android:exported="true"> | |
| <intent-filter> | |
| <action android:enabled="true" android:name="android.intent.action.DOWNLOAD_COMPLETE" /> | |
| </intent-filter> | |
| </receiver> |
This file contains hidden or 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 MyApplication extends Application { | |
| public static final PushConfig.Environment ENVIRONMENT = PushConfig.Environment.PROD; // can also be .QA | |
| private static final String TAG = "MyApplication"; | |
| @Override | |
| public void onCreate() { | |
| super.onCreate(); | |
| final PushConfig pushConfig = ENVIRONMENT.getPushConfig(); | |
| String appId = pushConfig.etAppId; |
This file contains hidden or 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.support.annotation.CheckResult; | |
| import android.support.annotation.NonNull; | |
| import android.support.annotation.Size; | |
| import android.support.v4.app.ActivityCompat; | |
| import static android.content.pm.PackageManager.PERMISSION_GRANTED; | |
| public class ActivityPermissionDelegate { | |
| public interface PermissionRationaleRetryBehavior { |
This file contains hidden or 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 onCreate(Bundle savedInstanceState) { | |
| ... | |
| BarcodeLoggerActivityPermissionsDispatcher.startBarcodeCaptureWithCheck(this); | |
| } | |
| @NeedsPermission(Manifest.permission.CAMERA) | |
| void startBarcodeCapture() { | |
| int orientation = WindowManagerHelper.getCurrentAccurateOrientation(this); | |
| Intent intent = CaptureActivity.buildIntent(this, orientation); |
This file contains hidden or 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
| // annotation processor will generate DevicePhoneNumberSumType (see: 4_DevicePhoneNumberSumType.java) | |
| @SumType | |
| public interface DevicePhoneNumber { | |
| String phoneNumber(); | |
| void phoneNumberNotAvailable(); | |
| String[] permissionsRequired(); | |
| } |
This file contains hidden or 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 DupeChecker { | |
| public boolean allDuplicateChars(final String input) { | |
| if (input == null || input.length() == 0) { | |
| return false; | |
| } | |
| String firstChar = input.substring(0,1); | |
| String matchingChars[] = input.split(firstChar + "+"); | |
| return matchingChars.length == 0; | |
| } | |
| } |
This file contains hidden or 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
| apply plugin: 'com.android.library' | |
| android { | |
| compileSdkVersion 'Google Inc.:Google APIs:22' | |
| Properties localProps = new Properties() | |
| localProps.load(new FileInputStream(file('../local.properties'))) | |
| def buildToolVer = file("${localProps['sdk.dir']}/build-tools/").listFiles().sort().reverse().first().name; | |
| buildToolsVersion buildToolVer; |