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
6 changes: 0 additions & 6 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListViewActivity"
android:windowSoftInputMode="adjustPan" />
<activity android:name=".NetworkActivity" />
<activity android:name=".JSONActivity" />
<activity android:name=".NotificationActivity" />
<activity
android:name=".PaceCalculatorActivity"
android:label="@string/title_activity_pace_calculator"
Expand Down
94 changes: 94 additions & 0 deletions src/main/java/nyc/c4q/BookInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package nyc.c4q;

/**
* Created by c4q-marbella on 8/30/15.
*/
public class BookInfo {

public int id;
public String title;
public String author;
public long isbn;
public long isbn13;
public String publisher;
public int publishyear;

public BookInfo(String author, int id, long isbn, long isbn13, int publishyear, String publisher, String title) {
this.author = author;
this.id = id;
this.isbn = isbn;
this.isbn13 = isbn13;
this.publishyear = publishyear;
this.publisher = publisher;
this.title = title;
}

public int getId() {
return id;
}

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

public String getAuthor() {
return author;
}

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

public long getIsbn13() {
return isbn13;
}

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

public long getIsbn() {
return isbn;
}

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

public int getPublishyear() {
return publishyear;
}

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

public String getPublisher() {
return publisher;
}

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

public String getTitle() {
return title;
}

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

@Override
public String toString() {
return "BookInfo{" +
"author='" + author + '\'' +
", id=" + id +
", title='" + title + '\'' +
", isbn=" + isbn +
", isbn13=" + isbn13 +
", publisher='" + publisher + '\'' +
", publishyear=" + publishyear +
'}';
}
}
53 changes: 53 additions & 0 deletions src/main/java/nyc/c4q/JSONHelperVerison.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package nyc.c4q;

import android.content.Context;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.reflect.Type;
import java.util.List;

/**
* Created by c4q-marbella on 8/30/15.
*/
public class JSONHelperVerison {

public static List<MemberInfo> loadStaticMemberJsonRawUsingGson(Context context, int jsonResource) {

InputStream raw = context.getResources().openRawResource(jsonResource);
Reader rd = new BufferedReader(new InputStreamReader(raw));
Gson gson = new Gson();

String jsonOutput = "Your JSON String";
Type listType = new TypeToken<List<MemberInfo>>(){}.getType();
List<MemberInfo> memberInfos = (List<MemberInfo>) gson.fromJson(jsonOutput, listType);
return memberInfos;
}

public static String convertToJsonUsingGson(MemberInfo memberInfo) {
Gson gson = new Gson();
String json = gson.toJson(memberInfo);
return json;
}


public static BookInfo loadStaticBookJsonRawUsingGson(Context context, int jsonResource) {

InputStream raw = context.getResources().openRawResource(jsonResource);
Reader rd = new BufferedReader(new InputStreamReader(raw));
Gson gson = new Gson();
BookInfo bookInfo = gson.fromJson(rd, BookInfo.class);
return bookInfo;
}

public static String convertToJsonUsingGson(BookInfo bookInfo) {
Gson gson = new Gson();
String json = gson.toJson(bookInfo);
return json;
}
}
33 changes: 33 additions & 0 deletions src/main/java/nyc/c4q/LibraryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,49 @@
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;


public class LibraryActivity extends Activity {

public EditText inputParameter;
private TextView display;
private Button buttonMemberInfo;
private Button buttonBookInfo;
private Button buttonCheckedOut;


private static final String TAG = LibraryActivity.class.getSimpleName();

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

inputParameter = (EditText) findViewById(R.id.input_parameter);
display = (TextView) findViewById(R.id.text_display);
buttonMemberInfo = (Button) findViewById(R.id.button_getMember);
buttonBookInfo = (Button) findViewById(R.id.button_getBook);
buttonCheckedOut = (Button) findViewById(R.id.button_getCheckedOut);

// // MemberInfo memberInfo = JSONHelperVerison.loadStaticMemberJsonRawUsingGson(this, R.raw.members);
// // Log.d(TAG, "membersJSON:\n" + memberInfo);
//
// String memberResponse = JSONHelperVerison.convertToJsonUsingGson(memberInfo);
// Log.d(TAG, "membersjson:" + memberResponse);
}

public void checkOut(int memberId, int bookId) {
// TODO This method is called when the member with the given ID checks
// out the book with the given ID. Update the system accordingly.
// The due date for the book is two weeks from today.





}

public boolean checkIn(int memberId, int bookId) {
Expand All @@ -36,6 +60,7 @@ public boolean checkIn(int memberId, int bookId) {
public void button_getMember_onClick(View view) {
String name = inputParameter.getText().toString();


// TODO Display member information for the member with the given name.
}

Expand All @@ -53,4 +78,12 @@ public void button_getCheckedOut_onClick(View view) {
// earliest due first.
}









}
66 changes: 64 additions & 2 deletions src/main/java/nyc/c4q/ListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@

import android.app.Activity;
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.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class ListActivity extends Activity {

public ListView list;
Button namebt;
Button colorbt;
ArrayAdapter<List> adapter;

public static final Person[] PEOPLE = {
new Person("Hannah", "Abbott", House.Hufflepuff),
Expand Down Expand Up @@ -47,7 +57,59 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);

final PersonsAdapter adapter = new PersonsAdapter(this,PEOPLE);
list = (ListView) findViewById(R.id.list);

final List memberList = Arrays.asList(PEOPLE);

list.setAdapter(adapter);

namebt = (Button) findViewById(R.id.button_name);
colorbt = (Button) findViewById(R.id.button_color);



namebt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
list.setAdapter(adapter);
if(namebt.isPressed()) {
Collections.sort(memberList);
adapter.notifyDataSetChanged();
}
// else{
// Collections.reverse(memberList);
// adapter.notifyDataSetChanged();
// }
}
});




colorbt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

Map<String, Integer> housecolors = new HashMap<String, Integer>();
housecolors.put("Gryffindor", R.color.gryffindor_red);
housecolors.put("Ravenclaw", R.color.ravenclaw_blue);
housecolors.put("Hufflepuff", R.color.hufflepuff_yellow);
housecolors.put("Slytherin", R.color.slytherin_green);


for(int i=0;i<list.getChildCount();i++) {
View item = list.getChildAt(i);
//TODO: fix null pointer
item.setBackgroundColor(housecolors.get(housecolors));
}
}


});


}


}
Loading