Skip to content

Instantly share code, notes, and snippets.

package leetcode
import org.junit.Test
import kotlin.test.assertEquals
internal class RomanToIntegerTest {
val sut = RomanToInteger()
@Tomas13
Tomas13 / itemdecorator.kt
Created May 26, 2020 19:07
Rv Item Decorator
// Get drawable object
val mDivider = ContextCompat.getDrawable(mWatchListRcv.context, R.drawable.divider_vertical)
// Create a DividerItemDecoration whose orientation is Horizontal
val hItemDecoration = DividerItemDecoration(mWatchListRcv.context,
DividerItemDecoration.VERTICAL)
// Set the drawable on it
hItemDecoration.setDrawable(mDivider!!)
// val mDividerItemDecoration = DividerItemDecoration(mWatchListRcv.context,
// linearLayoutManager.orientation)
@Tomas13
Tomas13 / swipe.java
Created April 17, 2020 09:18
Swipe to delete for RecyclerView
// Implements swipe to delete
ItemTouchHelper helper = new ItemTouchHelper(
new ItemTouchHelper.SimpleCallback(0,
(ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT)) {
@Override
public boolean onMove(RecyclerView rV,
RecyclerView.ViewHolder viewHolder,
RecyclerView.ViewHolder target) {
return false;
}
val localDate = Date()
val localDateTimeFormat2 = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
localDateTimeFormat2.timeZone = TimeZone.getTimeZone("America/New_York")
val day = localDateTimeFormat2.format(localDate)
val localDateTime = LocalDateTime.parse(day,
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))
Timber.d("localdate is $localDateTime dayOfMonth ${localDateTime.dayOfMonth}" +
" month ${localDateTime.month} " +
" hour ${localDateTime.hour}")
items = SortedList<Watchlist>(Watchlist::class.java, object : SortedList.Callback<Watchlist>() {
override fun areItemsTheSame(item1: Watchlist?, item2: Watchlist?): Boolean {
return item1 == item2
}
override fun onMoved(fromPosition: Int, toPosition: Int) {
notifyItemMoved(fromPosition, toPosition)
}
override fun onChanged(position: Int, count: Int) {
package com.stockstotrade.ui.watchlist.singlewatchlist
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.os.Handler
import android.os.Looper
import android.os.Parcelable
import android.view.Gravity
import android.view.LayoutInflater
@Tomas13
Tomas13 / textview.kt
Created September 17, 2019 09:22
config view and return it
private fun configTextView(textView: TextView, textValue: String): TextView {
return textView.apply {
text = textValue
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
setTextAppearance(R.style.AppText_Light)
} else {
setTextAppearance(context, R.style.AppText_Light)
}
setPadding(dpToPx(10), dpToPx(10), dpToPx(10), dpToPx(10))
}
package kz.senim.ui.module.buspayment.history
import android.databinding.ObservableArrayList
import android.databinding.ObservableBoolean
import android.databinding.ObservableList
import kz.senim.common.util.delay
import kz.senim.data.api.response.PaginationPage
import kz.senim.data.api.util.ApiCaller
import kz.senim.data.entity.BusTicket
import kz.senim.data.entity.Role
package kz.senim.ui.widget
import android.content.Context
import android.databinding.BindingAdapter
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.drawable.GradientDrawable
import android.support.annotation.ColorInt
import android.support.annotation.ColorRes
import android.text.TextPaint
package kz.senim.ui.module.buspayment.common.widget
import android.content.Context
import android.databinding.BindingAdapter
import android.support.annotation.StringRes
import android.support.v7.widget.AppCompatImageView
import android.support.v7.widget.AppCompatTextView
import android.util.AttributeSet
import android.view.Gravity
import android.view.Gravity.*