use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class BidTest method testSetBid.
/**
* Test for setting the bid
*/
public void testSetBid() {
User user = new User();
Task task = new Task();
AddUserRequest userRequest = new AddUserRequest(user);
RequestManager.getInstance().invokeRequest(userRequest);
userRequest.getResult();
AddTaskRequest request = new AddTaskRequest(task);
RequestManager.getInstance().invokeRequest(request);
request.getResult();
float bidAmount = 10.00f;
Bid bid = new Bid(user.getId(), task.getId(), 10.00f);
assertEquals(bid.getBidAmount(), bidAmount);
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class RequestManagerTest method testAddTaskRequest.
public void testAddTaskRequest() {
AddTaskRequest addTaskRequest = new AddTaskRequest(task);
RequestManager.getInstance().invokeRequest(ctx, addTaskRequest);
assertTrue(addTaskRequest.getResult());
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class SearchActivityTest method testSearch.
public void testSearch() {
// Set up for Test
MainActivity activity = (MainActivity) solo.getCurrentActivity();
solo.assertCurrentActivity("Wrong Activity", MainActivity.class);
solo.clickOnText("Sign Up");
solo.assertCurrentActivity("Wrong Activity", SignUpActivity.class);
solo.enterText((EditText) solo.getView(R.id.usernameField), "TestUser");
solo.enterText((EditText) solo.getView(R.id.nameField), "TestName");
solo.enterText((EditText) solo.getView(R.id.emailField), "Test@Email.com");
solo.enterText((EditText) solo.getView(R.id.phoneField), "1234567890");
solo.clickOnButton("Sign Up");
// Correct Log in Info
solo.clearEditText((EditText) solo.getView(R.id.usernameText));
solo.enterText((EditText) solo.getView(R.id.usernameText), "TestUser");
solo.clickOnButton("Log In");
solo.assertCurrentActivity("Wrong Activity", WelcomeActivity.class);
solo.waitForText("Search");
solo.clickOnText("Search");
solo.clickOnView((SearchView) solo.getView(R.id.searchView));
solo.sleep(9000);
// solo.enterText((EditText) solo.getView(R.id.searchView),"Task");
// solo.text
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class Task method setStatus.
/**
* changes task status to bidded if it is previously requested
* or changes it to requested if there are no longer any bids
* @param newStatus incoming new status that may be the new task status
*/
public void setStatus(String newStatus) {
if ((this.status.equals("requested") && newStatus.equals("bidded")) || (this.status.equals("bidded") && newStatus.equals("requested")) && this.getBids().size() == 1) {
this.status = newStatus;
AddTaskRequest request = new AddTaskRequest(this);
RequestManager.getInstance().invokeRequest(request);
}
// if newStatus == "assigned" delete all bids under this task
}
use of com.cmput301w18t05.taskzilla.Task in project Taskzilla by CMPUT301W18T05.
the class ViewTaskActivity method thePinkButton.
/**
* thePinkButton
* when the task is requested or bidded
* there will be a pink button where the requester can decline one of the existing bids
* onclick it shows a dialog with a listview of existing bids and a button to confirm declination
*
* @param view the view this button is in
* @author myapplestory
*/
public void thePinkButton(android.view.View view) {
final AlertDialog mBuilder = new AlertDialog.Builder(ViewTaskActivity.this).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_decline_bid, null);
final ListView declineBidListView = mView.findViewById(R.id.DeclineBidList);
final Button declineBidButton = mView.findViewById(R.id.DeclineBidButton);
ArrayList<String> tempList = new ArrayList<>();
selectedBid = null;
if (BidList.isEmpty()) {
tempList.add("No bids :'(");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, tempList);
declineBidListView.setAdapter(adapter);
declineBidButton.setText("SAD");
declineBidButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mBuilder.dismiss();
}
});
} else {
for (Bid bid : BidList) {
ProfileController controller = new ProfileController(mView, getBaseContext());
controller.setUserID(bid.getUserId());
controller.getUserRequest();
DecimalFormat cents = new DecimalFormat("#0.00");
tempList.add("Best bidder: " + controller.getUser().getName() + "\nBid Amount: $" + cents.format(bid.getBidAmount()));
}
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_single_choice, tempList);
declineBidListView.setAdapter(adapter);
declineBidListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
declineBidButton.setText("DECLINE BID");
declineBidListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
selectedBid = BidList.get(i);
}
});
declineBidButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (selectedBid == null) {
Toast.makeText(ViewTaskActivity.this, "Select a bid before declining", Toast.LENGTH_SHORT).show();
return;
}
RemoveBidRequest removeRequest = new RemoveBidRequest(selectedBid);
RequestManager.getInstance().invokeRequest(removeRequest);
String temp = "Your bid has been declined!";
Notification notification = new Notification("Bid Declined", task.getRequesterId(), selectedBid.getUserId(), taskID, taskName, temp, currentUser.getInstance());
NotificationManager.getInstance().sendNotification(notification);
BidList.remove(selectedBid);
updateBidsList();
if (BidList.size() == 1) {
EditButton.setVisibility(View.VISIBLE);
task.setStatus("requested");
TaskStatus.setText("requested");
updateBidsList();
} else {
Float bestBidTemp = -1.0f;
String bestBidderIdTemp = "-1";
for (Bid bid : BidList) {
if (bestBidTemp == -1.0f) {
bestBidTemp = bid.getBidAmount();
GetUserRequest request = new GetUserRequest(bid.getUserId());
RequestManager.getInstance().invokeRequest(getApplicationContext(), request);
User tempBidder = request.getResult();
bestBidderIdTemp = tempBidder.getId();
}
if (bid.getBidAmount() < bestBidTemp && !task.getBestBidder().equals(bid.getUserId())) {
Log.i("CHANGE", bid.getBidAmount().toString());
bestBidTemp = bid.getBidAmount();
GetUserRequest request = new GetUserRequest(bid.getUserId());
RequestManager.getInstance().invokeRequest(getApplicationContext(), request);
User tempBidder = request.getResult();
bestBidderIdTemp = tempBidder.getId();
}
}
task.setBestBid(bestBidTemp);
task.setBestBidder(bestBidderIdTemp);
task.updateThis();
}
setProviderField();
mBuilder.dismiss();
}
});
}
mBuilder.setView(mView);
mBuilder.show();
}
Aggregations