Skip to content

Instantly share code, notes, and snippets.

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

Vasileios Pallas VassilisPallas

🏠
Working from home
View GitHub Profile
@VassilisPallas
VassilisPallas / RecyclerItemClickListener.java
Last active May 8, 2016 14:55
Click and Long click listener for RecycleView
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by vasilis on 10/30/15.
*/
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
@VassilisPallas
VassilisPallas / OpenGoogleMapsFromNotification.java
Last active February 2, 2022 07:28
Open Google Maps with custom latitude and longtitute bt pressing the notification
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.NotificationCompat;
import android.widget.Toast;
import java.util.Locale;
@VassilisPallas
VassilisPallas / EmptyRequest.java
Created May 8, 2016 17:10
Empty Request for Volley
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import com.android.volley.toolbox.JsonObjectRequest;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
@VassilisPallas
VassilisPallas / BooleanRequest.java
Created May 8, 2016 17:11
Boolean Request for Volley
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import com.android.volley.toolbox.HttpHeaderParser;
import java.io.UnsupportedEncodingException;
@VassilisPallas
VassilisPallas / InputStreamVolleyRequest.java
Created May 8, 2016 17:12
InputStream Request for Volley
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.toolbox.HttpHeaderParser;
import java.util.Map;
/**
* Created by vspallas on 03/03/16.
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader;
/**
* Created by vspallas on 09/02/16.
*/
public class LruBitmapCache extends LruCache<String, Bitmap> implements
ImageLoader.ImageCache {
@VassilisPallas
VassilisPallas / SwipeRefreshLayoutScrollView.java
Created May 9, 2016 18:52
custom scrollview, which disables the swipeRefreshLayout when the ScrollView isn't at the top
import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ScrollView;
import android.support.v4.widget.SwipeRefreshLayout;
/**
@VassilisPallas
VassilisPallas / CustomDrawableColor.java
Created May 9, 2016 18:58
set custom color to any drawable image
/**
* change color on a drawable image
*
* @param context the context
* @param imageId the id from the image
* @param color the color hex
* @return
*/
public Drawable setCustomDrawableColor(Context context, int imageId, int color) {
try {
@VassilisPallas
VassilisPallas / DownloadFileNotification.java
Created May 9, 2016 19:04
Notification for file download. When the download is completed, the file can be opened by an app that supports the extension.
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.NotificationCompat;
import android.widget.Toast;
import org.sakaiproject.helpers.ActionsHelper;
import org.sakaiproject.sakai.R;
@VassilisPallas
VassilisPallas / copyText.java
Created May 9, 2016 19:27
copy selected text from Edittext on Android
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(label, text);
clipboard.setPrimaryClip(clip);