Skip to content

Instantly share code, notes, and snippets.

View azri92's full-sized avatar

Azri Azmi (Aba) azri92

View GitHub Profile
@azri92
azri92 / animate_layout.kt
Last active May 23, 2018 06:01
Android: How to animate a layout. Example is setting alpha.
var animate = ObjectAnimator.ofFloat(someLayout, "alpha", 0.5f)
animate.duration = resources.getInteger(R.integer.anim_short).toLong()
animate.start()
@azri92
azri92 / SetLogoDefaultInStyles.xml
Last active May 11, 2018 08:06
Set logo as default on Action Bar
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/Custom.ActionBar</item>
</style>
<style name="Custom.ActionBar" parent="Widget.AppCompat.ActionBar">
<item name="logo">@drawable/img_logo</item>
<item name="displayOptions">useLogo|showHome</item>
@azri92
azri92 / gist:9a16066b751f0bb84213886682dc6b3f
Created January 19, 2018 09:26 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@azri92
azri92 / gist:7900009518b5eca197cecd6f67bc8c80
Created January 19, 2018 09:25 — forked from dodyg/gist:5616605
Kotlin Programming Language Cheat Sheet Part 2

This is a quick guide to Kotlin programming language. The previous part of this guide is here

#Object Oriented

fun main(args : Array<String>) {
  class local (val x : Int)
  
  val y = local(10)
 println("${y.x}")
@azri92
azri92 / MyActivityOrFragment.java
Created January 16, 2018 10:22 — forked from eveliotc/MyActivityOrFragment.java
A variant of https://gist.github.com/eveliotc/6051367 to show a drop shadow, should not be used for performance in mind views
final ImageView imageView = (ImageView) view.findViewById(R.id.image);
final int shadowSize = getResources().getDimensionPixelSize(R.dimen.shadow_size);
final int shadowColor = getResources().getColor(R.color.shadow_color);
imageView.setImageDrawable(new RoundedAvatarDrawable(mBitmap, shadowSize, shadowColor));
if (SDK_INT >= HONEYCOMB) {
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
@azri92
azri92 / Manually build resource ID.java
Created August 17, 2017 23:44
Useful for filling out a group of textviews for example
String id = "randomtext_" + number; //let's say number is 1
int resourceId = getResources().getIdentifier(id, "id", getPackageName());
// the above will be the same as "R.id.randomtext_1"
TextView txtRandom = (TextView) findViewById(resourceId);
@azri92
azri92 / 0_reuse_code.js
Created August 3, 2017 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console