Skip to content

Instantly share code, notes, and snippets.

View andersonleite's full-sized avatar
🎯
Focusing

Anderson Leite andersonleite

🎯
Focusing
View GitHub Profile
private static final String TAG = "NFC";
private NfcAdapter nfcAdapter;
private PendingIntent nfcPendingIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initialize NFC
@Override
protected void onResume() {
super.onResume();
Log.d(TAG, "enableForegroundMode");
// foreground mode gives the current active application priority for reading scanned tags
IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); // filter for tags
IntentFilter[] writeTagFilters = new IntentFilter[] {tagDetected};
nfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, writeTagFilters, null);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "onNewIntent");
// check for NFC related actions
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
ImageView lata = (ImageView) findViewById(R.id.lata);
public class BillFilter {
private BillDao dao;
@Inject
public BillFilter(BillDao dao) {
this.dao = dao;
}
public List<Bill> filter() {
@Module
public class BillModule
{
@Provides
public BillDao provideBillDao() {
return new BillDao();
}
}
@Component(modules = BillModule.class)
public class MainActivity extends ActionBarActivity {
private List<Bill> filteredBills;
private TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:design:22.2.0'
compile 'com.jakewharton:butterknife:7.0.1'
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/root"
android:layout_width="match_parent"
public class MainActivity extends ActionBarActivity {
@Bind(R.id.root) CoordinatorLayout layoutRoot;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
}
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromYDelta="0%p"
android:toYDelta="50%p"
android:duration="4000" />