Friday, October 23, 2015

App a Day 18: Todo with DatePicker

https://github.com/victorman/TodoAndroid



Classes Used: DatePicker, Preference, PreferenceActivity, CheckBoxPreference, SharedPreferences, Preference Manager, OnPreferenceChangeListener, OnPreferenceClickListener

I fought with this one for a good while. I'll say if you're starting a new project it's probably a good idea to store dates as string. If you are storing them as integer's just remember that SQLite assumes your time is in the format epoch time in SECONDs. Not milliseconds, even though an integer in SQLite is 64 bits, same as java's long. Okay just remember that.

Saturday, October 17, 2015

App a Day 16: Coursera Android Concurrency Assignment 1

Day 16 is unconventional, I'm going through Coursera's online class called: "Programming Mobile Services for Android Handheld Systems: Concurrency." This is the first assignment from that course. The assignment is to implement a couple of predefined Threads and Runnables and use a java semaphore. The UI and the app structure already existed. Here's the unfinished source.

Thursday, October 15, 2015

App a Day 15: OneTableApp with Parse Login

https://github.com/victorman/OneTableAndroid/tree/login



As when you're doing anything simple in android simply combining yesterday's app with the previous OneTableApp using parse was 'anything other than simple. More build.gradle problems (remove "compile fileTree(dir: 'libs', include: ['*.jar'])"). Parse's signUpInBackground wasn't even running the SignUpCallback's done method (Restart your emulator). And somehow one of my AppCompatActivity wasn't using an AppCompat theme (check all of your styles.xml files, all of them).

Wednesday, October 14, 2015

App a Day 14: Simple Login w/ Parse

https://github.com/victorman/SimpleLogin/tree/parse



Uses Classes: ParseUser, ParseObject, Intent.

This app demonstrates a simple log in, log out, and sign up UI for parse. I started with the Login template from android studio, but I think things would have been simpler if I had just started from scratch and followed the parse guide.

Sunday, October 11, 2015

App a Day 13: Todo

https://github.com/victorman/TodoAndroid



Uses Classes: ListActivity, SQLiteOpenHelper, SQLiteDatabase, CursorAdapter, PreferenceActivity

I finally decided to make this staple app way later than I should have. There really isn't anything new in this app just reenforcing things I've already learned. I did make some effort to at least write down steps to implement the common patterns in this app that I would use again.

  • Local SQLiteDatabase for persistent storage
    1. Define one or more Contract classes. You could do one Contract for a number of tables or one contract for every table. It's up to you how you organize it. You just need to know where things are.
    2. Define a static Entry class, which implements BaseColumns, for every table you will use in your database.
    3. Extend SQLiteOpenHelper and override onCreate and onUpgrade methods and define a constructor. The onCreate method will call db.execSQL on a string containing your create table query.
    4. Define static CRUD methods for each action you'll be taking on the database. Make these methods of the Contract class so you can access them from anywhere (Activity, Adapter, etc.)
  • ListView with CursorAdapter
    1. Create a ListView with android:id="@android/id:list" in your main activities layout.
    2. Create a layout file layout/list_item_layout.xml.
    3. Extend CursorAdapter in a new class defining a constructor and overriding the newView and bindView methods. In new view inflate R.layout.list_item_layout and return it.
    4. Optionally, create a static private class called ViewHolder. In here define public field variables for each of the views in your list item's layout. Define a constructor that requires a view as a parameter and using that view's findViewById method assign your field variables to these views for easy access later. In your overridden newView method you instantiate a ViewHolder and call setTag on the view which you return. When you implement bindView call getTag on the view and cast it to the ViewHolder type to access the view identifiers.

Friday, October 9, 2015

App a Day 12: InsideArea

https://github.com/victorman/InsideAreaAndroid



Uses Classes: LocationListener, GoogleMap, Polygon, LatLng.

Today's app returns to google maps to determine if the gps location is in a given boundary. It implements a ray casting algorithm to determine if a point is within a polygon. I would have expected this to be built into the google maps API's library, but all of the solutions I found to do this suggest there is not. However, implementing the algorithm isn't very complex.

Thursday, October 8, 2015

App a Day 11: Checklist

https://github.com/victorman/ChecklistAndroid



Classes Used: AsyncTask, ArrayAdapter, ListActivity.

This one was much more problematic than I had anticipated. I will probably revisit this one soon.

Tuesday, October 6, 2015

App a Day 10: Camera

https://github.com/victorman/CameraAndroid




Uses Classes: Camera, SurfaceView, SurfaceHolder.Callback, CameraPreview.

I hadn't intended to take a week off, but I stayed with my parents before my sisters wedding and it was pretty difficult to not get involved in wedding preparations.

So I have a lot of running to do. But here's another simple app. I simply followed this guide omitting the video stuff and filling it in with a fix.