Click here to Skip to main content
15,885,537 members
Articles / Mobile Apps / Android

Android Puzzles Solver

Rate me:
Please Sign up or sign in to vote.
4.87/5 (17 votes)
1 Oct 2012Apache13 min read 102.5K   7.1K   77  
Puzzles Solver is an Android application for playing and solving puzzles.
package gr.sullenart.games.puzzles;

import gr.sullenart.ads.AdsManager;
import gr.sullenart.scores.Score;
import gr.sullenart.scores.ScoreItemAdapter;
import gr.sullenart.scores.ScoresManager;
import gr.sullenart.scores.ScoresManagerFactory;

import java.util.List;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class ScoresActivity extends ListActivity  {
	private ScoresManager scoresManager;

	public static String [] gameGroups = {"Q8Puzzle", "NumberSquarePuzzle",  "Solo"};
	
	private String gameGroup = "";

	private TextView emptyView;

	private AdsManager adsManager = new AdsManager();

	@Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);

    	setContentView(R.layout.scores);

        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();

        int type =  bundle.getInt("GameType");
        if (type >= 0 && type < gameGroups.length) {
        	 gameGroup = gameGroups[type];
        }

        emptyView = (TextView) findViewById(R.id.empty);

        final ListView listView = getListView();
        listView.setItemsCanFocus(false);
        listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        listView.setEmptyView(emptyView);

        scoresManager = ScoresManagerFactory.getScoresManager(getApplicationContext());

        LinearLayout layout = (LinearLayout)findViewById(R.id.banner_layout_scores);
        adsManager.addAdsView(this, layout);
    }

	   @Override
	    protected void onResume() {
	        super.onResume();

	        List<Score> scores = scoresManager.getScoresByGroup(gameGroup);
	        setListAdapter(new ScoreItemAdapter(this, scores));
	    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Software Developer (Senior) Self employed
Greece Greece
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions