Android Open Source - As1-301-CounterApp Counter Stats Activity






From Project

Back to project page As1-301-CounterApp.

License

The source code is released under:

GNU General Public License

If you think the Android project As1-301-CounterApp 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 pack.as1_301;
// w  w w.ja va2  s.c  o m
import java.util.ArrayList;
import java.util.Date;

import com.google.gson.Gson;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class CounterStatsActivity extends Activity {
  private Counter currentCounter;
  private ArrayList<Date> dates = new ArrayList<Date>();
  private ListView counterList;
  private ArrayAdapter<Date> adapter;
  
  // sets up the class for use
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.counter_stats);
    counterList = (ListView) findViewById(R.id.counter_stats_view);
    Intent intent = getIntent();
      String temp = intent.getStringExtra(MainActivity.CURRENT_COUNTER);
      currentCounter = deserialization(temp);
      dates = currentCounter.getChanges();
  }
  
  // refreshes the view with current values
  @Override
  protected void onResume() {
    super.onResume();
    dates = currentCounter.getChanges();
    adapter = new ArrayAdapter<Date>(this, R.layout.counter_listview, dates);
      counterList.setAdapter(adapter);
  }
    
  // returns a counter when given a serialized text
    private Counter deserialization(String text) {
        Gson gson = new Gson();
        Counter new_counter = gson.fromJson(text, Counter.class);
        return new_counter;
    }
}




Java Source Code List

pack.as1_301.CounterActivity.java
pack.as1_301.CounterSettingsActivity.java
pack.as1_301.CounterStatsActivity.java
pack.as1_301.Counter.java
pack.as1_301.CreateCounterActivity.java
pack.as1_301.MainActivity.java