-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1626b7
commit a05e954
Showing
27 changed files
with
21,205 additions
and
21,066 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package me.ag2s.tts.data; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
|
||
import java.util.Locale; | ||
import java.util.Objects; | ||
|
||
public class TtsActor { | ||
/** | ||
* 标准名称 | ||
*/ | ||
@NonNull | ||
private final String name; | ||
|
||
/** | ||
* 简写名称 | ||
*/ | ||
@NonNull | ||
private final String shortName; | ||
/** | ||
* 性别,true 为女性,false为男性 | ||
*/ | ||
private final boolean gender; | ||
|
||
/** | ||
* 地区 | ||
*/ | ||
@NonNull | ||
private final String locale; | ||
|
||
/** | ||
* 注释 | ||
*/ | ||
@Nullable | ||
private final String note; | ||
|
||
private Locale tempLocate; | ||
|
||
|
||
public TtsActor(@NonNull String name, @NonNull String shortName, boolean gender, @NonNull String locale, @NonNull String note) { | ||
this.name = name; | ||
this.shortName = shortName; | ||
this.gender = gender; | ||
this.locale = locale; | ||
this.note = note; | ||
} | ||
|
||
|
||
@NonNull | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@NonNull | ||
public String getShortName() { | ||
return shortName; | ||
} | ||
|
||
public boolean getGender() { | ||
return gender; | ||
} | ||
|
||
@NonNull | ||
public String getLocaleStr() { | ||
return locale; | ||
} | ||
|
||
public Locale getLocale() { | ||
|
||
if (tempLocate != null) { | ||
return tempLocate; | ||
} | ||
|
||
|
||
String tag = "-"; | ||
if (locale.contains("-")) { | ||
tag = "-"; | ||
} else if (locale.contains("_")) { | ||
tag = "_"; | ||
} | ||
String[] temp = locale.split(tag); | ||
tempLocate = new Locale(temp[0], temp[1], gender ? "Female" : "Male"); | ||
return tempLocate; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
TtsActor ttsActor = (TtsActor) o; | ||
return gender == ttsActor.gender && Objects.equals(name, ttsActor.name) && Objects.equals(shortName, ttsActor.shortName) && Objects.equals(locale, ttsActor.locale); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(name, shortName, gender, locale); | ||
} | ||
|
||
public Object getNote() { | ||
return this.note; | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/java/me/ag2s/tts/data/TtsActorComparator.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,71 @@ | ||
package me.ag2s.tts.data; | ||
|
||
import java.util.Comparator; | ||
import java.util.Locale; | ||
|
||
public class TtsActorComparator implements Comparator<TtsActor> { | ||
|
||
public static final TtsActorComparator INSTANCE = new TtsActorComparator(); | ||
private final Locale locale; | ||
|
||
public TtsActorComparator() { | ||
this.locale = Locale.getDefault(); | ||
} | ||
|
||
public TtsActorComparator(Locale locale) { | ||
this.locale = locale; | ||
} | ||
|
||
@Override | ||
public int compare(TtsActor o1, TtsActor o2) { | ||
Locale loc1 = o1.getLocale(); | ||
Locale loc2 = o2.getLocale(); | ||
boolean b11 = loc1.getISO3Language().equals(locale.getISO3Language()); | ||
boolean b12 = loc1.getISO3Country().equals(locale.getISO3Country()); | ||
boolean b13 = loc1.getDisplayVariant(Locale.US).equals(locale.getDisplayVariant(Locale.US)); | ||
boolean b21 = loc2.getISO3Language().equals(locale.getISO3Language()); | ||
boolean b22 = loc2.getISO3Country().equals(locale.getISO3Country()); | ||
boolean b23 = loc2.getDisplayVariant(Locale.US).equals(locale.getDisplayVariant(Locale.US)); | ||
|
||
|
||
if (b11 != b21) { | ||
return b11 ? -1 : 1; | ||
} | ||
if (b12 != b22) { | ||
return b12 ? -1 : 1; | ||
} | ||
|
||
|
||
// //语言都不同 | ||
// if ((!b11) && (!b21)) { | ||
// return 0; | ||
// } | ||
// //两个都相同 | ||
// if (b11 && b12 && b13 == b21 && b22 && b23) { | ||
// return 0; | ||
// } | ||
// if (b11 && b12 && b13) { | ||
// return -1; | ||
// } | ||
// if (b21 && b22 && b23) { | ||
// return 1; | ||
// } | ||
// if ((b11 && b12 == b21 && b22)) { | ||
// if (b13 == b23) { | ||
// return 0; | ||
// } | ||
// if (b13) { | ||
// return -1; | ||
// } else { | ||
// return 1; | ||
// } | ||
// } | ||
// if (b11 && b12) { | ||
// return -1; | ||
// } | ||
// if (b21 && b22) { | ||
// return 1; | ||
// } | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.