Search in sources :

Example 31 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class ViewTaskActivity method onCreate.

/**
 *onCreate
 * Retrieve the task using the task id that was sent using
 * intent into the activity updating the information on the
 * activity_ViewTaskActivity while checking if the task has
 * a provider, what the status is and if the user viewing
 * is the owner of the task
 *
 * @param savedInstanceState
 * @author Micheal-Nguyen, myapplestory
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_task);
    appColors = AppColors.getInstance();
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(appColors.getActionBarColor())));
    actionBar.setTitle(Html.fromHtml("<font color='" + appColors.getActionBarTextColor() + "'>Taskzilla</font>"));
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.dragdropMap);
    mapFragment.getMapAsync(this);
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    findViews();
    // starts the activity at the very top
    scrollView.setFocusableInTouchMode(true);
    scrollView.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    // gets the task id
    this.viewTaskController = new ViewTaskController(this.findViewById(android.R.id.content), this);
    taskID = getIntent().getStringExtra("TaskId");
    setValues();
    setRequesterField();
    setProviderField();
    photos = task.getPhotos();
    NoLocation = findViewById(R.id.NoLocationText);
    NoLocation.setVisibility(View.INVISIBLE);
    if (task.getLocation() == null) {
        NoLocation.setVisibility(View.VISIBLE);
    // mapFragment.s
    }
    linearLayout = findViewById(R.id.Photos);
    recyclerPhotosView = findViewById(R.id.listOfPhotos);
    layoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false);
    recyclerPhotosView.setLayoutManager(layoutManager);
    recyclerPhotosViewAdapter = new RecyclerViewAdapter(getApplicationContext(), photos, new CustomOnItemClick() {

        @Override
        public void onColumnClicked(int position) {
            Intent intent = new Intent(getApplicationContext(), ZoomImageActivity.class);
            intent.putExtra("Photo", photos.get(position).toString());
            startActivity(intent);
        }
    });
    recyclerPhotosView.setAdapter(recyclerPhotosViewAdapter);
    setVisibility();
    setUpBidsList();
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) ColorDrawable(android.graphics.drawable.ColorDrawable) Intent(android.content.Intent) RecyclerViewAdapter(com.cmput301w18t05.taskzilla.RecyclerViewAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) CustomOnItemClick(com.cmput301w18t05.taskzilla.CustomOnItemClick) ActionBar(android.support.v7.app.ActionBar) ViewTaskController(com.cmput301w18t05.taskzilla.controller.ViewTaskController)

Example 32 with User

use of com.cmput301w18t05.taskzilla.User 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)

Example 33 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class NewTaskController method addTask.

/**
 * Error checks the task name and description to enforce character limits.
 * Then the task is added to Elastic Search
 * @param name Task name
 * @param user User that is making the task
 * @param description Description of the task
 */
public void addTask(String name, User user, String description, LatLng taskLocation, ArrayList<Photo> photos) {
    // Check field lengths and give error
    EditText taskName = view.findViewById(R.id.TaskName);
    EditText taskDescription = view.findViewById(R.id.Description);
    if (TextUtils.getTrimmedLength(taskName.getText()) <= 55 && TextUtils.getTrimmedLength(taskName.getText()) > 0 && TextUtils.getTrimmedLength(taskDescription.getText()) <= 500 && TextUtils.getTrimmedLength(taskDescription.getText()) > 0) {
        Task task = new Task(name, user, description, taskLocation, photos);
        AddTaskRequest request = new AddTaskRequest(task);
        RequestManager.getInstance().invokeRequest(ctx, request);
        request.getResult();
        taskId = task.getId();
        Intent intent = new Intent();
        intent.putExtra("result", taskId);
        view.setResult(RESULT_OK, intent);
        // Toast.makeText(view, "New task created, refresh page to see updated list", Toast.LENGTH_SHORT).show();
        view.finish();
    } else {
        if (TextUtils.getTrimmedLength(taskName.getText()) > 55) {
            taskName.setError("Name can not exceed 55 characters");
        }
        if (TextUtils.getTrimmedLength(taskName.getText()) == 0) {
            taskName.setError("Name can not empty");
        }
        if (TextUtils.getTrimmedLength(taskDescription.getText()) > 500) {
            taskDescription.setError("Description can not exceed 500 characters");
        }
        if (TextUtils.getTrimmedLength(taskDescription.getText()) == 0) {
            taskDescription.setError("Description can not be empty");
        }
    }
}
Also used : EditText(android.widget.EditText) Task(com.cmput301w18t05.taskzilla.Task) Intent(android.content.Intent) AddTaskRequest(com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)

Example 34 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class ProfileFragment method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i("does this work", String.valueOf(requestCode));
    if (requestCode == 1) {
        // code to add to ESC
        if (resultCode == RESULT_OK) {
            String newName = data.getStringExtra("Name");
            String newEmail = data.getStringExtra("Email");
            String newPhone = data.getStringExtra("Phone");
            String newPhoto = data.getStringExtra("Photo");
            user.setName(newName);
            user.setEmail(new EmailAddress(newEmail));
            user.setPhone(new PhoneNumber(newPhone));
            user.setPhoto(new Photo(newPhoto));
            AddUserRequest request = new AddUserRequest(user);
            RequestManager.getInstance().invokeRequest(getContext(), request);
            nameField.setText(newName);
            emailField.setText(newEmail);
            phoneField.setText(newPhone);
            profilePicture.setImageBitmap(user.getPhoto().StringToBitmap());
        }
    }
}
Also used : PhoneNumber(com.cmput301w18t05.taskzilla.PhoneNumber) Photo(com.cmput301w18t05.taskzilla.Photo) EmailAddress(com.cmput301w18t05.taskzilla.EmailAddress) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 35 with User

use of com.cmput301w18t05.taskzilla.User in project Taskzilla by CMPUT301W18T05.

the class TasksRequesterFragment method updateBidded.

/**
 * if filter is requested, retrieve all requests owned by current user
 * from elastic search that have status 'bidded'
 */
public void updateBidded() {
    ArrayList<Task> res = cUser.getTasksRequested();
    taskList.clear();
    for (Task t : res) {
        if (t.getStatus().equalsIgnoreCase("bidded")) {
            taskList.add(t);
        }
    }
    adapter.notifyDataSetChanged();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task)

Aggregations

View (android.view.View)13 Task (com.cmput301w18t05.taskzilla.Task)11 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)8 AlertDialog (android.support.v7.app.AlertDialog)6 ListView (android.widget.ListView)6 TextView (android.widget.TextView)6 Photo (com.cmput301w18t05.taskzilla.Photo)6 EditText (android.widget.EditText)5 AddTaskRequest (com.cmput301w18t05.taskzilla.request.command.AddTaskRequest)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 ColorDrawable (android.graphics.drawable.ColorDrawable)4 ActionBar (android.support.v7.app.ActionBar)4 RecyclerView (android.support.v7.widget.RecyclerView)4 AdapterView (android.widget.AdapterView)4 ImageButton (android.widget.ImageButton)4 User (com.cmput301w18t05.taskzilla.User)4 DialogInterface (android.content.DialogInterface)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 ArrayAdapter (android.widget.ArrayAdapter)3