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 2012 Google Inc. | |
* | |
* 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
/* | |
* Copyright (C) 2006 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 java.io.Serializable; | |
public class Singleton implements Serializable { | |
private static volatile Singleton sInstance; | |
private Singleton() { | |
if (sInstance != null) { | |
throw new RuntimeException("Use getInstace() method to instantiate.") | |
} |
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.yipl.myapplication; | |
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.Comparator; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.LinkedHashMap; | |
import java.util.LinkedList; | |
import java.util.List; |
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 HeaderInterceptor | |
implements Interceptor { | |
@Override | |
public Response intercept(Chain chain) | |
throws IOException { | |
Request request = chain.request(); | |
request = request.newBuilder() | |
.addHeader("appid", "hello") | |
.addHeader("deviceplatform", "android") | |
.removeHeader("User-Agent") |
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 fun displayLocationSettingsRequest(context: Context) { | |
var googleApiClient = GoogleApiClient.Builder(context) | |
.addApi(LocationServices.API).build(); | |
googleApiClient.connect(); | |
var locationRequest = LocationRequest.create(); | |
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); | |
locationRequest.setInterval(30 * 1000); | |
locationRequest.setFastestInterval(5 * 1000); |
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 onActivityResult(final int requestCode, int resultCode, final Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
switch (requestCode) { | |
case REQUEST_TAKE_PICTURE: | |
try { | |
Uri uri = getImageUri(Profile.this, ((Bitmap) data.getExtras().get("data"))); | |
if (uri != null) { | |
InputStream iStream = getContentResolver().openInputStream(uri); | |
byte[] inputData = getBytes(iStream); |
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.util.Log; | |
public class Logger { | |
public static void d(String tag, String message) { | |
if (BuildConfig.DEBUG) Log.d(tag, message); | |
} | |
public static void e(String tag, String message) { | |
if (BuildConfig.DEBUG) Log.d(tag, message); | |
} |
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
//radapter | |
class $adapter$ : androidx.recyclerview.widget.RecyclerView.Adapter<$adapter$.ViewHolder>() { | |
var data: MutableList<$model$> = mutableListOf() | |
set(value) { | |
field = value | |
notifyDataSetChanged() | |
} | |
override fun onCreateViewHolder(parent: android.view.ViewGroup, viewType: Int): ViewHolder = |
OlderNewer