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();
}
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;
}
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");
}
}
}
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());
}
}
}
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();
}
Aggregations