PublicShareViewHolder.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *
  3. * Nextcloud Android client application
  4. *
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2020 Tobias Kaminsky
  7. * Copyright (C) 2020 Nextcloud GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. package com.owncloud.android.ui.adapter;
  23. import android.content.Context;
  24. import android.text.TextUtils;
  25. import android.view.View;
  26. import com.owncloud.android.databinding.FileDetailsSharePublicLinkItemBinding;
  27. import com.owncloud.android.lib.resources.shares.OCShare;
  28. import com.owncloud.android.utils.ThemeUtils;
  29. import androidx.annotation.NonNull;
  30. import androidx.recyclerview.widget.RecyclerView;
  31. class PublicShareViewHolder extends RecyclerView.ViewHolder {
  32. private FileDetailsSharePublicLinkItemBinding binding;
  33. private Context context;
  34. public PublicShareViewHolder(@NonNull View itemView) {
  35. super(itemView);
  36. }
  37. public PublicShareViewHolder(FileDetailsSharePublicLinkItemBinding binding, Context context) {
  38. this(binding.getRoot());
  39. this.binding = binding;
  40. this.context = context;
  41. }
  42. public void bind(OCShare publicShare, PublicShareInterface listener) {
  43. if (!TextUtils.isEmpty(publicShare.getLabel())) {
  44. binding.publicShareLabel.setText(publicShare.getLabel());
  45. }
  46. ThemeUtils.colorIconImageViewWithBackground(binding.copyInternalLinkIcon, context);
  47. binding.shareLinkCopyIcon.setOnClickListener(v -> listener.copyLink(publicShare));
  48. binding.overflowMenuShareLink.setOnClickListener(
  49. v -> listener.showLinkOverflowMenu(publicShare, binding.overflowMenuShareLink));
  50. }
  51. }