use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest 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();
}
use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class NewReviewActivity method setValues.
public void setValues() {
revieweeType = getIntent().getStringExtra("who");
targetUserId = getIntent().getStringExtra("id");
currentUserId = currentUser.getInstance().getId();
GetUserRequest request = new GetUserRequest(targetUserId);
request.execute();
targetUser = request.getResult();
targetUserName = targetUser.getName();
nameTextView.setText("Review for " + targetUserName);
}
use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileController method getUserRequest.
public void getUserRequest() {
GetUserRequest request = new GetUserRequest(userId);
RequestManager.getInstance().invokeRequest(ctx, request);
this.user = request.getResult();
}
use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileController method updateUserRequest.
/**
* getUserRequest
* get user from RequestManager and set the
* user to be the result for the controller
*
* @author Micheal-Nguyen
*/
public void updateUserRequest(User user) {
AddUserRequest request = new AddUserRequest(user);
RequestManager.getInstance().invokeRequest(ctx, request);
}
use of com.cmput301w18t05.taskzilla.request.command.GetUserRequest in project Taskzilla by CMPUT301W18T05.
the class ExpandableBidListAdapter method getChildView.
/**
* @param groupPosition which group was clicked
* @param childPosition which child was clicked
* @param isLastChild if it the last element in the list
* @param view the listview parent in context
* @param parent the parent group this group belongs to
* @return the textview to be displayed
* @author myapplestory
*
* gets bids on this task as well as the bid amount and big owner name
* and displays it
*/
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view, ViewGroup parent) {
Bid currentBid = this.bidList.get(childPosition);
GetUserRequest getUserRequest = new GetUserRequest(currentBid.getUserId());
RequestManager.getInstance().invokeRequest(getUserRequest);
User BidOwner = getUserRequest.getResult();
TextView textView = new TextView(context);
String output = "$" + String.format(Locale.CANADA, "%.2f", currentBid.getBidAmount()) + " By user: " + BidOwner.getName();
textView.setText(output);
textView.setTextColor(0xffff88ff);
textView.setTextSize(18);
textView.setPadding(144, 0, 0, 0);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(context, "Secret developer settings enabled", Toast.LENGTH_SHORT).show();
}
});
return textView;
}
Aggregations