Android Open Source - android-memorytrainer Statistics Overview Activity






From Project

Back to project page android-memorytrainer.

License

The source code is released under:

GNU General Public License

If you think the Android project android-memorytrainer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.hoffimar.android.memorytrainer;
/*from ww w.  j a  va 2s.  com*/
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.TextView;

import com.flurry.android.FlurryAgent;

public class StatisticsOverviewActivity extends Activity {

  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      
      setContentView(R.layout.stats_overview);
  
      TextView correctTextView = (TextView) findViewById(R.id.StatsTextView02);
    TextView incorrectTextView = (TextView) findViewById(R.id.StatsTextView04);
    TextView percCorrectTextView = (TextView) findViewById(R.id.StatsTextView06);
      
      DbAdapter mDbHelper;
    mDbHelper = new DbAdapter(this);
    mDbHelper.open();
    
    Cursor statsCursor = mDbHelper.fetchAllStats();
    startManagingCursor(statsCursor);
    
    int countCorrect = 0;
    int countIncorrect = 0;
    
    while (statsCursor.moveToNext()){
//      String date = statsCursor.getString(1);
//      String number = statsCursor.getString(2);
      int isCorrect = statsCursor.getInt(3);
      
      if (isCorrect == 0){
        countIncorrect++;
      } else {
        countCorrect++;
      }
      
    }
    
    mDbHelper.close();
    
    double percentageCorrect = 0;
    if (countCorrect + countIncorrect != 0){
      percentageCorrect = (new Double(countCorrect) / (countCorrect + countIncorrect)) * 100;
    }
    
    
    correctTextView.setText(Integer.toString(countCorrect));
    incorrectTextView.setText(Integer.toString(countIncorrect));
    
    if (countCorrect + countIncorrect != 0){
      percCorrectTextView.setText(Long.toString(Math.round(percentageCorrect)));
    } else {
      percCorrectTextView.setText("-");
    }
    
    FlurryAgent.onEvent(Constants.FLURRY_EVENTID_STATS_OVERVIEW);
    
  }
  
  @Override
    protected void onStart() {
      super.onStart();
      FlurryAgent.onStartSession(this, Constants.FLURRY_ID);
    }
    
    @Override
    protected void onStop() {
      super.onStop();
      FlurryAgent.onEndSession(this);
    }

}




Java Source Code List

org.hoffimar.android.memorytrainer.AboutActivity.java
org.hoffimar.android.memorytrainer.CheckLastNumberActivity.java
org.hoffimar.android.memorytrainer.Constants.java
org.hoffimar.android.memorytrainer.DbAdapter.java
org.hoffimar.android.memorytrainer.EditItemActivity.java
org.hoffimar.android.memorytrainer.EditPreferencesActivity.java
org.hoffimar.android.memorytrainer.GenerateNumberActivity.java
org.hoffimar.android.memorytrainer.InformationActivity.java
org.hoffimar.android.memorytrainer.ListHundredActivity.java
org.hoffimar.android.memorytrainer.MaintainListActivity.java
org.hoffimar.android.memorytrainer.Overview.java
org.hoffimar.android.memorytrainer.StatisticsOverviewActivity.java
org.hoffimar.android.memorytrainer.TreeListActivity.java
org.hoffimar.android.memorytrainer.TreeListGenerateActivity.java
org.hoffimar.android.memorytrainer.TreeListVerifyActivity.java
org.hoffimar.android.memorytrainer.model.CellEntry.java
org.hoffimar.android.memorytrainer.model.CellFeed.java
org.hoffimar.android.memorytrainer.model.Cell.java
org.hoffimar.android.memorytrainer.model.Content.java
org.hoffimar.android.memorytrainer.model.Entry.java
org.hoffimar.android.memorytrainer.model.Feed.java
org.hoffimar.android.memorytrainer.model.Link.java
org.hoffimar.android.memorytrainer.model.SpreadsheetEntry.java
org.hoffimar.android.memorytrainer.model.UserFeed.java
org.hoffimar.android.memorytrainer.model.WorksheetEntry.java
org.hoffimar.android.memorytrainer.model.WorksheetsFeed.java