Open tcqq opened 7 years ago
Thanks for your feedback.
Take a look an example.
public class UiTask
public UiTask() {
}
public UiTask(T item) {
super(item);
}
public UiTask(T item, Type itemType) {
super(item);
setItemType(itemType);
}
}
Word word = new Word;
UiTask
Hi, how to create "Word.java"? and how to accept the value?
Word is a custom object to accept any params you want. And must be implemented as parcelable or serializable. :)
@Entity(indices = {@Index(value = "word", unique = true)})
public class Word extends BaseSerial implements Comparable
@PrimaryKey
@NonNull
private String word;
private String pronunciation;
@Ignore
private List<Definition> definitions;
private List<String> examples;
@Ignore
private List<String> synonyms;
@Ignore
private List<String> antonyms;
private long timeToday;
private long time;
public Word(@NotNull String word) {
this.word = word;
}
@Override
public boolean equals(Object inObject) {
if (Word.class.isInstance(inObject)) {
Word word = (Word) inObject;
return this.word.equals(word.word);
}
return false;
}
@Override
public int hashCode() {
return word.hashCode();
}
@Override
public int compareTo(@NonNull Word item) {
return word.compareToIgnoreCase(item.word);
}
@Override
public String toString() {
StringBuilder result = new StringBuilder();
String newLine = System.getProperty("line.separator");
result.append(this.getClass().getName());
result.append(" Object {");
result.append(newLine);
//determine fields declared in this class only (no fields of superclass)
Field[] fields = this.getClass().getDeclaredFields();
for (Field field : fields) {
result.append(" ");
try {
result.append(field.getName());
result.append(": ");
result.append(field.get(this));
} catch (IllegalAccessException ex) {
}
result.append(newLine);
}
result.append("}");
return result.toString();
}
public void setWord(@NonNull String word) {
this.word = word;
}
public void setPronunciation(String pronunciation) {
this.pronunciation = pronunciation;
}
public void setDefinitions(List<Definition> definitions) {
this.definitions = definitions;
}
public void setExamples(List<String> examples) {
this.examples = examples;
}
public void setSynonyms(List<String> synonyms) {
this.synonyms = synonyms;
}
public void setAntonyms(List<String> antonyms) {
this.antonyms = antonyms;
}
public void setTimeToday(long timeToday) {
this.timeToday = timeToday;
}
public void setTime(long time) {
this.time = time;
}
@NonNull
public String getWord() {
return word;
}
public String getPronunciation() {
return pronunciation;
}
public List<Definition> getDefinitions() {
return definitions;
}
public List<String> getExamples() {
return examples;
}
public List<String> getSynonyms() {
return synonyms;
}
public List<String> getAntonyms() {
return antonyms;
}
public long getTimeToday() {
return timeToday;
}
public long getTime() {
return time;
}
//special public api
public void addDefinition(Definition definition) {
if (definitions == null) {
definitions = new ArrayList<>();
}
if (!definitions.contains(definition)) {
definitions.add(definition);}
}
public void addExample(String example) {
if (examples == null) {
examples = new ArrayList<>();
}
if (!examples.contains(example)) {
examples.add(example);}
}
public void addSynonym(String synonym) {
if (synonyms == null) {
synonyms = new ArrayList<>();
}
if (!synonyms.contains(synonym)) {
synonyms.add(synonym);
}
}
public void addAntonym(String antonym) {
if (antonyms == null) {
antonyms = new ArrayList<>();
}
if (!antonyms.contains(antonym)) {
antonyms.add(antonym);
}
}
public boolean hasDefinitions() {
return !(definitions == null || definitions.isEmpty());
}
public boolean hasExamples() {
return !(examples == null || examples.isEmpty());
}
public boolean hasSynonyms() {
return !(synonyms == null || synonyms.isEmpty());
}
public boolean hasAntonyms() {
return !(antonyms == null || antonyms.isEmpty());
}
public boolean containsDefinition(Definition definition) {
if (hasDefinitions()) {
return definitions.contains(definition);
}
return false;
}
public boolean containsExample(String example) {
if (hasExamples()) {
return examples.contains(example);
}
return false;
}
public boolean containsSynonym(String synonym) {
if (hasSynonyms()) {
return synonyms.contains(synonym);
}
return false;
}
public boolean containsAntonym(String antonym) {
if (hasAntonyms()) {
return antonyms.contains(antonym);
}
return false;
}
public boolean isToday() {
return timeToday > 0;
}
}
Hope it will help you. And one more thing, just ignore the Room annotation for your object.
I want use "Parcelable" to pass a (Test) value via Intent, I tried it for a moment, but something went wrong, what should I do now?
OneActivity.java:
Word word = new Word("Test");
UiTask task = new UiTask<>(word);
openActivity(TwoActivity.class, task);
TowActivity.java:
Word word = null;
LogKit.logInfo(word.getName());
Word.java:
public class Word extends BaseParcel { private String mName;
public Word(String name) {
this.mName = name;
}
protected Word(Parcel in) {
super(in);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
}
public static final Parcelable.Creator<Word> CREATOR = new Parcelable.Creator<Word>() {
@Override
public Word createFromParcel(Parcel in) {
return new Word(in);
}
@Override
public Word[] newArray(int size) {
return new Word[size];
}
};
@Override
public int describeContents() {
return 0;
}
public String getName() {
return mName;
}
public Word setName(String name) {
this.mName = name;
return this;
}
}
UiTask.java and SQLiteTask.java have problem
ColorUtil.java has a problem
Thanks TCQQ, I am going to update fully repository after solving this bug.
Ok.
BaseNavigationActivity:
onNavigationItemSelected have a problem, i fixed.
In single mode(android:checkableBehavior="single"), clicking selected item invalidates the click event is right, but in click mode(android:checkableBehavior="none") can not do this, because after clicking may jump to other interfaces, when returning from other interface, click the same button again before clicking, click will invalidates.
Hello thanks for your framework, I think your code write very well, but I encountered a problem in use:
BaseActivity.java:
I would like to use your packaging method to achieve Intent send value and accept value, but I will not use, you can give an example, ok?, thank you