Commit 46205330 authored by Edy Thenedy's avatar Edy Thenedy

I added lines to be able to view the result of the listings in a better way

parent 25b9498c
......@@ -7,11 +7,15 @@ import edu.gmu.srct.bookshare.api.Seller;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TableLayout;
......@@ -23,16 +27,39 @@ import android.widget.Toast;
@TargetApi(17)
public class Listings extends Activity implements OnClickListener,BookshareAPI {
private TextView myText = null;
private TextView myText, searchResult = null;
private Listing [] listing = new Listing[1000];
private TableLayout prodList;
private View ruler = null;
private String author = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listings);
myText = (TextView) findViewById(R.id.header);
//myText = (TextView) findViewById(R.id.header);
String value = getIntent().getExtras().getString("bookInfoRequest");
prodList = (TableLayout) findViewById(R.id.tbl_listing);
// Check to determine if the input is based on ISBN or Title or Author
try
{
int isbn = Integer.parseInt(value);
}
catch(NumberFormatException e)
{
author = value;
} // end try catch
/*
// Find the book based on ISBN
listing = getListingByISBN(value);
for(int i = 0; i < listing.length; i++)
{
//if(value.equals("something in the database or somewhere then show the listings"))
}
/*
try
{
......@@ -43,11 +70,144 @@ public class Listings extends Activity implements OnClickListener,BookshareAPI {
}
// This line works
//myText.append(value);
myText.append(value);
*/
//listing = getListingByISBN(value);
// Testing the setters
Seller seller [] = new Seller[1000];
String sellerName [] = {"Sarah Johnson", "Melissa Fly", "Andrew Jackson", "Mark Zuckerberg", "Matthew Matson", "John Legend"};
double price [] = {10, 25, 55, 20, 30, 30};
// Add GMU BOOKSHARE to the page
myText = new TextView(this);
myText.setText("GMU BOOKSHARE");
myText.setTextSize(30);
myText.setGravity(Gravity.CENTER);
prodList.addView(myText);
// Add Search Results to the page
searchResult = new TextView(this);
searchResult.setText("Search Results");
searchResult.setTextSize(20);
searchResult.setGravity(Gravity.CENTER);
prodList.addView(searchResult);
int i = 0;
// Create the objects
do
{
listing[i] = new Listing();
listing[i].setPrice(price[i]);
seller[i] = new Seller();
seller[i].setFullName(sellerName[i]);
i++;
}
while(i < price.length);
i = 0;
do
{
display("","");
display("Image" + "\ngoes" + "\nhere", "Title: Java\n" + "Price: " + listing[i].getPrice() + "\n" + "ISBN: 124546464445");
displaySellerButton("", "Contact: " + seller[i].getFullName() + "\n"); // To display the sellerButton on the second table
display("","");
// Ruler - To print the ruler after each listing
ruler = new View(this);
ruler.setBackgroundColor(Color.LTGRAY);
prodList.addView(ruler,
new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, 2));
display("","");
i++;
}
while(i < price.length);
display("Seller id: ", "Seller Name : ");
display("Author id: ", "Author Name:" + author + "\nBook Info: ");
} // end onCreate()
// To display the seller in a table
void displaySellerButton(String id, String name)
{
TableRow tr2 = new TableRow(this);
tr2.layout(0, 0, 0, 0);
TextView lblid = new TextView(this);
lblid.setText("" + id);
lblid.setTextColor(Color.BLACK);
lblid.setTextSize((float) 12);
lblid.setTypeface(null, 1);
lblid.setBackgroundColor(Color.TRANSPARENT);
lblid.setPadding(30, 0, 0, 0);
tr2.setPadding(0, 1, 0, 0);
tr2.addView(lblid);
TextView lblname = new TextView(this);
lblname.setText("" + name);
lblname.setTextColor(Color.BLACK);
lblname.setTextSize((float) 12);
lblname.setTypeface(null, 1);
Button contactButton = new Button(this);
contactButton.setText("" + lblname.getText().toString().trim());
contactButton.setTextSize(12);
contactButton.setTextColor(Color.WHITE);
contactButton.setWidth(10);
contactButton.setHeight(10);
contactButton.setBackgroundResource(R.color.button_background);
contactButton.setPadding(30, 0, 20, 0);
tr2.setPadding(0, 1, 0, 1);
tr2.addView(contactButton);
prodList.addView(tr2, new TableLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} // end displaySellerButton
// To display it in a table
void display(String id, String name) {
TableRow tr2 = new TableRow(this);
tr2.layout(0, 0, 0, 0);
TextView lblid = new TextView(this);
lblid.setText("" + id);
lblid.setTextColor(Color.BLACK);
lblid.setTextSize((float) 12);
lblid.setTypeface(null, 1);
lblid.setBackgroundColor(Color.TRANSPARENT);
lblid.setPadding(30, 0, 0, 0);
tr2.setPadding(0, 1, 0, 0);
tr2.addView(lblid);
TextView lblname = new TextView(this);
lblname.setText("" + name);
lblname.setTextColor(Color.BLACK);
lblname.setTextSize((float) 12);
lblname.setTypeface(null, 1);
lblname.setBackgroundColor(Color.TRANSPARENT);
lblname.setPadding(30, 0, 20, 0);
tr2.setPadding(0, 1, 0, 1);
tr2.addView(lblname);
prodList.addView(tr2, new TableLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
@Override
public void onClick(View arg0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment