Skip to content

Instantly share code, notes, and snippets.

View muratcanbur's full-sized avatar

Murat Can BUR muratcanbur

View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fde0dc</color>
<color name="md_red_100">#f9bdbb</color>
<color name="md_red_200">#f69988</color>
@muratcanbur
muratcanbur / launchGoogleMaps
Created November 29, 2014 19:34
if you don't want to integrate Google Maps to in your app, use this method
private void launchGoogleMaps(Context context, double latitude,
double longitude) {
try {
String format = "geo:0,0?q=" + Double.toString(latitude) + ","
+ Double.toString(longitude);
Uri uri = Uri.parse(format);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
@muratcanbur
muratcanbur / DrawableFromSVG
Created December 23, 2014 07:43
Drawable from .svg resource.
public void setDrawableFromSVG(ImageView imageView, int resource) {
SVG svg = new SVGBuilder()
.readFromResource(mContext.getResources(), resource)
.build();
imageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
imageView.setImageDrawable(new PictureDrawable(svg.getPicture()));
}
@muratcanbur
muratcanbur / checkPlayServices
Created March 1, 2015 08:36
method to verify google play services on the device
/**
* verify google play services on the device
* */
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
public void remove(PhotoCard card) {
int position = getItemPosition(card);
if (position != -1) {
mPhotoCards.remove(position);
notifyItemRemoved(position);
}
}
public void add(PhotoCard card, int position) {
mPhotoCards.add(position, card);
@muratcanbur
muratcanbur / initToolbar
Created March 11, 2015 20:27
Use a Toolbar as an Action Bar from Fragment
private void initToolbar(View view) {
mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
((ActionBarActivity) getActivity()).setSupportActionBar(mToolbar);
mToolbar.setTitle(getString(R.string.app_name));
mToolbar.setTitleTextColor(getResources().getColor(android.R.color.white));
}
private void initRecyclerView(View view) {
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
RecyclerAdapter recyclerAdapter = new RecyclerAdapter();
recyclerView.setAdapter(recyclerAdapter);
}
@muratcanbur
muratcanbur / VolleySingleton
Created April 20, 2015 08:32
This is a Singleton Pattern class that provides RequestQueue
public class VolleySingleton {
public static final String TAG = VolleySingleton.class
.getSimpleName();
private static VolleySingleton mInstance;
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static Context mCtx;
@muratcanbur
muratcanbur / ServiceHandler.java
Created June 16, 2015 06:32
a separate class to handle all HTTP calls. This class is responsible of making a HTTP call and getting the response.
public class ServiceHandler {
static String response = null;
public final static int GET = 1;
public final static int POST = 2;
public ServiceHandler() {
}
@muratcanbur
muratcanbur / build.gradle(app)
Created July 6, 2015 20:53
this is a Gradle guide to use on all Android applications in general.
apply plugin: 'com.android.application'
Properties local_properties = new Properties()
File localPropertiesFile = project.rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
local_properties.load(localPropertiesFile.newDataInputStream())
}
def STRING = 'String'
def GIT_SHA = 'GIT_SHA'