use of models.Student in project tutorials by eugenp.
the class StudentController method update.
public Result update() {
JsonNode json = request().body().asJson();
if (json == null) {
return badRequest(Util.createResponse("Expecting Json data", false));
}
Student student = StudentStore.getInstance().updateStudent(Json.fromJson(json, Student.class));
if (student == null) {
return notFound(Util.createResponse("Student not found", false));
}
JsonNode jsonObject = Json.toJson(student);
return ok(Util.createResponse(jsonObject, true));
}
use of models.Student in project instructure-android by instructure.
the class StudentViewActivity method configureUserCarousel.
private void configureUserCarousel() {
mCarouselViewPager = (ViewPager) findViewById(R.id.carouselPager);
mCarouselAdapter = new CarouselPagerAdapter(this);
mCarouselViewPager.addOnPageChangeListener(this);
mCarouselViewPager.setPageTransformer(true, new CarouselTransformer());
if (getIntent().getExtras().getParcelableArrayList(Const.USER) != null) {
ArrayList<Student> students = getIntent().getExtras().getParcelableArrayList(Const.USER);
if (students != null && students.size() > 0) {
mCarouselAdapter.clear();
mCarouselViewPager.setOffscreenPageLimit(students.size());
mCarouselAdapter.addAll(students);
}
}
mCarouselViewPager.post(new Runnable() {
@Override
public void run() {
mCarouselViewPager.setAdapter(mCarouselAdapter);
// Use this to set the offset for the viewpager
int childWidth = (int) getResources().getDimension(R.dimen.carousel_avatar_size);
double factor = 1.30;
if (getResources().getBoolean(R.bool.isTablet)) {
// adjust for tablets so the student's icons are closer together
factor = 1.15;
}
double width = (mCarouselViewPager.getWidth() / factor) + (childWidth / 2);
int truncWidth = (int) width;
mCarouselViewPager.setPageMargin(-truncWidth);
if (mCarouselAdapter.getCount() > 1) {
Prefs prefs = new Prefs(StudentViewActivity.this, com.instructure.parentapp.util.Const.CANVAS_PARENT_SP);
int pos = prefs.load(Const.POSITION, mCarouselAdapter.getCount() / 2);
mCarouselViewPager.setCurrentItem(pos);
onPageSelected(pos);
} else if (mCarouselAdapter.getCount() == 1) {
// need to call onPageSelected so that it shows the user's name
onPageSelected(0);
}
}
});
}
use of models.Student in project tutorials by eugenp.
the class StudentController method listStudents.
public Result listStudents() {
Set<Student> result = StudentStore.getInstance().getAllStudents();
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonData = mapper.convertValue(result, JsonNode.class);
return ok(Util.createResponse(jsonData, true));
}
use of models.Student in project tutorials by eugenp.
the class StudentController method create.
public Result create() {
JsonNode json = request().body().asJson();
if (json == null) {
return badRequest(Util.createResponse("Expecting Json data", false));
}
Student student = StudentStore.getInstance().addStudent(Json.fromJson(json, Student.class));
JsonNode jsonObject = Json.toJson(student);
return created(Util.createResponse(jsonObject, true));
}
Aggregations