Skip to content

Instantly share code, notes, and snippets.

🎯
Exploring things

Pratik Butani pratikbutani

🎯
Exploring things
Block or report user

Report or block pratikbutani

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pratikbutani
pratikbutani / PathUtils.java
Created Sep 9, 2019
Get Path from URI or URI from Path Utils.
View PathUtils.java
public class PathUtils {
/**
* To get URI from Path
*
* @param context context
* @param file file
* @return Uri
*/
public static Uri getUriFromPath(Context context, File file) {
String filePath = file.getAbsolutePath();
@pratikbutani
pratikbutani / DatePickerUniversal.java
Last active Jul 24, 2019
Using that Date Picker Universal for any view you can pick date very easily.
View DatePickerUniversal.java
/**
* @author Pratik Butani
*
* Main file for Date Picker.
*/
public class DatePickerUniversal implements View.OnFocusChangeListener, DatePickerDialog.OnDateSetListener, View.OnClickListener {
private EditText mEditText;
private Calendar mCalendar;
private SimpleDateFormat mFormat;
@pratikbutani
pratikbutani / LocationHelperActivity.java
Created Jun 14, 2019
Location Helper Activity to get continuously updates of location in your child activity. Just extend this activity in your every child activity where you want to get updates.
View LocationHelperActivity.java
public abstract class LocationHelperActivity extends AppCompatActivity {
private static final String TAG = "LocationHelperActivity";
private static final int PERMISSION_REQUEST_CODE = 200;
public static final long INTERVAL = 1000 * 3 * 60; // 3 = 3 minutes
public static final long FASTEST_INTERVAL = 1000 * 60; // 60 = 60 seconds = 1 minutes
public String mCurrentLatitude = "";
public String mCurrentLongitude = "";
View MyFirebaseMessagingService.java
public class MyFirebaseMessagingService extends FirebaseMessagingService {
private static final String TAG = "MyFirebaseMessagingServ";
private static int NOTIFICATION_ID = 1;
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
// Check if message contains a data payload.
@pratikbutani
pratikbutani / BaseFragment.java
Created Feb 26, 2019
Common Fragment for all Fragments (using DataBinding)
View BaseFragment.java
public abstract class BaseFragment extends Fragment {
/**
* DataBinding Object
*/
private ViewDataBinding mBindingObject;
/**
* Context common
*/
@pratikbutani
pratikbutani / BaseActivity.java
Last active Feb 26, 2019
Common Activity for all Activities (using DataBinding)
View BaseActivity.java
public abstract class BaseActivity extends AppCompatActivity {
/**
* DataBinding Object
*/
private ViewDataBinding mBindingObject;
/**
* Context common
*/
@pratikbutani
pratikbutani / TimePickerUniversal.java
Last active Dec 17, 2018
Android TimePicker to set time with/without AM/PM.
View TimePickerUniversal.java
/**
* Main file for Time Picker.
*/
public class TimePickerUniversal implements View.OnFocusChangeListener, TimePickerDialog.OnTimeSetListener, View.OnClickListener {
private EditText mEditText;
private Calendar mCalendar;
private SimpleDateFormat mFormat;
private boolean withAMPM;
@pratikbutani
pratikbutani / send_firebase_notification.php
Created Oct 24, 2018
Send Firebase Notification to more than 1000 users at a time from PHP
View send_firebase_notification.php
<?php
/**
* Created By : Pratik Butani
* Created Date : 24/10/2018
*/
// Database Connection
include "conn.php";
// Get Records from Table
$sql = "SELECT * from fcm";
@pratikbutani
pratikbutani / NetworkUtils.java
Last active May 3, 2017
NetworkUtils is useful to check the internet connection and it will be called when internet connection goes on/off using BroadcaseReceiver.
View NetworkUtils.java
/**
* @author Pratik Butani
*/
public class NetworkUtils extends BroadcastReceiver {
/**
* Context Variable
*/
Context context;
@pratikbutani
pratikbutani / EndlessRecyclerOnScrollListener.java
Last active Aug 15, 2019
Endless RecyclerView OnScrollListener for pagination
View EndlessRecyclerOnScrollListener.java
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
You can’t perform that action at this time.