Search in sources :

Example 1 with CriteriaAdapter

use of com.lieverandiver.thesisproject.adapter.CriteriaAdapter in project classify-system by anverliedoit.

the class Teacher_Activity_View_Subject_Datails method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.teacher_activity_view_subject_datails);
    try {
        subject = new SubjectServiceImpl().getSubjectById(getIntent().getExtras().getLong("subjectId"));
    } catch (SubjectException e) {
        e.printStackTrace();
    }
    textViewMidtermPercent = (TextView) findViewById(R.id.midterm_percent_sub_view);
    textViewMidtermPercent = (TextView) findViewById(R.id.finals_percent_sub_view);
    recyclerViewMidterm = (RecyclerView) findViewById(R.id.midterm_recycleview);
    recyclerViewFinals = (RecyclerView) findViewById(R.id.finals_recycleview);
    linearLayoutm = (LinearLayout) findViewById(R.id.midterm_setting);
    linearLayoutf = (LinearLayout) findViewById(R.id.finals_setting);
    name = (TextView) findViewById(R.id.a_class_f_view_subject_name);
    code = (TextView) findViewById(R.id.a_class_f_view_subject_code);
    desc = (TextView) findViewById(R.id.a_class_f_view_subject_desc);
    unit = (TextView) findViewById(R.id.a_class_f_view_subject_unit);
    toggleButtonM = (ToggleButton) findViewById(R.id.toggle_midview);
    toggleButtonF = (ToggleButton) findViewById(R.id.toggle_finview);
    recyclerViewMidterm.setVisibility(View.GONE);
    recyclerViewFinals.setVisibility(View.GONE);
    toggleButtonM.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                recyclerViewMidterm.setVisibility(View.VISIBLE);
            } else {
                recyclerViewMidterm.setVisibility(View.GONE);
            }
        }
    });
    toggleButtonF.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                recyclerViewFinals.setVisibility(View.VISIBLE);
            } else {
                recyclerViewFinals.setVisibility(View.GONE);
            }
        }
    });
    name.setText(subject.getName());
    code.setText(subject.getCode());
    desc.setText(subject.getDescription());
    unit.setText(subject.getUnit() + "");
    try {
        Formula formula = new FormulaHelper(this).getFormula("1-midterm");
        if (formula != null && formula.getSubject() != null) {
            if (formula.getSubject().getId() == subject.getId()) {
                recyclerViewMidterm.setVisibility(View.VISIBLE);
                String[] key = new String[6];
                key[0] = formula.getActivityPercentage() + "%";
                key[1] = formula.getAssignmentPercentage() + "%";
                key[2] = formula.getAttendancePercentage() + "%";
                key[3] = formula.getExamPercentage() + "%";
                key[4] = formula.getProjectPercentage() + "%";
                key[5] = formula.getQuizPercentage() + "%";
                List<String> datas = new ArrayList<>();
                for (String s : key) datas.add(s);
                CriteriaAdapter criteriaAdapter = new CriteriaAdapter(this, datas);
                LinearLayoutManager layoutManager = new LinearLayoutManager(this);
                layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                recyclerViewMidterm.setAdapter(criteriaAdapter);
                recyclerViewMidterm.setLayoutManager(layoutManager);
                recyclerViewMidterm.setItemAnimator(new DefaultItemAnimator());
            }
        }
    } catch (GradingFactorException e) {
        e.printStackTrace();
    }
    linearLayoutm.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Midterm.class);
            intent.putExtra("subjectId", subject.getId());
            startActivity(intent);
            finish();
        }
    });
    linearLayoutf.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            Intent intent = new Intent(Teacher_Activity_View_Subject_Datails.this, Teacher_GradingFactor_Activity_Finals.class);
            startActivity(intent);
            finish();
        }
    });
}
Also used : GradingFactorException(com.remswork.project.alice.exception.GradingFactorException) ArrayList(java.util.ArrayList) SubjectException(com.remswork.project.alice.exception.SubjectException) Intent(android.content.Intent) FormulaHelper(com.lieverandiver.thesisproject.helper.FormulaHelper) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Formula(com.remswork.project.alice.model.Formula) CriteriaAdapter(com.lieverandiver.thesisproject.adapter.CriteriaAdapter) SubjectServiceImpl(com.remswork.project.alice.service.impl.SubjectServiceImpl) CompoundButton(android.widget.CompoundButton)

Aggregations

Intent (android.content.Intent)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 TextView (android.widget.TextView)1 CriteriaAdapter (com.lieverandiver.thesisproject.adapter.CriteriaAdapter)1 FormulaHelper (com.lieverandiver.thesisproject.helper.FormulaHelper)1 GradingFactorException (com.remswork.project.alice.exception.GradingFactorException)1 SubjectException (com.remswork.project.alice.exception.SubjectException)1 Formula (com.remswork.project.alice.model.Formula)1 SubjectServiceImpl (com.remswork.project.alice.service.impl.SubjectServiceImpl)1 ArrayList (java.util.ArrayList)1