Android Open Source - donatello-y-raphael Maps Activity






From Project

Back to project page donatello-y-raphael.

License

The source code is released under:

MIT License

If you think the Android project donatello-y-raphael 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.example.ATracePath;
/*from   w  w w .  j  ava  2  s.c  o  m*/
import android.app.Activity;
import android.content.Intent;
import android.app.ActionBar.LayoutParams;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.List;

/**
 * Created by solberg on 22/09/14.
 */
public class MapsActivity extends Activity {

    private Global global = Global.getInstance();
    private final int GREEN = new Color().rgb(106, 166, 23);

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

        final LinearLayout layout = (LinearLayout) findViewById(R.id.maps);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        List<Challenge> challenge = global.mPacks.get(global.packID).getChallenge();

        final TextView mapsName = (TextView) findViewById(R.id.mapsName);
        mapsName.setText(global.mPacks.get(global.packID).getName());

        ProgressAdapter pa = new ProgressAdapter(getApplicationContext());


        for (int i = 0; i < challenge.size(); i++) {

            LinearLayout ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.HORIZONTAL);

            TextView levels = new TextView(this);
            levels.setText(challenge.get(i).getName());
            levels.setId(i);

            ll.addView(levels);
            layout.addView(ll);

            List<Puzzle> puzzles = challenge.get(i).getPuzzleList();

            LinearLayout bl = new LinearLayout(this);
            bl.setOrientation(LinearLayout.HORIZONTAL);
            layout.addView(bl);

            int lineBreak = 4;

            final int level = i;
            for (int j = 0; j < puzzles.size(); j++) {

                if (lineBreak == 4) {
                    bl = new LinearLayout(this);
                    bl.setOrientation(LinearLayout.HORIZONTAL);
                    layout.addView(bl);
                    lineBreak = 0;
                }

                lineBreak++;

                final Button btn = new Button(this);
                btn.setId(j);
                btn.setText(String.valueOf(j + 1));
                btn.setWidth(250);
                btn.setHeight(250);
                btn.setTextSize((float) 25);
                btn.setLayoutParams(params);

                if (pa.getBoardById(j, global.packID, i)) {
                    btn.setAlpha((float) 30);
                    btn.setTextColor(GREEN);
                }

                final int index = j;
                btn.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        global.puzzleID = index;
                        global.challengeID = level;
                        startActivity(new Intent(getApplicationContext(), PlayActivity.class));
                        Log.i("MapsActivity goto:", " PlayActivity");
                    }
                });
                bl.addView(btn);
            }
        }
    }
}




Java Source Code List

com.example.ATracePath.Board.java
com.example.ATracePath.Cellpath.java
com.example.ATracePath.Challenge.java
com.example.ATracePath.Coordinate.java
com.example.ATracePath.DbHelper.java
com.example.ATracePath.Global.java
com.example.ATracePath.LevelsActivity.java
com.example.ATracePath.MainActivity.java
com.example.ATracePath.MapsActivity.java
com.example.ATracePath.Pack.java
com.example.ATracePath.PlayActivity.java
com.example.ATracePath.ProgressAdapter.java
com.example.ATracePath.Puzzle.java
com.example.ATracePath.SettingsActivity.java