Search in sources :

Example 1 with BottomSheetListView

use of im.actor.sdk.view.adapters.BottomSheetListView in project actor-platform by actorapp.

the class AutocompleteFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    autocompleteList = new BottomSheetListView(getContext());
    autocompleteList.setVisibility(View.INVISIBLE);
    autocompleteList.setUnderlyingView(underlyingView);
    autocompleteList.setDivider(null);
    autocompleteList.setDividerHeight(0);
    autocompleteList.setBackgroundColor(Color.TRANSPARENT);
    if (autocompleteAdapter != null) {
        autocompleteList.setAdapter(autocompleteAdapter);
    }
    autocompleteList.setOnItemClickListener((adapterView, view, i, l) -> {
        Object item = autocompleteAdapter.getItem(i);
        if (item instanceof MentionFilterResult) {
            String mention = ((MentionFilterResult) item).getMentionString();
            Fragment parent = getParentFragment();
            if (parent instanceof AutocompleteCallback) {
                ((AutocompleteCallback) parent).onMentionPicked(mention);
            }
        } else if (item instanceof BotCommand) {
            String command = ((BotCommand) item).getSlashCommand();
            Fragment parent = getParentFragment();
            if (parent instanceof AutocompleteCallback) {
                ((AutocompleteCallback) parent).onCommandPicked(command);
            }
        }
    });
    // Initial zero height
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.BOTTOM;
    autocompleteList.setLayoutParams(params);
    return autocompleteList;
}
Also used : BotCommand(im.actor.core.entity.BotCommand) FrameLayout(android.widget.FrameLayout) MentionFilterResult(im.actor.core.entity.MentionFilterResult) BottomSheetListView(im.actor.sdk.view.adapters.BottomSheetListView) BaseFragment(im.actor.sdk.controllers.BaseFragment) Fragment(android.support.v4.app.Fragment) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 FrameLayout (android.widget.FrameLayout)1 BotCommand (im.actor.core.entity.BotCommand)1 MentionFilterResult (im.actor.core.entity.MentionFilterResult)1 BaseFragment (im.actor.sdk.controllers.BaseFragment)1 BottomSheetListView (im.actor.sdk.view.adapters.BottomSheetListView)1