use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleViewActivity method initRView.
public void initRView(final long classId) {
final Handler handler = new Handler(getMainLooper());
new Thread(new Runnable() {
@Override
public void run() {
try {
final ClassServiceImpl classService = new ClassServiceImpl();
final List<Schedule> scheduleList = new ArrayList<>();
final Set<Schedule> scheduleSet = classService.getScheduleList(classId);
for (Schedule schedule : scheduleSet) scheduleList.add(schedule);
final ScheduleAdapter scheduleAdapter = new ScheduleAdapter(ScheduleViewActivity.this, scheduleList);
final LinearLayoutManager layoutManager = new LinearLayoutManager(ScheduleViewActivity.this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
handler.post(new Runnable() {
@Override
public void run() {
recyclerView.setAdapter(scheduleAdapter);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
if (scheduleSet.size() < 1)
txtMsgContent.setVisibility(View.VISIBLE);
}
});
} catch (ClassException e) {
e.printStackTrace();
}
}
}).start();
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class Home_Schedule_Slidebar_Fragment method init.
public void init() {
new Thread(new Runnable() {
@Override
public void run() {
try {
final List<Schedule> scheduleList = new ArrayList<>();
TeacherHelper teacherHelper = new TeacherHelper(getContext());
ClassServiceImpl classService = new ClassServiceImpl();
Class _class = null;
for (Class c : classService.getClassList()) {
if (c.getTeacher() == null)
continue;
if (c.getTeacher().getId() == teacherHelper.loadUser().get().getId()) {
_class = c;
Log.i("myTAG", "id : " + c.getId());
break;
}
}
// test
_class = classService.getClassById(40);
if (_class != null) {
for (Schedule schedule : classService.getScheduleList(_class.getId())) scheduleList.add(schedule);
}
handler.post(new Runnable() {
@Override
public void run() {
scheduleRecyclerView = (RecyclerView) customView.findViewById(R.id.shedule_recyclerview);
ScheduleAdapter scheduleAdapter = new ScheduleAdapter(getContext(), scheduleList);
scheduleRecyclerView.setAdapter(scheduleAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
scheduleRecyclerView.setLayoutManager(layoutManager);
scheduleRecyclerView.setItemAnimator(new DefaultItemAnimator());
}
});
} catch (ClassException e) {
e.printStackTrace();
}
}
}).start();
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class SliderScheduleFragment method setSchedule.
public void setSchedule(final int id) {
switch(id) {
case schedule_today_rb:
new Thread(new Runnable() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.VISIBLE);
txtMsgNoContent.setVisibility(View.INVISIBLE);
}
});
try {
final List<Schedule> newSchedules = new ArrayList<>();
final TeacherHelper teacherHelper = new TeacherHelper(getContext());
if (teacherHelper.loadUser().get() != null) {
try {
for (Schedule schedule : new ScheduleServiceImpl().getScheduleListByTeacherId(teacherHelper.loadUser().get().getId())) newSchedules.add(schedule);
} catch (ScheduleException e) {
e.printStackTrace();
}
}
handler.post(new Runnable() {
@Override
public void run() {
int size = scheduleAdapter.getItemCount();
for (int i = 0; i < size; i++) {
if (scheduleList.size() > 0) {
scheduleList.remove(0);
scheduleAdapter.notifyItemRemoved(0);
}
}
ScheduleHelper scheduleHelper = new ScheduleHelper();
int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
for (Schedule schedule : newSchedules) {
if (scheduleHelper.dayInNumber(schedule.getDay()) == day) {
scheduleList.add(schedule);
scheduleAdapter.notifyItemRangeInserted(0, scheduleList.size());
}
}
progressBar.setVisibility(View.INVISIBLE);
if (scheduleList.size() < 1)
txtMsgNoContent.setVisibility(View.VISIBLE);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
break;
case schedule_tomorrow_rb:
new Thread(new Runnable() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.VISIBLE);
txtMsgNoContent.setVisibility(View.INVISIBLE);
}
});
try {
final List<Schedule> newSchedules = new ArrayList<>();
final TeacherHelper teacherHelper = new TeacherHelper(getContext());
if (teacherHelper.loadUser().get() != null) {
try {
for (Schedule schedule : new ScheduleServiceImpl().getScheduleListByTeacherId(teacherHelper.loadUser().get().getId())) newSchedules.add(schedule);
} catch (ScheduleException e) {
e.printStackTrace();
}
}
handler.post(new Runnable() {
@Override
public void run() {
int size = scheduleAdapter.getItemCount();
for (int i = 0; i < size; i++) {
if (scheduleList.size() > 0) {
scheduleList.remove(0);
scheduleAdapter.notifyItemRemoved(0);
}
}
ScheduleHelper scheduleHelper = new ScheduleHelper();
int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) + 1;
for (Schedule schedule : newSchedules) {
if (scheduleHelper.dayInNumber(schedule.getDay()) == day) {
scheduleList.add(schedule);
scheduleAdapter.notifyItemRangeInserted(0, scheduleList.size());
}
}
progressBar.setVisibility(View.INVISIBLE);
if (scheduleList.size() < 1)
txtMsgNoContent.setVisibility(View.VISIBLE);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
break;
default:
new Thread(new Runnable() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.VISIBLE);
txtMsgNoContent.setVisibility(View.INVISIBLE);
}
});
try {
final List<Schedule> newSchedules = new ArrayList<>();
final TeacherHelper teacherHelper = new TeacherHelper(getContext());
if (teacherHelper.loadUser().get() != null) {
try {
for (Schedule schedule : new ScheduleServiceImpl().getScheduleListByTeacherId(teacherHelper.loadUser().get().getId())) newSchedules.add(schedule);
} catch (ScheduleException e) {
e.printStackTrace();
}
}
handler.post(new Runnable() {
@Override
public void run() {
int size = scheduleAdapter.getItemCount();
for (int i = 0; i < size; i++) {
if (scheduleList.size() > 0) {
scheduleList.remove(0);
scheduleAdapter.notifyItemRemoved(0);
}
}
for (Schedule schedule : newSchedules) {
scheduleList.add(schedule);
scheduleAdapter.notifyItemRangeInserted(0, scheduleList.size());
}
progressBar.setVisibility(View.INVISIBLE);
if (scheduleList.size() < 1)
txtMsgNoContent.setVisibility(View.VISIBLE);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
break;
}
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ScheduleAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ScheduleViewHolder holder, int position) {
Schedule schedule = scheduleList.get(position);
holder.setView(schedule, position);
}
use of com.remswork.project.alice.model.Schedule in project classify-system by anverliedoit.
the class ClassServiceImpl method deleteScheduleById.
@Override
public Schedule deleteScheduleById(long classId, long scheduleId) throws ClassException {
try {
StringBuilder uri = new StringBuilder();
uri.append(targetProperties.getDomain());
uri.append("/");
uri.append(targetProperties.getBaseUri());
uri.append("/");
uri.append(payload);
uri.append("/");
uri.append(classId);
uri.append("/");
uri.append("schedule");
uri.append("/");
uri.append(scheduleId);
Client client = ClientBuilder.newClient();
WebTarget target = client.target(uri.toString());
Builder builder = target.request();
builder.accept("application/json");
Response response = builder.delete();
if (response.getStatus() == 200) {
return (Schedule) response.readEntity(Schedule.class);
} else if (response.getStatus() == 400) {
Message message = (Message) response.readEntity(Message.class);
throw new ClassServiceException(message.getMessage());
} else
throw new ClassServiceException("The request might invalid or server is down");
} catch (ClassServiceException e) {
throw new ClassException(e.getMessage());
}
}
Aggregations