Skip to content

Instantly share code, notes, and snippets.

View ademar111190's full-sized avatar
Lightning Networking the Bitcoin

Ademar ademar111190

Lightning Networking the Bitcoin
  • CEO of Bitcoin
  • Itatiba
View GitHub Profile
@ademar111190
ademar111190 / BottomNavigationViewIndicator.kt
Created June 12, 2019 21:57
Step 7, the lifecycle evets
...
import android.os.Build.VERSION.SDK_INT
import android.os.Build.VERSION_CODES.LOLLIPOP
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
...
private var target: BottomNavigationMenuView? = null
...
override fun onAttachedToWindow() {
super.onAttachedToWindow()
if (targetId == NO_ID) return attachedError("invalid target id $targetId, did you set the app:targetBottomNavigation attribute?")
...
import ademar.bnindicator.R.styleable.*
import androidx.appcompat.content.res.AppCompatResources.getDrawable
class BottomNavigationViewIndicator
...
private val targetId: Int
private val backgroundDrawable: Drawable
@ademar111190
ademar111190 / activity_main.xml
Last active June 12, 2019 20:09
Step 5, setting the properties in the layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/container"
...
<ademar.bnindicator.BottomNavigationViewIndicator
...
app:clipableBackground="@color/colorPrimary"
app:targetBottomNavigation="@+id/nav_view"/>
@ademar111190
ademar111190 / attrs.xml
Created June 12, 2019 17:31
Step 4, the attr file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="BottomNavigationViewIndicator">
<attr name="targetBottomNavigation" format="reference"/>
<attr name="clipableBackground" format="reference|color"/>
</declare-styleable>
</resources>
@ademar111190
ademar111190 / BottomNavigationViewIndicator.kt
Last active June 12, 2019 20:13
Step 3, starting up the view
package ademar.bnindicator
import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.util.AttributeSet
import android.view.View
class BottomNavigationViewIndicator @JvmOverloads constructor(
context: Context,
@ademar111190
ademar111190 / ListenableBottomNavigationView.kt
Last active June 12, 2019 20:12
Step 2, finishing the ListenableBottomNavigationView
...
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.bottomnavigation.BottomNavigationView.OnNavigationItemSelectedListener
class ListenableBottomNavigationView @JvmOverloads constructor(
...
) : BottomNavigationView(context, attrs, defStyleAttr), OnNavigationItemSelectedListener {
private val onNavigationItemSelectedListeners = mutableListOf<OnNavigationItemSelectedListener>()
@ademar111190
ademar111190 / ListenableBottomNavigationView.kt
Created June 11, 2019 21:42
first step, extends the BottomNavigationView and uses it on XML layout
package ademar.bnindicator
import android.content.Context
import android.util.AttributeSet
import com.google.android.material.bottomnavigation.BottomNavigationView
class ListenableBottomNavigationView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
@ademar111190
ademar111190 / as.vmoptions
Last active March 7, 2022 18:07
gradle and AS properties
-Dfile.encoding=UTF-8
-Didea.paths.selector=AndroidStudio
-Didea.platform.prefix=AndroidStudio
-Djava.net.preferIPv4Stack=true
-Djna.boot.library.path=
-Djna.debug_load.jna=true
-Djna.debug_load=true
-Djna.nosys=true
-Djsse.enableSNIExtension=false
-Dsun.io.useCanonCaches=false
@ademar111190
ademar111190 / twitter.sh
Created June 6, 2019 20:54
Get the access token from twitter api
#!/bin/bash
API_KEY="$(perl -MURI::Escape -e 'print uri_escape(" <<< HERE YOUR API KEY >>> ");' "$2")"
API_SECRET="$(perl -MURI::Escape -e 'print uri_escape(" <<< HERE YOUR API SECRET >>> ");' "$2")"
CONSUMER_URL=$API_KEY:$API_SECRET
CONSUMER_URL_64=`echo -n $CONSUMER_URL | base64`
curl -s \
-H "User-Agent: My Twitter App v1.0.23" \
-H "Authorization: Basic $CONSUMER_URL_64" \
--data-urlencode grant_type=client_credentials \
--compressed \
@ademar111190
ademar111190 / .gitignore
Last active June 4, 2019 14:20
Docker arch
*.swp