LingosHook Android Client 1.1.0终于写好了!主要更新如下:
,本来打算今晚写好在线文档的,但..怕是完成不了了...所以决定还是先Release,文档明天再说!
1. 支持XML格式导入;
2. 支持单个数据导入;
3. 支持远程(HTTP)方式导入;
4. 增加'Html界面点击'配置.
在线文档也更新了,这里查看; 有没有感觉新的导入和输入方式很强大啊..支持HTTP哦!!! 哇哈哈...
最后,
还是到这里下载!
简短说下更新:点击"导入"菜单,然后自己去试试先吧...
原来的在线文档在这里,新支持的XML文件格式请先参考如下例子吧...抱歉啊..今天有点累,真的连续写了好多天了...
新支持的XML文件格式的例子如下,请参考.
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<LingosHook Android Client>
<Version>1.0
</Version>
<DefaultDict>test
</DefaultDict>
<WordList>
<Item>
<Dict>dict
</Dict>
<Word>word
</Word>
<Symbol>wc'd
</Symbol>
<DataList>
<Item>
<Category>n.
</Category>
<Meaning>meaning
</Meaning>
</Item>
<Item>
<Category>v.
</Category>
<Meaning>meaning2
</Meaning>
</Item>
</DataList>
</Item>
<Item>
<Dict>dict2
</Dict>
<Word>word2
</Word>
<Symbol>wc'd2
</Symbol>
<DataList>
<Item>
<Category>n.
</Category>
<Meaning>中文啊
</Meaning>
</Item>
<Item>
<Category>v.
</Category>
<Meaning>测试啊
</Meaning>
</Item>
</DataList>
</Item>
</WordList>
</LingosHook Android Client>
有兴趣的可以下面看看俺怎么用JAVA解析的xml的(调试文件,不是最终的)
importdata.java
private void importXml(final String file, boolean overwrite) {
// File ifile = new File(file);
// if(!ifile.exists()) {
// return;
// }
try {
//FileInputStream is = new FileInputStream(ifile);
InputStream is = this.getAssets().open(file);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser xp = factory.newPullParser();
xp.setInput(is, "UTF-8");
DataFormat.Data data = new DataFormat.Data();
String defDict = "Default Dictionary";
int type = xp.getEventType();
while(type != XmlPullParser.END_DOCUMENT) {
if(type == XmlPullParser.START_TAG) {
if(xp.getName().equals("DefaultDict")) {
defDict = xp.getText();
}
else if(xp.getName().equals("WordList")) {
type = xp.nextTag();
if(type == XmlPullParser.START_TAG) {
while(xp.getName().equals("Item")) {
getItem(xp, data);
checkData(data, defDict);
// type = xp.next();
type = xp.nextTag();
type = xp.nextTag();
}
}
}
}
type = xp.next();
}
is.close();
}
catch (XmlPullParserException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
}
private int checkData(Data data, String defDict) {
return 0;
}
private int getItem(XmlPullParser xp, DataFormat.Data data) {
try {
//Dict
int type = xp.nextTag();
if(xp.getName().equals("Dict")) {
type = xp.next();
data.dict = xp.getText();
type = xp.next();
}
//Word
type = xp.nextTag();
if(xp.getName().equals("Word")) {
type = xp.next();
data.word = xp.getText();
type = xp.next();
}
else {
return -1;
}
//Symbol
type = xp.nextTag();
if(xp.getName().equals("Symbol")) {
type = xp.next();
data.symbol = xp.getText();
type = xp.next();
}
//DataList
type = xp.nextTag();
if(xp.getName().equals("DataList")) {
type = xp.nextTag();
if(type == XmlPullParser.START_TAG) {
while(xp.getName().equals("Item")) {
getWordData(xp, data);
checkWordData(data);
//type = xp.next();
type = xp.nextTag();
type = xp.nextTag();
}
}
}
else {
return -1;
}
}
catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
private int checkWordData(Data data) {
return 0;
}
private int getWordData(XmlPullParser xp, Data data) {
try {
//Category
int type = xp.nextTag();
if(xp.getName().equals("Category")) {
type = xp.next();
data.category.add(xp.getText());
type = xp.next();
}
else {
return -1;
}
//Meaning
type = xp.nextTag();
if(xp.getName().equals("Meaning")) {
type = xp.next();
data.meaning.add(xp.getText());
type = xp.next();
}
else {
return -1;
}
}
catch (XmlPullParserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
<---- 长舒一口气的分割线 ---->
文档总算写完了,可以轻松下了..结果,发现两个bug...唉,这两天就fix,1.1.1马上就不得不更新了...