Skip to content

Instantly share code, notes, and snippets.

View Palatis's full-sized avatar

Victor Tseng Palatis

View GitHub Profile
@Palatis
Palatis / RespectLayoutParamsActivity.java
Last active April 4, 2016 12:14
Activities with Dialog theme doesn't always respect to LayoutParams. This class addresses this, so wrap_conetnt actually **does** wrap_content.
import android.support.v7.app.AppCompatActivity;
//import android.app.Activity; // import this if you don't want to use the AppComat package.
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
import android.view.WindowManager;
/**
* the activity with a Dialog theme doesn't really respect the "wrap_content" params.
public class MyCustomView extends View {
public MyCustomView(Context context) { this(context, R.style.MyCustomView); }
public MyCustomView(Context context, AttributeSet attrs) { this(context, attrs, 0); }
public MyCustomView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final int defStyleRes = 0;
#include <Arduino.h>
#include <FS.h>
#include <i2s.h>
#include <opusfile_spiffs.hpp>
#define SAMPLE_RATE_HZ (32000)
void setup() {
#ifndef __ADCMUX_HPP__
#define __ADCMUX_HPP__
#include <Arduino.h>
#include <cstdarg>
extern "C" int system_adc_read();
#ifndef ADC_RESOLUTION_BITS
byte oldState = HIGH;
time_t downMillis = 0;
time_t lastTickMillis = 0;
void loop() {
byte state = digitalRead(BTN);
if (oldState != state) {
if (state == LOW) {
clock.tick(); // button just pressed, tick the first time...
lastTickMillis = downMillis = millis();
}
@Palatis
Palatis / TheActivity.java
Created April 24, 2017 11:42
RecyclerView recycle test
package com.fitivision.iot.p2p.ui;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
@Palatis
Palatis / CustomToolbar.java
Created June 16, 2017 14:49
CustomToolbar with custom Title/Subtitle and NavIcon views
public class CustomToolbar extends android.support.v7.widget.Toolbar {
private static final String TAG = "CustomToolbar";
public CustomToolbar(Context context) {
this(context, null);
}
public CustomToolbar(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
@Palatis
Palatis / .gitignore
Created June 19, 2017 09:44
archive output APK (AS 3.0 rc4)
/archive
@Palatis
Palatis / MultilineHintTextInputLayout.java
Last active June 24, 2017 01:00
MultilineHintTextInputLayout :-D
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.annotation.StringRes;
import android.support.design.widget.TextInputLayout;
@Palatis
Palatis / BindingFragment.java
Last active September 10, 2021 16:07
generic android DataBinding Fragment super class
public class BindingFragment<BindingT extends ViewDataBinding> extends Fragment {
private BindingT mBinding = null;
private boolean mSuperCalled = false;
protected BindingT getBinding() {
return mBinding;
}
@Nullable
@Override