Skip to content

Instantly share code, notes, and snippets.

View saddahussain's full-sized avatar
📱
Writing code for little green robots

Sadda Hussain saddahussain

📱
Writing code for little green robots
View GitHub Profile
@saddahussain
saddahussain / DateFormat.java
Last active August 24, 2019 06:37
DateFormat Patterns
DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy, HH:mm");
String date = df.format(Calendar.getInstance().getTime());
"yyyy.MM.dd G 'at' HH:mm:ss z" ---- 2001.07.04 AD at 12:08:56 PDT
"hh 'o''clock' a, zzzz" ----------- 12 o'clock PM, Pacific Daylight Time
"EEE, d MMM yyyy HH:mm:ss Z"------- Wed, 4 Jul 2001 12:08:56 -0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"------- 2001-07-04T12:08:56.235-0700
"yyMMddHHmmssZ"-------------------- 010704120856-0700
"K:mm a, z" ----------------------- 0:08 PM, PDT
"h:mm a" -------------------------- 12:08 PM
class SwipeLockableViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) {
private var swipeEnabled = false
override fun onTouchEvent(event: MotionEvent): Boolean {
return when (swipeEnabled) {
true -> super.onTouchEvent(event)
false -> false
}
}
@saddahussain
saddahussain / MapUtill.java
Created June 28, 2019 11:48
Maps zoom issue inside scrollview
mapView.setOnTouchListener { v, event ->
when (event?.action) {
MotionEvent.ACTION_MOVE ->
scrollView.requestDisallowInterceptTouchEvent(true)
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL ->
scrollView.requestDisallowInterceptTouchEvent(false)
}
mapView.onTouchEvent(event)
}
object RetrofitClient {
private const val BASE_URL = ""
private lateinit var retrofit: Retrofit
fun getClient(): APIService {
if (retrofit == null) {
retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
private void createNotification(String title, String message) {
int num = (int) System.currentTimeMillis();
Intent resultIntent = new Intent(PusherService.this, MainActivity.class);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent resultPendingIntent =
PendingIntent.getActivity(this, num, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this);
private FusedLocationProviderClient fusedLocationProviderClient;
private LocationRequest locationRequest;
private LocationCallback locationCallback;
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
fusedLocationProviderClient.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {