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;
|
package org.xbmc.kore.host;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
import org.xbmc.kore.jsonrpc.ApiCallback;
|
import org.xbmc.kore.jsonrpc.ApiCallback;
|
||||||
import org.xbmc.kore.jsonrpc.HostConnection;
|
import org.xbmc.kore.jsonrpc.HostConnection;
|
||||||
|
@ -145,7 +146,8 @@ public class HostConnectionObserver
|
||||||
// */
|
// */
|
||||||
// private Map<PlayerEventsObserver, Handler> observerHandlerMap = new HashMap<PlayerEventsObserver, Handler>();
|
// 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() {
|
private Runnable httpPlayerCheckerRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -124,12 +124,12 @@ public class VolumeControllerDialogFragmentListener extends AppCompatDialogFragm
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
HostConnectionObserver hostConnectionObserver = hostManager.getHostConnectionObserver();
|
HostConnectionObserver hostConnectionObserver = hostManager.getHostConnectionObserver();
|
||||||
if (hostConnectionObserver != null) {
|
if (hostConnectionObserver != null) {
|
||||||
hostConnectionObserver.unregisterApplicationObserver(this);
|
hostConnectionObserver.unregisterApplicationObserver(this);
|
||||||
}
|
}
|
||||||
unbinder.unbind();
|
unbinder.unbind();
|
||||||
super.onDestroyView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerObserver() {
|
private void registerObserver() {
|
||||||
|
|
|
@ -24,18 +24,20 @@ import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.xbmc.kore.R;
|
import org.xbmc.kore.R;
|
||||||
|
import org.xbmc.kore.utils.LogUtils;
|
||||||
|
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
|
|
||||||
public class VolumeLevelIndicator extends LinearLayout {
|
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_seek_bar) SeekBar volumeSeekBar;
|
||||||
@BindView(R.id.vli_volume_text) TextView volumeTextView;
|
@BindView(R.id.vli_volume_text) TextView volumeTextView;
|
||||||
|
|
||||||
private OnVolumeChangeListener onVolumeChangeListener;
|
private OnVolumeChangeListener onVolumeChangeListener;
|
||||||
private VolumeBarTouchTrackerListener volumeBarTouchTrackerListener;
|
private VolumeBarTouchTrackerListener volumeBarTouchTrackerListener;
|
||||||
private Unbinder unbinder;
|
|
||||||
|
|
||||||
public interface OnVolumeChangeListener {
|
public interface OnVolumeChangeListener {
|
||||||
void onVolumeChanged(int volume);
|
void onVolumeChanged(int volume);
|
||||||
|
@ -64,7 +66,6 @@ public class VolumeLevelIndicator extends LinearLayout {
|
||||||
@Override
|
@Override
|
||||||
protected void onDetachedFromWindow() {
|
protected void onDetachedFromWindow() {
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
unbinder.unbind();
|
|
||||||
onVolumeChangeListener = null;
|
onVolumeChangeListener = null;
|
||||||
volumeBarTouchTrackerListener = null;
|
volumeBarTouchTrackerListener = null;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ public class VolumeLevelIndicator extends LinearLayout {
|
||||||
private void initializeView(Context context) {
|
private void initializeView(Context context) {
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View view = inflater.inflate(R.layout.volume_level_indicator, this);
|
View view = inflater.inflate(R.layout.volume_level_indicator, this);
|
||||||
unbinder = ButterKnife.bind(view);
|
ButterKnife.bind(view);
|
||||||
|
|
||||||
volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
volumeSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue