-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
- Loading branch information
1 parent
8fd0dd4
commit 313cac0
Showing
5 changed files
with
233 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
src/com/owncloud/android/lib/resources/activities/models/PreviewListAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* Nextcloud Android Library is available under MIT license | ||
* Copyright (C) 2017 Joas Schilling | ||
* | ||
* @author Joas Schilling | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
package com.owncloud.android.lib.resources.activities.models; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonToken; | ||
import com.google.gson.stream.JsonWriter; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* PreviewList Parser | ||
*/ | ||
|
||
public class PreviewListAdapter extends TypeAdapter<PreviewObject> { | ||
|
||
@Override | ||
public void write(JsonWriter out, PreviewObject value) { | ||
|
||
} | ||
|
||
@Override | ||
public PreviewObject read(JsonReader in) throws IOException { | ||
PreviewObject preview = new PreviewObject(); | ||
in.beginObject(); | ||
|
||
while (in.hasNext()) { | ||
String name = in.nextName(); | ||
if (name != null && !name.isEmpty()) { | ||
preview = readObject(name, in); | ||
} | ||
} | ||
|
||
|
||
in.endObject(); | ||
|
||
return preview; | ||
} | ||
|
||
private PreviewObject readObject(String tag, JsonReader in) throws IOException { | ||
PreviewObject preview = new PreviewObject(); | ||
|
||
do { | ||
if (in.peek() == JsonToken.NAME) { | ||
tag = in.nextName(); | ||
} | ||
|
||
switch (tag) { | ||
case "source": | ||
preview.setSource(in.nextString()); | ||
break; | ||
|
||
case "link": | ||
preview.setLink(in.nextString()); | ||
break; | ||
|
||
case "isMimeTypeIcon": | ||
preview.setMimeTypeIcon(in.nextBoolean()); | ||
break; | ||
|
||
case "mimeType": | ||
preview.setMimeType(in.nextString()); | ||
break; | ||
|
||
case "fileId": | ||
preview.setFileId(in.nextInt()); | ||
break; | ||
|
||
case "view": | ||
preview.setView(in.nextString()); | ||
break; | ||
|
||
default: | ||
// do nothing | ||
break; | ||
} | ||
} while (in.hasNext()); | ||
|
||
return preview; | ||
} | ||
} | ||
|
91 changes: 91 additions & 0 deletions
91
src/com/owncloud/android/lib/resources/activities/models/PreviewObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* Nextcloud Android Library is available under MIT license | ||
* Copyright (C) 2017 Joas Schilling | ||
* | ||
* @author Joas Schilling | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
package com.owncloud.android.lib.resources.activities.models; | ||
|
||
/** | ||
* PreviewObject Data Model | ||
*/ | ||
|
||
public class PreviewObject { | ||
|
||
private int fileId; | ||
private String source; | ||
private String link; | ||
private Boolean isMimeTypeIcon; | ||
private String mimeType; | ||
private String view; | ||
|
||
public PreviewObject() { | ||
} | ||
|
||
public String getLink() { | ||
return link; | ||
} | ||
|
||
public void setLink(String link) { | ||
this.link = link; | ||
} | ||
|
||
public String getSource() { | ||
return source; | ||
} | ||
|
||
public void setSource(String source) { | ||
this.source = source; | ||
} | ||
|
||
public Boolean isMimeTypeIcon() { | ||
return isMimeTypeIcon; | ||
} | ||
|
||
public void setMimeTypeIcon(Boolean mimeTypeIcon) { | ||
isMimeTypeIcon = mimeTypeIcon; | ||
} | ||
|
||
public String getMimeType() { | ||
return mimeType; | ||
} | ||
|
||
public void setMimeType(String mimeType) { | ||
this.mimeType = mimeType; | ||
} | ||
|
||
public int getFileId() { | ||
return fileId; | ||
} | ||
|
||
public void setFileId(int fileId) { | ||
this.fileId = fileId; | ||
} | ||
|
||
public String getView() { | ||
return view; | ||
} | ||
|
||
public void setView(String view) { | ||
this.view = view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters