aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java69
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java19
2 files changed, 77 insertions, 11 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
index 57423fb3..0240d5a3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java
@@ -4,26 +4,50 @@ import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Handler;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import android.support.v4.view.ViewPager;
import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.fragments.MainFragment;
import github.daneren2005.dsub.fragments.SelectArtistFragment;
import github.daneren2005.dsub.fragments.SelectPlaylistFragment;
+import github.daneren2005.dsub.service.DownloadFile;
import github.daneren2005.dsub.service.DownloadServiceImpl;
import github.daneren2005.dsub.util.Util;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
public class MainActivity extends SubsonicActivity {
private static final String TAG = MainActivity.class.getSimpleName();
private static boolean infoDialogDisplayed;
+ private ScheduledExecutorService executorService;
+ private View coverArtView;
+ private TextView trackView;
+ private TextView artistView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
+ View bottomBar = findViewById(R.id.bottom_bar);
+ bottomBar.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent();
+ intent.setClass(v.getContext(), DownloadActivity.class);
+ startActivity(intent);
+ }
+ });
+ coverArtView = bottomBar.findViewById(R.id.album_art);
+ trackView = (TextView) bottomBar.findViewById(R.id.track_name);
+ artistView = (TextView) bottomBar.findViewById(R.id.artist_name);
+
viewPager = (ViewPager) findViewById(R.id.pager);
pagerAdapter = new TabPagerAdapter(this, viewPager);
viewPager.setAdapter(pagerAdapter);
@@ -48,9 +72,31 @@ public class MainActivity extends SubsonicActivity {
@Override
public void onResume() {
super.onResume();
+
+ final Handler handler = new Handler();
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ handler.post(new Runnable() {
+ @Override
+ public void run() {
+ update();
+ }
+ });
+ }
+ };
+
+ executorService = Executors.newSingleThreadScheduledExecutor();
+ executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS);
}
@Override
+ public void onPause() {
+ super.onPause();
+ executorService.shutdown();
+ }
+
+ @Override
public void onBackPressed() {
if(pagerAdapter.onBackPressed()) {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
@@ -66,7 +112,7 @@ public class MainActivity extends SubsonicActivity {
dialog.show();
}
}
-
+
@Override
public boolean onCreateOptionsMenu(Menu menu) {
com.actionbarsherlock.view.MenuInflater menuInflater = getSupportMenuInflater();
@@ -74,9 +120,28 @@ public class MainActivity extends SubsonicActivity {
return true;
}
@Override
- public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
return pagerAdapter.onOptionsItemSelected(item);
}
+
+ private void update() {
+ if (getDownloadService() == null) {
+ return;
+ }
+
+ DownloadFile current = getDownloadService().getCurrentPlaying();
+ if(current == null) {
+ trackView.setText("Title");
+ artistView.setText("Artist");
+ getImageLoader().loadImage(coverArtView, null, false, false);
+ return;
+ }
+
+ MusicDirectory.Entry song = current.getSong();
+ trackView.setText(song.getTitle());
+ artistView.setText(song.getArtist());
+ getImageLoader().loadImage(coverArtView, song, false, false);
+ }
private void showInfoDialog() {
if (!infoDialogDisplayed) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java
index a6161790..3a05b059 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -120,6 +120,7 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
rootView = inflater.inflate(R.layout.download, container, false);
+ setHasOptionsMenu(true);
setTitle(nowPlaying ? "Now Playing" : "Downloading");
WindowManager w = context.getWindowManager();
@@ -671,6 +672,15 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
updateButtons();
}
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ executorService.shutdown();
+ if (visualizerView != null && visualizerView.isActive()) {
+ visualizerView.setActive(false);
+ }
+ }
private void scheduleHideControls() {
if (hideControlsFuture != null) {
@@ -744,15 +754,6 @@ public class DownloadFragment extends SubsonicFragment implements OnGestureListe
}
}
- @Override
- public void onPause() {
- super.onPause();
- executorService.shutdown();
- if (visualizerView != null && visualizerView.isActive()) {
- visualizerView.setActive(false);
- }
- }
-
/*@Override
protected Dialog onCreateDialog(int id) {
if (id == DIALOG_SAVE_PLAYLIST) {