Android Open Source - Ascent Top10 Activity






From Project

Back to project page Ascent.

License

The source code is released under:

GNU General Public License

If you think the Android project Ascent 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 be.sourcery.ascent;
/*from  w w  w . j  av a  2s.c o m*/
import java.util.Date;

import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;



public class Top10Activity extends MyActivity {

    private InternalDB db;
    private Cursor cursor12Months;
    private Cursor cursorYear;
    private Cursor cursorAllTime;
    private CursorAdapter adapterYear;
    private CursorAdapter adapter12Months;
    private CursorAdapter adapterAllTime;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.top10);
        setTitle(R.string.top10);
        setupActionBar();
        db = new InternalDB(this);
        Date now = new Date();
        int year = now.getYear() + 1900;
        TextView thisYearScore = (TextView)this.findViewById(R.id.thisYearText);
        thisYearScore.setText("Score so far this year - "+ db.getScoreForYear(year));
        cursorYear = db.getTop10ForYear(year);
        startManagingCursor(cursorYear);
        adapterYear = new SimpleCursorAdapter(getApplicationContext(), R.layout.top10_ascent_list_item, cursorYear,
                new String[] {"date", "style", "route_grade", "route_name", "score"},
                new int[] {R.id.dateCell, R.id.styleCell, R.id.gradeCell, R.id.nameCell, R.id.scoreCell});
        ListView listView = (ListView)this.findViewById(R.id.thisYearList);
        listView.setAdapter(adapterYear);

        TextView twelveMonthScore = (TextView)this.findViewById(R.id.twelveMonthText);
        twelveMonthScore.setText("Score last 12 months - " + db.getScoreLast12Months());
        cursor12Months = db.getTop10TwelveMonths();
        startManagingCursor(cursor12Months);
        adapter12Months = new SimpleCursorAdapter(getApplicationContext(), R.layout.top10_ascent_list_item, cursor12Months,
                new String[] {"date", "style", "route_grade", "route_name", "score"},
                new int[] {R.id.dateCell, R.id.styleCell, R.id.gradeCell, R.id.nameCell, R.id.scoreCell});
        ListView listView2 = (ListView)this.findViewById(R.id.twelveMonthList);
        listView2.setAdapter(adapter12Months);

        TextView allTimeScore = (TextView)this.findViewById(R.id.allTimeText);
        allTimeScore.setText("Score all time - " + db.getScoreAllTime());
        cursorAllTime = db.getTop10AllTime();
        startManagingCursor(cursorAllTime);
        adapterAllTime = new SimpleCursorAdapter(getApplicationContext(), R.layout.top10_ascent_list_item, cursorAllTime,
                new String[] {"date", "style", "route_grade", "route_name", "score"},
                new int[] {R.id.dateCell, R.id.styleCell, R.id.gradeCell, R.id.nameCell, R.id.scoreCell});
        ListView listView3 = (ListView)this.findViewById(R.id.allTimeList);
        listView3.setAdapter(adapterAllTime);
    }

    public void onDestroy() {
        super.onDestroy();
        db.close();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                // app icon in action bar clicked; go home
                Intent intent = new Intent(this, MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

}




Java Source Code List

be.sourcery.ascent.AddAscentActivity.java
be.sourcery.ascent.AddCragActivity.java
be.sourcery.ascent.AddProjectActivity.java
be.sourcery.ascent.AscentApplication.java
be.sourcery.ascent.AscentProvider.java
be.sourcery.ascent.Ascent.java
be.sourcery.ascent.CragAscentsActivity.java
be.sourcery.ascent.CragListActivity.java
be.sourcery.ascent.Crag.java
be.sourcery.ascent.EditAscentActivity.java
be.sourcery.ascent.ExportDataActivity.java
be.sourcery.ascent.GradeAscentsActivity.java
be.sourcery.ascent.GradeGraphActivity.java
be.sourcery.ascent.GradeInfo.java
be.sourcery.ascent.GradeView.java
be.sourcery.ascent.ImportDataActivity.java
be.sourcery.ascent.InternalDB.java
be.sourcery.ascent.MainActivity.java
be.sourcery.ascent.MyActivity.java
be.sourcery.ascent.ProjectListActivity.java
be.sourcery.ascent.Project.java
be.sourcery.ascent.RepeatAscentActivity.java
be.sourcery.ascent.Route.java
be.sourcery.ascent.ScoreGraphActivity.java
be.sourcery.ascent.SearchAscentsActivity.java
be.sourcery.ascent.TickProjectActivity.java
be.sourcery.ascent.Top10Activity.java