Skip to content

Commit 2adf41f

Browse files
committed
check shareType
Signed-off-by: alperozturk <[email protected]>
1 parent 4898e09 commit 2adf41f

File tree

6 files changed

+22
-11
lines changed

6 files changed

+22
-11
lines changed

app/src/main/java/it/niedermann/owncloud/notes/share/NoteShareActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ private void handleContactResult(@NonNull Uri contactUri) {
534534

535535
private boolean containsNoNewPublicShare(List<OCShare> shares) {
536536
for (OCShare share : shares) {
537-
if (share.getShareType() == ShareType.NEW_PUBLIC_LINK) {
537+
if (share.getShareType() != null && share.getShareType() == ShareType.NEW_PUBLIC_LINK) {
538538
return false;
539539
}
540540
}
@@ -550,7 +550,7 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
550550
}
551551

552552
private boolean isReshareForbidden(OCShare share) {
553-
return ShareType.FEDERATED == share.getShareType() ||
553+
return (share.getShareType() != null && ShareType.FEDERATED == share.getShareType()) ||
554554
capabilities != null && !capabilities.isReSharingAllowed();
555555
}
556556

app/src/main/java/it/niedermann/owncloud/notes/share/adapter/ShareeListAdapter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,12 @@ protected final void sortShares() {
150150
List<OCShare> users = new ArrayList<>();
151151

152152
for (OCShare share : shares) {
153-
if (ShareType.PUBLIC_LINK == share.getShareType() || ShareType.EMAIL == share.getShareType()) {
154-
links.add(share);
155-
} else if (share.getShareType() != ShareType.INTERNAL) {
156-
users.add(share);
153+
if (share.getShareType() != null) {
154+
if (ShareType.PUBLIC_LINK == share.getShareType() || ShareType.EMAIL == share.getShareType()) {
155+
links.add(share);
156+
} else if (share.getShareType() != ShareType.INTERNAL) {
157+
users.add(share);
158+
}
157159
}
158160
}
159161

app/src/main/java/it/niedermann/owncloud/notes/share/adapter/holder/LinkShareViewHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public LinkShareViewHolder(ItemShareLinkShareBinding binding, Context context) {
3535
}
3636

3737
public void bind(OCShare publicShare, ShareeListAdapterListener listener) {
38-
if (ShareType.EMAIL == publicShare.getShareType()) {
38+
if (publicShare.getShareType() != null && ShareType.EMAIL == publicShare.getShareType()) {
3939
binding.name.setText(publicShare.getSharedWithDisplayName());
4040
binding.icon.setImageDrawable(ResourcesCompat.getDrawable(context.getResources(),
4141
R.drawable.ic_email,

app/src/main/java/it/niedermann/owncloud/notes/share/adapter/holder/ShareViewHolder.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ public void bind(OCShare share,
4242
String accountName = account.getDisplayName();
4343
String name = share.getSharedWithDisplayName();
4444
binding.icon.setTag(null);
45+
final var shareType = share.getShareType();
46+
if (shareType == null) {
47+
return;
48+
}
4549

46-
switch (share.getShareType()) {
50+
switch (shareType) {
4751
case GROUP:
4852
name = context.getString(R.string.share_group_clarification, name);
4953
// viewThemeUtils.files.createAvatar(share.getShareType(), binding.icon, context);
@@ -74,6 +78,11 @@ public void bind(OCShare share,
7478

7579
binding.name.setText(name);
7680

81+
if (accountName == null) {
82+
binding.overflowMenu.setVisibility(View.GONE);
83+
return;
84+
}
85+
7786
if (accountName.equalsIgnoreCase(share.getShareWith()) || accountName.equalsIgnoreCase(share.getUserId())) {
7887
binding.overflowMenu.setVisibility(View.VISIBLE);
7988

@@ -99,7 +108,7 @@ private void setPermissionName(String permissionName) {
99108

100109
private void setImage(ImageView avatar, String name, @DrawableRes int fallback) {
101110
try {
102-
// avatar.setImageDrawable(TextDrawable.createNamedAvatar(name, avatarRadiusDimension));
111+
AvatarLoader.INSTANCE.load(context, avatar, account);
103112
} catch (StringIndexOutOfBoundsException e) {
104113
avatar.setImageResource(fallback);
105114
}

app/src/main/java/it/niedermann/owncloud/notes/share/dialog/NoteShareActivityShareItemActionBottomSheetDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected void onCreate(Bundle savedInstanceState) {
5050
}
5151

5252
private void updateUI() {
53-
if (ocShare.getShareType() == ShareType.PUBLIC_LINK) {
53+
if (ocShare.getShareType() != null && ocShare.getShareType() == ShareType.PUBLIC_LINK) {
5454
binding.menuShareAddAnotherLink.setVisibility(View.VISIBLE);
5555
binding.menuShareSendLink.setVisibility(View.VISIBLE);
5656
} else {

app/src/main/java/it/niedermann/owncloud/notes/share/repository/ShareRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class ShareRepository(private val applicationContext: Context, private val accou
224224
val response = call.execute()
225225
if (response.isSuccessful) {
226226

227-
if (share.shareType == ShareType.PUBLIC_LINK) {
227+
if (share.shareType != null && share.shareType == ShareType.PUBLIC_LINK) {
228228
note.setIsShared(false)
229229
updateNote(note)
230230
}

0 commit comments

Comments
 (0)