Skip to content

Instantly share code, notes, and snippets.

tagFriendsTitle.text = SpannableStringBuilder("tag friend").apply {
setSpan(object : ClickableSpan() {
override fun onClick(widget: View?) {
Log.d("vorobeisj", "click on header")
}
}, 0, 9, 0)
}
tagFriendsTitle.movementMethod = LinkMovementMethod.getInstance()
http://archana-testing.blogspot.com/2016/02/calling-google-translation-api-in-java.html
@vorobeij
vorobeij / Diff.kt
Created July 12, 2018 17:00
Diff string
class StringDifference(sw: String, sn: String, cursorStartBefore: Int = 0, cursorEndBefore: Int = 0, cursorStartAfter: Int = 0, cursorEndAfter: Int = 0) {
var start: Int = 0
var count: Int = 0
var after: Int = 0
var added: Int = 0
get() = if (count == 0) after else 0
var removed = 0
get() = if (after == 0) count else 0
@vorobeij
vorobeij / activity.kt
Last active June 30, 2018 06:31
android webview
package au.sj.sparrow.adblockwebview
import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
@vorobeij
vorobeij / activity.kt
Last active June 23, 2018 11:34
vector drawable animations
package com.alexjlockwood.example.delight;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@vorobeij
vorobeij / layout.xml
Last active May 23, 2018 15:21
nestedscrollview recycler header footer
android:descendantFocusability="blocksDescendants":
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/nestedContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@vorobeij
vorobeij / Adapter.kt
Created May 20, 2018 17:53
Recycler view adapter
class GalleryAdapter(var items:List<DataHolder>) : Adapter<GalleryAdapter.ViewHolder>() {
override fun onBindViewHolder(holder: ViewHolder,
position: Int) {
TODO("not implemented") // File | Settings | File Templates.
}
override fun getItemCount(): Int = items.size
override fun onCreateViewHolder(parent: ViewGroup,
viewType: Int): ViewHolder {
@vorobeij
vorobeij / layout.xml
Last active May 13, 2018 19:56
swipe to refresh
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/rssSwipeRefreshContainer"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
// layouts to refresh
@vorobeij
vorobeij / DataHolder.kt
Last active October 27, 2021 15:30
room android
@Entity(tableName = "rss_feeds")
class DataHolder(@PrimaryKey(autoGenerate = false)
@ColumnInfo(name = "link")
var link: String,
@ColumnInfo(name = "title")
var title: String,
@ColumnInfo(name = "date")
var date: Long,
@ColumnInfo(name = "img_url")
var imgUrl: String = "",
rssdetWebView.loadUrl(rssItem.link)
rssdetWebView.webChromeClient = object : WebChromeClient() {
override fun onProgressChanged(view: WebView?,
newProgress: Int) {
progressBar.progress = newProgress
if (progress == 100) progressBar.visibility = View.GONE
else progressBar.visibility = View.VISIBLE
}
}