Search in sources :

Example 96 with Fragment

use of android.support.v4.app.Fragment in project actor-platform by actorapp.

the class InputBarFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_inputbar, container, false);
    res.setBackgroundColor(style.getMainBackgroundColor());
    //
    // Message Body
    //
    messageEditText = (BarEditText) res.findViewById(R.id.et_message);
    messageEditText.setTextColor(style.getTextPrimaryColor());
    messageEditText.setHintTextColor(style.getTextHintColor());
    // Hardware keyboard events
    messageEditText.setOnKeyListener((view, keycode, keyEvent) -> {
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent.getAction() == KeyEvent.ACTION_DOWN && keycode == KeyEvent.KEYCODE_ENTER) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    // Software keyboard events
    messageEditText.setOnEditorActionListener((textView, i, keyEvent) -> {
        if (i == EditorInfo.IME_ACTION_SEND) {
            onSendButtonPressed();
            return true;
        }
        if (i == EditorInfo.IME_ACTION_DONE) {
            onSendButtonPressed();
            return true;
        }
        if (messenger().isSendByEnterEnabled()) {
            if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                onSendButtonPressed();
                return true;
            }
        }
        return false;
    });
    messageEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            onBeforeTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            InputBarFragment.this.onTextChanged(charSequence, i, i1, i2);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            onAfterTextChanged(editable);
        }
    });
    messageEditText.addSelectionListener((start, length) -> {
        InputBarFragment.this.onSelectionChanged(start, length);
    });
    messageEditText.setOnFocusChangeListener((v, hasFocus) -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onTextFocusChanged(hasFocus);
        }
    });
    //
    // Send Button
    //
    sendButton = (TintImageView) res.findViewById(R.id.ib_send);
    sendButton.setResource(R.drawable.conv_send);
    sendButton.setOnClickListener(v -> {
        onSendButtonPressed();
    });
    //
    // Attach Button
    //
    attachButton = (ImageButton) res.findViewById(R.id.ib_attach);
    attachButton.setOnClickListener(v -> {
        onAttachButtonClicked();
    });
    //
    // Emoji keyboard
    //
    emojiButton = (ImageView) res.findViewById(R.id.ib_emoji);
    emojiButton.setOnClickListener(v -> emojiKeyboard.toggle());
    emojiKeyboard = getEmojiKeyboard();
    emojiKeyboard.setOnStickerClickListener(sticker -> {
        Fragment parent = getParentFragment();
        if (parent instanceof InputBarCallback) {
            ((InputBarCallback) parent).onStickerSent(sticker);
        }
    });
    emojiKeyboard.setKeyboardStatusListener(new KeyboardStatusListener() {

        @Override
        public void onDismiss() {
            emojiButton.setImageResource(R.drawable.ic_emoji);
        }

        @Override
        public void onShow() {
            emojiButton.setImageResource(R.drawable.ic_keyboard);
        }
    });
    //
    // Audio
    //
    audioContainer = res.findViewById(R.id.audioContainer);
    audioTimer = (TextView) res.findViewById(R.id.audioTimer);
    audioSlide = res.findViewById(R.id.audioSlide);
    recordPoint = res.findViewById(R.id.record_point);
    audioButton = (ImageView) res.findViewById(R.id.record_btn);
    audioButton.setVisibility(View.VISIBLE);
    audioButton.setOnTouchListener((v, event) -> {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (!isAudioVisible) {
                showAudio();
                slideStart = (int) event.getX();
            }
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            if (isAudioVisible) {
                hideAudio(false);
            }
        } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
            if (isAudioVisible) {
                int slide = slideStart - (int) event.getX();
                if (slide < 0) {
                    slide = 0;
                }
                if (slide > SLIDE_LIMIT) {
                    hideAudio(true);
                } else {
                    slideAudio(slide);
                }
            }
        }
        return true;
    });
    return res;
}
Also used : TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) KeyboardStatusListener(im.actor.sdk.view.emoji.keyboard.KeyboardStatusListener) TintImageView(im.actor.sdk.view.TintImageView) ImageView(android.widget.ImageView) ViewUtils.zoomInView(im.actor.sdk.util.ViewUtils.zoomInView) View(android.view.View) ViewUtils.zoomOutView(im.actor.sdk.util.ViewUtils.zoomOutView) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) MessagesDefaultFragment(im.actor.sdk.controllers.conversation.messages.MessagesDefaultFragment) MessagesFragment(im.actor.sdk.controllers.conversation.messages.MessagesFragment) Nullable(android.support.annotation.Nullable)

Example 97 with Fragment

use of android.support.v4.app.Fragment in project actor-platform by actorapp.

the class GroupInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState == null) {
        int groupId = getIntent().getIntExtra(Intents.EXTRA_GROUP_ID, 0);
        Fragment profileIntent = ActorSDK.sharedActor().getDelegate().fragmentForGroupInfo(groupId);
        if (profileIntent == null) {
            profileIntent = GroupInfoFragment.create(groupId);
        }
        showFragment(profileIntent, false);
    }
}
Also used : Fragment(android.support.v4.app.Fragment)

