Search in sources :

Example 1 with Task

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

Example 2 with Task

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

Example 3 with Task

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
}
Also used : MainActivity(com.cmput301w18t05.taskzilla.activity.MainActivity)

Example 4 with Task

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

Example 5 with 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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ProfileController(com.cmput301w18t05.taskzilla.controller.ProfileController) GetUserRequest(com.cmput301w18t05.taskzilla.request.command.GetUserRequest) User(com.cmput301w18t05.taskzilla.User) com.cmput301w18t05.taskzilla.currentUser(com.cmput301w18t05.taskzilla.currentUser) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) Notification(com.cmput301w18t05.taskzilla.Notification) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) ImageButton(android.widget.ImageButton) Button(android.widget.Button) Bid(com.cmput301w18t05.taskzilla.Bid) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) ExpandableListView(android.widget.ExpandableListView) RemoveBidRequest(com.cmput301w18t05.taskzilla.request.command.RemoveBidRequest) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

View (android.view.View)18 Task (com.cmput301w18t05.taskzilla.Task)16 MainActivity (com.cmput301w18t05.taskzilla.activity.MainActivity)10 AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)9 AlertDialog (android.support.v7.app.AlertDialog)6 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)6 GetTaskRequest (com.cmput301w18t05.taskzilla.request.command.GetTaskRequest)6 Intent (android.content.Intent)5 RecyclerView (android.support.v7.widget.RecyclerView)5 EditText (android.widget.EditText)5 ImageButton (android.widget.ImageButton)5 DecimalFormat (java.text.DecimalFormat)5 DialogInterface (android.content.DialogInterface)4 Button (android.widget.Button)4 TextView (android.widget.TextView)4 AppCache (com.cmput301w18t05.taskzilla.AppCache)4 Bid (com.cmput301w18t05.taskzilla.Bid)4 ColorDrawable (android.graphics.drawable.ColorDrawable)3 ActionBar (android.support.v7.app.ActionBar)3