-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sort Options on Tours (defaults to Alphabetic) with User Settings sup…
…port. Tours should be `Reload` from the related button after changing Settings (#90) * fix: minor code fixes Signed-off-by: Eleftherios Chrysochoidis <[email protected]> * feat: Sort options and settings for tours Signed-off-by: Eleftherios Chrysochoidis <[email protected]> * fix: Sorting issues. Unit Test and Changelog Signed-off-by: Eleftherios Chrysochoidis <[email protected]> * rel: Bump version to 0.0.10 Signed-off-by: Eleftherios Chrysochoidis <[email protected]> --------- Signed-off-by: Eleftherios Chrysochoidis <[email protected]>
- Loading branch information
1 parent
d052e2f
commit c8aa6fe
Showing
11 changed files
with
196 additions
and
29 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
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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/org/uom/lefterisxris/codetour/tours/state/LocalDateTimeAdapter.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,43 @@ | ||
package org.uom.lefterisxris.codetour.tours.state; | ||
|
||
import com.google.gson.TypeAdapter; | ||
import com.google.gson.stream.JsonReader; | ||
import com.google.gson.stream.JsonToken; | ||
import com.google.gson.stream.JsonWriter; | ||
import com.intellij.openapi.diagnostic.Logger; | ||
|
||
import java.io.IOException; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
/** | ||
* @author Eleftherios Chrysochoidis | ||
* Date: 26/11/2023 | ||
*/ | ||
public class LocalDateTimeAdapter extends TypeAdapter<LocalDateTime> { | ||
|
||
private static final Logger LOG = Logger.getInstance(LocalDateTimeAdapter.class); | ||
private final DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
|
||
@Override | ||
public void write(JsonWriter jsonWriter, LocalDateTime localDateTime) throws IOException { | ||
if (localDateTime == null) | ||
jsonWriter.nullValue(); | ||
else | ||
jsonWriter.value(localDateTime.format(df)); | ||
} | ||
|
||
@Override | ||
public LocalDateTime read(JsonReader jsonReader) throws IOException { | ||
if (jsonReader.peek() == JsonToken.NULL) { | ||
jsonReader.nextNull(); | ||
} else { | ||
try { | ||
return LocalDateTime.parse(jsonReader.nextString(), df); | ||
} catch (Exception e) { | ||
LOG.error("Could not parse Datetime value!", e); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
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
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
Oops, something went wrong.