Skip to content

Instantly share code, notes, and snippets.

@MimDal92
MimDal92 / RecyclerItemClick.java
Created Aug 5, 2020
Item click listener for recyclerView
View RecyclerItemClick.java
public class RecyclerItemClick implements RecyclerView.OnItemTouchListener {
private OnItemClickListener Listener;
public interface OnItemClickListener {
public void onItemClick(View view, int position);
}
GestureDetector GestureDetector;
public RecyclerItemClick(Context context, OnItemClickListener listener) {
Listener = listener;
@MimDal92
MimDal92 / DBHelper.java
Created Aug 1, 2020
singletone DBHelper
View DBHelper.java
public class DBHelper {
private static DBHelper dBHelperInstance;
private CreateTable createTable; // CreateTable is extended SQLiteOpenHelper class
private SQLiteDatabase database;
private int count = 0;
// this method should call in application class
public static synchronized void init(Context context) {
@MimDal92
MimDal92 / DBHelper.java
Created Aug 1, 2020
singletone DBHelper
View DBHelper.java
public class DBHelper {
private static DBHelper dBHelperInstance;
private CreateTable createTable; // CreateTable is extended SQLiteOpenHelper class
private SQLiteDatabase database;
private int count = 0;
// this method should call in application class
public static synchronized void init(Context context) {
View HttpURLConnectionSetup.java
public class HttpURLConnectionSetup {
public static String connectToServer(String link){
URL url = null;
try {
url = new URL(link);
HttpsURLConnection connection =(HttpsURLConnection) url.openConnection();
@MimDal92
MimDal92 / ConvertInputStreamToString.java
Last active Jul 25, 2020
Convert InputStream to String
View ConvertInputStreamToString.java
public class ConvertInputStreamToString {
public static String inputStreamToString(InputStream inputStream){
String line;
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder result = new StringBuilder();
try{
@MimDal92
MimDal92 / SingletoneSendSMS.java
Created Jun 28, 2020
SingletoneSendSMS class
View SingletoneSendSMS.java
import android.telephony.SmsManager;
/**
* single tone for send sms.
* note that, run time permission for send sms is needed for 6+ versions.
*
* call init() in custom application class.
*
*/
@MimDal92
MimDal92 / PermissionHelper.java
Last active Jun 27, 2020
PermissionHelper class
View PermissionHelper.java
/**
* Just create a new instance of this class and pass Activity and permission arrays for constructor.
*
* call onRequestPermissionsResult at the body of the same name callback method in activity and pass required parameters.
*
*/
public class PermissionHelper {
View SingletonSharedPrefs.java
/**
*
* This is a singleTone class for sharedPreference, with all read and write methods.
*
*
*
*/
public class SingletonSharedPrefs {
You can’t perform that action at this time.