use of com.instructure.canvasapi2.models.User in project instructure-android by instructure.
the class UserManager method updateUserShortName.
public static void updateUserShortName(String shortName, StatusCallback<User> callback) {
if (isTesting() || mTesting) {
// TODO
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(false).build();
UserAPI.updateUserShortName(adapter, params, shortName, callback);
}
}
use of com.instructure.canvasapi2.models.User in project instructure-android by instructure.
the class CourseManager_Test method getCourseStudents.
public static void getCourseStudents(long courseId, StatusCallback<List<User>> callback) {
// TODO:
Response response = new Response.Builder().request(new Request.Builder().url("https://test.com").build()).code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
List<User> users = new ArrayList<>();
retrofit2.Response<List<User>> response1 = retrofit2.Response.success(users, response);
callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
use of com.instructure.canvasapi2.models.User in project instructure-android by instructure.
the class RoboTesting method setAppStatePrefs.
static void setAppStatePrefs(Context context) {
// save parent id and user name
Prefs prefs = new Prefs(context, context.getString(R.string.app_name_parent));
prefs.save(com.instructure.pandautils.utils.Const.ID, BuildConfig.ROBO_TEST_USER_ID);
prefs.save(com.instructure.pandautils.utils.Const.NAME, BuildConfig.ROBO_TEST_USERNAME);
// save token
ApiPrefs.setToken(BuildConfig.ROBO_TEST_API_KEY);
// Set domain to gamma
ApiPrefs.setAirwolfDomain(BuildConfig.GAMMA_DOMAIN);
}
use of com.instructure.canvasapi2.models.User in project instructure-android by instructure.
the class StartingActivity method checkEnrollments.
// we need to know if the user is a teacher in any course
// track the enrollments of the user as well
private void checkEnrollments(List<Course> courses) {
int teacherCount = 0;
int studentCount = 0;
for (Course course : courses) {
if (course.isTeacher()) {
teacherCount++;
ApplicationManager.setHasTeacherEnrollment(getApplicationContext());
} else {
studentCount++;
ApplicationManager.setHasStudentEnrollment(getApplicationContext());
}
}
String enrollmentType = "";
if (teacherCount > 0) {
enrollmentType = getString(R.string.teacher);
} else if (studentCount > 0) {
enrollmentType = getString(R.string.student);
} else {
enrollmentType = getString(R.string.other);
}
if (ApplicationManager.hasViewPreference(this)) {
if (ApplicationManager.shouldShowTeacherView(this)) {
startActivity(FragmentManagerActivity.createIntent(getApplicationContext()));
} else {
startActivity(PollListActivity.createIntent(getApplicationContext()));
}
finish();
return;
} else if (ApplicationManager.hasTeacherEnrollment(getApplicationContext())) {
startActivity(FragmentManagerActivity.createIntent(getApplicationContext()));
} else {
startActivity(PollListActivity.createIntent(getApplicationContext()));
}
finish();
}
use of com.instructure.canvasapi2.models.User in project instructure-android by instructure.
the class PeopleListFragment method getAdapter.
@Override
protected PeopleListRecyclerAdapter getAdapter() {
if (mAdapter == null) {
mAdapter = new PeopleListRecyclerAdapter(getContext(), getPresenter(), new AdapterToFragmentCallback<User>() {
@Override
public void onRowClicked(User user, int position) {
CanvasContext canvasContext = getArguments().getParcelable(Const.CANVAS_CONTEXT);
if (CanvasContextExtensions.isDesigner(canvasContext)) {
Toast.makeText(getContext(), R.string.errorIsDesigner, Toast.LENGTH_SHORT).show();
return;
}
Bundle bundle = StudentContextFragment.makeBundle(user.getId(), canvasContext.getId(), true);
RouteMatcher.route(getContext(), new Route(null, StudentContextFragment.class, canvasContext, bundle));
}
});
}
return mAdapter;
}
Aggregations