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;
}
Aggregations