Search in sources :

Example 1 with DI

use of io.classify.DI in project classify-system by anverliedoit.

the class GradeResultActivity2 method load.

public void load() {
    try {
        final FormulaService formulaService = new FormulaServiceImpl();
        final GradeService gradeService = new GradeServiceImpl();
        final long termId = getIntent().getExtras().getLong("termId");
        final long classId = getIntent().getExtras().getLong("classId");
        final Class _class = classService.getClassById(classId);
        final long subjectId = _class.getSubject() != null ? _class.getSubject().getId() : 0;
        final long teacherId = _class.getTeacher() != null ? _class.getTeacher().getId() : 0;
        final Formula formula = formulaService.getFormulaBySubjectAndTeacherId(subjectId, teacherId, termId);
        Log.i("SOMETHINGGG", "CLASSID" + classId + " FORMULAID" + formula.getId());
        final io.classify.service.GradeService gr = new DI().getRetrofit().create(io.classify.service.GradeService.class);
        for (final Student student : classService.getStudentListOrdered(classId)) {
            Log.i("TATATE", String.format("test/total/class/{%d}/term/{%d}/teacher/{%d}/subject/{%d}/student/{%d}", classId, termId, teacherId, subjectId, student.getId()));
            gr.findAll(classId, teacherId, subjectId, student.getId()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<MarkDto>() {

                @Override
                public void accept(MarkDto result) throws Exception {
                    if (!result.getMidterm().equals("NaN")) {
                        Grade grade = new Grade();
                        grade.setStudent(student);
                        grade.setTotalScore(Double.parseDouble(result.getMidterm()));
                        Grade grade2 = new Grade();
                        grade2.setStudent(student);
                        grade2.setTotalScore(Double.parseDouble(result.getFinalterm()));
                        Mark mark = new Mark();
                        mark.setMidterm(grade);
                        mark.setFinalterm(grade2);
                        gradeList.add(mark);
                        notifyChange();
                    }
                }
            }, new Consumer<Throwable>() {

                @Override
                public void accept(Throwable throwable) throws Exception {
                    Log.i("TAETAE", throwable.toString());
                }
            });
        // final Student cStudent = student;
        // Log.i("SOMETHINGGG", "Student" + student.getId());
        // Log.i("FORMULA",formula.getId()+ "");
        // new Thread(new Runnable() {
        // @Override
        // public void run() {
        // try {
        // long studentId = cStudent.getId();
        // List<Grade> temp = gradeService.getGradeListByClass(classId, studentId, termId);
        // Grade grade = temp.size() > 0 ? temp.get(0) : new Grade();
        // 
        // Log.i("GRADE",grade.getId()+ "");
        // 
        // double actScore = ((double) formula.getActivityPercentage() / 100) * grade.getActivityScore();
        // double assScore = ((double) formula.getAssignmentPercentage() / 100) * grade.getAssignmentScore();
        // double attScore = ((double) formula.getAttendancePercentage() / 100) * grade.getAttendanceScore();
        // double exaScore = ((double) formula.getExamPercentage() / 100) * grade.getExamScore();
        // double proScore = ((double) formula.getProjectPercentage() / 100) * grade.getProjectScore();
        // double quiScore = ((double) formula.getQuizPercentage() / 100) * grade.getQuizScore();
        // 
        // grade.setTotalScore(
        // actScore + assScore + attScore + exaScore + proScore + quiScore
        // );
        // 
        // grade.setStudent(student);
        // 
        // Log.i("SOMETHINGGG", "actScore" + formula.getActivityPercentage());
        // Log.i("SOMETHINGGG", "assScore" + formula.getAssignmentPercentage());
        // Log.i("SOMETHINGGG", "attScore" + formula.getAttendancePercentage());
        // Log.i("SOMETHINGGG", "exaScore" + formula.getExamPercentage());
        // Log.i("SOMETHINGGG", "proScore" + formula.getProjectPercentage());
        // Log.i("SOMETHINGGG", "quiScore" + formula.getQuizPercentage());
        // Log.i("SOMETHINGGG", "Student" + studentId);
        // Log.i("SOMETHINGGG", "Grade" + grade.getId());
        // 
        // gradeList.add(grade);
        // notifyChange();
        // } catch (Exception e) {
        // e.printStackTrace();
        // }
        // }
        // }).start();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GradeService(com.remswork.project.alice.service.GradeService) FormulaService(com.remswork.project.alice.service.FormulaService) DI(io.classify.DI) Mark(io.classify.model.Mark) Grade(com.remswork.project.alice.model.Grade) Student(com.remswork.project.alice.model.Student) MarkDto(io.classify.model.MarkDto) Formula(com.remswork.project.alice.model.Formula) GradeServiceImpl(com.remswork.project.alice.service.impl.GradeServiceImpl) Class(com.remswork.project.alice.model.Class) FormulaServiceImpl(com.remswork.project.alice.service.impl.FormulaServiceImpl)

Example 2 with DI

use of io.classify.DI in project classify-system by anverliedoit.

the class LoginActivity method doLogin.

@Override
public void doLogin(final String _username, final String _password) {
    Log.i(TAG, "doLogin");
    progressBar.setVisibility(View.VISIBLE);
    screen.setVisibility(View.VISIBLE);
    username = _username;
    password = _password;
    UserService userService = new DI().getRetrofit().create(UserService.class);
    userService.getByUsername(username).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Consumer<User>() {

        @Override
        public void accept(User user) throws Exception {
            if (user.getPassword().equals(password)) {
                teacherHelper.saveUser(user.getTeacherId());
                Intent intent = new Intent(getApplicationContext(), MainActivity2.class);
                intent.putExtra("teacherId", user.getTeacherId());
                isVaild = true;
                startActivity(intent);
            } else {
                if (!isVaild)
                    Toast.makeText(LoginActivity.this, "Incorrect username or password", Toast.LENGTH_SHORT).show();
                progressBar.setVisibility(View.INVISIBLE);
                screen.setVisibility(View.INVISIBLE);
            }
        }
    }, new Consumer<Throwable>() {

        @Override
        public void accept(Throwable throwable) throws Exception {
            if (!isVaild)
                Toast.makeText(LoginActivity.this, "Incorrect username or password", Toast.LENGTH_SHORT).show();
            progressBar.setVisibility(View.INVISIBLE);
            screen.setVisibility(View.INVISIBLE);
        }
    });
}
Also used : User(io.classify.model.User) UserService(io.classify.service.UserService) DI(io.classify.DI) Intent(android.content.Intent)

Example 3 with DI

use of io.classify.DI in project classify-system by anverliedoit.

the class ActivityChangePassword method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_changepassword);
    text1 = findViewById(R.id.activity_changepassword_text1);
    text2 = findViewById(R.id.activity_changepassword_text2);
    button = findViewById(R.id.activityt_changepassword_button);
    btnCancel = findViewById(R.id.activityt_changepassword_button_cancel);
    progressBar = findViewById(R.id.progressbar_cp);
    button.setOnClickListener(this);
    btnCancel.setOnClickListener(this);
    retrofit = new DI().getRetrofit();
    userService = retrofit.create(UserService.class);
    teacherService = new TeacherServiceImpl();
    progressBar.setVisibility(View.INVISIBLE);
    try {
        teacher = teacherService.getTeacherById(getIntent().getExtras().getLong("teacherId"));
    } catch (Exception e) {
        e.printStackTrace();
        teacher = new Teacher();
    }
}
Also used : DI(io.classify.DI) UserService(io.classify.service.UserService) Teacher(com.remswork.project.alice.model.Teacher) TeacherServiceImpl(com.remswork.project.alice.service.impl.TeacherServiceImpl)

Aggregations

DI (io.classify.DI)3 UserService (io.classify.service.UserService)2 Intent (android.content.Intent)1 Class (com.remswork.project.alice.model.Class)1 Formula (com.remswork.project.alice.model.Formula)1 Grade (com.remswork.project.alice.model.Grade)1 Student (com.remswork.project.alice.model.Student)1 Teacher (com.remswork.project.alice.model.Teacher)1 FormulaService (com.remswork.project.alice.service.FormulaService)1 GradeService (com.remswork.project.alice.service.GradeService)1 FormulaServiceImpl (com.remswork.project.alice.service.impl.FormulaServiceImpl)1 GradeServiceImpl (com.remswork.project.alice.service.impl.GradeServiceImpl)1 TeacherServiceImpl (com.remswork.project.alice.service.impl.TeacherServiceImpl)1 Mark (io.classify.model.Mark)1 MarkDto (io.classify.model.MarkDto)1 User (io.classify.model.User)1