Skip to content

Commit

Permalink
PApplet does not subclass Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Oct 17, 2015
1 parent 41ff925 commit 3667f94
Show file tree
Hide file tree
Showing 13 changed files with 485 additions and 258 deletions.
2 changes: 1 addition & 1 deletion .classpath
Expand Up @@ -3,8 +3,8 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-app"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-java"/>
<classpathentry kind="lib" path="/processing-java/mode/antlr.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/processing-core"/>
<classpathentry kind="output" path="core/bin"/>
</classpath>
10 changes: 8 additions & 2 deletions build.xml
Expand Up @@ -80,11 +80,17 @@
description="Create AndroidMode.zip and AndroidMode.txt">
<mkdir dir="release" />

<copy todir="mode">
<fileset dir="core/library">
<include name="*.jar" />
</fileset>
</copy>

<zip destfile="${mode.dist.path}">
<zipfileset dir="." prefix="AndroidMode">
<include name="android-core.zip" />
<include name="mode.properties" />
<include name="mode/**" />
<include name="mode.properties" />
<include name="mode/**" />
<include name="examples/**" />
<include name="icons/**" />
<include name="theme/**" />
Expand Down
1 change: 1 addition & 0 deletions core/.classpath
Expand Up @@ -2,5 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="var" path="ANDROID_LIB"/>
<classpathentry kind="lib" path="library/cardboard.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
3 changes: 2 additions & 1 deletion core/build.xml
Expand Up @@ -33,7 +33,8 @@
target="1.7"
encoding="UTF-8"
includeAntRuntime="false"
bootclasspath="${env.ANDROID_SDK}/platforms/android-15/android.jar"
classpath="library/cardboard.jar"
bootclasspath="${env.ANDROID_SDK}/platforms/android-19/android.jar"
srcdir="src" destdir="bin" />

<!-- Copy the shaders to the bin folder.
Expand Down
Binary file added core/library/cardboard.jar
Binary file not shown.
98 changes: 98 additions & 0 deletions core/src/processing/app/PFragment.java
@@ -0,0 +1,98 @@
package processing.app;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

import android.app.Fragment;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import processing.core.PApplet;
import processing.core.PConstants;

public class PFragment extends Fragment implements PConstants {

private PApplet sketch;

public PFragment() {
}

public PFragment(PApplet sketch) {
System.err.println("-----> PFragment CONSTRUCTOR: " + sketch);
this.sketch = sketch;
}

public void setSketch(PApplet sketch) {
this.sketch = sketch;
}

@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (sketch != null) {
sketch.initSurface(getActivity());
return sketch.surface.getRootView();
} else {
return null;
}
}


@Override
public void onResume() {
super.onResume();
sketch.onResume();
}


@Override
public void onPause() {
super.onPause();
sketch.onPause();
}


@Override
public void onDestroy() {
sketch.onDestroy();
super.onDestroy();
}


@Override
public void onStart() {
super.onStart();
System.err.println("----> ON START: " + sketch);
sketch.onStart();
}


@Override
public void onStop() {
sketch.onStop();
super.onStop();
}


@Override
public void onConfigurationChanged(Configuration newConfig) {
if (PApplet.DEBUG) System.out.println("configuration changed: " + newConfig);
super.onConfigurationChanged(newConfig);
}


public void onBackPressed() {
sketch.onBackPressed();
}


public void setOrientation(int which) {
if (which == PORTRAIT) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (which == LANDSCAPE) {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
}
7 changes: 7 additions & 0 deletions core/src/processing/app/PStereo.java
@@ -0,0 +1,7 @@
package processing.app;

import com.google.vrtoolkit.cardboard.CardboardActivity;

public class PStereo extends CardboardActivity{

}

0 comments on commit 3667f94

Please sign in to comment.