Skip to content

Instantly share code, notes, and snippets.

/***
* USAGE:
* DataManager.getInstance().setItemsList(itemsList);
*
* Item item = DataManager.getInstance().getItemByIdx(5);
*
* Please, notice that the getItemByIdx() function my throw an exception!!!
*/
public class DataManager {
private static DataManager ourInstance = new DataManager();
/**
* Created by todor.kostov on 6/25/2016.
*/
public interface AsyncResponse {
void processFinish(String output);
}
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
#parse("File Header.java")
public class ${NAME} extends AppCompatActivity {
private static final String TAG = ${NAME}.class.getSimpleName();
/**
@kostovtd
kostovtd / Activity.java
Last active October 30, 2016 10:13
Code Template - Activity & RecyclerViewAdapter
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
#parse("File Header.java")
public class ${NAME} extends AppCompatActivity {
private static final String TAG = ${NAME}.class.getSimpleName();
/**
@kostovtd
kostovtd / TabsMargin.java
Created November 2, 2016 19:00
A way to add margins between the tabs of a TabLayout
for(int i=0; i < mTabLayout.getTabCount(); i++) {
View tab = ((ViewGroup) mTabLayout.getChildAt(0)).getChildAt(i);
ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) tab.getLayoutParams();
p.setMargins(0, 0, 50, 0);
tab.requestLayout();
}
File path = new File("path\to\your\folder");
File file= new File(path,".nomedia");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
productFlavors {
newYorkTimes {
applicationId "com.nyt.rss"
buildConfigField 'String', 'HOST', '"http://nytimes.com"'
}
theGuardian {
applicationId "com.theguardian.rss"
buildConfigField 'String', 'HOST', '"http://theguardian.com"'
productFlavors {
newYorkTimes {
...
}
theGuardian {
...
}
@kostovtd
kostovtd / CompanyLocation.java
Created December 3, 2016 08:21
Model Layer for GeofencingExample app
import com.google.android.gms.location.Geofence;
import com.google.android.gms.maps.model.LatLng;
/**
* Just a dummy container class in order to
* collect {@link com.google.android.gms.location.Geofence}
* and {@link com.google.android.gms.maps.model.LatLng} in one entity
*/
public class CompanyLocation {
@kostovtd
kostovtd / MapsActivity.java
Created December 3, 2016 08:23
View Layer for GeofencingExample app
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;