This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeUtils { | |
public static final long DAY = 86400000; | |
public static final long HOUR = 3600000; | |
public static final long MINUTE = 60000; | |
public static final long SECOND = 1000; | |
public static long getMinuteDifference(long startTime, long endTime) { | |
return (endTime - startTime) / MINUTE; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.support.v4.view.MotionEventCompat; | |
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
public class Hash { | |
public static String getHash(String txt, String hashType) { | |
try { | |
byte[] array = MessageDigest.getInstance(hashType).digest(txt.getBytes()); | |
StringBuffer sb = new StringBuffer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Validator { | |
public static boolean isValidEmailAddress(String email) { | |
String emailRegex; | |
String stricterFilterString = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; | |
String laxString = ".+@.+\\.[A-Za-z]{2}[A-Za-z]*"; | |
if (true) { | |
emailRegex = stricterFilterString; | |
} else { | |
emailRegex = laxString; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean isAppIsInBackground(Context context) { | |
boolean isInBackground = true; | |
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); | |
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT_WATCH) { | |
List<ActivityManager.RunningAppProcessInfo> runningProcesses = am.getRunningAppProcesses(); | |
for (ActivityManager.RunningAppProcessInfo processInfo : runningProcesses) { | |
if (processInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { | |
for (String activeProcess : processInfo.pkgList) { | |
if (activeProcess.equals(context.getPackageName())) { | |
isInBackground = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ir.gushtomorghebaradaran.Utils; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
import android.preference.PreferenceManager; | |
import com.google.gson.Gson; | |
public class Prefs<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.besat.Utils; | |
import java.text.DateFormat; | |
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
import java.util.GregorianCalendar; | |
import java.util.Locale; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObservableRxList<T> { | |
protected final List<T> list; | |
protected final PublishSubject<List<T>> subject; | |
public ObservableRxList() { | |
this.list = new ArrayList<T>(); | |
this.subject = PublishSubject.create(); | |
} | |
public void add(T value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LiveDataList<T> extends LiveData<List<T>> { | |
public void addAll(List<T> items) { | |
if (getValue() != null && items != null) { | |
getValue().addAll(items); | |
setValue(getValue()); | |
} | |
} | |
public void clear() { | |
if (getValue() != null) { |