Android Open Source - candymem Main Activity






From Project

Back to project page candymem.

License

The source code is released under:

GNU General Public License

If you think the Android project candymem 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 se.tube42.kidsmem.android;
/*from ww  w . j a v a  2s.co  m*/
import android.os.Bundle;
import android.app.Activity;
import android.net.Uri;
import android.content.Intent;
import android.widget.Toast;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;

import se.tube42.kidsmem.*;
import se.tube42.kidsmem.data.*;

public class MainActivity
extends AndroidApplication
implements SystemHandler
{
    private boolean is_full = false;

    class UpdateFullscreen implements Runnable {
        @Override public void run() {
            final int flags = 0x00001000 | 0x00000004 | 0x00000002;
            try {
                int opt = getWindow().getDecorView().getSystemUiVisibility();
                int optold = opt;
                if(is_full) opt |= flags;
                else opt &= ~flags;
                getWindow().getDecorView().setSystemUiVisibility(opt);

                System.out.println("*** SystemUiVisibility " + optold + " -> " + opt); // DEBUG

            } catch(Exception exx) {
                exx.printStackTrace();
            }
        }
    }


    private Runnable update_fullscreen = new UpdateFullscreen();

    // ---------------------------------------
    // SystemHandler
    private boolean try_run(Runnable r)
    {
        try {
            runOnUiThread(r);
            return true;
        } catch(Exception exx) {
            System.out.println("[2] " + exx);
            return false;
        }
    }

    public void showMessage(final String text)
    {
        try_run(new Runnable() {
            @Override public void run(){
                try {
                    Toast t = Toast.makeText(MainActivity.this, text, 12000);
                    t.show();
                } catch(Exception exx) {
                System.out.println("ERROR: " + exx);
            }}});
    }

    public void setFullscreen(final boolean new_full)
    {
        if(new_full == is_full)
            return;

        is_full = new_full;
        try_run(update_fullscreen);
    }

    // --------------------------------------------

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

        World.sys = this;

        AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
        cfg.useAccelerometer = false;
        cfg.useCompass = false;
        // cfg.useGL20 = true;
        cfg.useWakelock = true;

        initialize(new KidsMemoryApp(), cfg);
    }
}




Java Source Code List

com.badlogic.gdx.backends.lwjgl.LwjglApplication.java
se.tube42.kidsmem.KidsMemoryApp.java
se.tube42.kidsmem.SystemHandler.java
se.tube42.kidsmem.android.MainActivity.java
se.tube42.kidsmem.data.Assets.java
se.tube42.kidsmem.data.Constants.java
se.tube42.kidsmem.data.Settings.java
se.tube42.kidsmem.data.UI.java
se.tube42.kidsmem.data.World.java
se.tube42.kidsmem.desktop.DesktopMain.java
se.tube42.kidsmem.item.Button.java
se.tube42.kidsmem.item.FireworkItem.java
se.tube42.kidsmem.item.GameStat.java
se.tube42.kidsmem.item.TileSprite.java
se.tube42.kidsmem.item.TopBar.java
se.tube42.kidsmem.logic.AssetHelper.java
se.tube42.kidsmem.logic.GameHelper.java
se.tube42.kidsmem.logic.SettingsHelper.java
se.tube42.kidsmem.logic.SizeHelper.java
se.tube42.kidsmem.scene.BackgroundScene.java
se.tube42.kidsmem.scene.GameScene.java
se.tube42.kidsmem.scene.MenuScene.java
se.tube42.kidsmem.service.ServiceProvider.java
se.tube42.lib.item.BaseItem.java
se.tube42.lib.item.BaseText.java
se.tube42.lib.item.ParticleItem.java
se.tube42.lib.item.PatchItem.java
se.tube42.lib.item.SpriteItem.java
se.tube42.lib.scene.LayerList.java
se.tube42.lib.scene.Layer.java
se.tube42.lib.scene.SceneManager.java
se.tube42.lib.scene.Scene.java
se.tube42.lib.service.AssetService.java
se.tube42.lib.service.JobService.java
se.tube42.lib.service.RandomService.java
se.tube42.lib.service.StorageService.java
se.tube42.lib.util.BaseApp.java
se.tube42.lib.util.UIC.java