Skip to content

Instantly share code, notes, and snippets.

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

Deni Rohimat derohimat

🏠
Working from home
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditTextPreference
android:defaultValue="@string/pref_location_default"
android:inputType="text"
android:key="@string/pref_location_key"
android:singleLine="true"
<resources>
<string name="app_name">Sunshine</string>
<string name="action_settings">Settings</string>
<string name="action_map">Map Location</string>
<string name="pref_location_label">Location</string>
<string name="pref_location_key" translatable="false">location</string>
<string name="pref_location_default" translatable="false">40377</string>
<string name="pref_units_label">Temperature Units</string>
public class SettingsActivity extends PreferenceActivity
implements Preference.OnPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add 'general' preferences, defined in the XML file
// TODO: Add preferences from XML
addPreferencesFromResource(R.xml.pref_general);
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="pref_units_options">
<item>@string/pref_units_label_metric</item>
<item>@string/pref_units_label_imperial</item>
</string-array>
<string-array name="pref_units_values">
<item>@string/pref_units_metric</item>
<item>@string/pref_units_imperial</item>
@derohimat
derohimat / SimpleService
Last active April 9, 2016 04:47
Gist Simple Service Sunshine
public final class SimpleService {
public static final String API_URL = "http://api.openweathermap.org/data/2.5/forecast/";
public interface OpenWeatherMap {
@GET("daily?mode=json")
Call<ApiResponse> getWeather(
@Query("q") String city,
@Query("units") String units,
@Query("cnt") int count,
@derohimat
derohimat / MainFragment load Data
Last active April 9, 2016 04:49
Gist Sunshine MainFragment
private void loadData() {
mWeekForecastAdapter.clear();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
String location = sharedPreferences.getString(getString(R.string.pref_location_key),
getString(R.string.pref_location_default));
String units = sharedPreferences.getString(getString(R.string.pref_units_key),
getString(R.string.pref_units_metric));
Retrofit retrofit = new Retrofit.Builder()
private void onPreferedLocationInMap() {
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(mContext);
String location = sharedPreferences.getString(getString(R.string.pref_location_key),
getString(R.string.pref_location_default));
Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", location)
.build();
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply from: '../config/quality.gradle'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
package com.gaharitechnology.vokon.ui.fragment.main;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.GridLayoutManager;
import android.view.LayoutInflater;
package com.gaharitechnology.vokon.ui.view;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class GridHeaderSpacingItemDecoration extends RecyclerView.ItemDecoration {
private int spanCount;
private int spacing;