Skip to content

Instantly share code, notes, and snippets.

View zerobranch's full-sized avatar

Arman Sargsyan zerobranch

View GitHub Profile
@zerobranch
zerobranch / Main.java
Last active March 15, 2021 20:25
reverseLinkedList
public class Main {
public static void main(String[] args) {
new Main().modeMain();
}
private void modeMain() {
Node head = getNodes();
print(head);
@zerobranch
zerobranch / radio_button.xml
Created September 5, 2020 13:17
Custom radio button
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0.8"
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
android:drawablePadding="16dp"
@zerobranch
zerobranch / AppLauncher.kt
Created September 5, 2020 13:04
AppLauncher
class AppLauncher @Inject constructor(
private val launchUseCase: LaunchUseCase,
private val router: Router
) {
fun launch() {
val rootScreen =
if (launchUseCase.hasAccount) Screens.Home
else Screens.Auth
if (launchUseCase.isFirstLaunch) {
@zerobranch
zerobranch / AndroidManifest.xml
Last active February 5, 2021 11:35
Android push notification handler
<service
android:name=".services.FirebaseMessageService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
@zerobranch
zerobranch / ripple_background.xml
Created September 5, 2020 12:50
Ripple background
<?xml version="1.0" encoding="utf-8"?>
<ripple
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="#f7f7f7" />
<corners android:radius="10dp" />
</shape>
@zerobranch
zerobranch / RoundedTextView.java
Created April 13, 2019 17:58
RoundedTextView is a TextView that allows to specify parameters such as the border, the radius of the element, etc., directly from the layout.
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Arman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@zerobranch
zerobranch / ProgressTextView.java
Last active February 27, 2019 19:30
ProgressTextView is a FrameLayout consisting of TextView and ProgressBar elements. It displays either text or download animation. It is also possible to specify the border of the element (color, width, radius) directly from the layout.
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Arman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@zerobranch
zerobranch / App.java
Created October 4, 2018 08:36
Class allows to catch all exceptions
import android.app.Application;
import timber.log.Timber;
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
if (BuildConfig.DEBUG) {
@zerobranch
zerobranch / CustomTypefaceSpan.java
Created October 4, 2018 08:34
SpannableUtils allows you to format a different part of a text
import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextPaint;
import android.text.style.TypefaceSpan;
public class CustomTypefaceSpan extends TypefaceSpan {
private final Typeface newType;
public CustomTypefaceSpan(String family, Typeface type) {
super(family);
@zerobranch
zerobranch / KeyboardVisibilityUtils.java
Created October 4, 2018 08:27
Keyboard visibility utils
import android.app.Activity;
import android.view.View;
import android.view.ViewTreeObserver;
public class KeyboardVisibilityUtils {
private int appHeight;
private final View contentView;
private ViewTreeObserver.OnGlobalLayoutListener layoutListener;
public KeyboardVisibilityUtils(Activity activity) {