mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-13 15:54:59 +01:00
Move more things to Kotlin & Coil
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
561f7bff69
commit
2238454ffb
@ -1,181 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.nextcloud.talk.adapters.items;
|
|
||||||
|
|
||||||
import android.accounts.Account;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.RelativeLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.emoji.widget.EmojiTextView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
|
||||||
import com.facebook.drawee.interfaces.DraweeController;
|
|
||||||
import com.facebook.drawee.view.SimpleDraweeView;
|
|
||||||
import com.nextcloud.talk.R;
|
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
||||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem;
|
|
||||||
import eu.davidea.flexibleadapter.items.IFilterable;
|
|
||||||
import eu.davidea.flexibleadapter.utils.FlexibleUtils;
|
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class AdvancedUserItem extends AbstractFlexibleItem<AdvancedUserItem.UserItemViewHolder>
|
|
||||||
implements
|
|
||||||
IFilterable<String> {
|
|
||||||
|
|
||||||
private Participant participant;
|
|
||||||
private UserEntity userEntity;
|
|
||||||
@Nullable
|
|
||||||
private Account account;
|
|
||||||
|
|
||||||
public AdvancedUserItem(Participant participant, UserEntity userEntity,
|
|
||||||
@Nullable Account account) {
|
|
||||||
this.participant = participant;
|
|
||||||
this.userEntity = userEntity;
|
|
||||||
this.account = account;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o instanceof AdvancedUserItem) {
|
|
||||||
AdvancedUserItem inItem = (AdvancedUserItem) o;
|
|
||||||
return participant.equals(inItem.getModel());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return participant.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the model object
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Participant getModel() {
|
|
||||||
return participant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserEntity getEntity() {
|
|
||||||
return userEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public Account getAccount() {
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutRes() {
|
|
||||||
return R.layout.rv_item_conversation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserItemViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
return new UserItemViewHolder(view, adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindViewHolder(FlexibleAdapter adapter, UserItemViewHolder holder, int position,
|
|
||||||
List payloads) {
|
|
||||||
holder.avatarImageView.setController(null);
|
|
||||||
|
|
||||||
if (adapter.hasFilter()) {
|
|
||||||
FlexibleUtils.highlightText(holder.contactDisplayName, participant.getName(),
|
|
||||||
String.valueOf(adapter.getFilter(String.class)),
|
|
||||||
NextcloudTalkApplication.Companion.getSharedApplication()
|
|
||||||
.getResources().getColor(R.color.colorPrimary));
|
|
||||||
} else {
|
|
||||||
holder.contactDisplayName.setText(participant.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
holder.serverUrl.setText(userEntity.getBaseUrl());
|
|
||||||
|
|
||||||
if (userEntity != null && userEntity.getBaseUrl() != null && userEntity.getBaseUrl()
|
|
||||||
.startsWith("http://") || userEntity.getBaseUrl().startsWith("https://")) {
|
|
||||||
holder.avatarImageView.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
|
|
||||||
.setOldController(holder.avatarImageView.getController())
|
|
||||||
.setAutoPlayAnimations(true)
|
|
||||||
.setImageRequest(DisplayUtils.getImageRequestForUrl(
|
|
||||||
ApiUtils.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
|
||||||
participant.getUserId(), R.dimen.avatar_size), null))
|
|
||||||
.build();
|
|
||||||
holder.avatarImageView.setController(draweeController);
|
|
||||||
} else {
|
|
||||||
holder.avatarImageView.setVisibility(View.GONE);
|
|
||||||
RelativeLayout.LayoutParams layoutParams =
|
|
||||||
(RelativeLayout.LayoutParams) holder.linearLayout.getLayoutParams();
|
|
||||||
layoutParams.setMarginStart(
|
|
||||||
(int) NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext()
|
|
||||||
.getResources().getDimension(R.dimen.activity_horizontal_margin));
|
|
||||||
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START);
|
|
||||||
holder.linearLayout.setLayoutParams(layoutParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean filter(String constraint) {
|
|
||||||
return participant.getName() != null &&
|
|
||||||
Pattern.compile(constraint, Pattern.CASE_INSENSITIVE | Pattern.LITERAL)
|
|
||||||
.matcher(participant.getName().trim())
|
|
||||||
.find();
|
|
||||||
}
|
|
||||||
|
|
||||||
static class UserItemViewHolder extends FlexibleViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.name_text)
|
|
||||||
public EmojiTextView contactDisplayName;
|
|
||||||
@BindView(R.id.secondary_text)
|
|
||||||
public TextView serverUrl;
|
|
||||||
@BindView(R.id.avatar_image)
|
|
||||||
public SimpleDraweeView avatarImageView;
|
|
||||||
@BindView(R.id.linear_layout)
|
|
||||||
LinearLayout linearLayout;
|
|
||||||
@BindView(R.id.more_menu)
|
|
||||||
ImageButton moreMenuButton;
|
|
||||||
@BindView(R.id.password_protected_image_view)
|
|
||||||
ImageView passwordProtectedImageView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
UserItemViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
super(view, adapter);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
moreMenuButton.setVisibility(View.GONE);
|
|
||||||
passwordProtectedImageView.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,168 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.adapters.items
|
||||||
|
|
||||||
|
import android.accounts.Account
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageButton
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.RelativeLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.emoji.widget.EmojiTextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
|
import butterknife.BindView
|
||||||
|
import butterknife.ButterKnife
|
||||||
|
import coil.api.load
|
||||||
|
import coil.transform.CircleCropTransformation
|
||||||
|
import com.nextcloud.talk.R
|
||||||
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
|
import com.nextcloud.talk.models.database.UserEntity
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant
|
||||||
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
|
import eu.davidea.flexibleadapter.items.IFilterable
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.davidea.flexibleadapter.utils.FlexibleUtils
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class AdvancedUserItem(
|
||||||
|
/**
|
||||||
|
* @return the model object
|
||||||
|
*/
|
||||||
|
|
||||||
|
val model: Participant,
|
||||||
|
val entity: UserEntity?,
|
||||||
|
val account: Account?
|
||||||
|
) : AbstractFlexibleItem<AdvancedUserItem.UserItemViewHolder>(), IFilterable<String> {
|
||||||
|
override fun bindViewHolder(
|
||||||
|
adapter: FlexibleAdapter<IFlexible<ViewHolder>>?,
|
||||||
|
holder: UserItemViewHolder?,
|
||||||
|
position: Int,
|
||||||
|
payloads: MutableList<Any>?
|
||||||
|
) {
|
||||||
|
|
||||||
|
if (adapter!!.hasFilter()) {
|
||||||
|
FlexibleUtils.highlightText(
|
||||||
|
holder!!.contactDisplayName!!, model.name,
|
||||||
|
adapter.getFilter(String::class.java).toString(),
|
||||||
|
NextcloudTalkApplication.sharedApplication!!
|
||||||
|
.resources.getColor(R.color.colorPrimary)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
holder!!.contactDisplayName!!.text = model.name
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.serverUrl!!.text = entity!!.baseUrl
|
||||||
|
|
||||||
|
if (entity.baseUrl != null && entity.baseUrl
|
||||||
|
.startsWith("http://") || entity.baseUrl.startsWith("https://")
|
||||||
|
) {
|
||||||
|
holder.avatarImageView!!.visibility = View.VISIBLE
|
||||||
|
|
||||||
|
holder.avatarImageView?.load(
|
||||||
|
ApiUtils.getUrlForAvatarWithName(
|
||||||
|
entity.baseUrl,
|
||||||
|
model.userId, R.dimen.avatar_size
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
transformations(CircleCropTransformation())
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
holder.avatarImageView!!.visibility = View.GONE
|
||||||
|
val layoutParams = holder.linearLayout!!.layoutParams as RelativeLayout.LayoutParams
|
||||||
|
layoutParams.marginStart = NextcloudTalkApplication.sharedApplication!!.applicationContext
|
||||||
|
.resources.getDimension(R.dimen.activity_horizontal_margin)
|
||||||
|
.toInt()
|
||||||
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START)
|
||||||
|
holder.linearLayout!!.layoutParams = layoutParams
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createViewHolder(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<IFlexible<ViewHolder>>
|
||||||
|
): UserItemViewHolder {
|
||||||
|
return UserItemViewHolder(view, adapter)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is AdvancedUserItem) {
|
||||||
|
val inItem = other as AdvancedUserItem?
|
||||||
|
return model == inItem!!.model
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return model.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutRes(): Int {
|
||||||
|
return R.layout.rv_item_conversation
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun filter(constraint: String): Boolean {
|
||||||
|
return model.name != null && Pattern.compile(
|
||||||
|
constraint, Pattern.CASE_INSENSITIVE or Pattern.LITERAL
|
||||||
|
)
|
||||||
|
.matcher(model.name.trim(' '))
|
||||||
|
.find()
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserItemViewHolder
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<*>
|
||||||
|
) : FlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.name_text)
|
||||||
|
var contactDisplayName: EmojiTextView? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.secondary_text)
|
||||||
|
var serverUrl: TextView? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.avatar_image)
|
||||||
|
var avatarImageView: ImageView? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.linear_layout)
|
||||||
|
var linearLayout: LinearLayout? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.more_menu)
|
||||||
|
var moreMenuButton: ImageButton? = null
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.password_protected_image_view)
|
||||||
|
var passwordProtectedImageView: ImageView? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
ButterKnife.bind(this, view)
|
||||||
|
moreMenuButton!!.visibility = View.GONE
|
||||||
|
passwordProtectedImageView!!.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* Nextcloud Talk application
|
|
||||||
*
|
|
||||||
* @author Mario Danic
|
|
||||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.nextcloud.talk.adapters.items;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import butterknife.BindView;
|
|
||||||
import butterknife.ButterKnife;
|
|
||||||
import com.nextcloud.talk.R;
|
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter;
|
|
||||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem;
|
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible;
|
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GenericTextHeaderItem
|
|
||||||
extends AbstractHeaderItem<GenericTextHeaderItem.HeaderViewHolder> {
|
|
||||||
private static final String TAG = "GenericTextHeaderItem";
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
public GenericTextHeaderItem(String title) {
|
|
||||||
super();
|
|
||||||
setHidden(false);
|
|
||||||
setSelectable(false);
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModel() {
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (o instanceof GenericTextHeaderItem) {
|
|
||||||
GenericTextHeaderItem inItem = (GenericTextHeaderItem) o;
|
|
||||||
return title.equals(inItem.getModel());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutRes() {
|
|
||||||
return R.layout.rv_item_title_header;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, HeaderViewHolder holder,
|
|
||||||
int position, List<Object> payloads) {
|
|
||||||
if (payloads.size() > 0) {
|
|
||||||
Log.d(TAG, "We have payloads, so ignoring!");
|
|
||||||
} else {
|
|
||||||
holder.titleTextView.setText(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HeaderViewHolder createViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
return new HeaderViewHolder(view, adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
static class HeaderViewHolder extends FlexibleViewHolder {
|
|
||||||
|
|
||||||
@BindView(R.id.title_text_view)
|
|
||||||
public TextView titleTextView;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default constructor.
|
|
||||||
*/
|
|
||||||
HeaderViewHolder(View view, FlexibleAdapter adapter) {
|
|
||||||
super(view, adapter, true);
|
|
||||||
ButterKnife.bind(this, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.adapters.items
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||||
|
import butterknife.BindView
|
||||||
|
import butterknife.ButterKnife
|
||||||
|
import com.nextcloud.talk.R
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
|
||||||
|
class GenericTextHeaderItem(val model: String) : AbstractHeaderItem<GenericTextHeaderItem.HeaderViewHolder>() {
|
||||||
|
override fun createViewHolder(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<IFlexible<ViewHolder>>
|
||||||
|
): HeaderViewHolder {
|
||||||
|
return HeaderViewHolder(view, adapter)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
isHidden = false
|
||||||
|
isSelectable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other is GenericTextHeaderItem) {
|
||||||
|
val inItem = other as GenericTextHeaderItem?
|
||||||
|
return model == inItem!!.model
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getLayoutRes(): Int {
|
||||||
|
return R.layout.rv_item_title_header
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindViewHolder(
|
||||||
|
adapter: FlexibleAdapter<IFlexible<*>>,
|
||||||
|
holder: HeaderViewHolder,
|
||||||
|
position: Int,
|
||||||
|
payloads: List<Any>
|
||||||
|
) {
|
||||||
|
if (payloads.size > 0) {
|
||||||
|
Log.d(TAG, "We have payloads, so ignoring!")
|
||||||
|
} else {
|
||||||
|
holder.titleTextView!!.text = model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HeaderViewHolder
|
||||||
|
/**
|
||||||
|
* Default constructor.
|
||||||
|
*/
|
||||||
|
(
|
||||||
|
view: View,
|
||||||
|
adapter: FlexibleAdapter<*>
|
||||||
|
) : FlexibleViewHolder(view, adapter, true) {
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
@BindView(R.id.title_text_view)
|
||||||
|
var titleTextView: TextView? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
ButterKnife.bind(this, view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val TAG = "GenericTextHeaderItem"
|
||||||
|
}
|
||||||
|
}
|
@ -44,12 +44,11 @@
|
|||||||
android:src="@drawable/ic_lock_white_24px"
|
android:src="@drawable/ic_lock_white_24px"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
<com.facebook.drawee.view.SimpleDraweeView xmlns:app="http://schemas.android.com/apk/res-auto"
|
<ImageView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/avatar_image"
|
android:id="@+id/avatar_image"
|
||||||
android:layout_width="@dimen/small_item_height"
|
android:layout_width="@dimen/small_item_height"
|
||||||
android:layout_height="@dimen/small_item_height"
|
android:layout_height="@dimen/small_item_height"
|
||||||
android:layout_margin="@dimen/margin_between_elements"
|
android:layout_margin="@dimen/margin_between_elements"/>
|
||||||
app:roundAsCircle="true" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user