Skip to content

Commit

Permalink
Fixed Issue #20 now hiding asset image while volume is zero or 'pause…
Browse files Browse the repository at this point in the history
…d' adjusted the current asset to allow the resume funcationality to show an image if relevant
  • Loading branch information
multidynamic authored and 13rac1 committed Jan 23, 2015
1 parent 1b56709 commit 0e72aa3
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions app/src/main/java/org/famsf/roundware/activity/ListenActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class ListenActivity extends Activity {
private final static String AS_VOTE_TYPE_FLAG = "flag";
private final static String AS_VOTE_TYPE_LIKE = "like";

private final static int ASSET_IMAGE_LINGER_MS = 5200;
private final static int ASSET_IMAGE_LINGER_MS = 2500;

// fields
private ProgressDialog mProgressDialog;
Expand Down Expand Up @@ -489,9 +489,11 @@ private void startPlayback() {
showProgress(getString(R.string.starting_playback_title), getString(R.string.starting_playback_message), true, true);
mCurrentAssetId = -1;
mPreviousAssetId = -1;
AssetData assetData = new AssetData(null, null);
setPendingAsset(assetData);
setCurrentAsset(assetData);
if(mCurrentAsset == null) {
AssetData assetData = new AssetData(null, null);
setPendingAsset(assetData);
setCurrentAsset(assetData);
}
mRwBinder.playbackStart(mTagsList);
}
mRwBinder.playbackFadeIn(mVolumeLevel);
Expand All @@ -507,9 +509,6 @@ private void stopPlayback() {
mRwBinder.playbackFadeOut();
mCurrentAssetId = -1;
mPreviousAssetId = -1;
AssetData assetData = new AssetData(null, null);
setPendingAsset(assetData);
setCurrentAsset(assetData);
updateUIState();
}

Expand Down Expand Up @@ -542,11 +541,12 @@ private void handleAssetChange(Uri uri) {
if(tags.isEmpty()){
String remaining = RWUriHelper.getQueryParameter(uri, RW.METADATA_URI_NAME_REMAINING);
if(remaining != null && !remaining.equals("0") ){
// this metadata message is verbose, remaining asset probably still has same image
// this metadata message is verbose, remaining assets probably still use same image
return;
}
}


// update display
String url = null;
String description = null;
Expand All @@ -572,7 +572,13 @@ private void handleAssetChange(Uri uri) {

AssetData assetData = new AssetData(url, description);
setPendingAsset(assetData);
Log.v(LOGTAG, "Scheduling " + url + " in " + mMetaPlayLatency);
mEventPool.schedule(new AssetEvent(assetData), mMetaPlayLatency, TimeUnit.MILLISECONDS);

if (!TextUtils.isEmpty(url)) {
//pre-load into cache
Picasso.with(this).load(url);
}
}


Expand Down Expand Up @@ -613,16 +619,22 @@ private void updateAssetImageUi(){
}
synchronized (mAssetImageLock) {
boolean hasUrl = !TextUtils.isEmpty(mCurrentAsset.url);
if(hasUrl){
// Only show images if volume level is audible
boolean showUrl = hasUrl && (mRwBinder.getVolumeLevel() > 0);
if(showUrl){
//load
Picasso picasso = Picasso.with(this);
// set below true, to view image source debugging
picasso.setIndicatorsEnabled(false);

final String description = mCurrentAsset.description;
picasso.load(mCurrentAsset.url)
.noFade()
.into(mAssetImageView, new Callback() {
@Override
public void onSuccess() { }
public void onSuccess() {
mAssetTextView.setText(description);
mAssetImageLayout.setVisibility(View.VISIBLE);
}

@Override
public void onError() {
Expand All @@ -631,9 +643,9 @@ public void onError() {
}
});
}
//TODO fade?
mAssetTextView.setText(mCurrentAsset.description);
mAssetImageLayout.setVisibility(hasUrl ? View.VISIBLE : View.INVISIBLE);
else {
mAssetImageLayout.setVisibility(View.INVISIBLE);
}
}
}

Expand Down Expand Up @@ -814,7 +826,7 @@ public void run() {
mEventPool.schedule(new AssetEvent(assetData), ASSET_IMAGE_LINGER_MS,
TimeUnit.MILLISECONDS);
}else{
Log.v(LOGTAG, "AssetEvent now, now drawing");
Log.v(LOGTAG, "Delayed AssetEvent ("+this.assetData.url+") starting now");
runOnUiThread(new Runnable() {
@Override
public void run() {
Expand Down

0 comments on commit 0e72aa3

Please sign in to comment.