Android Open Source - Netball Dashboard Activity






From Project

Back to project page Netball.

License

The source code is released under:

GNU General Public License

If you think the Android project Netball 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 com.prisch.activities;
/*  w ww . ja  v a2 s. c  o  m*/
import android.app.Activity;
import android.app.LoaderManager;
import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import com.prisch.R;
import com.prisch.repositories.GameRepository;

public class DashboardActivity extends Activity implements LoaderManager.LoaderCallbacks<Cursor> {

    private static final int GAME_LOADER = 0;

    private GameRepository gameRepository;

    // ===== Lifecycle Methods =====

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dashboard);

        gameRepository = new GameRepository(this);

        getLoaderManager().initLoader(GAME_LOADER, null, this);
        configureButtons();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.dashboard, menu);
        return true;
    }

    @Override
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        return gameRepository.getActiveGameLoader();
    }

    @Override
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        if (data.getCount() == 0) {
            switchToStandbyMode();
        } else {
            switchToRecordingMode();
        }
    }

    @Override
    public void onLoaderReset(Loader<Cursor> loader) {
        // Nothing to cleanup
    }

    // ===== Helper Methods =====

    private void configureButtons() {
        Button buttonRecordGame = (Button)findViewById(R.id.button_recordGame);
        buttonRecordGame.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent teamIntent = new Intent(getApplicationContext(), TeamActivity.class);
                teamIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                startActivity(teamIntent);
            }
        });

        Button continueRecording = (Button)findViewById(R.id.button_continueRecording);
        continueRecording.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent positionIntent = new Intent(getApplicationContext(), PositionsActivity.class);
                startActivity(positionIntent);
            }
        });

        Button stopRecording = (Button)findViewById(R.id.button_stopRecording);
        stopRecording.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                gameRepository.stopActiveGame();
            }
        });

        Button buttonManagePlayers = (Button)findViewById(R.id.button_managePlayers);
        buttonManagePlayers.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent playersIntent = new Intent(getApplicationContext(), PlayersActivity.class);
                startActivity(playersIntent);
            }
        });

        Button buttonViewGames = (Button)findViewById(R.id.button_viewGames);
        buttonViewGames.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent gamesIntent = new Intent(getApplicationContext(), GamesActivity.class);
                startActivity(gamesIntent);
            }
        });
    }

    private void switchToRecordingMode() {
        findViewById(R.id.button_recordGame).setVisibility(View.GONE);
        findViewById(R.id.button_continueRecording).setVisibility(View.VISIBLE);
        findViewById(R.id.button_stopRecording).setVisibility(View.VISIBLE);
    }

    private void switchToStandbyMode() {
        findViewById(R.id.button_recordGame).setVisibility(View.VISIBLE);
        findViewById(R.id.button_continueRecording).setVisibility(View.GONE);
        findViewById(R.id.button_stopRecording).setVisibility(View.GONE);
    }
}




Java Source Code List

com.prisch.activities.ActionsActivity.java
com.prisch.activities.BaseTeamActivity.java
com.prisch.activities.DashboardActivity.java
com.prisch.activities.GameStatsActivity.java
com.prisch.activities.GamesActivity.java
com.prisch.activities.PlayersActivity.java
com.prisch.activities.PositionsActivity.java
com.prisch.activities.SubstitutionActivity.java
com.prisch.activities.TeamActivity.java
com.prisch.content.DatabaseHelper.java
com.prisch.content.NetballContentProvider.java
com.prisch.controls.ActionButton.java
com.prisch.fragments.PositionStatsFragment.java
com.prisch.loaders.GameStatsLoader.java
com.prisch.model.Action.java
com.prisch.model.GameStats.java
com.prisch.model.Game.java
com.prisch.model.OpponentAction.java
com.prisch.model.OpponentRecord.java
com.prisch.model.PlayerStats.java
com.prisch.model.Player.java
com.prisch.model.Position.java
com.prisch.model.Record.java
com.prisch.model.TeamMember.java
com.prisch.repositories.GameRepository.java
com.prisch.repositories.OpponentRecordRepository.java
com.prisch.repositories.PlayerRepository.java
com.prisch.repositories.RecordRepository.java
com.prisch.repositories.StatsRepository.java
com.prisch.repositories.TeamMemberRepository.java
com.prisch.util.DateUtils.java
com.prisch.views.GameAdapter.java
com.prisch.views.GameStatsAdapter.java
com.prisch.views.PlayerStatsAdapter.java
com.prisch.views.PlayerStatsListItem.java
com.prisch.views.TeamAdapter.java