Always call requestRequery on UI thead
This commit is contained in:
parent
48588fa8ac
commit
9a4fe3dc76
@ -26,7 +26,6 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Log;
|
||||
@ -53,12 +52,6 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
public static final int DISPLAY_INFO_WIDGETS = 2;
|
||||
public static final int DISPLAY_INFO_WIDGETS_ZOOMED = 3;
|
||||
|
||||
/**
|
||||
* A Handler running on the UI thread, in contrast with mHandler which runs
|
||||
* on a worker thread.
|
||||
*/
|
||||
private final Handler mUiHandler = new Handler(this);
|
||||
|
||||
private TextView mOverlayText;
|
||||
private View mControlsBottom;
|
||||
|
||||
@ -410,17 +403,20 @@ public class FullPlaybackActivity extends PlaybackActivity
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||
{
|
||||
if (fromUser)
|
||||
PlaybackService.get(this).seekToProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar)
|
||||
{
|
||||
mSeekBarTracking = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar)
|
||||
{
|
||||
mSeekBarTracking = false;
|
||||
|
@ -36,6 +36,7 @@ import android.graphics.drawable.PaintDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.provider.MediaStore;
|
||||
import android.text.Editable;
|
||||
@ -112,7 +113,7 @@ public class LibraryActivity
|
||||
@Override
|
||||
public void onChange(boolean selfChange)
|
||||
{
|
||||
requestRequery(mPlaylistAdapter);
|
||||
mUiHandler.sendMessage(mUiHandler.obtainMessage(MSG_REQUEST_REQUERY, mPlaylistAdapter));
|
||||
}
|
||||
};
|
||||
|
||||
@ -837,6 +838,11 @@ public class LibraryActivity
|
||||
* Save the sort mode for the adapter passed in obj.
|
||||
*/
|
||||
private static final int MSG_SAVE_SORT = 16;
|
||||
/**
|
||||
* Call {@link LibraryActivity#requestRequery(MediaAdapter)} on the adapter
|
||||
* passed in obj.
|
||||
*/
|
||||
private static final int MSG_REQUEST_REQUERY = 17;
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message message)
|
||||
@ -889,6 +895,9 @@ public class LibraryActivity
|
||||
editor.commit();
|
||||
break;
|
||||
}
|
||||
case MSG_REQUEST_REQUERY:
|
||||
requestRequery((MediaAdapter)message.obj);
|
||||
break;
|
||||
default:
|
||||
return super.handleMessage(message);
|
||||
}
|
||||
@ -900,6 +909,8 @@ public class LibraryActivity
|
||||
* Requery the given adapter. If it is the current adapter, requery
|
||||
* immediately. Otherwise, mark the adapter as needing a requery and requery
|
||||
* when its tab is selected.
|
||||
*
|
||||
* Must be called on the UI thread.
|
||||
*/
|
||||
public void requestRequery(MediaAdapter adapter)
|
||||
{
|
||||
@ -927,8 +938,10 @@ public class LibraryActivity
|
||||
@Override
|
||||
public void onMediaChange()
|
||||
{
|
||||
for (MediaAdapter adapter : mAdapters)
|
||||
requestRequery(adapter);
|
||||
Handler handler = mUiHandler;
|
||||
for (MediaAdapter adapter : mAdapters) {
|
||||
handler.sendMessage(handler.obtainMessage(MSG_REQUEST_REQUERY, adapter));
|
||||
}
|
||||
}
|
||||
|
||||
private void setSearchBoxVisible(boolean visible)
|
||||
|
@ -70,7 +70,18 @@ public class PlaybackActivity extends Activity
|
||||
private Action mUpAction;
|
||||
private Action mDownAction;
|
||||
|
||||
/**
|
||||
* A Handler running on the UI thread, in contrast with mHandler which runs
|
||||
* on a worker thread.
|
||||
*/
|
||||
protected final Handler mUiHandler = new Handler(this);
|
||||
/**
|
||||
* A Handler running on a worker thread.
|
||||
*/
|
||||
protected Handler mHandler;
|
||||
/**
|
||||
* The looper for the worker thread.
|
||||
*/
|
||||
protected Looper mLooper;
|
||||
|
||||
protected CoverView mCoverView;
|
||||
|
Loading…
x
Reference in New Issue
Block a user