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
private fun RecyclerView.smoothScrollToPositionWithOffset(position: Int, offset: Int) { | |
if (position < 0 || position >= (adapter?.itemCount ?: 0)) return | |
val linearSmoothScroller = object : LinearSmoothScroller(context) { | |
override fun onTargetFound(targetView: View, state: RecyclerView.State, action: Action) { | |
super.onTargetFound(targetView, state, action) | |
val dx = calculateDxToMakeVisible(targetView, horizontalSnapPreference) | |
val dy = calculateDyToMakeVisible(targetView, SNAP_TO_START) | |
val distance = sqrt((dx * dx + dy * dy).toDouble()).toInt() |
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.filipkowicz.headeritemdecorator | |
/* | |
solution based on - based on Sevastyan answer on StackOverflow | |
changes: | |
- take to account views offsets | |
- transformed to Kotlin | |
- now works on viewHolders |
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
class EllipsizeTextView @JvmOverloads constructor( | |
context: Context, attrs: AttributeSet? = null | |
) : AppCompatTextView(context, attrs) { | |
override fun onDraw(canvas: Canvas?) { | |
// maxLines 를 넘어갈 경우만 처리 | |
if( lineCount >= maxLines ) { | |
val charSequence = text | |
val lastCharDown = layout.getLineVisibleEnd(maxLines - 1) | |
if( charSequence.length > lastCharDown ) { | |
val ssb = SpannableStringBuilder() |
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
val desLng = 126.978390 | |
val desLat = 37.303638 | |
val title = "목적" | |
// 구글맵 길찾기 | |
private fun findGoogleMap() { | |
Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:q=$desLat, $desLng&title=$title")).apply { | |
`package` = "com.google.android.apps.maps" | |
}.let { | |
startActivity(it) |
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
/* | |
* Copyright 2019 Google LLC | |
* | |
* 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 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
<?xml version="1.0" encoding="utf-8"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > | |
<!-- Drop Shadow Stack --> | |
<item> | |
<shape> | |
<padding | |
android:bottom="1dp" | |
android:left="1dp" | |
android:right="1dp" |