Commit 27a76b48 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

display a progress bar behind loading info

parent e362f01f
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<gradient
android:angle="270"
android:centerColor="#AADDDDDD"
android:endColor="#AAAAAAAA"
android:startColor="#AAAAAAAA" />
</shape>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<gradient
android:angle="270"
android:endColor="#FFAA4400"
android:startColor="#FFEE8800" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
......@@ -42,11 +42,30 @@
android:padding="10dip"
android:onClick="searchClick" />
</LinearLayout>
<TextView
android:id="@+id/text_info"
android:layout_width="wrap_content"
<RelativeLayout
android:id="@+id/info_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
android:visibility="visible">
<ProgressBar
android:id="@+id/info_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:progressDrawable="@drawable/progress"/>
<TextView
android:id="@+id/info_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:singleLine="true"
android:textColor="#FFFFFFFF"
android:shadowColor="#CC000000"
android:shadowRadius="1.5"
android:shadowDx="1"
android:shadowDy="1"/>
</RelativeLayout>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
......
......@@ -47,7 +47,9 @@ public class MainActivity extends TabActivity {
private ImageButton mChangeTab;
private AudioMiniPlayer mAudioPlayer;
private AudioServiceController mAudioController;
private TextView mTextInfo;
private View mInfoLayout;
private ProgressBar mInfoProgress;
private TextView mInfoText;
private SharedPreferences mSettings;
......@@ -65,7 +67,9 @@ public class MainActivity extends TabActivity {
mInstance = this;
mProgressBar = (ProgressBar) findViewById(R.id.ml_progress_bar);
mChangeTab = (ImageButton) findViewById(R.id.change_tab);
mTextInfo = (TextView) findViewById(R.id.text_info);
mInfoLayout = (View) findViewById(R.id.info_layout);
mInfoProgress = (ProgressBar) findViewById(R.id.info_progress);
mInfoText = (TextView) findViewById(R.id.info_text);
/* Initialize the TabView */
mTabHost = getTabHost();
......@@ -291,17 +295,31 @@ public class MainActivity extends TabActivity {
case SHOW_TEXTINFO:
Bundle b = msg.getData();
String info = b.getString("info");
mTextInfo.setText(info);
mTextInfo.setVisibility(info != null ? View.VISIBLE : View.GONE);
mInfoText.setText(info);
mInfoProgress.setMax(b.getInt("max"));
mInfoProgress.setProgress(b.getInt("progress"));
mInfoLayout.setVisibility(info != null ? View.VISIBLE : View.GONE);
break;
}
};
};
public static void sendTextInfo(Handler handler, String info) {
public static void clearTextInfo(Handler handler)
{
Message m = handler.obtainMessage(MainActivity.SHOW_TEXTINFO);
Bundle b = m.getData();
b.putString("info", null);
b.putInt("progress", 0);
b.putInt("max", 100);
handler.sendMessage(m);
}
public static void sendTextInfo(Handler handler, String info, int progress, int max) {
Message m = handler.obtainMessage(MainActivity.SHOW_TEXTINFO);
Bundle b = m.getData();
b.putString("info", info);
b.putInt("progress", progress);
b.putInt("max", max);
handler.sendMessage(m);
}
}
......@@ -115,7 +115,6 @@ public class MediaLibrary {
int count = 0;
int total = 0;
String prefix = mContext.getResources().getString(R.string.loading);
//first pass : count total files
while (!directorys.isEmpty()) {
......@@ -141,8 +140,7 @@ public class MediaLibrary {
for (int i = 0; i < f.length; i++) {
if (f[i].isFile()) {
MainActivity.sendTextInfo(mainHandler, String.format("%s %d/%d : %s",
prefix, count, total, f[i].getName()));
MainActivity.sendTextInfo(mainHandler, f[i].getName(), count, total);
count++;
if (existingFiles.contains(f[i])) {
......@@ -165,7 +163,7 @@ public class MediaLibrary {
}
}
}
MainActivity.sendTextInfo(mainHandler, null);
MainActivity.clearTextInfo(mainHandler);
// update the video and audio activities
for (int i = 0; i < mUpdateHandler.size(); i++) {
......
......@@ -76,7 +76,7 @@ public class ThumbnailerManager extends Thread {
mMediaLibraryActivity.mHandler.sendEmptyMessage(
MainActivity.HIDE_PROGRESSBAR);
Log.i(TAG, "hide ProgressBar!");
MainActivity.sendTextInfo(mMediaLibraryActivity.mHandler, null);
MainActivity.clearTextInfo(mMediaLibraryActivity.mHandler);
notEmpty.await();
} catch (InterruptedException e) {
killed = true;
......@@ -93,8 +93,7 @@ public class ThumbnailerManager extends Thread {
MainActivity.SHOW_PROGRESSBAR);
Log.i(TAG, "show ProgressBar!");
MainActivity.sendTextInfo(mMediaLibraryActivity.mHandler, String.format("%s %d/%d : %s",
prefix, count, total, item.getFileName()));
MainActivity.sendTextInfo(mMediaLibraryActivity.mHandler, String.format("%s %s", prefix, item.getFileName()), count, total);
count++;
int width = 120;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment