Skip to content

Instantly share code, notes, and snippets.

View mdumrauf's full-sized avatar

Matías Dumrauf mdumrauf

  • Buenos Aires, Argentina
View GitHub Profile
@Zhuinden
Zhuinden / realm-databinding-main-activity.java
Last active August 23, 2017 02:38
Realm Data Binding Example - MainActivity
public class MainActivity
extends RealmActivity {
Post post;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
post = realm.where(Post.class).equalTo("id", 1L).findFirst();
@geftimov
geftimov / android-connectivity-change
Last active August 1, 2018 15:16
Register and unregister connectivity receiver when needed.
private ConnectivityChangeReceiver mConnectivityChangeReceiver;
@Override
protected void onResume() {
super.onResume();
mConnectivityChangeReceiver = new ConnectivityChangeReceiver();
registerReceiver(mConnectivityChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
@Override
@Rexee
Rexee / RealmList.java
Last active August 3, 2018 01:38
Parceler and RealmList
@Parcel(implementations = { CountryRealmProxy.class },
value = Parcel.Serialization.FIELD,
analyze = { Country.class })
public class Country extends RealmObject {
@ParcelPropertyConverter(RealmListParcelConverter.class)
public RealmList<RealmString> languages;
}
public class RealmListParcelConverter
implements TypeRangeParcelConverter<RealmList<? extends RealmObject>,
@VladSumtsov
VladSumtsov / MyActivity.java
Last active July 29, 2019 10:09
RecycleView PullToRefresh SwipeRefreshLayout
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.togethernetworks.basesdk.BaseActivity;
import com.togethernetworks.gallery.samples.mortar.UiModule;
@berkkaraoglu
berkkaraoglu / BorderedCircleTransform.java
Created November 14, 2014 09:12
BorderedCircleTransform for Picasso (Based on https://gist.github.com/julianshen/5829333)
import android.graphics.Bitmap;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import com.squareup.picasso.Transformation;
public class CircleTransform implements Transformation {
private final int BORDER_COLOR = Color.WHITE;
@christopherperry
christopherperry / CheckableLinearLayout
Created September 18, 2012 22:43
A LinearLayout that implements the Checkable interface, allowing a LinearLayout to be put into a checked state.
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Checkable;
import android.widget.LinearLayout;
@mayank-shekhar
mayank-shekhar / Rename Package Name in React Native
Created February 16, 2018 07:28
Rename App ID and Package name for a React Native App.
For Android:
Manually change it in android/app/src/main/java/com/PROJECT_NAME/MainActivity.java:
package MY.APP.ID;
In android/app/src/main/java/com/PROJECT_NAME/MainApplication.java:
package MY.APP.ID;
In android/app/src/main/AndroidManifest.xml:
package="MY.APP.ID"
@sheharyarn
sheharyarn / SimpleRVAdapter.java
Last active February 9, 2021 10:11
Simple Recycler View adapter (without XML layout)
/**
* SimpleRVAdapter to quickly get started with simple Lists in Recyclerview
*
* Usage:
*
* RecyclerView rv = (RecyclerView)findViewById(R.id.rv);
* rv.setLayoutManager(new LinearLayoutManager(getContext()));
* rv.setAdapter(new SimpleRVAdapter(new String[] {"1", "2", "3", "4", "5", "6", "7"}));
*
* @author Sheharyar Naseer
@joeljeske
joeljeske / patch-android-studio-check.js
Created April 2, 2018 14:40
Fixes android plugin install that fail because it cannot find AndroidManifest.xml
/**
* This hook overrides a function check at runtime. Currently, cordova-android 7+ incorrectly detects that we are using
* an eclipse style project. This causes a lot of plugins to fail at install time due to paths actually being setup
* for an Android Studio project. Some plugins choose to install things into 'platforms/android/libs' which makes
* this original function assume it is an ecplise project.
*/
module.exports = function(context) {
if (context.opts.cordova.platforms.indexOf('android') < 0) {
return;
}
@necolas
necolas / gist:2215692
Created March 27, 2012 13:12
Git submodules
# Workflow from https://github.com/necolas/dotfiles
# Add the new submodule
git submodule add git://example.com/remote/path/to/repo.git vim/bundle/one-submodule
# Initialize the submodule
git submodule init
# Clone the submodule
git submodule update
# Stage the changes
git add vim/bundle/one-submodule