Skip to content

Instantly share code, notes, and snippets.

View fnzainal's full-sized avatar
🏠
Working from home

Zainal Fahrudin fnzainal

🏠
Working from home
View GitHub Profile
@fnzainal
fnzainal / boot-repair.md
Created March 28, 2017 14:36
boot-repair is tool to repair boot grub on linux.

#install

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
@fnzainal
fnzainal / HitungJarakMapsGoogleAPI.md
Last active February 24, 2017 02:18
untuk menghitung jarak di maps melalui jalan, bukan jarak lurus. Menggunakan api GoogleMaps

##URL FORMAT:

http://maps.googleapis.com/maps/api/directions/json?origin=" + lat1 + "," + lon1 + "&destination=" + lat2 + "," + lon2 + "&sensor=false&units=metric&mode=driving

##URL example:

http://maps.googleapis.com/maps/api/directions/json?origin=-7.0753592,110.3586899&destination=-7.1206129,110.4038428&sensor=false&units=metric&mode=driving

##JSON response with GET Request:

@fnzainal
fnzainal / StringToCurrency.java
Created January 24, 2017 14:32
to make currency format
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.SimpleDateFormat;
/**
* convert string to currency format
* @param value money
* @return
@fnzainal
fnzainal / GetViewItemListView.java
Created January 13, 2017 01:47
untuk mengambil View pada item listview
/**
* untuk mencari posisi item pada listview
* @param position : posisi item pada listview
* @param listView : listview
* @return View posisi item
*/
public static View getViewByPosition(int position, ListView listView) {
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition
@fnzainal
fnzainal / TabFragment.java
Created January 12, 2017 07:09
adapter to setup tab fragment on Android App
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class TabFragmentAdapter extends FragmentPagerAdapter {
@fnzainal
fnzainal / FloatingActionMenuBehavior
Created December 17, 2016 00:56 — forked from lodlock/FloatingActionMenuBehavior
Quick behavior that allows for https://github.com/Clans/FloatingActionButton to be compatible with CoordinatorLayout. Add app:layout_behavior="wherever.you.want.to.keep.your.behaviors.FloatingActionMenuBehavior" (of course modify it to match your code) to your FloatingActionMenu that resides within a CoordinatorLayout.
import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPropertyAnimatorListener;
import android.util.AttributeSet;
import android.view.View;
import com.github.clans.fab.FloatingActionMenu;
@fnzainal
fnzainal / SpeechToTextActivity.java
Created December 15, 2016 09:52 — forked from hendrawd/SpeechToTextActivity.java
Simple working test of IBM Watson Speech To Text capability on Android platform
/**
* Copyright (C) 2016 hendrawd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@fnzainal
fnzainal / rounded_rectangle.xml
Created December 13, 2016 02:31
to draw rounded rectangle on android
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:color="@color/color_primary"
android:width="5dp" />
<stroke
android:width="5dp"
android:color="@color/black"/>
<corners
@fnzainal
fnzainal / IntentGmail.java
Created November 23, 2016 02:57
to start gmail with extra string
final Intent intentGmail = new Intent(Intent.ACTION_VIEW);
intentGmail.setClassName("com.google.android.gm","com.google.android.gm.ComposeActivityGmail");
intentGmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "user@email.com" });
intentGmail.putExtra(Intent.EXTRA_SUBJECT, "SUBJECT EMAIL");
intentGmail.setType("plain/text");
intentGmail.putExtra(Intent.EXTRA_TEXT, "message email is here.."
);
try {
startActivity(intentGmail);
@fnzainal
fnzainal / IntentShare.java
Created November 21, 2016 07:36
intent to share text on android.
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "The lorem ipsum content.";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share Title"));