Skip to content

Instantly share code, notes, and snippets.

View cesarferreira's full-sized avatar

César Ferreira cesarferreira

View GitHub Profile
@cesarferreira
cesarferreira / DataWebService.java
Last active December 22, 2015 15:43 — forked from lopspower/1-README.md
Retrofit Introduction
import retrofit.Call;
import retrofit.http.GET;
/**
* Copyright (C) 2016 Mikhael LOPEZ
* Licensed under the Apache License Version 2.0
* Example Data WebService
* Created by Mikhael LOPEZ on 18/12/2015.
*/
public interface DataWebService {
@cesarferreira
cesarferreira / .travis.yml
Created November 9, 2015 19:35 — forked from mariotaku/.travis.yml
Sign and upload compiled apk to Github releases automatically using Travis CI
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-22.0.0
@cesarferreira
cesarferreira / optparse-template.rb
Created October 18, 2015 11:07 — forked from rtomayko/optparse-template.rb
Ruby optparse template
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"
@cesarferreira
cesarferreira / service.java
Created October 18, 2015 09:26
[android] Adding views to services (yes, it's possible)
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams windowParams = new WindowManager.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams. WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
windowManager.addView(listView, windowParams);
@cesarferreira
cesarferreira / SomeFragment.java
Created September 24, 2015 17:33 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);
@cesarferreira
cesarferreira / rx.gradle
Last active December 15, 2015 01:52
Reactive extensions
dependencies {
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'com.jakewharton.rxbinding:rxbinding:0.3.0'
}
@cesarferreira
cesarferreira / api.java
Last active February 1, 2022 16:32
RxJava and Retrofit sample
public interface API {
@GET("/user/{username}/dogs")
Observable<Dog> getAllDogsOf(@Path("username") String username);
@GET("/dog/{id}")
Observable<Dog> getDogInfoById(@Path("id") int dogId);
}
@cesarferreira
cesarferreira / OnBackPressed.java
Created August 20, 2015 16:36
Using onBackPressed() in Android Fragments
private final static String TAG_FRAGMENT = "TAG_FRAGMENT";
private void showFragment() {
final Myfragment fragment = new MyFragment();
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment, fragment, TAG_FRAGMENT);
transaction.addToBackStack(null);
transaction.commit();
}
@cesarferreira
cesarferreira / sample.json
Last active August 29, 2015 14:26
sample json for the j2j article
{
"total": 2,
"people": [
{
"id": 1551,
"full_name": "Jon snow",
"family_name": "Stark",
"password": "iknownothing",
"status": "unknown",
"gender": "male",
@cesarferreira
cesarferreira / RxJava.md
Last active March 30, 2025 00:28
Party tricks with RxJava, RxAndroid & Retrolambda

View Click

Instead of the verbose setOnClickListener:

RxView.clicks(submitButton).subscribe(o -> log("submit button clicked!"));

Filter even numbers

Observable
    .just(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)