Skip to content

Instantly share code, notes, and snippets.

View mohamad-shafaee's full-sized avatar

Mohammad Shafaei mohamad-shafaee

View GitHub Profile
public class InnerClassReferenceLeakActivity extends AppCompatActivity {
private LeakyClass leakyClass;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
/*
public class InnerClassReferenceLeakActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
new LeakyClass(this).redirectToAnotherActivity();
}
public class PieView extends View {
public PieView(Context context){
//this(context, null, 0);
super(context);
}
public PieView(Context context, AttributeSet attrs){
//this(context, attrs, 0);
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
width = w;
height = h;
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
rect.left = 0;
rect.top = 0;
if(ori == Configuration.ORIENTATION_PORTRAIT) {
rect.bottom = height / 3;
rect.right = width;
package com.msh_n.myp.customview1;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
<com.msh_n.myp.customview1.PieView
android:id="@+id/pieView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:backgroundColor="@color/light_green"
app:titleText="Foreground color"
app:viewColor="@color/pink" />
<com.msh_n.myp.customview1.PieView
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="PieView">
<attr name="titleText" format="string" localization="suggested" />
<attr name="backgroundColor" format="color" />
<attr name="viewColor" format="color" />
</declare-styleable>
</resources>
package com.msh_n.myp.customview1;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
android:animateLayoutChanges="true"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.msh_n.myp.customview1.MainActivity">