Fix NPE on volume change by not unbinding the controls in the Volume Level Indicator too soon
This commit is contained in:
parent
36675bba47
commit
94693cb5a5
|
@ -16,6 +16,7 @@
|
|||
package org.xbmc.kore.host;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import org.xbmc.kore.jsonrpc.ApiCallback;
|
||||
import org.xbmc.kore.jsonrpc.HostConnection;
|
||||
|
@ -145,7 +146,8 @@ public class HostConnectionObserver
|
|||
// */
|
||||
// private Map<PlayerEventsObserver, Handler> observerHandlerMap = new HashMap<PlayerEventsObserver, Handler>();
|
||||
|
||||
private Handler checkerHandler = new Handler();
|
||||
// Associate the Handler with the UI thread
|
||||
private Handler checkerHandler = new Handler(Looper.getMainLooper());
|
||||
private Runnable httpPlayerCheckerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
|
|
@ -124,12 +124,12 @@ public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragm
|
|||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
HostConnectionObserver hostConnectionObserver = hostManager.getHostConnectionObserver();
|
||||
if (hostConnectionObserver != null) {
|
||||
hostConnectionObserver.unregisterApplicationObserver(this);
|
||||
}
|
||||
unbinder.unbind();
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
private void registerObserver() {
|
||||
|
|
|
@ -24,18 +24,20 @@ import android.widget.SeekBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.utils.LogUtils;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.BindView;
|
||||
import butterknife.Unbinder;
|
||||
|
||||
public class VolumeLevelIndicator extends LinearLayout {
|
||||
public static final String TAG = LogUtils.makeLogTag(VolumeLevelIndicator.class);
|
||||
|
||||
@BindView(R.id.vli_seek_bar) SeekBar volumeSeekBar;
|
||||
@BindView(R.id.vli_volume_text) TextView volumeTextView;
|
||||
|
||||
private OnVolumeChangeListener onVolumeChangeListener;
|
||||
private VolumeBarTouchTrackerListener volumeBarTouchTrackerListener;
|
||||
private Unbinder unbinder;
|
||||
|
||||
public interface OnVolumeChangeListener {
|
||||
void onVolumeChanged(int volume);
|
||||
|
@ -64,7 +66,6 @@ public class VolumeLevelIndicator extends LinearLayout {
|
|||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
unbinder.unbind();
|
||||
onVolumeChangeListener = null;
|
||||
volumeBarTouchTrackerListener = null;
|
||||
}
|
||||
|
@ -72,7 +73,7 @@ public class VolumeLevelIndicator extends LinearLayout {
|
|||
private void initializeView(Context context) {
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.volume_level_indicator, this);
|
||||
unbinder = ButterKnife.bind(view);
|
||||
ButterKnife.bind(view);
|
||||
|
||||
volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue