Code Monkey home page Code Monkey logo

android-inventory-app's Introduction

android-inventory-app

I developed this project as part of the Udacity Code Reviewer training.

This is an inventory app that implementes a Realm database. It allows you to create item records, view them in a list, and modify their quantities on a detail Layout. On the detail Layout, you can sell the item by clicking on the Fab button, modify the quantities on hand, send an email to the vendor for reorder, or delete the item.

I implemented two kinds of intent.

  • ACTION_PICK intent on the uploadImage method so you can select an image from your Gallery/Documents folder and store it in the app
  • ACTION_SENDTO intent on the composeEmail method so you can send an email to item's vendor to purchase more of the item when you're running low

I also implemented a RecyclerView.Adapter to bind the Realm data to the item's list.

You can see some screenshots below.

ScreenShot ScreenShot ScreenShot

android-inventory-app's People

Contributors

throwrocks avatar

Stargazers

 avatar

Watchers

 avatar  avatar

android-inventory-app's Issues

THE APP CRASHED

the app has crashed
at rocks.athrow.android_inventory_app.ItemListActivity.setupRecyclerView(ItemListActivity.java:62)
at rocks.athrow.android_inventory_app.ItemListActivity.onStart(ItemListActivity.java:51).

package rocks.athrow.android_inventory_app;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.View;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmResults;

public class ItemListActivity extends AppCompatActivity {
private static final String LOG_TAG = ItemListActivity.class.getSimpleName();

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_list);


    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if (toolbar != null) {
        toolbar.setTitle(getTitle());
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    if (fab != null) {
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getApplicationContext(), ItemDetailDataEntry.class);
                startActivity(intent);

            }
        });
    }
}

@Override
protected void onStart() {
    super.onStart();
    View recyclerView = findViewById(R.id.item_list);
    assert recyclerView != null;
    setupRecyclerView((RecyclerView) recyclerView);

}

private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    RealmConfiguration realmConfig = new RealmConfiguration.Builder(this).build();
    Realm.setDefaultConfiguration(realmConfig);
    Realm realm = Realm.getDefaultInstance();
    realm.beginTransaction();
    final RealmResults<Item> items = realm.where(Item.class).findAll();
    realm.commitTransaction();
    int size = items.size();
    Log.e(LOG_TAG, "size " + size);
    if (size > 0) {
        recyclerView.setAdapter(new ItemListAdapter(this, realm.where(Item.class).findAllAsync()));
        recyclerView.setHasFixedSize(true);
    }

}

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.