Example 98 with Fragment

use of android.support.v4.app.Fragment in project actor-platform by actorapp.

the class GlobalSearchBaseFragment method showSearch.

private void showSearch() {
    if (isSearchVisible) {
        return;
    }
    isSearchVisible = true;
    searchDisplay = messenger().buildSearchDisplayList();
    searchDisplay.setBindHook(new BindedDisplayList.BindHook<SearchEntity>() {

        @Override
        public void onScrolledToEnd() {
            scrolledToEnd = true;
            checkGlobalSearch();
        }

        @Override
        public void onItemTouched(SearchEntity item) {
        }
    });
    searchAdapter = new SearchAdapter(getActivity(), searchDisplay, new OnItemClickedListener<SearchEntity>() {

        @Override
        public void onClicked(SearchEntity item) {
            onPeerPicked(item.getPeer());
            searchMenu.collapseActionView();
        }

        @Override
        public boolean onLongClicked(SearchEntity item) {
            return false;
        }
    });
    HeaderViewRecyclerAdapter recyclerAdapter = new HeaderViewRecyclerAdapter(searchAdapter);
    View header = new View(getActivity());
    header.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(0)));
    header.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    recyclerAdapter.addHeaderView(header);
    searchList.setAdapter(recyclerAdapter);
    RecyclerView.ItemAnimator animator = searchList.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
    searchDisplay.addListener(searchListener);
    showView(searchHintView, false);
    goneView(searchEmptyView, false);
    showView(searchContainer, false);
    Fragment parent = getParentFragment();
    if (parent != null && parent instanceof GlobalSearchStateDelegate) {
        ((GlobalSearchStateDelegate) parent).onGlobalSearchStarted();
    }
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) SearchView(android.support.v7.widget.SearchView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) BindedDisplayList(im.actor.runtime.generic.mvvm.BindedDisplayList) HeaderViewRecyclerAdapter(im.actor.sdk.view.adapters.HeaderViewRecyclerAdapter) SearchEntity(im.actor.core.entity.SearchEntity) PeerSearchEntity(im.actor.core.entity.PeerSearchEntity) OnItemClickedListener(im.actor.sdk.view.adapters.OnItemClickedListener) FrameLayout(android.widget.FrameLayout) RecyclerView(android.support.v7.widget.RecyclerView)

Example 99 with Fragment

use of android.support.v4.app.Fragment in project actor-platform by actorapp.

the class GlobalSearchBaseFragment method hideSearch.

private void hideSearch() {
    if (!isSearchVisible) {
        return;
    }
    isSearchVisible = false;
    if (searchDisplay != null) {
        searchDisplay.dispose();
        searchDisplay = null;
    }
    searchAdapter = null;
    searchList.setAdapter(null);
    searchQuery = null;
    goneView(searchContainer, false);
    if (searchMenu != null) {
        if (searchMenu.isActionViewExpanded()) {
            searchMenu.collapseActionView();
        }
    }
    Fragment parent = getParentFragment();
    if (parent != null && parent instanceof GlobalSearchStateDelegate) {
        ((GlobalSearchStateDelegate) parent).onGlobalSearchEnded();
    }
}
Also used : BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment)

Example 100 with Fragment

use of android.support.v4.app.Fragment in project actor-platform by actorapp.

the class FragmentNoMenuStatePagerAdapter method destroyItem.

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment) object;
    if (mCurTransaction == null) {
        mCurTransaction = mFragmentManager.beginTransaction();
    }
    if (DEBUG)
        Log.v(TAG, "Removing item #" + position + ": f=" + object + " v=" + ((Fragment) object).getView());
    while (mSavedState.size() <= position) {
        mSavedState.add(null);
    }
    mSavedState.set(position, mFragmentManager.saveFragmentInstanceState(fragment));
    mFragments.set(position, null);
    mCurTransaction.remove(fragment);
}
Also used : Fragment(android.support.v4.app.Fragment)

Aggregations

Fragment (android.support.v4.app.Fragment)617 FragmentTransaction (android.support.v4.app.FragmentTransaction)220 Bundle (android.os.Bundle)140 View (android.view.View)129 FragmentManager (android.support.v4.app.FragmentManager)115 DialogFragment (android.support.v4.app.DialogFragment)77 TextView (android.widget.TextView)55 FragmentInstruction (de.madcyph3r.example.example.FragmentInstruction)48 MaterialMenu (de.madcyph3r.materialnavigationdrawer.menu.MaterialMenu)48 MaterialItemSectionFragment (de.madcyph3r.materialnavigationdrawer.menu.item.section.MaterialItemSectionFragment)48 FragmentDummy (de.madcyph3r.example.example.FragmentDummy)43 Intent (android.content.Intent)39 ViewPager (android.support.v4.view.ViewPager)35 FragmentActivity (android.support.v4.app.FragmentActivity)34 BaseFragment (com.waz.zclient.pages.BaseFragment)29 ImageView (android.widget.ImageView)27 FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)25 Button (android.widget.Button)24 ArrayList (java.util.ArrayList)24 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)21