Commit 58d29f99 authored by Sébastien Toque's avatar Sébastien Toque
Browse files
parent 2fd6a4f4
......@@ -47,7 +47,7 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
public class AudioBrowserActivity extends Activity {
public class AudioBrowserActivity extends Activity implements Sortable {
public final static String TAG = "VLC/AudioBrowserActivity";
private FlingViewGroup mFlingViewGroup;
......@@ -74,11 +74,8 @@ public class AudioBrowserActivity extends Activity {
public final static int MENU_PLAY_ALL = Menu.FIRST + 2;
public final static int MENU_APPEND_ALL = Menu.FIRST + 3;
private static AudioBrowserActivity mInstance;
@Override
protected void onCreate(Bundle savedInstanceState) {
mInstance = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.audio_browser);
......@@ -115,10 +112,6 @@ public class AudioBrowserActivity extends Activity {
updateLists();
}
public static AudioBrowserActivity getInstance() {
return mInstance;
}
OnItemClickListener songListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int p, long id) {
......
......@@ -22,6 +22,8 @@ package org.videolan.vlc.android;
import org.videolan.vlc.android.widget.AudioMiniPlayer;
import android.app.Activity;
import android.app.ActivityGroup;
import android.app.Dialog;
import android.app.TabActivity;
import android.content.Intent;
......@@ -57,9 +59,6 @@ public class MainActivity extends TabActivity {
public static final String START_FROM_NOTIFICATION = "from_notification";
private static final String PREF_SHOW_INFO = "show_info";
private VideoListActivity mVideoListActivity = null;
private AudioBrowserActivity mAudioBrowserActivity = null;
private static MainActivity mInstance;
private ProgressBar mProgressBar;
private TabHost mTabHost;
......@@ -99,10 +98,6 @@ public class MainActivity extends TabActivity {
mTabHost.addTab(mTabHost.newTabSpec("AUDIO TAB").setIndicator("AUDIO TAB")
.setContent(new Intent(this, AudioActivityGroup.class)));
// Get video & audio list instances to sort the list.
mVideoListActivity = VideoListActivity.getInstance();
mAudioBrowserActivity = AudioBrowserActivity.getInstance();
// add mini audio player
mAudioPlayer = (AudioMiniPlayer) findViewById(R.id.audio_mini_player);
mAudioController = AudioServiceController.getInstance();
......@@ -186,27 +181,20 @@ public class MainActivity extends TabActivity {
// Intent to start new Activity
Intent intent;
Activity activity;
// Handle item selection
switch (item.getItemId()) {
// Sort by name
case R.id.ml_menu_sortby_name:
if (mCurrentState == VIDEO_TAB) {
mVideoListActivity.sortBy(
VideoListAdapter.SORT_BY_TITLE);
} else if(mCurrentState == AUDIO_TAB) {
mAudioBrowserActivity.sortBy(
AudioBrowserActivity.SORT_BY_TITLE);
}
break;
// Sort by length
case R.id.ml_menu_sortby_length:
if (mCurrentState == VIDEO_TAB) {
mVideoListActivity.sortBy(
VideoListAdapter.SORT_BY_LENGTH);
} else if(mCurrentState == AUDIO_TAB) {
mAudioBrowserActivity.sortBy(
AudioBrowserActivity.SORT_BY_LENGTH);
}
activity = getCurrentActivity();
if (!(activity instanceof ActivityGroup))
break;
activity = ((ActivityGroup) activity).getCurrentActivity();
if (activity instanceof Sortable)
((Sortable) activity).sortBy(item.getItemId() == R.id.ml_menu_sortby_name
? VideoListAdapter.SORT_BY_TITLE
: VideoListAdapter.SORT_BY_LENGTH);
break;
// About
case R.id.ml_menu_about:
......@@ -297,8 +285,6 @@ public class MainActivity extends TabActivity {
mChangeTab.setImageResource(R.drawable.header_icon_video);
mTabHost.setCurrentTab(AUDIO_TAB);
mCurrentState = AUDIO_TAB;
if(mAudioBrowserActivity == null)
mAudioBrowserActivity = AudioBrowserActivity.getInstance();
}
/**
......
package org.videolan.vlc.android;
public interface Sortable {
public void sortBy(int sortby);
}
......@@ -33,7 +33,7 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;
public class VideoListActivity extends ListActivity {
public class VideoListActivity extends ListActivity implements Sortable {
private LinearLayout mNoFileLayout;
private LinearLayout mLoadFileLayout;
......
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