Skip to content

Instantly share code, notes, and snippets.

View SelvinPL's full-sized avatar

SelvinPL SelvinPL

View GitHub Profile
interface BTPrinter
{
void printAt(int top, int left, String message);
//add more methods here
void selectFont(String font);
void cutThePaper();
}
class ZebraPrinter implements BTPrinter
private int _styleId = SOMEDEFAULTSTYLE;
public void setCustomStyle(int styleId) {
_styleId = styleId;
if(mEditText != null){
if(styleId == 1) {
mEditText.setTextAppearance(getActivity(), android.R.style.TextAppearance_Small);
}
else if(styleId == 2) {
apply plugin: 'com.android.application'
def createTheme(colorPrimary, colorPrimaryDark, colorAccent, colorDisabled) {
def returnTheme = new Expando()
returnTheme.colorPrimary = colorPrimary
returnTheme.colorPrimaryDark = colorPrimaryDark
returnTheme.colorAccent = colorAccent
returnTheme.colorDisabled = colorDisabled
return returnTheme
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Automatically generated file. DO NOT MODIFY -->
<!-- Values from the variant -->
<item name="colorAccent" type="color">#8CC63F</item>
<item name="colorAccentA10" type="color">#198CC63F</item>
<item name="colorAccentA20" type="color">#338CC63F</item>
<item name="colorAccentA30" type="color">#4c8CC63F</item>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-6dp"
android:right="-6dp"
android:top="-6dp">
<shape>
<solid android:color="@android:color/black" />
<stroke
android:width="5dp"
//use this builder instead NotificationCompat.BigPictureStyle (also use standard Notification not compat)
static class MyPictureBuilder extends Notification.BigPictureStyle{
@NonNull
@Override
protected RemoteViews getStandardView(int layoutId) {
RemoteViews ret = super.getStandardView(layoutId);
int id = Resources.getSystem().getIdentifier("text", "id", "android");
ret.setBoolean(id, "setSingleLine", false);
ret.setInt(id, "setLines", 4);
package pl.selvin.android.broadcastkilled;
import android.app.Activity;
import android.app.Notification;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
@SelvinPL
SelvinPL / gist:d94b2b617519e0510a40
Last active January 24, 2018 10:46
usage: WebPUtils.isWebPSupported() works with API >= 8
package pl.selvin.android.xxxxxx;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
/**
* Created by selvin on 2015-01-28.
*/
public class WebPUtils {
//states
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class TestActivity extends Activity {
//well context is not valid yet, but we will use later so it is ok to use "this"
private Helper helper = new Helper(this);
interface IMySuperInterface {
void setNumPlats(int numero);
}
class MyAtivity extends Activity implements IMySuperInterface {
//do the implentation and other stuff;
}
class MyFragment extends Fragment {
IMySuperInterface defaultInstance = new IMySuperInterface {