Skip to content

Instantly share code, notes, and snippets.

Avatar

Ted Park ParkSangGwon

View GitHub Profile
View handleDeepLink.kt
View handleDeepLinkWithSkipMain.kt
private fun handleDeepLink() {
val deepLinkUri = intent.data
logd("deepLinkUri: $deepLinkUri")
val deepLinkIntent = deepLinkUri?.let {
DeepLinkInfo.invoke(deepLinkUri).getIntent(this, it)
} ?: DeepLinkInfo.getMainIntent(this)
if (isTaskRoot) {
TaskStackBuilder.create(this).apply {
if (needAddMainForParent(deepLinkIntent)) {
addNextIntentWithParentStack(DeepLinkInfo.getMainIntent(this@SchemeActivity))
View DeepLinkInfo.kt
enum class DeepLinkInfo(@StringRes val hostStringResId: Int) {
MAIN(R.string.scheme_host_main) {
override fun getIntent(context: Context, deepLinkUri: Uri) =
getMainIntent(context)
},
DETAIL(R.string.scheme_host_detail) {
override fun getIntent(context: Context, deepLinkUri: Uri) =
DetailActivity.getIntent(context, deepLinkUri)
View TedContentProvider.kt
class TedContentProvider : ContentProvider() {
override fun onCreate(): Boolean {
Log.d("ted", "TedContentProvider::onCreate")
val application = context as Application
Stetho.initializeWithDefaults(application)
startKoin {
androidContext(application)
}
View QuickReturnFooterBehavior
public class QuickReturnFooterBehavior extends CoordinatorLayout.Behavior<View> {
private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator();
private static final long ANIMATION_DURATION = 200;
private int dyDirectionSum;
private boolean isShowing;
private boolean isHiding;
public QuickReturnFooterBehavior(Context context, AttributeSet attrs) {
View NotificationChannelCreate.java
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel = new NotificationChannel("channel_id", "channel_name", NotificationManager.IMPORTANCE_DEFAULT);
notificationChannel.setDescription("channel description");
notificationChannel.enableLights(true);
notificationChannel.setLightColor(Color.GREEN);
notificationChannel.enableVibration(true);
notificationChannel.setVibrationPattern(new long[]{100, 200, 100, 200});
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationManager.createNotificationChannel(notificationChannel);
View ClearEditText.java
/**
* Created by TedPark on 16. 4. 11..
*/
public class ClearEditText extends AppCompatEditText implements TextWatcher, View.OnTouchListener, View.OnFocusChangeListener {
private Drawable clearDrawable;
private OnFocusChangeListener onFocusChangeListener;
private OnTouchListener onTouchListener;
View marker_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:id="@+id/tv_marker"
View NotificationChannel.java
android.app.NotificationManager notificationManager = (android.app.NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channelMessage = new NotificationChannel("channel_id", "channel_name", android.app.NotificationManager.IMPORTANCE_DEFAULT);
channelMessage.setDescription("channel description");
channelMessage.enableLights(true);
channelMessage.setLightColor(Color.GREEN);
channelMessage.enableVibration(true);
channelMessage.setVibrationPattern(new long[]{100, 200, 100, 200});
channelMessage.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationManager.createNotificationChannel(channelMessage);
View ObjectUtils
public class ObjectUtils {
public static boolean isEmpty(Object s) {
if (s == null) {
return true;
}
if ((s instanceof String) && (((String)s).trim().length() == 0)) {
return true;
}
if (s instanceof Map) {