mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 13:05:31 +03:00
check if view is (still) available
...since grid initialization is called in various places throughout the lifecycle Fixes #1233 Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
e9fb3eda84
commit
996770e470
2 changed files with 114 additions and 80 deletions
|
@ -516,58 +516,60 @@ public class CallController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGridAdapter() {
|
private void initGridAdapter() {
|
||||||
GridView gridView = conversationView.findViewById(R.id.gridview);
|
if (conversationView != null) {
|
||||||
|
GridView gridView = conversationView.findViewById(R.id.gridview);
|
||||||
|
|
||||||
int columns;
|
int columns;
|
||||||
int participantsInGrid = participantDisplayItems.size();
|
int participantsInGrid = participantDisplayItems.size();
|
||||||
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
if (participantsInGrid > 8) {
|
if (participantsInGrid > 8) {
|
||||||
columns = 3;
|
columns = 3;
|
||||||
} else if (participantsInGrid > 2) {
|
} else if (participantsInGrid > 2) {
|
||||||
columns = 2;
|
columns = 2;
|
||||||
|
} else {
|
||||||
|
columns = 1;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
columns = 1;
|
if (participantsInGrid > 8) {
|
||||||
}
|
columns = 4;
|
||||||
} else {
|
} else if (participantsInGrid > 2) {
|
||||||
if (participantsInGrid > 8) {
|
columns = 3;
|
||||||
columns = 4;
|
} else if (participantsInGrid > 1) {
|
||||||
} else if (participantsInGrid > 2) {
|
columns = 2;
|
||||||
columns = 3;
|
} else {
|
||||||
} else if (participantsInGrid > 1) {
|
columns = 1;
|
||||||
columns = 2;
|
}
|
||||||
} else {
|
|
||||||
columns = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gridView.setNumColumns(columns);
|
||||||
|
|
||||||
|
RelativeLayout gridViewWrapper = conversationView.findViewById(R.id.conversationRelativeLayoutView);
|
||||||
|
gridViewWrapper.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
gridViewWrapper.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
int height = gridViewWrapper.getMeasuredHeight();
|
||||||
|
gridView.setMinimumHeight(height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
LinearLayout callInfosLinearLayout = conversationView.findViewById(R.id.callInfosLinearLayout);
|
||||||
|
callInfosLinearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
callInfosLinearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
participantsAdapter = new ParticipantsAdapter(
|
||||||
|
this.getActivity(),
|
||||||
|
participantDisplayItems,
|
||||||
|
gridViewWrapper,
|
||||||
|
callInfosLinearLayout,
|
||||||
|
columns,
|
||||||
|
isVoiceOnlyCall);
|
||||||
|
gridView.setAdapter(participantsAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
gridView.setNumColumns(columns);
|
|
||||||
|
|
||||||
RelativeLayout gridViewWrapper = conversationView.findViewById(R.id.conversationRelativeLayoutView);
|
|
||||||
gridViewWrapper.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
gridViewWrapper.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
int height = gridViewWrapper.getMeasuredHeight();
|
|
||||||
gridView.setMinimumHeight(height);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
LinearLayout callInfosLinearLayout = conversationView.findViewById(R.id.callInfosLinearLayout);
|
|
||||||
callInfosLinearLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
|
||||||
@Override
|
|
||||||
public void onGlobalLayout() {
|
|
||||||
callInfosLinearLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
participantsAdapter = new ParticipantsAdapter(
|
|
||||||
this.getActivity(),
|
|
||||||
participantDisplayItems,
|
|
||||||
gridViewWrapper,
|
|
||||||
callInfosLinearLayout,
|
|
||||||
columns,
|
|
||||||
isVoiceOnlyCall);
|
|
||||||
gridView.setAdapter(participantsAdapter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1586,27 +1588,29 @@ public class CallController extends BaseController {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<GenericOverall>() {
|
.subscribe(new Observer<GenericOverall>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(GenericOverall genericOverall) {
|
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
|
||||||
if (shutDownView && getActivity() != null) {
|
if (shutDownView && getActivity() != null) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
} else if (!shutDownView && (currentCallStatus.equals(CallStatus.RECONNECTING) || currentCallStatus.equals(CallStatus.PUBLISHER_FAILED))) {
|
} else if (!shutDownView &&
|
||||||
|
(currentCallStatus == CallStatus.RECONNECTING ||
|
||||||
|
currentCallStatus == CallStatus.PUBLISHER_FAILED)) {
|
||||||
initiateCall();
|
initiateCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1619,25 +1623,25 @@ public class CallController extends BaseController {
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<GenericOverall>() {
|
.subscribe(new Observer<GenericOverall>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(GenericOverall genericOverall) {
|
public void onNext(@io.reactivex.annotations.NonNull GenericOverall genericOverall) {
|
||||||
if (shutDownView && getActivity() != null) {
|
if (shutDownView && getActivity() != null) {
|
||||||
getActivity().finish();
|
getActivity().finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1713,12 +1717,12 @@ public class CallController extends BaseController {
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.subscribe(new Observer<ParticipantsOverall>() {
|
.subscribe(new Observer<ParticipantsOverall>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(ParticipantsOverall participantsOverall) {
|
public void onNext(@io.reactivex.annotations.NonNull ParticipantsOverall participantsOverall) {
|
||||||
participantMap = new HashMap<>();
|
participantMap = new HashMap<>();
|
||||||
for (Participant participant : participantsOverall.getOcs().getData()) {
|
for (Participant participant : participantsOverall.getOcs().getData()) {
|
||||||
participantMap.put(participant.getSessionId(), participant);
|
participantMap.put(participant.getSessionId(), participant);
|
||||||
|
@ -1726,13 +1730,13 @@ public class CallController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||||
Log.e(TAG, "error while executing getPeersForCall", e);
|
Log.e(TAG, "error while executing getPeersForCall", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1759,18 +1763,45 @@ public class CallController extends BaseController {
|
||||||
} else {
|
} else {
|
||||||
if (hasMCU && publisher) {
|
if (hasMCU && publisher) {
|
||||||
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
||||||
iceServers, sdpConstraintsForMCU, sessionId, callSession, localMediaStream, true, true, type);
|
iceServers,
|
||||||
|
sdpConstraintsForMCU,
|
||||||
|
sessionId, callSession,
|
||||||
|
localMediaStream,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
type);
|
||||||
|
|
||||||
} else if (hasMCU) {
|
} else if (hasMCU) {
|
||||||
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
||||||
iceServers, sdpConstraints, sessionId, callSession, null, false, true, type);
|
iceServers,
|
||||||
|
sdpConstraints,
|
||||||
|
sessionId,
|
||||||
|
callSession,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
type);
|
||||||
} else {
|
} else {
|
||||||
if (!"screen".equals(type)) {
|
if (!"screen".equals(type)) {
|
||||||
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
||||||
iceServers, sdpConstraints, sessionId, callSession, localMediaStream, false, false, type);
|
iceServers,
|
||||||
|
sdpConstraints,
|
||||||
|
sessionId,
|
||||||
|
callSession,
|
||||||
|
localMediaStream,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
type);
|
||||||
} else {
|
} else {
|
||||||
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
magicPeerConnectionWrapper = new MagicPeerConnectionWrapper(peerConnectionFactory,
|
||||||
iceServers, sdpConstraints, sessionId, callSession, null, false, false, type);
|
iceServers,
|
||||||
|
sdpConstraints,
|
||||||
|
sessionId,
|
||||||
|
callSession,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1818,10 +1849,13 @@ public class CallController extends BaseController {
|
||||||
private void removeMediaStream(String sessionId) {
|
private void removeMediaStream(String sessionId) {
|
||||||
Log.d(TAG, "removeMediaStream");
|
Log.d(TAG, "removeMediaStream");
|
||||||
participantDisplayItems.remove(sessionId);
|
participantDisplayItems.remove(sessionId);
|
||||||
initGridAdapter();
|
|
||||||
|
|
||||||
if (callControls != null) {
|
if (!isBeingDestroyed() && !isDestroyed()) {
|
||||||
callControls.setZ(100.0f);
|
initGridAdapter();
|
||||||
|
|
||||||
|
if (callControls != null) {
|
||||||
|
callControls.setZ(100.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1928,23 +1962,23 @@ public class CallController extends BaseController {
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(new Observer<Long>() {
|
.subscribe(new Observer<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Disposable d) {
|
public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(Long aLong) {
|
public void onNext(@io.reactivex.annotations.NonNull Long aLong) {
|
||||||
magicPeerConnectionWrapper.sendNickChannelData(dataChannelMessage);
|
magicPeerConnectionWrapper.sendNickChannelData(dataChannelMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
|
// unused atm
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
438
|
437
|
Loading…
Reference in a new issue