Required tools for playing around with memory:
hexdump
objdump
readelf
xxd
gcore
fun PopupWindow.dimBehind(dim: Float = 0.3f) { | |
val container: View = contentView.rootView | |
val context = contentView.context | |
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager; | |
val p = container.layoutParams as WindowManager.LayoutParams; | |
p.flags = p.flags or WindowManager.LayoutParams.FLAG_DIM_BEHIND; // add a flag here instead of clear others | |
p.dimAmount = dim | |
wm.updateViewLayout(container, p); | |
} |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.text.style.ImageSpan; | |
import androidx.annotation.Px; | |
public class CenterVerticalImageSpan extends ImageSpan { |
/** | |
* If the return type must be the type of the class that implements the interface, | |
* then what you want is called an F-bounded type | |
*/ | |
public interface A<T extends A<T>> { | |
public T b(); | |
} | |
public class C implements A<C> { | |
public C b() { ... } |
apply plugin: 'jacoco' | |
jacoco { | |
version "0.7.1.201405082137" | |
} | |
task jacocoTestReportAndroidTest(type: JacocoReport, dependsOn: "connectedAndroidTest") { | |
def coverageSourceDirs = [ | |
'src/main/java' | |
] | |
group = "Reporting" |
import android.content.Context; | |
import android.content.DialogInterface; | |
import android.content.res.Resources; | |
import android.media.AudioManager; | |
import android.media.MediaPlayer; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.RequiresApi; | |
import android.support.v7.app.AlertDialog; |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.PrintWriter; | |
import java.net.Socket; | |
import java.net.SocketException; | |
import java.net.UnknownHostException; | |
import java.text.SimpleDateFormat; | |
import java.util.Arrays; | |
import java.util.Date; |
package com.example.jianguo.handlertest.adapters; | |
/** | |
* Created by JianGuo on 9/26/16. | |
* interface for all kinds of animals. | |
*/ | |
public interface Animal extends Visitable { | |
String say(); | |
} |
// Make a custom Gson instance, with a custom TypeAdapter for each wrapper object. | |
// In this instance we only have RealmList<RealmInt> as a a wrapper for RealmList<Integer> | |
Type token = new TypeToken<RealmList<RealmInt>>(){}.getType(); | |
Gson gson = new GsonBuilder() | |
.setExclusionStrategies(new ExclusionStrategy() { | |
@Override | |
public boolean shouldSkipField(FieldAttributes f) { | |
return f.getDeclaringClass().equals(RealmObject.class); | |
} |