Skip to content

Instantly share code, notes, and snippets.

View IhwanID's full-sized avatar

Ihwan IhwanID

View GitHub Profile
@IhwanID
IhwanID / main.dart
Created January 30, 2020 04:15
tenary & if else
void main() {
isOddOrEven(18);
}
void isOddOrEven(int number){
if(number % 2 == 0){
print("$number is even");
}else{
print("$number is odd");
}
@IhwanID
IhwanID / main.dart
Last active January 29, 2020 09:49
list & maps
void main() {
List<int> primeNumber = [2,3,5,7];
primeNumber.addAll([11, 13, 17, 19]);
primeNumber.add(23);
print(primeNumber);
//map
var person = <String, dynamic>{
'name' : 'Dewi',
'age' : 17,
@IhwanID
IhwanID / main.dart
Created January 29, 2020 01:48
mixin
void main() {
final person = Person(name: 'Arin', height: 160.0, weight: 55.0);
print(person.bmi);
}
mixin BMI{
double calculate(double height, double weight){
return weight / (height * height);
}
}
@IhwanID
IhwanID / abstract.dart
Last active January 29, 2020 01:35
Introduction to dart
import 'dart:math';
void main() {
final square = Square(side: 2.0);
print(square.area);
final circle = Circle(radius:14.0);
printArea(circle);
}
@IhwanID
IhwanID / SplashActivity.kt
Created October 18, 2019 23:09
The Right Way to Create Splash Screen on Android
package com.example.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.content.Intent
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Keybase proof

I hereby claim:

  • I am ihwanid on github.
  • I am ihwanid (https://keybase.io/ihwanid) on keybase.
  • I have a public key ASC2CF9mXFR2wuDupH3cLmZ4HmUcSTM9RHeMDfrgdOWTYAo

To claim this, I am signing this object:

@IhwanID
IhwanID / main.kt
Created August 27, 2019 12:28
Open Whatsapp Intent in Kotlin Android
try {
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, "Hello Swapz")
putExtra("jid", "${data.phone}@s.whatsapp.net")
type = "text/plain"
setPackage("com.whatsapp")
}
startActivity(sendIntent)
}catch (e: Exception){
@IhwanID
IhwanID / Navigation.md
Created July 14, 2019 13:16
Principle of Navigation Android (Jetpack)

Principle of Navigation (Android Architecture Component / Jetpack)

  1. There's Always Starting Place
  2. You can always go back
  3. Up goes back (mostly)
@IhwanID
IhwanID / main.kt
Created July 11, 2019 04:44
Hide the keyboard Android kotlin
// Hide the keyboard.
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
@IhwanID
IhwanID / BindingAdapters.kt
Created July 3, 2019 05:03
Binding Adapter Collection
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.GradientDrawable
import android.graphics.drawable.ShapeDrawable
import android.os.Build
import android.text.Html
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.cardview.widget.CardView