Skip to content

Commit

Permalink
fixed flickering bug on list view, and fixed splash screen issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedre committed Aug 7, 2010
1 parent 0d0caf8 commit 180946c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
1 change: 1 addition & 0 deletions res/layout/quran_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:background="@drawable/list"
android:cacheColorHint="#00000000"
android:layout_height="wrap_content"/>
38 changes: 13 additions & 25 deletions src/com/quran/labs/androidquran/QuranDataActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.os.AsyncTask;
import android.os.AsyncTask.Status;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.view.Display;
Expand All @@ -29,8 +30,8 @@ public class QuranDataActivity extends Activity {
private AsyncTask<?, ?, ?> currentTask = null;
private boolean starting = true;

protected static Thread splashThread = null;
protected boolean _active = true;
protected Handler splashHandler = null;
protected Runnable splashRunner = null;
protected int _splashTime = 3000; // time to display the splash screen in ms

/** Called when the activity is first created. */
Expand All @@ -51,28 +52,14 @@ public void onCreate(Bundle savedInstanceState) {
}

private void showSplashScreen() {
if (splashThread == null) {
// http://www.droidnova.com/how-to-create-a-splash-screen,561.html
splashThread = new Thread() {
@Override
public void run() {
try {
int waited = 0;
while (_active && (waited < _splashTime)) {
sleep(100);
if (_active) {
waited += 100;
}
}
} catch (InterruptedException e) {
} finally {
checkDataStatus();
}
}
};

splashThread.start();
}
splashHandler = new Handler();
splashRunner = new Runnable(){
@Override
public void run(){
checkDataStatus();
}
};
splashHandler.postDelayed(splashRunner, _splashTime);
}

private void initializeQuranScreen() {
Expand Down Expand Up @@ -101,7 +88,8 @@ public void checkDataStatus(){
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
_active = false;
splashHandler.removeCallbacks(splashRunner);
checkDataStatus();
}
return true;
}
Expand Down

0 comments on commit 180946c

Please sign in to comment.