use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class UserUnitTest method testUser.
@Test
public void testUser() {
Gson gson = CanvasRestAdapter.getGSONParser();
User user = gson.fromJson(userJSON, User.class);
assertEquals(user.getAvatarURL(), "https://www.example.com");
assertEquals(user.getId(), 1111);
assertEquals(user.getEmail(), "primary_email");
assertEquals(user.getLoginId(), "login_id");
assertEquals(user.getName(), "Sam Franklen");
assertEquals(user.getShortName(), "Samf");
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class APIHelpers method setCachedName.
/**
* setCachedName is a helper to set a value on the cached user.
* @param context
* @param name
* @return
*/
public static boolean setCachedName(Context context, String name) {
User user = getCacheUser(context);
if (user == null) {
return false;
}
user.setName(name);
return setCacheUser(context, user);
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class RatingDialog method populateMailIntent.
private Intent populateMailIntent(String subject, String title) {
// let the user open their favorite mail client
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.utils_mobileSupportEmailAddress) });
// try to get the version number and version code
PackageInfo pInfo = null;
String versionName = "";
int versionCode = 0;
try {
pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
versionName = pInfo.versionName;
versionCode = pInfo.versionCode;
} catch (PackageManager.NameNotFoundException e) {
Utils.d(e.getMessage());
}
intent.putExtra(Intent.EXTRA_SUBJECT, subject + " " + versionName);
User user = APIHelpers.getCacheUser(getActivity());
// populate the email body with information about the user
String emailBody = "";
emailBody += title + "\n\n";
emailBody += getActivity().getString(R.string.userId) + ": " + user.getId() + "\n";
emailBody += getActivity().getString(R.string.email) + ": " + user.getEmail() + "\n";
emailBody += getActivity().getString(R.string.domain) + ": " + APIHelpers.getDomain(getActivity()) + "\n";
emailBody += getActivity().getString(R.string.versionNum) + " " + versionName + " " + versionCode + "\n";
emailBody += getString(R.string.device) + ": " + Build.MANUFACTURER + " " + Build.MODEL + "\n";
emailBody += getString(R.string.osVersion) + ": " + Build.VERSION.RELEASE + "\n";
emailBody += "-----------------------\n";
intent.putExtra(Intent.EXTRA_TEXT, emailBody);
return intent;
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class DocumentActivity method addEmptySubmissionsForUsersAndGetGradedCount.
/**
* CanvasAPI will return a submission for students who have turned in an mAssignment. Given a list of all students
* in the course, we need to generate a dummy Submission object with a username that can be passed to our
* submissions adapter.
*
* @param submissions
* @param courseStudents
* @return
*/
public ArrayList<Submission> addEmptySubmissionsForUsersAndGetGradedCount(Submission[] submissions, User[] courseStudents) {
ArrayList<Submission> tempSubmissions = new ArrayList<>(Arrays.asList(submissions));
ArrayList<User> tempUsers = new ArrayList<>(Arrays.asList(courseStudents));
for (Submission submission : tempSubmissions) {
tempUsers.remove(submission.getUser());
if (UserSubmissionsListAdapter.isGraded(submission)) {
gradedCount++;
}
}
for (User user : tempUsers) {
tempSubmissions.add(createEmptySubmissionForUser(user));
}
return tempSubmissions;
}
use of com.instructure.canvasapi.model.User in project instructure-android by instructure.
the class GuessWhoFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getArguments() != null) {
Course course = getArguments().getParcelable(Const.COURSE);
courseName.setText(course.getName());
canvasContext = getArguments().getParcelable(Const.SECTION);
sectionName.setText(canvasContext.getName());
sectionPeople = getArguments().getParcelableArrayList(Const.SECTION_PEOPLE);
for (User user : sectionPeople) {
adapter.addItem(user);
}
if (adapter.getCount() == 0) {
// show the empty view
pager.setVisibility(View.INVISIBLE);
emptyView.setVisibility(View.VISIBLE);
}
}
getParentActivity().setActionBarTitle(getString(R.string.guessWho));
}
Aggregations