- ASSERT ->
#A800FF
- DEBUG ->
#3D9D2A
- ERROR ->
#D80D15
- INFO ->
#003CC8
- VERBOSE ->
#BBBBBB
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 PositionUtils { | |
public static float calculateHaversineDistance(double lat1, double lon1, double lat2, double lon2) { | |
final double p = 0.017453292519943295; // Math.PI / 180 | |
final double earthRad2 = 12742000f; // 2 * R; R = 6371 km | |
final double lat1p = lat1 * p; | |
final double lat2p = lat2 * p; | |
double a = 0.5 - Math.cos(lat2p - lat1p) / 2 + | |
Math.cos(lat1p) * Math.cos(lat2p) * | |
(1 - Math.cos((lon2 - lon1) * p)) / 2; | |
return (float) (earthRad2 * Math.asin(Math.sqrt(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
private boolean checkPlayServices() { | |
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance(); | |
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this); | |
if (resultCode != ConnectionResult.SUCCESS) { | |
if (apiAvailability.isUserResolvableError(resultCode)) { | |
apiAvailability.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST) | |
.show(); | |
} else { | |
Log.i(TAG, "This device is not supported."); | |
finish(); |
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 static Integer[] bubble(Integer[] integers) { | |
for (int curr = 0; curr < integers.length; ++curr) { | |
for (int other = curr + 1; other < integers.length; ++other) { | |
if (integers[curr] > integers[other]) { | |
int tmp = integers[curr]; | |
integers[curr] = integers[other]; | |
integers[other] = tmp; | |
} | |
} | |
} |
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 static volatile DoubleCheckedLockingSingleton sInstance; | |
public static DoubleCheckedLockingSingleton getInstance() { | |
if (sInstance == null) { | |
synchronized (DoubleCheckedLockingSingleton.class) { | |
if (sInstance == null) { | |
sInstance = new DoubleCheckedLockingSingleton(); | |
} | |
} | |
} |
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 org.reactivestreams.Publisher; | |
import io.reactivex.Flowable; | |
import io.reactivex.FlowableTransformer; | |
import io.reactivex.Observable; | |
import io.reactivex.ObservableSource; | |
import io.reactivex.ObservableTransformer; | |
import io.reactivex.android.schedulers.AndroidSchedulers; | |
import io.reactivex.schedulers.Schedulers; |
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 void openEmailAppsChooser() { | |
Intent intent = new Intent(Intent.ACTION_SENDTO); | |
intent.setData(Uri.parse("mailto:")); | |
Intent chooser = Intent.createChooser(intent, "test1"); | |
if(intent.resolveActivity(getPackageManager()) != null) { | |
startActivity(chooser); | |
} | |
} |
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
Notification notification = new NotificationCompat.Builder(this); | |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
notification.setSmallIcon(R.drawable.icon_transperent); | |
notification.setColor(getResources().getColor(R.color.notification_color)); | |
} else { | |
notification.setSmallIcon(R.drawable.icon); | |
} |
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
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | |
((ViewGroup) findViewById(R.id.llRoot)).getLayoutTransition() | |
.enableTransitionType(LayoutTransition.CHANGING); | |
} |
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
class ArchLifecycleApp : Application(), LifecycleObserver { | |
override fun onCreate() { | |
super.onCreate() | |
ProcessLifecycleOwner.get().lifecycle.addObserver(this) | |
} | |
@OnLifecycleEvent(Lifecycle.Event.ON_STOP) | |
fun onAppBackgrounded() { | |
Log.d("TAG", "App in background") |
OlderNewer