Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
Eliminate flash issue
Browse files Browse the repository at this point in the history
Issue #52
  • Loading branch information
Aphid Mobile committed Apr 28, 2013
1 parent 919e7fe commit 2dca94e
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 86 deletions.
Binary file modified FlipView/Demo/APK/Aphid-FlipView-Demo.apk
Binary file not shown.
25 changes: 1 addition & 24 deletions FlipView/Demo/Aphid-FlipView-Demo.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,7 @@
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/libs" />
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="" />
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
<option name="CUSTOM_COMPILER_MANIFEST" value="" />
<option name="APK_PATH" value="" />
<option name="LIBRARY_PROJECT" value="false" />
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="true" />
<option name="GENERATE_UNSIGNED_APK" value="false" />
<option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
<option name="PACK_TEST_CODE" value="false" />
<option name="RUN_PROGUARD" value="false" />
<option name="PROGUARD_CFG_PATH" value="/proguard-project.txt" />
<resOverlayFolders>
<path>/res-overlay</path>
</resOverlayFolders>
<includeSystemProguardFile>true</includeSystemProguardFile>
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
<additionalNativeLibs />
</configuration>
</facet>
</component>
Expand All @@ -56,7 +33,7 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/../../../../../../Develop/android-sdk-mac_86/extras/android/support/v4/src/java" />
<root url="file:///home/Develop/android-sdk-mac_86/extras/android/support/v4/src/java" />
</SOURCES>
<jarDirectory url="file://$MODULE_DIR$/libs" recursive="false" />
</library>
Expand Down
22 changes: 0 additions & 22 deletions FlipView/FlipLibrary/Aphid-FlipView-Library.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,8 @@
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/libs" />
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="" />
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
<option name="CUSTOM_COMPILER_MANIFEST" value="" />
<option name="APK_PATH" value="" />
<option name="LIBRARY_PROJECT" value="true" />
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="true" />
<option name="GENERATE_UNSIGNED_APK" value="false" />
<option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
<option name="PACK_TEST_CODE" value="false" />
<option name="RUN_PROGUARD" value="false" />
<option name="PROGUARD_CFG_PATH" value="/proguard-project.txt" />
<resOverlayFolders>
<path>/res-overlay</path>
</resOverlayFolders>
<includeSystemProguardFile>true</includeSystemProguardFile>
<includeAssetsFromLibraries>true</includeAssetsFromLibraries>
<additionalNativeLibs />
</configuration>
</facet>
</component>
Expand Down
13 changes: 8 additions & 5 deletions FlipView/FlipLibrary/src/com/aphidmobile/flip/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import static javax.microedition.khronos.opengles.GL10.GL_DEPTH_TEST;
import static javax.microedition.khronos.opengles.GL10.GL_FLOAT;
import static javax.microedition.khronos.opengles.GL10.GL_LIGHTING;
import static javax.microedition.khronos.opengles.GL10.GL_ONE;
import static javax.microedition.khronos.opengles.GL10.GL_ONE_MINUS_SRC_ALPHA;
import static javax.microedition.khronos.opengles.GL10.GL_SRC_ALPHA;
import static javax.microedition.khronos.opengles.GL10.GL_TEXTURE_2D;
import static javax.microedition.khronos.opengles.GL10.GL_TEXTURE_COORD_ARRAY;
import static javax.microedition.khronos.opengles.GL10.GL_TEXTURE_WRAP_S;
Expand Down Expand Up @@ -154,7 +154,7 @@ public void draw(GL10 gl) {
gl.glEnableClientState(GL_VERTEX_ARRAY);

gl.glEnable(GL_BLEND);
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

gl.glColor4f(1f, 1.0f, 1f, 1.0f);

Expand Down Expand Up @@ -217,9 +217,6 @@ public void draw(GL10 gl) {
float[] shadowVertices;

if (angle > 0) {
gl.glDisable(GL_LIGHTING);
gl.glDisable(GL_DEPTH_TEST);

float alpha = 1f * (90f - angle) / 90f;

if (axis == AXIS_TOP) {
Expand Down Expand Up @@ -264,10 +261,16 @@ public void draw(GL10 gl) {
}
}

gl.glDisable(GL_LIGHTING);
gl.glDisable(GL_DEPTH_TEST);
gl.glDisable(GL_TEXTURE_2D);
gl.glEnable(GL_BLEND);
gl.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
gl.glColor4f(0f, 0.0f, 0f, alpha);
gl.glVertexPointer(3, GL_FLOAT, 0, toFloatBuffer(shadowVertices));
gl.glDrawElements(GL_TRIANGLES, indices.length, GL_UNSIGNED_SHORT, indexBuffer);

gl.glEnable(GL_TEXTURE_2D);
gl.glEnable(GL_DEPTH_TEST);
gl.glEnable(GL_LIGHTING);
}
Expand Down
12 changes: 1 addition & 11 deletions FlipView/FlipLibrary/src/com/aphidmobile/flip/FlipCards.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class FlipCards {
private FlipViewController controller;

private volatile boolean visible = false;
private volatile boolean waitForFirstDraw = false;

private int maxIndex = 0;

Expand All @@ -76,10 +75,6 @@ public void setVisible(boolean visible) {
this.visible = visible;
}

public void setWaitForFirstDraw(boolean waitForFirstDraw) {
this.waitForFirstDraw = waitForFirstDraw;
}

boolean refreshPageView(View view) {
boolean match = false;
if (frontCards.getView() == view) {
Expand Down Expand Up @@ -223,7 +218,7 @@ public synchronized void draw(FlipRenderer renderer, GL10 gl) {
AphidLog.e("Invalid state: " + state);
break;
}

float angle = getDisplayAngle();
if (angle < 0) {
frontCards.getTopCard().setAxis(Card.AXIS_BOTTOM);
Expand Down Expand Up @@ -257,11 +252,6 @@ public synchronized void draw(FlipRenderer renderer, GL10 gl) {
backCards.getBottomCard().draw(gl);
}
}

if (waitForFirstDraw) {
waitForFirstDraw = false;
controller.sendMessage(FlipViewController.MSG_ANIMATION_READY);
}
}

public void invalidateTexture() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static interface ViewFlipListener {
private static final int MAX_RELEASED_VIEW_SIZE = 1;

static final int MSG_SURFACE_CREATED = 1;
static final int MSG_ANIMATION_READY = 2;

private Handler handler = new Handler(new Handler.Callback() {
@Override
Expand All @@ -66,11 +65,8 @@ public boolean handleMessage(Message msg) {
contentHeight = 0;
requestLayout();
return true;
} else if (msg.what == MSG_ANIMATION_READY) {
if (inFlipAnimation) {
AphidLog.i("First draw is ready, hide real views");
updateVisibleView(-1);
}
} else {
AphidLog.w("Unknown msg.what: " + msg.what);
}
return false;
}
Expand All @@ -96,11 +92,7 @@ public boolean handleMessage(Message msg) {
private DataSetObserver adapterDataObserver;

private final LinkedList<View> bufferedViews = new LinkedList<View>();
private final
LinkedList<View>
releasedViews =
new LinkedList<View>();
//XXX: use a SparseArray to keep the related view indices?
private final LinkedList<View> releasedViews = new LinkedList<View>(); //XXX: use a SparseArray to keep the related view indices?
private int bufferIndex = -1;
private int adapterIndex = -1;
private final int sideBufferSize = 1;
Expand Down Expand Up @@ -490,11 +482,7 @@ private void setupAdapterView(View view, boolean addToTop, boolean isReusedView)
}
}

private void updateVisibleView(int index) { /*
if (AphidLog.ENABLE_DEBUG)
AphidLog.d("Update visible views, index %d, buffered: %d, adapter %d", index, bufferedViews.size(), adapterIndex);
*/

private void updateVisibleView(int index) {
for (int i = 0; i < bufferedViews.size(); i++) {
bufferedViews.get(i).setVisibility(index == i ? VISIBLE : INVISIBLE);
}
Expand Down Expand Up @@ -568,7 +556,6 @@ void showFlipAnimation() {
inFlipAnimation = true;

cards.setVisible(true);
cards.setWaitForFirstDraw(true);
surfaceView.requestRender();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class AphidLog {

public static final boolean ENABLE_DEBUG = true;
public static final boolean ENABLE_DEBUG = false;

private AphidLog() {
}
Expand Down
11 changes: 5 additions & 6 deletions FlipView/FlipView.ipr
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
</component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<excludeFromCompile>
Expand Down Expand Up @@ -483,12 +480,14 @@
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<ADDITIONAL_INDENT_OPTIONS fileType="haml">
<option name="INDENT_SIZE" value="2" />
</ADDITIONAL_INDENT_OPTIONS>
<ADDITIONAL_INDENT_OPTIONS fileType="sass">
<option name="INDENT_SIZE" value="2" />
</ADDITIONAL_INDENT_OPTIONS>
<codeStyleSettings language="CoffeeScript">
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="METHOD_PARAMETERS_WRAP" value="1" />
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
</codeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
Expand Down

0 comments on commit 2dca94e

Please sign in to comment.