Skip to content
This repository was archived by the owner on Apr 20, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ dependencies {
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.google.code.gson:gson:2.3.1'

compile 'com.j256.ormlite:ormlite-android:4.48'

// TODO: requires special build of robolectric right now. working on this...
testCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
Expand Down
170 changes: 170 additions & 0 deletions src/main/java/nyc/c4q/Book.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package nyc.c4q;

/**
* Created by c4q-raynaldie on 8/30/15.
*/
public class Book {
int id;
String title;
String author;
String isbn;
String isbn13;
String publisher;
String publishyear;
boolean checkedout;
String checkedoutby;
String checkoutdateyear;
String checkoutdatemonth;
String checkoutdateday;
String duedateyear;
String duedatemonth;
String duedateday;


public Book(int id, String title, String author, String isbn, String isbn13, String publisher, String publishyear, boolean checkedout, String checkedoutby, String checkoutdateyear, String checkoutdatemonth, String checkoutdateday, String duedateyear, String duedatemonth, String duedateday) {
this.id = id;
this.title = title;
this.author = author;
this.isbn = isbn;
this.isbn13 = isbn13;
this.publisher = publisher;
this.publishyear = publishyear;
this.checkedout = checkedout;
this.checkedoutby = checkedoutby;
this.checkoutdateyear = checkoutdateyear;
this.checkoutdatemonth = checkoutdatemonth;
this.checkoutdateday = checkoutdateday;
this.duedateyear = duedateyear;
this.duedatemonth = duedatemonth;
this.duedateday = duedateday;
}

public Book() {
}


public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getAuthor() {
return author;
}

public void setAuthor(String author) {
this.author = author;
}

public String getIsbn() {
return isbn;
}

public void setIsbn(String isbn) {
this.isbn = isbn;
}

public String getIsbn13() {
return isbn13;
}

public void setIsbn13(String isbn13) {
this.isbn13 = isbn13;
}

public String getPublisher() {
return publisher;
}

public void setPublisher(String publisher) {
this.publisher = publisher;
}

public String getPublishyear() {
return publishyear;
}

public void setPublishyear(String publishyear) {
this.publishyear = publishyear;
}

public boolean isCheckedout() {
return checkedout;
}

public void setCheckedout(boolean checkedout) {
this.checkedout = checkedout;
}

public String getCheckedoutby() {
return checkedoutby;
}

public void setCheckedoutby(String checkedoutby) {
this.checkedoutby = checkedoutby;
}

public String getCheckoutdateyear() {
return checkoutdateyear;
}

public void setCheckoutdateyear(String checkoutdateyear) {
this.checkoutdateyear = checkoutdateyear;
}

public String getCheckoutdatemonth() {
return checkoutdatemonth;
}

public void setCheckoutdatemonth(String checkoutdatemonth) {
this.checkoutdatemonth = checkoutdatemonth;
}

public String getCheckoutdateday() {
return checkoutdateday;
}

public void setCheckoutdateday(String checkoutdateday) {
this.checkoutdateday = checkoutdateday;
}

public String getDuedateyear() {
return duedateyear;
}

public void setDuedateyear(String duedateyear) {
this.duedateyear = duedateyear;
}

public String getDuedatemonth() {
return duedatemonth;
}

public void setDuedatemonth(String duedatemonth) {
this.duedatemonth = duedatemonth;
}

public String getDuedateday() {
return duedateday;
}

public void setDuedateday(String duedateday) {
this.duedateday = duedateday;
}
}





151 changes: 117 additions & 34 deletions src/main/java/nyc/c4q/ListActivity.java
Original file line number Diff line number Diff line change
@@ -1,53 +1,136 @@
package nyc.c4q;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;


public class ListActivity extends Activity {
private Button flip;
private ListView list;
private ArrayAdapter<String> adapter;

ArrayList names;
ArrayList names2;

public ListView list;

public static final Person[] PEOPLE = {
new Person("Hannah", "Abbott", House.Hufflepuff),
new Person("Katie", "Bell", House.Gryffindor),
new Person("Susan", "Bones", House.Hufflepuff),
new Person("Terry", "Boot", House.Ravenclaw),
new Person("Lavender", "Brown", House.Gryffindor),
new Person("Cho", "Chang", House.Ravenclaw),
new Person("Michael", "Corner", House.Ravenclaw),
new Person("Colin", "Creevey", House.Gryffindor),
new Person("Marietta", "Edgecombe", House.Ravenclaw),
new Person("Justin", "Finch-Fletchley", House.Hufflepuff),
new Person("Seamus", "Finnigan", House.Gryffindor),
new Person("Anthony", "Goldstein", House.Ravenclaw),
new Person("Hermione", "Granger", House.Gryffindor),
new Person("Angelina", "Johnson", House.Gryffindor),
new Person("Lee", "Jordan", House.Gryffindor),
new Person("Neville", "Longbottom", House.Gryffindor),
new Person("Luna", "Lovegood", House.Ravenclaw),
new Person("Ernie", "Macmillan", House.Hufflepuff),
new Person("Parvati", "Patil", House.Gryffindor),
new Person("Padma", "Patil", House.Ravenclaw),
new Person("Harry", "Potter", House.Gryffindor),
new Person("Zacharias", "Smith", House.Hufflepuff),
new Person("Alicia", "Spinnet", House.Gryffindor),
new Person("Dean", "Thomas", House.Gryffindor),
new Person("Fred", "Weasley", House.Gryffindor),
new Person("George", "Weasley", House.Gryffindor),
new Person("Ginny", "Weasley", House.Gryffindor),
new Person("Ron", "Weasley", House.Gryffindor)
};

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

list = (ListView) findViewById(R.id.list);
flip = (Button) findViewById(R.id.flipID);

SharedPreferences settings;
settings = ListActivity.this.getSharedPreferences("PREFS_NAME", 0);
String name = settings.getString("flipText","");
//button.setVisibility(View.VISIBLE);
if (! name.equals("")){
flip.setText(name);
}

names = new ArrayList<String>();
names.add("Hannah Abbott");
names.add("Katie Bell");
names.add("Susan Bones");
names.add("Terry Boot");
names.add("Lavender Brown");
names.add("Cho Chang");
names.add("Michael Corner");
names.add("Colin Creevey");
names.add("Marietta Edgecombe");
names.add("Justin Finch-Fletchley");
names.add("Seamus Finnigan");
names.add("Anthony Goldstein");
names.add("Hermione Granger");
names.add("Angelina Johnson");
names.add("Lee Jordan");
names.add("Neville Longbottom");
names.add("Luna Lovegood");
names.add("Ernin Macmillan");
names.add("Parvati Patil");
names.add("Padma Patil");
names.add("Harry Potter");
names.add("Zacharias Smith");
names.add("Alicia Spinnet");
names.add("Dean Thomas");
names.add("Fred Weasley");
names.add("George Weasley");
names.add("Ginny Weasley");
names.add("Ron Weasley");

names2 = new ArrayList<String>();
names2.add("Abbott, Hannah");
names2.add("Bell, Katie");
names2.add("Bones, Susan");
names2.add("Boot, Terry");
names2.add("Brown, Lavender");
names2.add("Chang, Cho");
names2.add("Corner, Michael");
names2.add("Creevey, Colin");
names2.add("Edgecombe, Marietta");
names2.add("Finch-Fletchley, Justin");
names2.add("Finnigan, Seamus");
names2.add("Goldstein, Anthony");
names2.add("Granger, Hermione");
names2.add("Johnson, Angelina ");
names2.add("Jordan, Lee");
names2.add("Longbottom, Neville");
names2.add("Lovegood, Luna");
names2.add("Macmillan, Ernin");
names2.add("Patil, Parvati");
names2.add("Patil, Padma");
names2.add("Potter, Harry");
names2.add("Smith, Zacharias");
names2.add("Spinnet, Alicia");
names2.add("Thomas, Dean");
names2.add("Weasley, Fred");
names2.add("Weasley, George");
names2.add("Weasley, Ginny");
names2.add("Weasley, Ron");

if (flip.getText().toString().equals("Last, First")){
adapter = new ArrayAdapter<>(ListActivity.this, android.R.layout.simple_list_item_1, names);
list.setAdapter(adapter);
}
else {
adapter = new ArrayAdapter<>(ListActivity.this, android.R.layout.simple_list_item_1, names2);
list.setAdapter(adapter);
}


}
public void flipM (View v){
if (flip.getText().toString().equals("Last, First")){
flip.setText("First Last");
adapter = new ArrayAdapter<>(ListActivity.this, android.R.layout.simple_list_item_1, names2);
list.setAdapter(adapter);
}
else {
flip.setText("Last, First");
adapter = new ArrayAdapter<>(ListActivity.this, android.R.layout.simple_list_item_1, names);
list.setAdapter(adapter);
}
}
@Override
protected void onStop() {
super.onStop();

String flipText = flip.getText().toString();

SharedPreferences settings;
settings = ListActivity.this.getSharedPreferences("PREFS_NAME", 0);
SharedPreferences.Editor editor = settings.edit();

editor.putString("flipText", flipText);
editor.commit();

}
}
Loading