Project

General

Profile

« Previous | Next » 

Revision 3441bb94

Added by Leszek Koltunski over 2 years ago

Lots of progress with the main screen

View differences:

distorted-sokoban/src/main/AndroidManifest.xml
15 15
    <uses-feature android:name="android.hardware.touchscreen"/>
16 16
    
17 17
    <application android:icon="@drawable/icon" android:label="@string/app_name">
18
        <activity android:name=".SokobanSplash"
18
        <activity android:name=".SokobanActivity"
19 19
                  android:label="@string/app_name"
20 20
                  android:exported="true"
21 21
                  android:screenOrientation="portrait"
......
26 26
                <category android:name="android.intent.category.LAUNCHER" />
27 27
            </intent-filter>
28 28
        </activity>
29
        <activity android:name=".SokobanActivity"
30
                  android:exported="true"
31
                  android:screenOrientation="portrait"
32
                  android:label="@string/app_name"
33
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
34
                  android:finishOnTaskLaunch="true">
35
            <intent-filter>
36
                <action android:name="android.intent.action.MAIN" />
37
                <category android:name="android.intent.category.DEFAULT" />
38
            </intent-filter>
39
        </activity>
40 29
    </application>
41 30

  
42 31
</manifest>
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanActivity.java
76 76

  
77 77
    LinearLayout upper = findViewById(R.id.upper_layout);
78 78
    createUpperLayout(upper);
79

  
80
    SokobanLevels.init(this);
81
    SokobanLevels sl = SokobanLevels.getInstance();
82
    SokobanDatabase.init(this);
83
    SokobanTimer.init();
84
    SokobanRecords.setLevels(sl);
85

  
86
    GridView gridview = findViewById(R.id.gridview);
87
    gridview.setAdapter(new SokobanGridAdapter(this));
88

  
89
    gridview.setOnItemClickListener(new AdapterView.OnItemClickListener()
90
      {
91
      @Override
92
      public void onItemClick(AdapterView<?> parent, View v, int position, long id)
93
        {
94
        android.util.Log.e("D", "position="+position);
95
        }
96
      });
79 97
    }
80 98

  
81 99
///////////////////////////////////////////////////////////////////////////////////////////////////
......
116 134
  public void onResume()
117 135
    {
118 136
    super.onResume();
119

  
120
    GridView gridview = findViewById(R.id.gridview);
121
    gridview.setAdapter(new SokobanGridAdapter(this));
122

  
123
    gridview.setOnItemClickListener(new AdapterView.OnItemClickListener()
124
      {
125
      @Override
126
      public void onItemClick(AdapterView<?> parent, View v, int position, long id)
127
        {
128
        android.util.Log.e("D", "position="+position);
129
        }
130
      });
131 137
    }
132 138

  
133 139
///////////////////////////////////////////////////////////////////////////////////////////////////
......
136 142
  public void onPause()
137 143
    {
138 144
    super.onPause();
145
    SokobanDatabase.onExit();
139 146
    }
140 147

  
141 148
///////////////////////////////////////////////////////////////////////////////////////////////////
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanDatabase.java
628 628
	private SokobanDatabase( Context co )
629 629
	{
630 630
	    mContext = new WeakReference<>(co);
631
	    
632 631
	    SokobanLevels levels = SokobanLevels.getInstance();
633 632
	    mNumRunnings = 0;
634 633
	    mNumPlayings = 0;
......
766 765
	  if( mThis==null ) mThis = new SokobanDatabase((Context)act);
767 766
	}
768 767

  
768
///////////////////////////////////////////////////////////////////
769

  
770
  public static void onExit()
771
		{
772
		mThis = null;
773
		}
774

  
769 775
///////////////////////////////////////////////////////////////////
770 776

  
771 777
	public int getNumRunnings()
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanGridAdapter.java
1 1
package org.distorted.sokoban;
2 2

  
3
import android.content.Context;
4

  
5 3
import android.util.TypedValue;
6 4
import android.view.LayoutInflater;
7 5
import android.view.View;
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanLevels.java
114 114
      mNumLevels = 0;
115 115
      mScrollPos = 0;
116 116
      mScrollSpeed=0;
117
      
117

  
118 118
      res = context.getResources();
119 119
      
120 120
      mVertical = (scrWidth<=scrHeight);
distorted-sokoban/src/main/java/org/distorted/sokoban/SokobanSplash.java
1
package org.distorted.sokoban;
2

  
3
import android.app.Activity;
4
import android.content.Intent;
5
import android.os.Bundle;
6
import android.util.Log;
7

  
8
import com.google.firebase.analytics.FirebaseAnalytics;
9
import com.google.firebase.inappmessaging.FirebaseInAppMessaging;
10

  
11
import org.distorted.messaging.SokobanInAppMessanging;
12

  
13
///////////////////////////////////////////////////////////////////
14

  
15
public class SokobanSplash extends Activity
16
{
17
	private int sleepTime=2000;
18

  
19
  private class SplashThread extends Thread
20
    {
21
    private boolean bootup=true;
22
		
23
		public void run() 
24
		  {
25
			int milis=0;
26
			
27
			while(bootup)
28
			  {
29
				try
30
				  {
31
					milis+=100;
32
					Thread.sleep(100);
33
				  }
34
				catch( InterruptedException ex) { }
35
			  }
36
			
37
			if( milis<sleepTime )
38
			  {
39
				try
40
				  {
41
					Thread.sleep(sleepTime-milis);
42
				  }
43
				catch( InterruptedException ex) { }
44
			  }
45

  
46
			finish();
47
			Intent mainInt = new Intent( getApplicationContext(), SokobanActivity.class);
48
			startActivity(mainInt);
49
		  }
50
		public void bootupReady()
51
		{
52
			bootup=false;
53
		}
54
    };
55
    
56
///////////////////////////////////////////////////////////////////
57
	
58
  public void onCreate(Bundle savedInstanceState)
59
    {
60
    super.onCreate(savedInstanceState);
61
  	setContentView(R.layout.splash);
62
    sleepTime=2000;
63
    }
64

  
65
///////////////////////////////////////////////////////////////////
66

  
67
  public void onStart()
68
    {
69
    super.onStart();
70
    	
71
    SplashThread splashThread = new SplashThread();
72
    splashThread.start();
73
    	
74
    SokobanLevels.init(this);
75
    SokobanLevels sl = SokobanLevels.getInstance();
76
        
77
    SokobanCanvas.init(this);
78
    SokobanCanvas.setActivity(this);
79
    	
80
    SokobanDatabase.init(this);
81
    SokobanTimer.init();
82
    SokobanCanvas.setLevels(sl);
83
    SokobanRecords.setLevels(sl);
84

  
85
    splashThread.bootupReady();
86
    }
87

  
88
///////////////////////////////////////////////////////////////////
89
// end of file
90
}

Also available in: Unified diff