Skip to content

Instantly share code, notes, and snippets.

@MensObscura
MensObscura / AudioDecoder.java
Created December 6, 2017 12:43
Read sound file (mp3 at least)
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
import android.media.MediaCodecInfo;
@MensObscura
MensObscura / AudioRecorder.java
Created December 6, 2017 12:39
AudioRecorder
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.util.Log;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@MensObscura
MensObscura / SoundWaveView
Last active December 6, 2017 12:25
Sound Wave Animation for vocal Listening
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
@MensObscura
MensObscura / PaddingTabLayout.java
Last active December 6, 2017 12:48
TabLayout WithPadding and no white bar on ripple
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.content.Context;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.widget.ImageView;
public class StartCropImageView extends ImageView {
Matrix matrix = new Matrix(getImageMatrix());
@MensObscura
MensObscura / CustomBottomNavigationView.java
Last active July 15, 2019 12:42
BottomNavigationView with shifModeDisable and Badge
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.support.design.internal.BottomNavigationItemView;
import android.support.design.internal.BottomNavigationMenuView;
import android.support.design.widget.BottomNavigationView;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.Gravity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.WindowManager;
public class SplashActivity extends Activity {
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.graphics.drawable.BitmapDrawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.ImageView;
public void movedListener() {
if (mImageFloating != null) {
final GestureDetector gestureDetector = new GestureDetector(getActivity(), new SingleTapConfirm());
final float maxWidth = UIUtils.getScreenWidthInPx(getContext()) - DisplayMetricsUtils.convertDpToPx(getContext(), 70);
final float maxHeight = UIUtils.getScreenHeightInPx(getContext()) - DisplayMetricsUtils.convertDpToPx(getContext(), 200);
final float minWidth = DisplayMetricsUtils.convertDpToPx(getContext(), 10);
final float minHeight = minWidth;
mImageFloating.setOnTouchListener(new View.OnTouchListener() {
public static class BlurTransformation implements com.squareup.picasso.Transformation {
private final float radius;
private Context mContext;
// radius is corner radii in dp
public BlurTransformation(final float radius, Context context) {
this.radius = radius;
this.mContext = context;
}