Skip to content

Instantly share code, notes, and snippets.

@maxim-petlyuk
maxim-petlyuk / ScrollSensitiveLinkMovementMethod
Last active November 7, 2018 12:15
LinkMovementMethod class, which helps to find, highlight and handle clicks on links inside the TextView, has the issue with processing onTouch() method - if you tap on the link and try to scroll the textview, you will see that no scrolling will occur. ScrollSensitiveLinkMovementMethod has better processing touches and allows you to scroll even i…
package your_package_name;
import android.text.Layout;
import android.text.Selection;
import android.text.Spannable;
import android.text.method.LinkMovementMethod;
import android.text.method.Touch;
import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import android.widget.TextView;
@maxim-petlyuk
maxim-petlyuk / CloneView
Created August 23, 2018 10:04
Draw view from the existing original view
public class CloneView extends View {
private View mSource;
public CloneView(Context context) {
super(context);
}
public CloneView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
@maxim-petlyuk
maxim-petlyuk / PreferenceStorage
Created January 23, 2020 13:57
Util class which incapsulate work with shared preference in android
package /* your package name */
import android.content.Context
const val PREFS_FILE_NAME = "your_prefs_file_name"
class PreferenceStorage constructor(private val context: Context) {
fun save(_key: String, _value: String) {
val prefs = context.getSharedPreferences(PREFS_FILE_NAME, Context.MODE_PRIVATE)
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.ObservableTransformer
import io.reactivex.functions.Predicate
import retrofit2.Response
enum class HttpCode(val code: Int) {
UNAUTHORIZED(401)
}