Skip to content

Instantly share code, notes, and snippets.

Mohamed Fathy MuhamedFathy

  • Rytalo
  • Egypt
Block or report user

Report or block MuhamedFathy

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
@MuhamedFathy
MuhamedFathy / README.md
Created Mar 21, 2018 — forked from lopspower/README.md
How to Analyze & Manage Memory on Android Like a Boss
View README.md

Analyze & Manage Memory on Android Like a Boss

This Blog is all about memory management in Android. It provides information about how you can analyze & reduce memory usage while developing an Android app.

Memory management is a complex field of computer science and there are many techniques being developed to make it more efficient. This guide is designed to introduce you to some of the basic memory management issues that programmers face.

Memory Management in Android

Android is a Linux based operating system. It uses native open source C libraries which power Linux machines. All the basic operating system operations like I/O, memory management and so on are handled by the Linux kernel. Like Java and .NET, Android uses its own run time and virtual machine to manage application memory. Unlike either of these frameworks, the Android run time also manages the lifetime processes. Each Android application runs in a separate process within its own Dalvik instance, relinquishing all responsibility for memo

@MuhamedFathy
MuhamedFathy / StickyRxBus.java
Created Nov 9, 2017 — forked from brendanw/StickyRxBus.java
RxBus with Sticky Events
View StickyRxBus.java
/**
* An RxJava-backed EventBus class that can support sending and receiving multiple event types.
*
* Based on https://gist.github.com/benjchristensen/04eef9ca0851f3a5d7bf
*/
public class EventBus<T> {
private static EventBus<Object> INSTANCE;
private List<T> events;
View EndlessRecyclerOnScrollListener.java
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@MuhamedFathy
MuhamedFathy / build.gradle
Created Apr 3, 2017 — forked from jackgris/build.gradle
Example of use from Proguard, from Android Studio
View build.gradle
buildscript {
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT'
View MapAnimator.java
import android.graphics.Color;
import android.location.Location;
import android.os.Handler;
import android.os.SystemClock;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
View Animator.java
public class Animator implements Runnable {
private static final int ANIMATE_SPEEED = 800;
private static final int ANIMATE_SPEEED_TURN = 1000;
private static final int BEARING_OFFSET = 20;
private final Interpolator interpolator = new LinearInterpolator();
int currentIndex = 0;
View 1MarkerAnimation.java
/* Copyright 2013 Google Inc.
Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0.html */
package com.example.latlnginterpolation;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;
@MuhamedFathy
MuhamedFathy / ActivityA.java
Created Mar 14, 2017
Stackoverflow answer, "Singleton in Android"
View ActivityA.java
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
@MuhamedFathy
MuhamedFathy / ResizeAnimation.java
Created Feb 11, 2017 — forked from rafali/ResizeAnimation.java
Resize animation on Android
View ResizeAnimation.java
public class ResizeAnimation extends Animation {
final int startWidth;
final int targetWidth;
View view;
public ResizeAnimation(View view, int targetWidth) {
this.view = view;
this.targetWidth = targetWidth;
startWidth = view.getWidth();
}
@MuhamedFathy
MuhamedFathy / SwipeRefreshLayoutWithEmpty.java
Created Jan 29, 2017 — forked from grennis/SwipeRefreshLayoutWithEmpty.java
This class allows easy use of SwipeRefreshLayout with RecyclerView (or ListView) and an "empty" view that can still be pulled to refresh
View SwipeRefreshLayoutWithEmpty.java
package com.innodroid.sample;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
//
You can’t perform that action at this time.