Search in sources :

Example 1 with MessagesDefaultFragment

use of im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment in project actor-platform by actorapp.

the class ChatFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_chat, container, false);
    quoteContainer = res.findViewById(R.id.quoteFragment);
    res.findViewById(R.id.sendContainer).setBackgroundColor(style.getMainBackgroundColor());
    inputContainer = res.findViewById(R.id.sendFragment);
    inputOverlayContainer = res.findViewById(R.id.inputOverlay);
    inputOverlayContainer.setBackgroundColor(style.getMainBackgroundColor());
    inputOverlayText = (TextView) res.findViewById(R.id.overlayText);
    inputOverlayText.setOnClickListener(view -> onOverlayPressed());
    inputOverlayContainer.setVisibility(View.GONE);
    emptyContainer = res.findViewById(R.id.emptyPlaceholder);
    emptyContainer.setVisibility(View.GONE);
    if (savedInstanceState == null) {
        Fragment toolbarFragment = ActorSDK.sharedActor().getDelegate().fragmentForToolbar(peer);
        if (toolbarFragment == null) {
            toolbarFragment = new ChatToolbarFragment(peer);
        }
        InputBarFragment inputBarFragment = ActorSDK.sharedActor().getDelegate().fragmentForChatInput();
        if (inputBarFragment == null) {
            inputBarFragment = new InputBarFragment();
        }
        AutocompleteFragment autocompleteFragment = ActorSDK.sharedActor().getDelegate().fragmentForAutocomplete(peer);
        if (autocompleteFragment == null) {
            autocompleteFragment = AutocompleteFragment.create(peer);
            autocompleteFragment.setUnderlyingView(res.findViewById(R.id.messagesFragment));
        }
        QuoteFragment quoteFragment = ActorSDK.sharedActor().getDelegate().fragmentForQuote();
        if (quoteFragment == null) {
            quoteFragment = new QuoteFragment();
        }
        MessagesDefaultFragment messagesDefaultFragment = MessagesDefaultFragment.create(peer);
        messagesDefaultFragment.setNewMessageListener(inputBarFragment);
        getChildFragmentManager().beginTransaction().add(toolbarFragment, "toolbar").add(R.id.messagesFragment, messagesDefaultFragment).add(R.id.sendFragment, inputBarFragment).add(R.id.quoteFragment, quoteFragment).add(R.id.emptyPlaceholder, new EmptyChatPlaceholder()).add(R.id.autocompleteContainer, autocompleteFragment).commitNow();
        AbsAttachFragment fragment = ActorSDK.sharedActor().getDelegate().fragmentForAttachMenu(peer);
        if (fragment == null) {
            fragment = new AttachFragment(peer);
        }
        getFragmentManager().beginTransaction().add(R.id.overlay, fragment).commit();
    }
    return res;
}
Also used : InputBarFragment(im.actor.sdk.controllers.conversation.inputbar.InputBarFragment) ChatToolbarFragment(im.actor.sdk.controllers.conversation.toolbar.ChatToolbarFragment) AttachFragment(im.actor.sdk.controllers.conversation.attach.AttachFragment) AbsAttachFragment(im.actor.sdk.controllers.conversation.attach.AbsAttachFragment) MessagesDefaultFragment(im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment) AbsAttachFragment(im.actor.sdk.controllers.conversation.attach.AbsAttachFragment) EmptyChatPlaceholder(im.actor.sdk.controllers.conversation.placeholder.EmptyChatPlaceholder) View(android.view.View) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) InputBarFragment(im.actor.sdk.controllers.conversation.inputbar.InputBarFragment) AutocompleteFragment(im.actor.sdk.controllers.conversation.mentions.AutocompleteFragment) AttachFragment(im.actor.sdk.controllers.conversation.attach.AttachFragment) AbsAttachFragment(im.actor.sdk.controllers.conversation.attach.AbsAttachFragment) Fragment(android.support.v4.app.Fragment) MessagesDefaultFragment(im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment) QuoteFragment(im.actor.sdk.controllers.conversation.quote.QuoteFragment) ChatToolbarFragment(im.actor.sdk.controllers.conversation.toolbar.ChatToolbarFragment) AutocompleteFragment(im.actor.sdk.controllers.conversation.mentions.AutocompleteFragment) QuoteFragment(im.actor.sdk.controllers.conversation.quote.QuoteFragment) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 View (android.view.View)1 TextView (android.widget.TextView)1 BaseFragment (im.actor.sdk.controllers.BaseFragment)1 AbsAttachFragment (im.actor.sdk.controllers.conversation.attach.AbsAttachFragment)1 AttachFragment (im.actor.sdk.controllers.conversation.attach.AttachFragment)1 InputBarFragment (im.actor.sdk.controllers.conversation.inputbar.InputBarFragment)1 AutocompleteFragment (im.actor.sdk.controllers.conversation.mentions.AutocompleteFragment)1 MessagesDefaultFragment (im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment)1 EmptyChatPlaceholder (im.actor.sdk.controllers.conversation.placeholder.EmptyChatPlaceholder)1 QuoteFragment (im.actor.sdk.controllers.conversation.quote.QuoteFragment)1 ChatToolbarFragment (im.actor.sdk.controllers.conversation.toolbar.ChatToolbarFragment)1