Skip to content

Commit

Permalink
Fix code analytics
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Oct 25, 2023
1 parent 9dba116 commit e936a6a
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.owncloud.android.ui.adapter;

import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.ViewGroup;
Expand Down Expand Up @@ -94,15 +95,15 @@ public int getItemViewType(int position) {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
switch (ShareType.fromValue(viewType)) {
case PUBLIC_LINK:
case EMAIL:
case PUBLIC_LINK, EMAIL -> {
return new LinkShareViewHolder(
FileDetailsShareLinkShareItemBinding.inflate(LayoutInflater.from(fileActivity),
parent,
false),
fileActivity,
viewThemeUtils);
case NEW_PUBLIC_LINK:
}
case NEW_PUBLIC_LINK -> {
if (encrypted) {
return new NewSecureFileDropViewHolder(
FileDetailsShareSecureFileDropAddNewItemBinding.inflate(LayoutInflater.from(fileActivity),
Expand All @@ -116,17 +117,20 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
false)
);
}
case INTERNAL:
}
case INTERNAL -> {
return new InternalShareViewHolder(
FileDetailsShareInternalShareLinkBinding.inflate(LayoutInflater.from(fileActivity), parent, false),
fileActivity);
default:
}
default -> {
return new ShareViewHolder(FileDetailsShareShareItemBinding.inflate(LayoutInflater.from(fileActivity),
parent,
false),
user,
fileActivity,
viewThemeUtils);
}
}
}

Expand All @@ -138,17 +142,13 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi

final OCShare share = shares.get(position);

if (holder instanceof LinkShareViewHolder) {
LinkShareViewHolder publicShareViewHolder = (LinkShareViewHolder) holder;
if (holder instanceof LinkShareViewHolder publicShareViewHolder) {
publicShareViewHolder.bind(share, listener);
} else if (holder instanceof InternalShareViewHolder) {
InternalShareViewHolder internalShareViewHolder = (InternalShareViewHolder) holder;
} else if (holder instanceof InternalShareViewHolder internalShareViewHolder) {
internalShareViewHolder.bind(share, listener);
} else if (holder instanceof NewLinkShareViewHolder) {
NewLinkShareViewHolder newLinkShareViewHolder = (NewLinkShareViewHolder) holder;
} else if (holder instanceof NewLinkShareViewHolder newLinkShareViewHolder) {
newLinkShareViewHolder.bind(listener);
} else if (holder instanceof NewSecureFileDropViewHolder) {
NewSecureFileDropViewHolder newSecureFileDropViewHolder = (NewSecureFileDropViewHolder) holder;
} else if (holder instanceof NewSecureFileDropViewHolder newSecureFileDropViewHolder) {
newSecureFileDropViewHolder.bind(listener);
} else {
ShareViewHolder userViewHolder = (ShareViewHolder) holder;
Expand All @@ -166,6 +166,7 @@ public int getItemCount() {
return shares.size();
}

@SuppressLint("NotifyDataSetChanged")
public void addShares(List<OCShare> sharesToAdd) {
shares.addAll(sharesToAdd);
sortShares();
Expand All @@ -174,22 +175,21 @@ public void addShares(List<OCShare> sharesToAdd) {

@Override
public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
if (callContext instanceof ImageView) {
ImageView iv = (ImageView) callContext;
if (callContext instanceof ImageView iv) {
iv.setImageDrawable(avatarDrawable);
}
}

@Override
public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
if (callContext instanceof ImageView) {
ImageView iv = (ImageView) callContext;
if (callContext instanceof ImageView iv) {
// needs to be changed once federated users have avatars
return String.valueOf(iv.getTag()).equals(tag.split("@")[0]);
}
return false;
}

@SuppressLint("NotifyDataSetChanged")
public void remove(OCShare share) {
shares.remove(share);
notifyDataSetChanged();
Expand All @@ -210,8 +210,8 @@ protected final void sortShares() {
}
}

Collections.sort(links, (o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
Collections.sort(users, (o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
links.sort((o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));
users.sort((o1, o2) -> Long.compare(o2.getSharedDate(), o1.getSharedDate()));

shares = links;
shares.addAll(users);
Expand Down

0 comments on commit e936a6a

Please sign in to comment.