Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2020-07-22 16:35:11 +0300
committerStefan Niedermann <info@niedermann.it>2020-07-22 16:35:11 +0300
commitfbcab20336437825c56d6dc6a399787a988dfc24 (patch)
tree669e360325eb9a44d01541148cbc9b9ce9157ffa /app/src/main
parent3c9c8489dc3823c6ed2ac62c5ab4c1661a303375 (diff)
#573 projects - Harding resources
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/model/ocs/projects/OcsProjectResource.java12
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourceViewHolder.java51
2 files changed, 38 insertions, 25 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/model/ocs/projects/OcsProjectResource.java b/app/src/main/java/it/niedermann/nextcloud/deck/model/ocs/projects/OcsProjectResource.java
index b4aa0f822..f889cc66c 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/model/ocs/projects/OcsProjectResource.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/model/ocs/projects/OcsProjectResource.java
@@ -53,19 +53,21 @@ public class OcsProjectResource extends AbstractRemoteEntity implements Serializ
this.projectId = projectId;
}
+ @Nullable
public String getType() {
return type;
}
- public void setType(String type) {
+ public void setType(@Nullable String type) {
this.type = type;
}
+ @Nullable
public String getName() {
return name;
}
- public void setName(String name) {
+ public void setName(@Nullable String name) {
this.name = name;
}
@@ -73,19 +75,21 @@ public class OcsProjectResource extends AbstractRemoteEntity implements Serializ
* Caution: the Link might be a full url or only the relative path!
* @return The link to the Resource
*/
+ @Nullable
public String getLink() {
return link;
}
- public void setLink(String link) {
+ public void setLink(@Nullable String link) {
this.link = link;
}
+ @Nullable
public String getIconUrl() {
return iconUrl;
}
- public void setIconUrl(String iconUrl) {
+ public void setIconUrl(@Nullable String iconUrl) {
this.iconUrl = iconUrl;
}
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourceViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourceViewHolder.java
index 6cad48940..377d890ab 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourceViewHolder.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/projectresources/CardProjectResourceViewHolder.java
@@ -5,6 +5,7 @@ import android.content.res.Resources;
import android.net.Uri;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import java.net.URL;
@@ -30,30 +31,38 @@ public class CardProjectResourceViewHolder extends RecyclerView.ViewHolder {
public void bind(@NonNull Account account, @NonNull OcsProjectResource resource) {
final Resources resources = itemView.getResources();
binding.name.setText(resource.getName());
- try {
- binding.getRoot().setOnClickListener((v) -> itemView.getContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(getResourceUri(account, resource.getLink()))));
- } catch (IllegalArgumentException e) {
- DeckLog.logError(e);
+ final @Nullable String link = resource.getLink();
+ if (link != null) {
+ try {
+ binding.getRoot().setOnClickListener((v) -> itemView.getContext().startActivity(new Intent(Intent.ACTION_VIEW).setData(getResourceUri(account, resource.getLink()))));
+ } catch (IllegalArgumentException e) {
+ DeckLog.logError(e);
+ }
}
binding.type.setVisibility(VISIBLE);
- switch (resource.getType()) {
- case "deck-board": {
- binding.type.setText(resources.getString(R.string.project_type_deck_board));
- break;
- }
- case "deck-card": {
- binding.type.setText(resources.getString(R.string.project_type_deck_card));
- break;
- }
- case "file": {
- binding.type.setText(resources.getString(R.string.project_type_file));
- break;
- }
- default: {
- DeckLog.warn("Unknown project type: " + resource.getType());
- binding.type.setVisibility(GONE);
- break;
+ if (resource.getType() != null) {
+ switch (resource.getType()) {
+ case "deck": {
+ binding.type.setText(resources.getString(R.string.project_type_deck_board));
+ break;
+ }
+ case "deck-card": {
+ binding.type.setText(resources.getString(R.string.project_type_deck_card));
+ break;
+ }
+ case "file": {
+ binding.type.setText(resources.getString(R.string.project_type_file));
+ break;
+ }
+ default: {
+ DeckLog.info("Unknown resource type for " + resource.getName() + ": " + resource.getType());
+ binding.type.setVisibility(GONE);
+ break;
+ }
}
+ } else {
+ DeckLog.warn("Resource type for " + resource.getName() + " is null");
+ binding.type.setVisibility(GONE);
}
}