Commit 836d4be2 authored by Sébastien Toque's avatar Sébastien Toque
Browse files

Display filename while parsing & generating thumbnails

parent ff98012f
......@@ -42,6 +42,11 @@
android:padding="10dip"
android:onClick="searchClick"/>
</LinearLayout>
<TextView
android:id="@+id/text_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
......
......@@ -52,4 +52,5 @@
<string name="surface_fit_vertical">Ajuster verticalement</string>
<string name="surface_fill">Etirer</string>
<string name="surface_original">Centrer</string>
<string name="thumbnail">Miniature</string>
</resources>
......@@ -54,4 +54,5 @@
<string name="surface_fill">Fill</string>
<string name="surface_original">Center</string>
<string name="about_text" translatable="false">VLC media player\n\nVLC authors and VideoLAN\n\nLicensed under the GPLv2\n</string>
<string name="thumbnail">Thumbnail</string>
</resources>
......@@ -25,12 +25,14 @@ import android.widget.CheckBox;
import android.widget.ImageButton;
import android.widget.ProgressBar;
import android.widget.TabHost;
import android.widget.TextView;
public class MainActivity extends TabActivity {
public final static String TAG = "VLC/MainActivity";
protected static final int HIDE_PROGRESSBAR = 0;
protected static final int SHOW_PROGRESSBAR = 1;
protected static final int SHOW_TEXTINFO = 2;
private static final int VIDEO_TAB = 0;
private static final int AUDIO_TAB = 1;
public static final String START_FROM_NOTIFICATION = "from_notification";
......@@ -45,6 +47,7 @@ public class MainActivity extends TabActivity {
private ImageButton mChangeTab;
private AudioMiniPlayer mAudioPlayer;
private AudioServiceController mAudioController;
private TextView mTextInfo;
private SharedPreferences mSettings;
......@@ -63,6 +66,7 @@ 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);
/* Initialize the TabView */
mTabHost = getTabHost();
......@@ -267,8 +271,20 @@ public class MainActivity extends TabActivity {
case HIDE_PROGRESSBAR:
mProgressBar.setVisibility(View.INVISIBLE);
break;
case SHOW_TEXTINFO:
Bundle b = msg.getData();
String info = b.getString("info");
mTextInfo.setText(info);
mTextInfo.setVisibility(info != null ? View.VISIBLE : View.GONE);
break;
}
};
};
public static void sendTextInfo(Handler handler, String info) {
Message m = handler.obtainMessage(MainActivity.SHOW_TEXTINFO);
Bundle b = m.getData();
b.putString("info", info);
handler.sendMessage(m);
}
}
......@@ -113,15 +113,23 @@ public class MediaLibrary {
MediaItemFilter mediaFileFilter = new MediaItemFilter();
int count = 0;
int total = 0;
String prefix = mContext.getResources().getString(R.string.loading);
while (!directorys.isEmpty()) {
File dir = directorys.pop();
File[] f = null;
if ((f = dir.listFiles(mediaFileFilter)) != null) {
total += f.length;
for (int i = 0; i < f.length; i++) {
if (f[i].isFile()) {
if (existingFiles.contains(f[i])) {
MainActivity.sendTextInfo(mainHandler, String.format("%s %d/%d : %s",
prefix, count, total, f[i].getName()));
count++;
if (existingFiles.contains(f[i])) {
/** only add file if it is not already in the
* list. eg. if user select an subfolder as well
*/
......@@ -141,6 +149,7 @@ public class MediaLibrary {
}
}
}
MainActivity.sendTextInfo(mainHandler, null);
// update the video and audio activities
for (int i = 0; i < mUpdateHandler.size(); i++) {
......
......@@ -24,7 +24,7 @@ public class ThumbnailerManager extends Thread {
private LibVLC mLibVlc;
private MainActivity mMediaLibraryActivity;
private VideoListActivity mVideoListActivity;
private int totalCount;
public ThumbnailerManager() {
mMediaLibraryActivity = MainActivity.getInstance();
......@@ -45,6 +45,7 @@ public class ThumbnailerManager extends Thread {
{
lock.lock();
mItems.clear();
totalCount = 0;
lock.unlock();
}
......@@ -55,6 +56,7 @@ public class ThumbnailerManager extends Thread {
public void addJob(Media item) {
lock.lock();
mItems.add(item);
totalCount++;
notEmpty.signal();
lock.unlock();
Log.i(TAG, "Job added!");
......@@ -65,6 +67,10 @@ public class ThumbnailerManager extends Thread {
*/
public void run()
{
int count = 0;
int total = 0;
String prefix = mVideoListActivity.getResources().getString(R.string.thumbnail);
while (!isInterrupted()) {
lock.lock();
// Get the id of the file browser item to create its thumbnail.
......@@ -75,6 +81,7 @@ public class ThumbnailerManager extends Thread {
mMediaLibraryActivity.mHandler.sendEmptyMessage(
MainActivity.HIDE_PROGRESSBAR);
Log.i(TAG, "hide ProgressBar!");
MainActivity.sendTextInfo(mMediaLibraryActivity.mHandler, null);
notEmpty.await();
} catch (InterruptedException e) {
killed = true;
......@@ -83,6 +90,7 @@ public class ThumbnailerManager extends Thread {
}
if (killed)
break;
total = totalCount;
lock.unlock();
Media item = mItems.poll();
......@@ -90,6 +98,9 @@ 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()));
count++;
int width = 120;
int height = 120;
......@@ -123,6 +134,4 @@ public class ThumbnailerManager extends Thread {
}
}
}
}
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