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