Skip to content

Instantly share code, notes, and snippets.

View mzelzoghbi's full-sized avatar

Mohamed Zakaria El-Zoghbi mzelzoghbi

View GitHub Profile
@mzelzoghbi
mzelzoghbi / Logger.java
Last active April 20, 2020 17:57
Simple logger class
package com.instabug.my_awesome_library;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
/**
* Basic class for logging instead of using Log class directly.
*/
public class Logger {
private static LoggerImpl logger;
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.SecurityException: Caller no longer running, last stopped +8s783ms because: timed out while starting
at android.os.Parcel.readException(Parcel.java:1942)
@mzelzoghbi
mzelzoghbi / MyServiceImpl.java
Last active December 23, 2018 15:49
JobIntentService SecurityException
public abstract class MyServiceImpl extends JobIntentService {
// This method is the main reason for the bug and crash
@Override
GenericWorkItem dequeueWork() {
try {
return super.dequeueWork();
} catch (SecurityException exception) {
// the exception will be ignored here.
}
return null;
@mzelzoghbi
mzelzoghbi / InteractiveScrollView.java
Created May 15, 2017 11:10 — forked from marteinn/InteractiveScrollView.java
ScrollView with a OnBottomReachedListener for Android
package se.marteinn.ui;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ScrollView;
/**
* Triggers a event when scrolling reaches bottom.
@mzelzoghbi
mzelzoghbi / AbstractRecyclerViewFooterAdapter.java
Created February 6, 2017 12:33 — forked from mSobhy90/AbstractRecyclerViewFooterAdapter.java
An example of how-to implement an infinite scrolling adapter for a RecyclerView, with a ProgressBar footer. Blog post can be found here: http://msobhy.me/2015/09/05/infinite_scrolling_recyclerview/
package net.sarmady.contactcarswithtabs.adapters;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
public class Regex {
/**
* Regular expression pattern to match all IANA top-level domains.
* List accurate as of 2007/06/15. List taken from:
* http://data.iana.org/TLD/tlds-alpha-by-domain.txt
* This pattern is auto-generated by //device/tools/make-iana-tld-pattern.py
*/
private static final Pattern TOP_LEVEL_DOMAIN_PATTERN
= Pattern.compile(
"((aero|arpa|asia|a[cdefgilmnoqrstuwxz])"
@mzelzoghbi
mzelzoghbi / SquareRelativeLayout
Last active March 13, 2017 08:57
Square Relative Layout view
public class SquareRelativeLayout extends RelativeLayout {
public SquareRelativeLayout(Context context) {
super(context);
}
public SquareRelativeLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override