Skip to content

Instantly share code, notes, and snippets.

Avatar

Ted Park ParkSangGwon

View GitHub Profile
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 handleDeepLink.kt
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 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 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);
@ParkSangGwon
ParkSangGwon / BaseActivity.java
Last active Aug 24, 2017
Progress dialog using GIF image
View BaseActivity.java
public class BaseActivity extends AppCompatActivity {
public void progressON() {
BaseApplication.getInstance().progressON(this, null);
}
public void progressON(String message) {
BaseApplication.getInstance().progressON(this, message);
}
View PaletteGlideSample.java
Glide.with(this)
.load("http://...")
.asBitmap()
.into(new BitmapImageViewTarget(ivImage) {
@Override
public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
super.onResourceReady(bitmap, anim);
Palette palette=Palette.from(bitmap).generate();
View PaletteSample.java
Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
@Override
public void onGenerated(Palette palette) {
if(palette==null)
return;
Palette.Swatch vibrantSwatch = palette.getVibrantSwatch();
if(vibrantSwatch!=null){
@ParkSangGwon
ParkSangGwon / MainActivity.java
Created Aug 10, 2016
Linkify로 TextView의 특정단어 클릭시 URL이동시키기
View MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tvLinkify = (TextView) findViewById(R.id.tvLinkify);