Skip to content

Commit e4da5d3

Browse files
committed
Restored Certain Deleted Folders
1 parent d5f0f5c commit e4da5d3

File tree

4 files changed

+409
-0
lines changed

4 files changed

+409
-0
lines changed

mygdx/game/AndroidLauncher.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.mygdx.game;
2+
3+
import android.os.Bundle;
4+
5+
import com.badlogic.gdx.backends.android.AndroidApplication;
6+
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
7+
import com.mygdx.game.FlappyBird;
8+
9+
public class AndroidLauncher extends AndroidApplication {
10+
@Override
11+
protected void onCreate (Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
14+
initialize(new FlappyBird(), config);
15+
}
16+
}

new/connect3/MainActivity.java

+167
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
package com.robpercival.connect3;
2+
3+
import android.support.v7.app.ActionBarActivity;
4+
import android.os.Bundle;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
import android.view.View;
8+
import android.widget.GridLayout;
9+
import android.widget.ImageView;
10+
import android.widget.LinearLayout;
11+
import android.widget.TextView;
12+
13+
14+
public class MainActivity extends ActionBarActivity {
15+
16+
// 0 = yellow, 1 = red
17+
18+
int activePlayer = 0;
19+
20+
boolean gameIsActive = true;
21+
22+
// 2 means unplayed
23+
24+
int[] gameState = {2, 2, 2, 2, 2, 2, 2, 2, 2};
25+
26+
int[][] winningPositions = {{0,1,2}, {3,4,5}, {6,7,8}, {0,3,6}, {1,4,7}, {2,5,8}, {0,4,8}, {2,4,6}};
27+
28+
public void dropIn(View view) {
29+
30+
ImageView counter = (ImageView) view;
31+
32+
33+
34+
int tappedCounter = Integer.parseInt(counter.getTag().toString());
35+
36+
if (gameState[tappedCounter] == 2 && gameIsActive) {
37+
38+
gameState[tappedCounter] = activePlayer;
39+
40+
counter.setTranslationY(-1000f);
41+
42+
if (activePlayer == 0) {
43+
44+
counter.setImageResource(R.drawable.yellow);
45+
46+
activePlayer = 1;
47+
48+
} else {
49+
50+
counter.setImageResource(R.drawable.red);
51+
52+
activePlayer = 0;
53+
54+
}
55+
56+
counter.animate().translationYBy(1000f).rotation(360).setDuration(300);
57+
58+
for (int[] winningPosition : winningPositions) {
59+
60+
if (gameState[winningPosition[0]] == gameState[winningPosition[1]] &&
61+
gameState[winningPosition[1]] == gameState[winningPosition[2]] &&
62+
gameState[winningPosition[0]] != 2) {
63+
64+
// Someone has won!
65+
66+
gameIsActive = false;
67+
68+
String winner = "Red";
69+
70+
if (gameState[winningPosition[0]] == 0) {
71+
72+
winner = "Yellow";
73+
74+
}
75+
76+
TextView winnerMessage = (TextView) findViewById(R.id.winnerMessage);
77+
78+
winnerMessage.setText(winner + " has won!");
79+
80+
LinearLayout layout = (LinearLayout)findViewById(R.id.playAgainLayout);
81+
82+
layout.setVisibility(View.VISIBLE);
83+
84+
} else {
85+
86+
boolean gameIsOver = true;
87+
88+
for (int counterState : gameState) {
89+
90+
if (counterState == 2) gameIsOver = false;
91+
92+
}
93+
94+
if (gameIsOver) {
95+
96+
TextView winnerMessage = (TextView) findViewById(R.id.winnerMessage);
97+
98+
winnerMessage.setText("It's a draw");
99+
100+
LinearLayout layout = (LinearLayout)findViewById(R.id.playAgainLayout);
101+
102+
layout.setVisibility(View.VISIBLE);
103+
104+
}
105+
106+
}
107+
108+
}
109+
}
110+
111+
112+
}
113+
114+
public void playAgain(View view) {
115+
116+
gameIsActive = true;
117+
118+
LinearLayout layout = (LinearLayout)findViewById(R.id.playAgainLayout);
119+
120+
layout.setVisibility(View.INVISIBLE);
121+
122+
activePlayer = 0;
123+
124+
for (int i = 0; i < gameState.length; i++) {
125+
126+
gameState[i] = 2;
127+
128+
}
129+
130+
GridLayout gridLayout = (GridLayout)findViewById(R.id.gridLayout);
131+
132+
for (int i = 0; i< gridLayout.getChildCount(); i++) {
133+
134+
((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
135+
136+
}
137+
138+
}
139+
140+
@Override
141+
protected void onCreate(Bundle savedInstanceState) {
142+
super.onCreate(savedInstanceState);
143+
setContentView(R.layout.activity_main);
144+
}
145+
146+
@Override
147+
public boolean onCreateOptionsMenu(Menu menu) {
148+
// Inflate the menu; this adds items to the action bar if it is present.
149+
getMenuInflater().inflate(R.menu.menu_main, menu);
150+
return true;
151+
}
152+
153+
@Override
154+
public boolean onOptionsItemSelected(MenuItem item) {
155+
// Handle action bar item clicks here. The action bar will
156+
// automatically handle clicks on the Home/Up button, so long
157+
// as you specify a parent activity in AndroidManifest.xml.
158+
int id = item.getItemId();
159+
160+
//noinspection SimplifiableIfStatement
161+
if (id == R.id.action_settings) {
162+
return true;
163+
}
164+
165+
return super.onOptionsItemSelected(item);
166+
}
167+
}

newsreader/ArticleActivity.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.lenovo.newsreader;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.webkit.WebView;
7+
import android.webkit.WebViewClient;
8+
9+
public class ArticleActivity extends AppCompatActivity {
10+
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
setContentView(R.layout.activity_article);
15+
16+
WebView webView = (WebView) findViewById(R.id.webview);
17+
18+
webView.getSettings().setJavaScriptEnabled(true);
19+
20+
webView.setWebViewClient(new WebViewClient());
21+
22+
Intent intent = getIntent();
23+
24+
webView.loadData(intent.getStringExtra("content"), "text/html", "UTF-8");
25+
26+
}
27+
}

0 commit comments

Comments
 (0)