use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class Task method userRequest.
/**
* @param uid the user id
* @return user object
*/
private User userRequest(String uid) {
GetUserRequest getUser = new GetUserRequest(uid);
RequestManager.getInstance().invokeRequest(getUser);
User user = getUser.getResult();
if (// maybe connection is lost
user == null)
return new User();
return user;
}
use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class ViewTaskActivity method updateBestBid.
/**
* updateBestBid
* updates best bidder field if new bid has value less than the current best bid
*
* @param incomingBidFloat the bid amount the new bid will be
* @return 0 if best bidder needs update, -1 if not
* @author myapplestory, Micheal-Nguyen
*/
public Integer updateBestBid(Float incomingBidFloat) {
Log.i("CURRENTBESTBIDDER", task.getBestBidder());
Log.i("CURRENTUSER", currentUserId);
if (task.getBestBid() > incomingBidFloat || task.getBestBid() == -1.0f) {
Log.i("in", "1");
task.setBestBidder(currentUserId);
task.setBestBid(incomingBidFloat);
task.updateThis();
} else if (task.getBestBid().equals(incomingBidFloat)) {
Toast.makeText(ViewTaskActivity.this, "A similar bid already exists. Please bid another value", Toast.LENGTH_SHORT).show();
return -1;
} else if (task.getBestBidder().equals(currentUserId)) {
Float bestBidTemp = incomingBidFloat;
String bestBidderIdTemp = currentUserId;
for (Bid bid : BidList) {
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();
return 0;
}
Aggregations