Search in sources :

Example 6 with GetUserRequest

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;
}
Also used : GetUserRequest(com.cmput301w18t05.taskzilla.request.command.GetUserRequest)

Example 7 with GetUserRequest

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;
}
Also used : GetUserRequest(com.cmput301w18t05.taskzilla.request.command.GetUserRequest) User(com.cmput301w18t05.taskzilla.User) com.cmput301w18t05.taskzilla.currentUser(com.cmput301w18t05.taskzilla.currentUser) Bid(com.cmput301w18t05.taskzilla.Bid)

Aggregations

GetUserRequest (com.cmput301w18t05.taskzilla.request.command.GetUserRequest)6 View (android.view.View)2 TextView (android.widget.TextView)2 Bid (com.cmput301w18t05.taskzilla.Bid)2 User (com.cmput301w18t05.taskzilla.User)2 com.cmput301w18t05.taskzilla.currentUser (com.cmput301w18t05.taskzilla.currentUser)2 AlertDialog (android.support.v7.app.AlertDialog)1 RecyclerView (android.support.v7.widget.RecyclerView)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 Button (android.widget.Button)1 ExpandableListView (android.widget.ExpandableListView)1 ImageButton (android.widget.ImageButton)1 ListView (android.widget.ListView)1 ScrollView (android.widget.ScrollView)1 Notification (com.cmput301w18t05.taskzilla.Notification)1 ProfileController (com.cmput301w18t05.taskzilla.controller.ProfileController)1 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)1 RemoveBidRequest (com.cmput301w18t05.taskzilla.request.command.RemoveBidRequest)1 DecimalFormat (java.text.DecimalFormat)1