Attempts at fixing things

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-06-06 22:31:23 +02:00
parent df8439fe34
commit 5914ecb099
3 changed files with 23 additions and 22 deletions

View file

@ -126,11 +126,11 @@ public class ChatController extends BaseController implements MessagesListAdapte
@Inject @Inject
Cache cache; Cache cache;
@BindView(R.id.messagesList) @BindView(R.id.messagesListView)
MessagesList messagesList; MessagesList messagesListView;
@BindView(R.id.nc_message_input) @BindView(R.id.messageInputView)
MessageInput messageInput; MessageInput messageInputView;
@BindView(R.id.nc_popup_bubble) @BindView(R.id.popupBubbleView)
PopupBubble popupBubble; PopupBubble popupBubble;
private List<Disposable> disposableList = new ArrayList<>(); private List<Disposable> disposableList = new ArrayList<>();
private String conversationName; private String conversationName;
@ -297,14 +297,14 @@ public class ChatController extends BaseController implements MessagesListAdapte
} }
messagesList.setAdapter(adapter); messagesListView.setAdapter(adapter);
adapter.setLoadMoreListener(this); adapter.setLoadMoreListener(this);
adapter.setDateHeadersFormatter(this::format); adapter.setDateHeadersFormatter(this::format);
adapter.setOnMessageLongClickListener(this); adapter.setOnMessageLongClickListener(this);
layoutManager = (LinearLayoutManager) messagesList.getLayoutManager(); layoutManager = (LinearLayoutManager) messagesListView.getLayoutManager();
popupBubble.setRecyclerView(messagesList); popupBubble.setRecyclerView(messagesListView);
popupBubble.setPopupBubbleListener(context -> { popupBubble.setPopupBubbleListener(context -> {
if (newMessagesCount != 0) { if (newMessagesCount != 0) {
@ -314,11 +314,11 @@ public class ChatController extends BaseController implements MessagesListAdapte
} else { } else {
scrollPosition = newMessagesCount - 1; scrollPosition = newMessagesCount - 1;
} }
new Handler().postDelayed(() -> messagesList.smoothScrollToPosition(scrollPosition), 200); new Handler().postDelayed(() -> messagesListView.smoothScrollToPosition(scrollPosition), 200);
} }
}); });
messagesList.addOnScrollListener(new RecyclerView.OnScrollListener() { messagesListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override @Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) { public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState); super.onScrollStateChanged(recyclerView, newState);
@ -338,8 +338,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
}); });
messageInput.getInputEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); messageInputView.getInputEditText().setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
messageInput.setInputListener(input -> { messageInputView.setInputListener(input -> {
sendMessage(input.toString(), 1); sendMessage(input.toString(), 1);
return true; return true;
}); });
@ -359,8 +359,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
AutocompletePresenter<Mention> presenter = new MentionAutocompletePresenter(getApplicationContext(), roomToken); AutocompletePresenter<Mention> presenter = new MentionAutocompletePresenter(getApplicationContext(), roomToken);
AutocompleteCallback<Mention> callback = new MentionAutocompleteCallback(); AutocompleteCallback<Mention> callback = new MentionAutocompleteCallback();
if (messageInput != null && messageInput.getInputEditText() != null) { if (messageInputView != null && messageInputView.getInputEditText() != null) {
mentionAutocomplete = Autocomplete.<Mention>on(messageInput.getInputEditText()) mentionAutocomplete = Autocomplete.<Mention>on(messageInputView.getInputEditText())
.with(elevation) .with(elevation)
.with(backgroundDrawable) .with(backgroundDrawable)
.with(new CharPolicy('@')) .with(new CharPolicy('@'))
@ -543,8 +543,8 @@ public class ChatController extends BaseController implements MessagesListAdapte
popupBubble.hide(); popupBubble.hide();
} }
if (messagesList != null) { if (messagesListView != null) {
messagesList.smoothScrollToPosition(0); messagesListView.smoothScrollToPosition(0);
} }
} }
@ -559,7 +559,7 @@ public class ChatController extends BaseController implements MessagesListAdapte
popupBubble.hide(); popupBubble.hide();
} }
messagesList.smoothScrollToPosition(0); messagesListView.smoothScrollToPosition(0);
} else { } else {
sendMessage(message, attempt + 1); sendMessage(message, attempt + 1);
} }

View file

@ -25,10 +25,10 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.stfalcon.chatkit.messages.MessagesList <com.stfalcon.chatkit.messages.MessagesList
android:id="@+id/messagesList" android:id="@+id/messagesListView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/nc_message_input" android:layout_above="@+id/messageInputView"
app:incomingDefaultBubbleColor="@color/white_two" app:incomingDefaultBubbleColor="@color/white_two"
app:incomingDefaultBubblePressedColor="@color/white_two" app:incomingDefaultBubblePressedColor="@color/white_two"
app:incomingDefaultBubbleSelectedColor="@color/colorPrimaryDark" app:incomingDefaultBubbleSelectedColor="@color/colorPrimaryDark"
@ -47,7 +47,7 @@
app:textAutoLink="all"/> app:textAutoLink="all"/>
<com.webianks.library.PopupBubble <com.webianks.library.PopupBubble
android:id="@+id/nc_popup_bubble" android:id="@+id/popupBubbleView"
android:layout_margin="16dp" android:layout_margin="16dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -63,13 +63,13 @@
android:id="@+id/separator" android:id="@+id/separator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:layout_above="@+id/nc_message_input" android:layout_above="@+id/messageInputView"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:background="@color/nc_light_grey"/> android:background="@color/nc_light_grey"/>
<com.stfalcon.chatkit.messages.MessageInput <com.stfalcon.chatkit.messages.MessageInput
android:id="@+id/nc_message_input" android:id="@+id/messageInputView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"

View file

@ -12,6 +12,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.2' classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files