protected void onPause() { super.onPause(); // Retirar somente a data de cada matéria ArrayList<SubjectData> materiasData = new ArrayList<SubjectData>(); for (SubjectCard lm : mSubjectCards) { materiasData.add(lm.getData()); mSqlHelper.update(lm.getData()); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSqlHelper = new SQLHelper(this); setContentView(R.layout.main); mScrollView = (ScrollView) findViewById(R.id.scrllvwNo1); mSubjectsLayout = (LinearLayout) findViewById(R.id.llmaterias); mTotalAbsencesTextView = (TextView) findViewById(R.id.tvFaltasTotais); mAddButton = (Button) findViewById(R.id.btnNovaMateria); mAddButton.setOnClickListener( new OnClickListener() { public void onClick(View v) { final SubjectCard materia = SubjectCard.createSubjectCard( AbsenceActivity.this, new SubjectData(), mSubjectsLayout); final ObjectAnimator btAnimator = ObjectAnimator.ofFloat(mAddButton, "alpha", 0); btAnimator.setDuration(500); btAnimator.start(); createEditSubjectDialog( materia, new Runnable() { @Override public void run() { mSubjectCards.add(materia); mSubjectsLayout.addView(materia); mSqlHelper.insertAndID(materia.getData()); ViewHelper.setTranslationX(materia, -mSubjectsLayout.getWidth()); materia.swipeBack(0, 700); btAnimator.setFloatValues(1); btAnimator.setStartDelay(1100); btAnimator.start(); } }, new Runnable() { @Override public void run() { btAnimator.setFloatValues(1); btAnimator.start(); } }) .show(); updateTotal(); } }); mSubjectCards = new ArrayList<SubjectCard>(); ArrayList<SubjectData> materiasData = mSqlHelper.retrieveAllMateriaData(); for (SubjectData mData : materiasData) { mSubjectCards.add(SubjectCard.createSubjectCard(this, mData, mSubjectsLayout)); } for (SubjectCard lm : mSubjectCards) mSubjectsLayout.addView(lm); // Atualiza a contagem do total de faltas updateTotal(); }