Back to project page BookHunter.
The source code is released under:
Apache License
If you think the Android project BookHunter listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.appspot.brownbookhunter; /*from w w w . j a v a 2 s . c om*/ import org.json.JSONException; import org.json.JSONObject; import android.os.Parcel; import android.os.Parcelable; public class Book implements Comparable<Book>, Parcelable{ private int allTimeCheckouts; private int recentCheckouts; private String isbn; private String callNumber; private String author; private String publisher; private String publisherPlace; private String title; private String year; private String barcode; public Book(JSONObject j) throws JSONException { allTimeCheckouts = Integer.parseInt((String) j.get("all_time_checkouts")); recentCheckouts = Integer.parseInt((String) j.get("recent_checkouts")); isbn = (String) j.get("isbn_dirty"); callNumber = (String) j.get("call_no"); author = (String) j.get("author"); publisher = (String) j.get("publisher"); publisherPlace = (String) j.get("pub_place"); title = (String) j.get("title"); year = (String) j.get("year"); barcode = (String) j.get("barcode"); } public Book(Parcel in) { String[] data = new String[10]; in.readStringArray(data); allTimeCheckouts = Integer.parseInt(data[0]); recentCheckouts = Integer.parseInt(data[1]); isbn = data[2]; callNumber = data[3]; author = data[4]; publisher = data[5]; publisherPlace = data[6]; title = data[7]; year = data[8]; barcode = data[9]; } //negative if less than @Override public int compareTo(Book arg0) { return (arg0.allTimeCheckouts + arg0.recentCheckouts * 2) - (allTimeCheckouts + 2 * recentCheckouts); } public int getAllTimeCheckouts() { return allTimeCheckouts; } public int getRecentCheckouts() { return recentCheckouts; } public String getIsbn() { return isbn; } public String getCallNumber() { return callNumber; } public String getAuthor() { return author; } public String getPublisher() { return publisher; } public String getPublisherPlace() { return publisherPlace; } public String getTitle() { return title; } public String getYear() { return year; } public String getBarcode() { return barcode; } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeStringArray(new String[]{ ""+allTimeCheckouts, ""+recentCheckouts, isbn, callNumber, author, publisher, publisherPlace, title, year, barcode }); } public static final Parcelable.Creator<Book> CREATOR= new Parcelable.Creator<Book>() { @Override public Book createFromParcel(Parcel source) { return new Book(source); //using parcelable constructor } @Override public Book[] newArray(int size) { return new Book[size]; } }; }