Search in sources :

Example 1 with User

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");
}
Also used : User(com.instructure.canvasapi.model.User) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 2 with User

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);
}
Also used : User(com.instructure.canvasapi.model.User)

Example 3 with 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;
}
Also used : User(com.instructure.canvasapi.model.User) PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) Intent(android.content.Intent)

Example 4 with User

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;
}
Also used : User(com.instructure.canvasapi.model.User) Submission(com.instructure.canvasapi.model.Submission) ArrayList(java.util.ArrayList)

Example 5 with User

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));
}
Also used : User(com.instructure.canvasapi.model.User) Course(com.instructure.canvasapi.model.Course)

Aggregations

User (com.instructure.canvasapi.model.User)23 TextView (android.widget.TextView)4 Gson (com.google.gson.Gson)4 LinkHeaders (com.instructure.canvasapi.utilities.LinkHeaders)4 Response (retrofit.client.Response)4 Intent (android.content.Intent)3 View (android.view.View)3 ImageView (android.widget.ImageView)3 Test (org.junit.Test)3 RetrofitError (retrofit.RetrofitError)3 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 Bundle (android.os.Bundle)2 Course (com.instructure.canvasapi.model.Course)2 Section (com.instructure.canvasapi.model.Section)2 Submission (com.instructure.canvasapi.model.Submission)2 CanvasRestAdapter (com.instructure.canvasapi.utilities.CanvasRestAdapter)2 UserCallback (com.instructure.canvasapi.utilities.UserCallback)2 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)2 RestAdapter (retrofit.RestAdapter)2