Skip to content

Instantly share code, notes, and snippets.

View ar-android's full-sized avatar
:octocat:
NULL

Ahmad Rosid ar-android

:octocat:
NULL
View GitHub Profile
@ar-android
ar-android / buildSynkc.java
Created November 28, 2015 06:26
Retrofit dua
@GET("/data/2.5/weather?q=Yogyakarta,id&appid=2de143494c0b295cca9337e1e96b00e0")
Call<CurrentCity> getCurrentCityCall();
private void buildSynkc() throws IOException {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
// Create a very simple REST adapter which points the GitHub API.
Retrofit retrofit = new Retrofit.Builder()
@ar-android
ar-android / RxAndroidRetrofit.java
Last active August 8, 2016 04:46
Restfull with RxAndroid and Retrofit
@GET("/data/2.5/weather?q=Yogyakarta,id&appid=2de143494c0b295cca9337e1e96b00e0")
Observable<CurrentCity> getCurrentCityCallRx();
private void getWithRx() {
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(API_URL)
@ar-android
ar-android / set toolbar
Last active December 16, 2015 00:31
Fast set toolbar in your app development with arrow back
private void setToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (toolbar != null) {
setSupportActionBar(toolbar);
toolbar.setTitle("Home");
toolbar.setTitleTextColor(Color.WHITE);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
@ar-android
ar-android / LimitLeghtEdittext.java
Created December 5, 2015 04:56
Limtit Edittext
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
@ar-android
ar-android / musicapp_layout.xml
Last active January 4, 2016 00:12
Implementasi music app layout dengan relative layout dan lineat layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ededed"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
/**
* set fragment sctive
* @param fragment
*/
private void setFragment(Fragment fragment) {
mFragmentManager = getSupportFragmentManager();
mFragmentTransaction = mFragmentManager.beginTransaction();
mFragmentTransaction.replace(R.id.frameLayout, fragment).commit();
@ar-android
ar-android / style.css
Created December 21, 2015 06:49
Css cover
.main {
background: url('../image/background.jpg');
background-position-x: center;
background-size: cover;
height: auto;
left: 0;
min-height: 100%;
min-width: 100%;
position: absolute;
@ar-android
ar-android / GPSTracker.java
Last active December 28, 2015 14:37
get your location in latitude and langitude
package ocittwo.id.ayo_jek.services;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@ar-android
ar-android / UriToBitmap.java
Created January 3, 2016 14:14
Convert uri to Bitmap
public Bitmap getThumbnail(Uri uri) throws FileNotFoundException, IOException {
InputStream input = this.getContentResolver().openInputStream(uri);
BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options();
onlyBoundsOptions.inJustDecodeBounds = true;
onlyBoundsOptions.inDither=true;//optional
onlyBoundsOptions.inPreferredConfig=Bitmap.Config.ARGB_8888;//optional
BitmapFactory.decodeStream(input, null, onlyBoundsOptions);
input.close();
@ar-android
ar-android / AdapterRVBarang.java
Created January 19, 2016 11:07
recyclerview adapter with onitemclick listener
package com.ahmadrosid.inventoryapp.adapter;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;