use of com.waz.zclient.core.stores.IStoreFactory in project wire-android by wireapp.
the class ConversationFragment method onCurrentConversationHasChanged.
@Override
public void onCurrentConversationHasChanged(final IConversation fromConversation, final IConversation toConversation, final ConversationChangeRequester conversationChangeRequester) {
if (toConversation == null) {
return;
}
if (LayoutSpec.isPhone(getContext())) {
conversationModelObserver.setAndUpdate(toConversation);
}
if (isPreviewShown && fromConversation != null && !toConversation.getId().equals(fromConversation.getId())) {
onCancelPreview();
}
extendedCursorContainer.close(true);
getControllerFactory().getConversationScreenController().setSingleConversation(toConversation.getType() == IConversation.Type.ONE_TO_ONE);
if (BuildConfig.SHOW_MENTIONING) {
getControllerFactory().getMentioningController().setCurrentConversation(toConversation);
}
int duration = getResources().getInteger(R.integer.framework_animation_duration_short);
// post to give the RootFragment the chance to drive its animations first
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (cursorLayout == null) {
return;
}
final boolean changeToDifferentConversation = fromConversation == null || !fromConversation.getId().equals(toConversation.getId());
// handle draft
if (fromConversation != null && changeToDifferentConversation && !cursorLayout.isEditingMessage()) {
getStoreFactory().getDraftStore().setDraft(fromConversation, cursorLayout.getText().trim());
}
if (toConversation.getType() == IConversation.Type.WAIT_FOR_CONNECTION) {
return;
}
KeyboardUtils.hideKeyboard(getActivity());
conversationLoadingIndicatorViewView.hide();
cursorLayout.enableMessageWriting();
if (changeToDifferentConversation) {
getControllerFactory().getConversationScreenController().setConversationStreamUiReady(false);
toConversationType = toConversation.getType();
// messagesListModelObserver.setAndUpdate(toConversation.getMessages());
getControllerFactory().getSharingController().maybeResetSharedText(fromConversation);
getControllerFactory().getSharingController().maybeResetSharedUris(fromConversation);
cursorLayout.setVisibility(toConversation.isActive() ? View.VISIBLE : View.GONE);
if (!inSplitPortraitMode()) {
resetCursor();
}
final String draftText = getStoreFactory().getDraftStore().getDraft(toConversation);
if (TextUtils.isEmpty(draftText)) {
resetCursor();
} else {
cursorLayout.setText(draftText);
}
cursorLayout.setConversation(toConversation);
hideAudioMessageRecording();
}
final boolean isSharing = getControllerFactory().getSharingController().isSharedConversation(toConversation);
final boolean isSharingText = !TextUtils.isEmpty(getControllerFactory().getSharingController().getSharedText()) && isSharing;
final List<Uri> sharedFileUris = getControllerFactory().getSharingController().getSharedFileUris();
final boolean isSharingFiles = !(sharedFileUris == null || sharedFileUris.isEmpty()) && isSharing;
if (isSharing) {
if (isSharingText) {
final String draftText = getControllerFactory().getSharingController().getSharedText();
if (TextUtils.isEmpty(draftText)) {
resetCursor();
} else {
cursorLayout.setText(draftText);
}
cursorLayout.enableMessageWriting();
KeyboardUtils.showKeyboard(getActivity());
getControllerFactory().getSharingController().maybeResetSharedText(toConversation);
} else if (isSharingFiles) {
if (PermissionUtils.hasSelfPermissions(getActivity(), FILE_SHARING_PERMISSION)) {
for (Uri uri : sharedFileUris) {
getStoreFactory().getConversationStore().sendMessage(AssetFactory.fromContentUri(uri), assetErrorHandler);
}
} else {
sharingUris.addAll(sharedFileUris);
ActivityCompat.requestPermissions(getActivity(), FILE_SHARING_PERMISSION, FILE_SHARING_PERMISSION_REQUEST_ID);
}
getControllerFactory().getSharingController().maybeResetSharedUris(toConversation);
}
}
if (!getControllerFactory().getStreamMediaPlayerController().isSelectedConversation(toConversation.getId())) {
onHideMediaBar();
}
if (inputStateIndicator != null) {
inputStateIndicator.getTypingUsers().removeUpdateListener(typingListener);
}
inputStateIndicator = toConversation.getInputStateIndicator();
typingIndicatorView.setInputStateIndicator(inputStateIndicator);
if (inputStateIndicator != null) {
inputStateIndicator.getTypingUsers().addUpdateListener(typingListener);
}
}
}, duration);
// Saving factories since this fragment may be re-created before the runnable is done,
// but we still want runnable to work.
final IStoreFactory storeFactory = getStoreFactory();
final IControllerFactory controllerFactory = getControllerFactory();
// TODO: Remove when call issue is resolved with https://wearezeta.atlassian.net/browse/CM-645
// And also why do we use the ConversationFragment to start a call from somewhere else....
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (storeFactory == null || storeFactory.isTornDown() || controllerFactory == null || controllerFactory.isTornDown()) {
return;
}
switch(conversationChangeRequester) {
case START_CONVERSATION_FOR_VIDEO_CALL:
controllerFactory.getCallingController().startCall(true);
break;
case START_CONVERSATION_FOR_CALL:
controllerFactory.getCallingController().startCall(false);
break;
case START_CONVERSATION_FOR_CAMERA:
controllerFactory.getCameraController().openCamera(CameraContext.MESSAGE);
break;
}
}
}, 1000);
}
use of com.waz.zclient.core.stores.IStoreFactory in project wire-android by wireapp.
the class SpotifyController method setActivity.
@Override
public void setActivity(Activity activity) {
final IStoreFactory storeFactory = ZApplication.from(activity).getStoreFactory();
if (storeFactory == null || storeFactory.isTornDown()) {
return;
}
final IZMessagingApiStore zMessagingApiStore = storeFactory.getZMessagingApiStore();
final ZMessagingApi api = zMessagingApiStore.getApi();
this.spotify = api.getSpotify();
}
Aggregations