Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit e107e8f

Browse files
committed
added layouts example
1 parent 3bc8ef0 commit e107e8f

File tree

38 files changed

+772
-0
lines changed

38 files changed

+772
-0
lines changed

Diff for: android_studio/ex3_layoutsv4/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

Diff for: android_studio/ex3_layoutsv4/.idea/compiler.xml

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/copyright/profiles_settings.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/gradle.xml

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/misc.xml

+62
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: android_studio/ex3_layoutsv4/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: android_studio/ex3_layoutsv4/app/build.gradle

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 23
5+
buildToolsVersion "24.0.1"
6+
defaultConfig {
7+
applicationId "processing.test.processingintegration"
8+
minSdkVersion 21
9+
targetSdkVersion 23
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(include: ['*.jar'], dir: 'libs')
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:23.4.0'
28+
compile 'com.android.support:design:23.4.0'
29+
testCompile 'junit:junit:4.12'
30+
compile files('libs/android-core.jar')
31+
}
470 KB
Binary file not shown.

Diff for: android_studio/ex3_layoutsv4/app/proguard-rules.pro

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/andres/code/android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package processing.test.processingintegration;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("processing.test.processingintegration", appContext.getPackageName());
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest package="processing.test.processingintegration"
3+
xmlns:android="http://schemas.android.com/apk/res/android">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:supportsRtl="true"
10+
android:theme="@style/AppTheme">
11+
<activity
12+
android:name=".MainActivity"
13+
android:label="@string/app_name"
14+
android:theme="@style/AppTheme.NoActionBar">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN"/>
17+
<category android:name="android.intent.category.LAUNCHER"/>
18+
</intent-filter>
19+
</activity>
20+
</application>
21+
22+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package processing.test.processingintegration;
2+
3+
import android.os.Bundle;
4+
import android.support.design.widget.FloatingActionButton;
5+
import android.support.design.widget.Snackbar;
6+
import android.support.v4.app.FragmentManager;
7+
import android.support.v4.app.FragmentTransaction;
8+
import android.support.v7.app.AppCompatActivity;
9+
import android.support.v7.widget.Toolbar;
10+
import android.view.View;
11+
import android.view.ViewTreeObserver;
12+
import android.view.Menu;
13+
import android.view.MenuItem;
14+
import android.os.Build;
15+
16+
import processing.android.PFragment;
17+
18+
public class MainActivity extends AppCompatActivity {
19+
Sketch sketch;
20+
21+
@Override
22+
protected void onCreate(Bundle savedInstanceState) {
23+
super.onCreate(savedInstanceState);
24+
setContentView(R.layout.activity_main);
25+
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
26+
setSupportActionBar(toolbar);
27+
28+
sketch = new Sketch();
29+
PFragment fragment = new PFragment();
30+
fragment.setSketch(sketch);
31+
fragment.init(R.id.content_main, getSupportFragmentManager());
32+
33+
// FragmentManager fragmentManager = getSupportFragmentManager();
34+
// FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
35+
// fragmentTransaction.add(R.id.content_main, fragment);
36+
// fragmentTransaction.commit();
37+
38+
39+
40+
// final View parent = findViewById(R.id.content_main);
41+
// parent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
42+
// @Override
43+
// public void onGlobalLayout() {
44+
// int availableWidth = parent.getMeasuredWidth();
45+
// int availableHeight = parent.getMeasuredHeight();
46+
// if (availableHeight > 0 && availableWidth > 0) {
47+
// System.err.println(availableWidth + " " + availableHeight);
48+
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
49+
// parent.getViewTreeObserver().removeGlobalOnLayoutListener(this);
50+
// } else {
51+
// parent.getViewTreeObserver().removeOnGlobalLayoutListener(this);
52+
// }
53+
//
54+
// }
55+
// }
56+
//
57+
//
58+
// });
59+
}
60+
61+
@Override
62+
public boolean onCreateOptionsMenu(Menu menu) {
63+
// Inflate the menu; this adds items to the action bar if it is present.
64+
getMenuInflater().inflate(R.menu.menu_main, menu);
65+
return true;
66+
}
67+
68+
@Override
69+
public boolean onOptionsItemSelected(MenuItem item) {
70+
// Handle action bar item clicks here. The action bar will
71+
// automatically handle clicks on the Home/Up button, so long
72+
// as you specify a parent activity in AndroidManifest.xml.
73+
int id = item.getItemId();
74+
75+
//noinspection SimplifiableIfStatement
76+
if (id == R.id.action_settings) {
77+
return true;
78+
}
79+
80+
return super.onOptionsItemSelected(item);
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package processing.test.processingintegration;
2+
3+
import processing.core.PApplet;
4+
5+
public class Sketch extends PApplet {
6+
public void settings() {
7+
layout(R.layout.content_main, P3D);
8+
}
9+
10+
public void setup() {
11+
textFont(createFont("Serif", 80));
12+
textAlign(CENTER, CENTER);
13+
strokeWeight(5);
14+
}
15+
16+
public void draw() {
17+
background(180);
18+
fill(0);
19+
line(0, 0, mouseX, mouseY);
20+
line(width, 0, mouseX, mouseY);
21+
line(0, height, mouseX, mouseY);
22+
line(width, height, mouseX, mouseY);
23+
fill(255, 0, 0);
24+
text(width + "x" + height, width/2, height/2);
25+
26+
lights();
27+
translate(mouseX, mouseY);
28+
rotateX(frameCount * 0.01f);
29+
rotateY(frameCount * 0.01f);
30+
box(100);
31+
32+
}
33+
}

0 commit comments

Comments
 (0)