├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── adm │ │ └── dictionary │ │ └── dictionary │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── dictionary.db │ ├── java │ │ └── com │ │ │ └── adm │ │ │ └── dictionary │ │ │ ├── app │ │ │ └── MyApp.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ └── BaseFragment.java │ │ │ ├── bean │ │ │ ├── ChineseBean.java │ │ │ ├── DictionaryBean.java │ │ │ ├── EnglishBean.java │ │ │ ├── EveryDayWords.java │ │ │ ├── Part.java │ │ │ ├── PlanCount.java │ │ │ ├── SentenceBean.java │ │ │ └── WordBean.java │ │ │ ├── dao │ │ │ ├── DaoMaster.java │ │ │ ├── DaoSession.java │ │ │ ├── PartDao.java │ │ │ └── WordBeanDao.java │ │ │ ├── dictionary │ │ │ ├── ChineseSearchActivity.java │ │ │ ├── DanCiBenActivity.java │ │ │ ├── DictionaryActivity.java │ │ │ ├── EnglishSearchActivity.java │ │ │ ├── FaXianFragment.java │ │ │ ├── MainActivity.java │ │ │ ├── PlanActivity.java │ │ │ ├── PlanPracticeActivity.java │ │ │ ├── SentenceTranslateActivity.java │ │ │ ├── TuijianFragment.java │ │ │ └── WoDeFragment.java │ │ │ ├── http │ │ │ ├── ApiService.java │ │ │ ├── Constants.java │ │ │ └── HttpMethods.java │ │ │ ├── util │ │ │ ├── FileUtil.java │ │ │ ├── HttpUtil.java │ │ │ └── SharedPreUtil.java │ │ │ └── view │ │ │ ├── CardAdapter.java │ │ │ ├── CardPagerAdapter.java │ │ │ ├── ShadowTransformer.java │ │ │ └── XCRoundRectImageView.java │ └── res │ │ ├── drawable-xhdpi │ │ ├── add.png │ │ ├── add_pressed.png │ │ ├── banner1.jpg │ │ ├── banner2.jpg │ │ ├── banner3.jpg │ │ ├── dictionary.png │ │ ├── edit.png │ │ ├── edit_pressed.png │ │ ├── staroff.png │ │ ├── staron.png │ │ ├── voice.png │ │ └── voice_press.png │ │ ├── drawable │ │ ├── add_selector.xml │ │ ├── but_selector.xml │ │ ├── clear_history.xml │ │ ├── edit_selector.xml │ │ ├── his_selector.xml │ │ ├── ic_bookmark_24dp.xml │ │ ├── remember.xml │ │ ├── translate.xml │ │ ├── unremember.xml │ │ └── voice_selector.xml │ │ ├── layout │ │ ├── activity_chinese_search.xml │ │ ├── activity_danciben.xml │ │ ├── activity_dictionary.xml │ │ ├── activity_english_search.xml │ │ ├── activity_main.xml │ │ ├── activity_plan_practice.xml │ │ ├── activity_planlist.xml │ │ ├── activity_sentence.xml │ │ ├── adapter.xml │ │ ├── frag_faxian.xml │ │ ├── frag_tuijian.xml │ │ ├── frag_wode.xml │ │ ├── item_danci.xml │ │ ├── item_dictionary.xml │ │ ├── item_plan.xml │ │ ├── text_his.xml │ │ ├── text_history.xml │ │ ├── text_means.xml │ │ └── view_et.xml │ │ ├── mipmap-xxhdpi │ │ ├── faxianoff.png │ │ ├── faxianon.png │ │ ├── tuijianoff.png │ │ ├── tuijianon.png │ │ ├── wodeoff.png │ │ └── wodeon.png │ │ ├── mipmap-xxxhdpi │ │ ├── banner1.jpg │ │ ├── banner2.jpg │ │ └── banner3.jpg │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── adm │ └── dictionary │ └── dictionary │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshots ├── img1.jpg ├── img2.jpg ├── img3.jpg ├── img4.jpg └── img5.jpg └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Dictionary -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 23 | 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 1.7 51 | 52 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Dictionary 2 | 单词助手,可提供单词中英文的翻译,以及长句子的翻译。另外,可对感兴趣的单词加入本地生词本,以及新建复习计划。做完这个感觉RxJavax真的不是一般的强,Retrofit和greenDAO都提供了对其的支持,让你开发起来更加便捷。因为做的比较仓促,自己也刚刚接触MVP,没有用到MVP,z还是很遗憾的。 3 | *** 4 | 下面是這個項目中使用的第三方框架,感谢开源的小伙伴~另外感谢金山词霸提供的API 5 | 6 | * Retrofit 网络请求 7 | * RxJava+RxAndroid 响应式编程配合请求 8 | * GreenDAO3.0 本地数据库存储 9 | * CardView 卡片布局 10 | * CBDDialog (做的很漂亮的Dialog) 11 | 12 | ######截图# 13 | 14 | > 15 | > 16 | > 17 | > 18 | > 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | } 7 | dependencies { 8 | classpath 'org.greenrobot:greendao-gradle-plugin:3.1.0' 9 | } 10 | } 11 | apply plugin: 'org.greenrobot.greendao' 12 | android { 13 | compileSdkVersion 23 14 | buildToolsVersion "23.0.1" 15 | 16 | defaultConfig { 17 | applicationId "com.adm.dictionary.dictionary" 18 | minSdkVersion 16 19 | targetSdkVersion 23 20 | versionCode 1 21 | versionName "1.0" 22 | } 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | } 30 | 31 | dependencies { 32 | compile fileTree(dir: 'libs', include: ['*.jar']) 33 | testCompile 'junit:junit:4.12' 34 | compile 'io.reactivex:rxjava:1.1.0' 35 | compile 'io.reactivex:rxandroid:1.1.0' 36 | compile 'com.android.support:appcompat-v7:23.0.1' 37 | compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4' 38 | compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' 39 | compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4' 40 | compile 'com.squareup.okhttp3:logging-interceptor:3.1.2' 41 | compile 'com.github.bumptech.glide:glide:3.5.2' 42 | compile 'com.android.support:support-v4:23.0.1' 43 | compile 'org.greenrobot:greendao:3.1.0' 44 | compile 'com.android.support:cardview-v7:23.0.1' 45 | compile 'com.zhl.cbdialog:CBDialog:1.0.0' 46 | } 47 | //配置GreenDao代码生成路径 48 | greendao { 49 | //数据库schema版本号,迁移等操作会用到 50 | schemaVersion 1 51 | //通过gradle插件生成的数据库相关文件的包名,默认为你的entity所在的包名 52 | daoPackage 'com.adm.dictionary.dao' 53 | //这就是我们上面说到的自定义生成数据库文件的目录了,可以将生成的文件放到我们的java目录中,而不是build中,这样就不用额外的设置资源目录了 54 | targetGenDir 'src/main/java' 55 | } 56 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\adt-bundle-windows-x86_64-20130219\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/adm/dictionary/dictionary/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/assets/dictionary.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/assets/dictionary.db -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/app/MyApp.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.app; 2 | 3 | import android.app.Application; 4 | 5 | import com.adm.dictionary.dao.DaoMaster; 6 | import com.adm.dictionary.dao.DaoSession; 7 | 8 | import org.greenrobot.greendao.database.Database; 9 | 10 | 11 | /** 12 | * APP入口 13 | * Created by Administrator on 2016/10/24. 14 | */ 15 | public class MyApp extends Application { 16 | 17 | private DaoSession daoSession; 18 | 19 | @Override 20 | public void onCreate() { 21 | super.onCreate(); 22 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(this, "word_db" ); 23 | Database db = helper.getReadableDb(); 24 | daoSession = new DaoMaster(db).newSession(); 25 | } 26 | 27 | public DaoSession getDaoSession(){ 28 | return daoSession; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.base; 2 | 3 | import android.support.v4.app.FragmentActivity; 4 | import android.widget.Button; 5 | import android.widget.EditText; 6 | import android.widget.ImageView; 7 | import android.widget.LinearLayout; 8 | import android.widget.TextView; 9 | import android.widget.Toast; 10 | 11 | /** 12 | * Created by Administrator on 2016/10/18. 13 | */ 14 | public abstract class BaseActivity extends FragmentActivity { 15 | 16 | public TextView findTextViewById(int id) { 17 | return (TextView) findViewById(id); 18 | } 19 | 20 | public ImageView findImageViewById(int id) { 21 | return (ImageView) findViewById(id); 22 | } 23 | 24 | public LinearLayout findLinById(int id) { 25 | return (LinearLayout) findViewById(id); 26 | } 27 | 28 | public EditText findEtnById(int id) { 29 | return (EditText) findViewById(id); 30 | } 31 | 32 | public Button findButById(int id) { 33 | return (Button) findViewById(id); 34 | } 35 | 36 | public void showToast(String str) { 37 | Toast.makeText(this, str, Toast.LENGTH_SHORT).show(); 38 | } 39 | 40 | public abstract void initView(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.base; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.view.View; 5 | import android.widget.Button; 6 | import android.widget.EditText; 7 | import android.widget.ImageView; 8 | import android.widget.LinearLayout; 9 | import android.widget.TextView; 10 | import android.widget.Toast; 11 | 12 | /** 13 | * Created by Administrator on 2016/10/18. 14 | */ 15 | public abstract class BaseFragment extends Fragment { 16 | 17 | public TextView findTextViewbyId(View v, int id) { 18 | return (TextView) v.findViewById(id); 19 | } 20 | 21 | public ImageView findImageViewbyId(View v, int id) { 22 | return (ImageView) v.findViewById(id); 23 | } 24 | 25 | public LinearLayout findLinbyId(View v, int id) { 26 | return (LinearLayout) v.findViewById(id); 27 | } 28 | 29 | public EditText findEtbyId(View v, int id) { 30 | return (EditText) v.findViewById(id); 31 | } 32 | 33 | public Button findButById(View v, int id) { 34 | return (Button) v.findViewById(id); 35 | } 36 | 37 | public void showToast(String str) { 38 | Toast.makeText(getActivity(), str, Toast.LENGTH_SHORT).show(); 39 | } 40 | 41 | public abstract void initView(); 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/ChineseBean.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 返回为中文信息的Bean 7 | * Created by Administrator on 2016/10/18. 8 | */ 9 | public class ChineseBean { 10 | private String word_name; 11 | private List symbols; 12 | 13 | public String getWord_name() { 14 | return word_name; 15 | } 16 | 17 | public void setWord_name(String word_name) { 18 | this.word_name = word_name; 19 | } 20 | 21 | public List getSymbols() { 22 | return symbols; 23 | } 24 | 25 | public void setSymbols(List symbols) { 26 | this.symbols = symbols; 27 | } 28 | 29 | public class Symbol{ 30 | private String word_symbol; 31 | private String symbol_mp3; 32 | private List parts; 33 | private String ph_am_mp3; 34 | private String ph_en_mp3; 35 | private String ph_tts_mp3; 36 | private String ph_other; 37 | 38 | public String getWord_symbol() { 39 | return word_symbol; 40 | } 41 | 42 | public void setWord_symbol(String word_symbol) { 43 | this.word_symbol = word_symbol; 44 | } 45 | 46 | public String getSymbol_mp3() { 47 | return symbol_mp3; 48 | } 49 | 50 | public void setSymbol_mp3(String symbol_mp3) { 51 | this.symbol_mp3 = symbol_mp3; 52 | } 53 | 54 | public List getParts() { 55 | return parts; 56 | } 57 | 58 | public void setParts(List parts) { 59 | this.parts = parts; 60 | } 61 | 62 | public String getPh_am_mp3() { 63 | return ph_am_mp3; 64 | } 65 | 66 | public void setPh_am_mp3(String ph_am_mp3) { 67 | this.ph_am_mp3 = ph_am_mp3; 68 | } 69 | 70 | public String getPh_en_mp3() { 71 | return ph_en_mp3; 72 | } 73 | 74 | public void setPh_en_mp3(String ph_en_mp3) { 75 | this.ph_en_mp3 = ph_en_mp3; 76 | } 77 | 78 | public String getPh_tts_mp3() { 79 | return ph_tts_mp3; 80 | } 81 | 82 | public void setPh_tts_mp3(String ph_tts_mp3) { 83 | this.ph_tts_mp3 = ph_tts_mp3; 84 | } 85 | 86 | public String getPh_other() { 87 | return ph_other; 88 | } 89 | 90 | public void setPh_other(String ph_other) { 91 | this.ph_other = ph_other; 92 | } 93 | 94 | public class Parts{ 95 | private String part_name; 96 | private List means; 97 | 98 | public String getPart_name() { 99 | return part_name; 100 | } 101 | 102 | public void setPart_name(String part_name) { 103 | this.part_name = part_name; 104 | } 105 | 106 | public List getMeans() { 107 | return means; 108 | } 109 | 110 | public void setMeans(List means) { 111 | this.means = means; 112 | } 113 | 114 | public class Means{ 115 | private String word_mean; 116 | private String has_mean; 117 | private String split; 118 | 119 | public String getWord_mean() { 120 | return word_mean; 121 | } 122 | 123 | public void setWord_mean(String word_mean) { 124 | this.word_mean = word_mean; 125 | } 126 | 127 | public String getHas_mean() { 128 | return has_mean; 129 | } 130 | 131 | public void setHas_mean(String has_mean) { 132 | this.has_mean = has_mean; 133 | } 134 | 135 | public String getSplit() { 136 | return split; 137 | } 138 | 139 | public void setSplit(String split) { 140 | this.split = split; 141 | } 142 | } 143 | } 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/DictionaryBean.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | /** 4 | * 本地词库的Bean 5 | * Created by Administrator on 2016/10/28. 6 | */ 7 | public class DictionaryBean { 8 | private String english; 9 | private String chinese; 10 | 11 | public String getEnglish() { 12 | return english; 13 | } 14 | 15 | public void setEnglish(String english) { 16 | this.english = english; 17 | } 18 | 19 | public String getChinese() { 20 | return chinese; 21 | } 22 | 23 | public void setChinese(String chinese) { 24 | this.chinese = chinese; 25 | } 26 | 27 | public DictionaryBean(String english, String chinese) { 28 | this.english = english; 29 | this.chinese = chinese; 30 | } 31 | 32 | public DictionaryBean() { 33 | } 34 | 35 | @Override 36 | public String toString() { 37 | return "DictionaryBean{" + 38 | "english='" + english + '\'' + 39 | ", chinese='" + chinese + '\'' + 40 | '}'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/EnglishBean.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * 返回为英文信息的Bean 7 | * Created by Administrator on 2016/10/18. 8 | */ 9 | public class EnglishBean { 10 | private String word_name; 11 | private String is_CRI; 12 | private List symbols; 13 | 14 | public String getWord_name() { 15 | return word_name; 16 | } 17 | 18 | public void setWord_name(String word_name) { 19 | this.word_name = word_name; 20 | } 21 | 22 | public String getIs_CRI() { 23 | return is_CRI; 24 | } 25 | 26 | public void setIs_CRI(String is_CRI) { 27 | this.is_CRI = is_CRI; 28 | } 29 | 30 | public List getSymbols() { 31 | return symbols; 32 | } 33 | 34 | public void setSymbols(List symbols) { 35 | this.symbols = symbols; 36 | } 37 | 38 | public class Symbols{ 39 | private String ph_en; 40 | private String ph_am; 41 | private String ph_other; 42 | private String ph_en_mp3; 43 | private String ph_am_mp3; 44 | private String ph_tts_mp3; 45 | private List parts; 46 | 47 | public class Parts{ 48 | private String part; 49 | private List means; 50 | 51 | public String getPart() { 52 | return part; 53 | } 54 | 55 | public void setPart(String part) { 56 | this.part = part; 57 | } 58 | 59 | public List getMeans() { 60 | return means; 61 | } 62 | 63 | public void setMeans(List means) { 64 | this.means = means; 65 | } 66 | } 67 | 68 | public String getPh_en() { 69 | return ph_en; 70 | } 71 | 72 | public void setPh_en(String ph_en) { 73 | this.ph_en = ph_en; 74 | } 75 | 76 | public String getPh_am() { 77 | return ph_am; 78 | } 79 | 80 | public void setPh_am(String ph_am) { 81 | this.ph_am = ph_am; 82 | } 83 | 84 | public String getPh_other() { 85 | return ph_other; 86 | } 87 | 88 | public void setPh_other(String ph_other) { 89 | this.ph_other = ph_other; 90 | } 91 | 92 | public String getPh_en_mp3() { 93 | return ph_en_mp3; 94 | } 95 | 96 | public void setPh_en_mp3(String ph_en_mp3) { 97 | this.ph_en_mp3 = ph_en_mp3; 98 | } 99 | 100 | public String getPh_am_mp3() { 101 | return ph_am_mp3; 102 | } 103 | 104 | public void setPh_am_mp3(String ph_am_mp3) { 105 | this.ph_am_mp3 = ph_am_mp3; 106 | } 107 | 108 | public String getPh_tts_mp3() { 109 | return ph_tts_mp3; 110 | } 111 | 112 | public void setPh_tts_mp3(String ph_tts_mp3) { 113 | this.ph_tts_mp3 = ph_tts_mp3; 114 | } 115 | 116 | public List getParts() { 117 | return parts; 118 | } 119 | 120 | public void setParts(List parts) { 121 | this.parts = parts; 122 | } 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/EveryDayWords.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Administrator on 2016/10/18. 7 | */ 8 | public class EveryDayWords { 9 | private String sid; 10 | private String tts; 11 | private String content; 12 | private String note; 13 | private String love; 14 | private String translation; 15 | private String picture; 16 | private String picture2; 17 | private String caption; 18 | private String dateline; 19 | private String s_pv; 20 | private String sp_pv; 21 | private List tags; 22 | 23 | public String getSid() { 24 | return sid; 25 | } 26 | 27 | public void setSid(String sid) { 28 | this.sid = sid; 29 | } 30 | 31 | public String getContent() { 32 | return content; 33 | } 34 | 35 | public void setContent(String content) { 36 | this.content = content; 37 | } 38 | 39 | public String getTts() { 40 | return tts; 41 | } 42 | 43 | public void setTts(String tts) { 44 | this.tts = tts; 45 | } 46 | 47 | public String getNote() { 48 | return note; 49 | } 50 | 51 | public void setNote(String note) { 52 | this.note = note; 53 | } 54 | 55 | public String getLove() { 56 | return love; 57 | } 58 | 59 | public void setLove(String love) { 60 | this.love = love; 61 | } 62 | 63 | public String getTranslation() { 64 | return translation; 65 | } 66 | 67 | public void setTranslation(String translation) { 68 | this.translation = translation; 69 | } 70 | 71 | public String getPicture() { 72 | return picture; 73 | } 74 | 75 | public void setPicture(String picture) { 76 | this.picture = picture; 77 | } 78 | 79 | public String getCaption() { 80 | return caption; 81 | } 82 | 83 | public void setCaption(String caption) { 84 | this.caption = caption; 85 | } 86 | 87 | public String getPicture2() { 88 | return picture2; 89 | } 90 | 91 | public void setPicture2(String picture2) { 92 | this.picture2 = picture2; 93 | } 94 | 95 | public String getDateline() { 96 | return dateline; 97 | } 98 | 99 | public void setDateline(String dateline) { 100 | this.dateline = dateline; 101 | } 102 | 103 | public String getS_pv() { 104 | return s_pv; 105 | } 106 | 107 | public void setS_pv(String s_pv) { 108 | this.s_pv = s_pv; 109 | } 110 | 111 | public String getSp_pv() { 112 | return sp_pv; 113 | } 114 | 115 | public void setSp_pv(String sp_pv) { 116 | this.sp_pv = sp_pv; 117 | } 118 | 119 | public List getTags() { 120 | return tags; 121 | } 122 | 123 | public void setTags(List tags) { 124 | this.tags = tags; 125 | } 126 | 127 | class Tag{ 128 | private String id; 129 | private String name; 130 | 131 | public String getName() { 132 | return name; 133 | } 134 | 135 | public void setName(String name) { 136 | this.name = name; 137 | } 138 | 139 | public String getId() { 140 | return id; 141 | } 142 | 143 | public void setId(String id) { 144 | this.id = id; 145 | } 146 | } 147 | 148 | 149 | 150 | } 151 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/Part.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import org.greenrobot.greendao.annotation.Entity; 4 | import org.greenrobot.greendao.annotation.Id; 5 | 6 | import java.util.List; 7 | 8 | import org.greenrobot.greendao.annotation.Generated; 9 | 10 | /** 11 | * Created by Administrator on 2016/10/24. 12 | */ 13 | @Entity 14 | public class Part { 15 | @Id 16 | private Long id; 17 | private Long wordId; 18 | private String part; 19 | private String means; 20 | 21 | public Long getWordId() { 22 | return wordId; 23 | } 24 | 25 | public void setWordId(Long wordId) { 26 | this.wordId = wordId; 27 | } 28 | 29 | public Part(String part, String means) { 30 | this.part = part; 31 | this.means = means; 32 | } 33 | 34 | 35 | @Generated(hash = 1811726784) 36 | public Part(Long id, Long wordId, String part, String means) { 37 | this.id = id; 38 | this.wordId = wordId; 39 | this.part = part; 40 | this.means = means; 41 | } 42 | 43 | @Generated(hash = 130301790) 44 | public Part() { 45 | } 46 | 47 | 48 | public String getMeans() { 49 | return this.means; 50 | } 51 | 52 | public void setMeans(String means) { 53 | this.means = means; 54 | } 55 | 56 | public String getPart() { 57 | return this.part; 58 | } 59 | 60 | public void setPart(String part) { 61 | this.part = part; 62 | } 63 | 64 | public Long getId() { 65 | return this.id; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "Part{" + 71 | "id=" + id + 72 | ", part='" + part + '\'' + 73 | ", means='" + means + '\'' + 74 | '}'; 75 | } 76 | 77 | public void setId(Long id) { 78 | this.id = id; 79 | } 80 | } -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/PlanCount.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | /** 4 | * Created by Administrator on 2016/10/26. 5 | */ 6 | public class PlanCount { 7 | private long total; 8 | private long done; 9 | 10 | public long getTotal() { 11 | return total; 12 | } 13 | 14 | public void setTotal(long total) { 15 | this.total = total; 16 | } 17 | 18 | public long getDone() { 19 | return done; 20 | } 21 | 22 | public void setDone(long dong) { 23 | this.done = done; 24 | } 25 | 26 | public PlanCount(long total, long done) { 27 | this.total = total; 28 | this.done = done; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/SentenceBean.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import com.google.gson.annotations.SerializedName; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * 查询句子的返回的Bean 9 | * Created by Administrator on 2016/10/17. 10 | */ 11 | public class SentenceBean { 12 | 13 | private List translation; 14 | private Basic basic; 15 | private String query; 16 | private String errorCode; 17 | private List web; 18 | 19 | public List getWeb() { 20 | return web; 21 | } 22 | 23 | public void setWeb(List web) { 24 | this.web = web; 25 | } 26 | 27 | public List getTranslation() { 28 | return translation; 29 | } 30 | 31 | public void setTranslation(List translation) { 32 | this.translation = translation; 33 | } 34 | 35 | public Basic getBasic() { 36 | return basic; 37 | } 38 | 39 | public void setBasic(Basic basic) { 40 | this.basic = basic; 41 | } 42 | 43 | public String getQuery() { 44 | return query; 45 | } 46 | 47 | public void setQuery(String query) { 48 | this.query = query; 49 | } 50 | 51 | public String getErrorCode() { 52 | return errorCode; 53 | } 54 | 55 | public void setErrorCode(String errorCode) { 56 | this.errorCode = errorCode; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "SentenceBean{" + 62 | "translation=" + translation + 63 | ", basic=" + basic + 64 | ", query='" + query + '\'' + 65 | ", errorCode='" + errorCode + '\'' + 66 | ", web=" + web + 67 | '}'; 68 | } 69 | 70 | class Basic { 71 | @SerializedName("us-phonetic") private String us_phonetic; 72 | private String phonetic; 73 | @SerializedName("uk-phonetic") private String uk_phonetic; 74 | private List explains; 75 | 76 | public String getUs_phonetic() { 77 | return us_phonetic; 78 | } 79 | 80 | public void setUs_phonetic(String us_phonetic) { 81 | this.us_phonetic = us_phonetic; 82 | } 83 | 84 | public String getPhonetic() { 85 | return phonetic; 86 | } 87 | 88 | public void setPhonetic(String phonetic) { 89 | this.phonetic = phonetic; 90 | } 91 | 92 | public String getUk_phonetic() { 93 | return uk_phonetic; 94 | } 95 | 96 | public void setUk_phonetic(String uk_phonetic) { 97 | this.uk_phonetic = uk_phonetic; 98 | } 99 | 100 | public List getExplains() { 101 | return explains; 102 | } 103 | 104 | public void setExplains(List explains) { 105 | this.explains = explains; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "Basic{" + 111 | "us_phonetic='" + us_phonetic + '\'' + 112 | ", phonetic='" + phonetic + '\'' + 113 | ", uk_phonetic='" + uk_phonetic + '\'' + 114 | ", explains=" + explains + 115 | '}'; 116 | } 117 | } 118 | 119 | class Web{ 120 | private String key; 121 | private List value; 122 | 123 | @Override 124 | public String toString() { 125 | return "Web{" + 126 | "key='" + key + '\'' + 127 | ", value=" + value + 128 | '}'; 129 | } 130 | 131 | public String getKey() { 132 | return key; 133 | } 134 | 135 | public void setKey(String key) { 136 | this.key = key; 137 | } 138 | 139 | public List getValue() { 140 | return value; 141 | } 142 | 143 | public void setValue(List value) { 144 | this.value = value; 145 | } 146 | } 147 | 148 | 149 | } 150 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/bean/WordBean.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.bean; 2 | 3 | import org.greenrobot.greendao.annotation.Entity; 4 | import org.greenrobot.greendao.annotation.Generated; 5 | import org.greenrobot.greendao.annotation.Id; 6 | import org.greenrobot.greendao.annotation.ToMany; 7 | 8 | import java.util.List; 9 | 10 | import org.greenrobot.greendao.DaoException; 11 | import org.greenrobot.greendao.annotation.Transient; 12 | 13 | import com.adm.dictionary.dao.DaoSession; 14 | import com.adm.dictionary.dao.WordBeanDao; 15 | import com.adm.dictionary.dao.PartDao; 16 | 17 | /** 18 | * 生词本的Bean 19 | * Created by Administrator on 2016/10/24. 20 | */ 21 | @Entity 22 | public class WordBean { 23 | @Id(autoincrement = true) 24 | private Long id; 25 | private String name; 26 | private String en_sympol; 27 | private String am_symbol; 28 | private String en_mp3; 29 | private String am_mp3; 30 | private String groupName; 31 | @Transient 32 | private boolean checked; 33 | private boolean done; 34 | 35 | public boolean isDone() { 36 | return done; 37 | } 38 | 39 | public void setDone(boolean done) { 40 | this.done = done; 41 | } 42 | 43 | public boolean isChecked() { 44 | return checked; 45 | } 46 | 47 | public void setChecked(boolean checked) { 48 | this.checked = checked; 49 | } 50 | 51 | public String getGroupName() { 52 | return groupName; 53 | } 54 | 55 | public void setGroupName(String groupName) { 56 | this.groupName = groupName; 57 | } 58 | 59 | @ToMany(referencedJoinProperty = "wordId") 60 | private List parts; 61 | /** 62 | * Used for active entity operations. 63 | */ 64 | @Generated(hash = 2056944827) 65 | private transient WordBeanDao myDao; 66 | /** 67 | * Used to resolve relations 68 | */ 69 | @Generated(hash = 2040040024) 70 | private transient DaoSession daoSession; 71 | 72 | 73 | public Long getId() { 74 | return id; 75 | } 76 | 77 | public void setId(Long id) { 78 | this.id = id; 79 | } 80 | 81 | /** 82 | * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}. 83 | * Entity must attached to an entity context. 84 | */ 85 | @Generated(hash = 1942392019) 86 | public void refresh() { 87 | if (myDao == null) { 88 | throw new DaoException("Entity is detached from DAO context"); 89 | } 90 | myDao.refresh(this); 91 | } 92 | 93 | /** 94 | * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}. 95 | * Entity must attached to an entity context. 96 | */ 97 | @Generated(hash = 713229351) 98 | public void update() { 99 | if (myDao == null) { 100 | throw new DaoException("Entity is detached from DAO context"); 101 | } 102 | myDao.update(this); 103 | } 104 | 105 | /** 106 | * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}. 107 | * Entity must attached to an entity context. 108 | */ 109 | @Generated(hash = 128553479) 110 | public void delete() { 111 | if (myDao == null) { 112 | throw new DaoException("Entity is detached from DAO context"); 113 | } 114 | myDao.delete(this); 115 | } 116 | 117 | /** 118 | * Resets a to-many relationship, making the next get call to query for a fresh result. 119 | */ 120 | @Generated(hash = 352649916) 121 | public synchronized void resetParts() { 122 | parts = null; 123 | } 124 | 125 | /** 126 | * To-many relationship, resolved on first access (and after reset). 127 | * Changes to to-many relations are not persisted, make changes to the target entity. 128 | */ 129 | @Generated(hash = 1228913115) 130 | public List getParts() { 131 | if (parts == null) { 132 | final DaoSession daoSession = this.daoSession; 133 | if (daoSession == null) { 134 | throw new DaoException("Entity is detached from DAO context"); 135 | } 136 | PartDao targetDao = daoSession.getPartDao(); 137 | List partsNew = targetDao._queryWordBean_Parts(id); 138 | synchronized (this) { 139 | if (parts == null) { 140 | parts = partsNew; 141 | } 142 | } 143 | } 144 | return parts; 145 | } 146 | 147 | public String getAm_mp3() { 148 | return this.am_mp3; 149 | } 150 | 151 | public void setAm_mp3(String am_mp3) { 152 | this.am_mp3 = am_mp3; 153 | } 154 | 155 | public String getEn_mp3() { 156 | return this.en_mp3; 157 | } 158 | 159 | public void setEn_mp3(String en_mp3) { 160 | this.en_mp3 = en_mp3; 161 | } 162 | 163 | public String getAm_symbol() { 164 | return this.am_symbol; 165 | } 166 | 167 | public void setAm_symbol(String am_symbol) { 168 | this.am_symbol = am_symbol; 169 | } 170 | 171 | public String getEn_sympol() { 172 | return this.en_sympol; 173 | } 174 | 175 | public void setEn_sympol(String en_sympol) { 176 | this.en_sympol = en_sympol; 177 | } 178 | 179 | public String getName() { 180 | return this.name; 181 | } 182 | 183 | public void setName(String name) { 184 | this.name = name; 185 | } 186 | 187 | /** 188 | * called by internal mechanisms, do not call yourself. 189 | */ 190 | @Generated(hash = 954740466) 191 | public void __setDaoSession(DaoSession daoSession) { 192 | this.daoSession = daoSession; 193 | myDao = daoSession != null ? daoSession.getWordBeanDao() : null; 194 | } 195 | 196 | public WordBean(Long id, String name, String en_sympol, String am_symbol, String en_mp3, String am_mp3, String groupName, List parts) { 197 | this.id = id; 198 | this.name = name; 199 | this.en_sympol = en_sympol; 200 | this.am_symbol = am_symbol; 201 | this.en_mp3 = en_mp3; 202 | this.am_mp3 = am_mp3; 203 | this.groupName = groupName; 204 | this.parts = parts; 205 | } 206 | 207 | @Generated(hash = 477143817) 208 | public WordBean(Long id, String name, String en_sympol, String am_symbol, String en_mp3, String am_mp3, String groupName, boolean done) { 209 | this.id = id; 210 | this.name = name; 211 | this.en_sympol = en_sympol; 212 | this.am_symbol = am_symbol; 213 | this.en_mp3 = en_mp3; 214 | this.am_mp3 = am_mp3; 215 | this.groupName = groupName; 216 | this.done = done; 217 | } 218 | 219 | @Generated(hash = 1596526216) 220 | public WordBean() { 221 | } 222 | 223 | public void setParts(List parts) { 224 | this.parts = parts; 225 | } 226 | 227 | @Override 228 | public String toString() { 229 | return "WordBean{" + 230 | "id=" + id + 231 | ", name='" + name + '\'' + 232 | ", en_sympol='" + en_sympol + '\'' + 233 | ", am_symbol='" + am_symbol + '\'' + 234 | ", en_mp3='" + en_mp3 + '\'' + 235 | ", am_mp3='" + am_mp3 + '\'' + 236 | ", groupName='" + groupName + '\'' + 237 | ", checked=" + checked + 238 | ", parts=" + parts + 239 | '}'; 240 | } 241 | 242 | public boolean getDone() { 243 | return this.done; 244 | } 245 | } 246 | 247 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dao/DaoMaster.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dao; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteDatabase.CursorFactory; 6 | import android.util.Log; 7 | 8 | import org.greenrobot.greendao.AbstractDaoMaster; 9 | import org.greenrobot.greendao.database.StandardDatabase; 10 | import org.greenrobot.greendao.database.Database; 11 | import org.greenrobot.greendao.database.DatabaseOpenHelper; 12 | import org.greenrobot.greendao.identityscope.IdentityScopeType; 13 | 14 | 15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 16 | /** 17 | * Master of DAO (schema version 1): knows all DAOs. 18 | */ 19 | public class DaoMaster extends AbstractDaoMaster { 20 | public static final int SCHEMA_VERSION = 1; 21 | 22 | /** Creates underlying database table using DAOs. */ 23 | public static void createAllTables(Database db, boolean ifNotExists) { 24 | PartDao.createTable(db, ifNotExists); 25 | WordBeanDao.createTable(db, ifNotExists); 26 | } 27 | 28 | /** Drops underlying database table using DAOs. */ 29 | public static void dropAllTables(Database db, boolean ifExists) { 30 | PartDao.dropTable(db, ifExists); 31 | WordBeanDao.dropTable(db, ifExists); 32 | } 33 | 34 | /** 35 | * WARNING: Drops all table on Upgrade! Use only during development. 36 | * Convenience method using a {@link DevOpenHelper}. 37 | */ 38 | public static DaoSession newDevSession(Context context, String name) { 39 | Database db = new DevOpenHelper(context, name).getWritableDb(); 40 | DaoMaster daoMaster = new DaoMaster(db); 41 | return daoMaster.newSession(); 42 | } 43 | 44 | public DaoMaster(SQLiteDatabase db) { 45 | this(new StandardDatabase(db)); 46 | } 47 | 48 | public DaoMaster(Database db) { 49 | super(db, SCHEMA_VERSION); 50 | registerDaoClass(PartDao.class); 51 | registerDaoClass(WordBeanDao.class); 52 | } 53 | 54 | public DaoSession newSession() { 55 | return new DaoSession(db, IdentityScopeType.Session, daoConfigMap); 56 | } 57 | 58 | public DaoSession newSession(IdentityScopeType type) { 59 | return new DaoSession(db, type, daoConfigMap); 60 | } 61 | 62 | /** 63 | * Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} - 64 | */ 65 | public static abstract class OpenHelper extends DatabaseOpenHelper { 66 | public OpenHelper(Context context, String name) { 67 | super(context, name, SCHEMA_VERSION); 68 | } 69 | 70 | public OpenHelper(Context context, String name, CursorFactory factory) { 71 | super(context, name, factory, SCHEMA_VERSION); 72 | } 73 | 74 | @Override 75 | public void onCreate(Database db) { 76 | Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION); 77 | createAllTables(db, false); 78 | } 79 | } 80 | 81 | /** WARNING: Drops all table on Upgrade! Use only during development. */ 82 | public static class DevOpenHelper extends OpenHelper { 83 | public DevOpenHelper(Context context, String name) { 84 | super(context, name); 85 | } 86 | 87 | public DevOpenHelper(Context context, String name, CursorFactory factory) { 88 | super(context, name, factory); 89 | } 90 | 91 | @Override 92 | public void onUpgrade(Database db, int oldVersion, int newVersion) { 93 | Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables"); 94 | dropAllTables(db, true); 95 | onCreate(db); 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dao/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dao; 2 | 3 | import java.util.Map; 4 | 5 | import org.greenrobot.greendao.AbstractDao; 6 | import org.greenrobot.greendao.AbstractDaoSession; 7 | import org.greenrobot.greendao.database.Database; 8 | import org.greenrobot.greendao.identityscope.IdentityScopeType; 9 | import org.greenrobot.greendao.internal.DaoConfig; 10 | 11 | import com.adm.dictionary.bean.Part; 12 | import com.adm.dictionary.bean.WordBean; 13 | 14 | import com.adm.dictionary.dao.PartDao; 15 | import com.adm.dictionary.dao.WordBeanDao; 16 | 17 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 18 | 19 | /** 20 | * {@inheritDoc} 21 | * 22 | * @see org.greenrobot.greendao.AbstractDaoSession 23 | */ 24 | public class DaoSession extends AbstractDaoSession { 25 | 26 | private final DaoConfig partDaoConfig; 27 | private final DaoConfig wordBeanDaoConfig; 28 | 29 | private final PartDao partDao; 30 | private final WordBeanDao wordBeanDao; 31 | 32 | public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig> 33 | daoConfigMap) { 34 | super(db); 35 | 36 | partDaoConfig = daoConfigMap.get(PartDao.class).clone(); 37 | partDaoConfig.initIdentityScope(type); 38 | 39 | wordBeanDaoConfig = daoConfigMap.get(WordBeanDao.class).clone(); 40 | wordBeanDaoConfig.initIdentityScope(type); 41 | 42 | partDao = new PartDao(partDaoConfig, this); 43 | wordBeanDao = new WordBeanDao(wordBeanDaoConfig, this); 44 | 45 | registerDao(Part.class, partDao); 46 | registerDao(WordBean.class, wordBeanDao); 47 | } 48 | 49 | public void clear() { 50 | partDaoConfig.clearIdentityScope(); 51 | wordBeanDaoConfig.clearIdentityScope(); 52 | } 53 | 54 | public PartDao getPartDao() { 55 | return partDao; 56 | } 57 | 58 | public WordBeanDao getWordBeanDao() { 59 | return wordBeanDao; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dao/PartDao.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dao; 2 | 3 | import java.util.List; 4 | import android.database.Cursor; 5 | import android.database.sqlite.SQLiteStatement; 6 | 7 | import org.greenrobot.greendao.AbstractDao; 8 | import org.greenrobot.greendao.Property; 9 | import org.greenrobot.greendao.internal.DaoConfig; 10 | import org.greenrobot.greendao.database.Database; 11 | import org.greenrobot.greendao.database.DatabaseStatement; 12 | import org.greenrobot.greendao.query.Query; 13 | import org.greenrobot.greendao.query.QueryBuilder; 14 | 15 | import com.adm.dictionary.bean.Part; 16 | 17 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 18 | /** 19 | * DAO for table "PART". 20 | */ 21 | public class PartDao extends AbstractDao { 22 | 23 | public static final String TABLENAME = "PART"; 24 | 25 | /** 26 | * Properties of entity Part.
27 | * Can be used for QueryBuilder and for referencing column names. 28 | */ 29 | public static class Properties { 30 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 31 | public final static Property WordId = new Property(1, Long.class, "wordId", false, "WORD_ID"); 32 | public final static Property Part = new Property(2, String.class, "part", false, "PART"); 33 | public final static Property Means = new Property(3, String.class, "means", false, "MEANS"); 34 | } 35 | 36 | private Query wordBean_PartsQuery; 37 | 38 | public PartDao(DaoConfig config) { 39 | super(config); 40 | } 41 | 42 | public PartDao(DaoConfig config, DaoSession daoSession) { 43 | super(config, daoSession); 44 | } 45 | 46 | /** Creates the underlying database table. */ 47 | public static void createTable(Database db, boolean ifNotExists) { 48 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 49 | db.execSQL("CREATE TABLE " + constraint + "\"PART\" (" + // 50 | "\"_id\" INTEGER PRIMARY KEY ," + // 0: id 51 | "\"WORD_ID\" INTEGER," + // 1: wordId 52 | "\"PART\" TEXT," + // 2: part 53 | "\"MEANS\" TEXT);"); // 3: means 54 | } 55 | 56 | /** Drops the underlying database table. */ 57 | public static void dropTable(Database db, boolean ifExists) { 58 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PART\""; 59 | db.execSQL(sql); 60 | } 61 | 62 | @Override 63 | protected final void bindValues(DatabaseStatement stmt, Part entity) { 64 | stmt.clearBindings(); 65 | 66 | Long id = entity.getId(); 67 | if (id != null) { 68 | stmt.bindLong(1, id); 69 | } 70 | 71 | Long wordId = entity.getWordId(); 72 | if (wordId != null) { 73 | stmt.bindLong(2, wordId); 74 | } 75 | 76 | String part = entity.getPart(); 77 | if (part != null) { 78 | stmt.bindString(3, part); 79 | } 80 | 81 | String means = entity.getMeans(); 82 | if (means != null) { 83 | stmt.bindString(4, means); 84 | } 85 | } 86 | 87 | @Override 88 | protected final void bindValues(SQLiteStatement stmt, Part entity) { 89 | stmt.clearBindings(); 90 | 91 | Long id = entity.getId(); 92 | if (id != null) { 93 | stmt.bindLong(1, id); 94 | } 95 | 96 | Long wordId = entity.getWordId(); 97 | if (wordId != null) { 98 | stmt.bindLong(2, wordId); 99 | } 100 | 101 | String part = entity.getPart(); 102 | if (part != null) { 103 | stmt.bindString(3, part); 104 | } 105 | 106 | String means = entity.getMeans(); 107 | if (means != null) { 108 | stmt.bindString(4, means); 109 | } 110 | } 111 | 112 | @Override 113 | public Long readKey(Cursor cursor, int offset) { 114 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 115 | } 116 | 117 | @Override 118 | public Part readEntity(Cursor cursor, int offset) { 119 | Part entity = new Part( // 120 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 121 | cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // wordId 122 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // part 123 | cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // means 124 | ); 125 | return entity; 126 | } 127 | 128 | @Override 129 | public void readEntity(Cursor cursor, Part entity, int offset) { 130 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 131 | entity.setWordId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1)); 132 | entity.setPart(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); 133 | entity.setMeans(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); 134 | } 135 | 136 | @Override 137 | protected final Long updateKeyAfterInsert(Part entity, long rowId) { 138 | entity.setId(rowId); 139 | return rowId; 140 | } 141 | 142 | @Override 143 | public Long getKey(Part entity) { 144 | if(entity != null) { 145 | return entity.getId(); 146 | } else { 147 | return null; 148 | } 149 | } 150 | 151 | @Override 152 | public boolean hasKey(Part entity) { 153 | return entity.getId() != null; 154 | } 155 | 156 | @Override 157 | protected final boolean isEntityUpdateable() { 158 | return true; 159 | } 160 | 161 | /** Internal query to resolve the "parts" to-many relationship of WordBean. */ 162 | public List _queryWordBean_Parts(Long wordId) { 163 | synchronized (this) { 164 | if (wordBean_PartsQuery == null) { 165 | QueryBuilder queryBuilder = queryBuilder(); 166 | queryBuilder.where(Properties.WordId.eq(null)); 167 | wordBean_PartsQuery = queryBuilder.build(); 168 | } 169 | } 170 | Query query = wordBean_PartsQuery.forCurrentThread(); 171 | query.setParameter(0, wordId); 172 | return query.list(); 173 | } 174 | 175 | } 176 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dao/WordBeanDao.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dao; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteStatement; 5 | 6 | import org.greenrobot.greendao.AbstractDao; 7 | import org.greenrobot.greendao.Property; 8 | import org.greenrobot.greendao.internal.DaoConfig; 9 | import org.greenrobot.greendao.database.Database; 10 | import org.greenrobot.greendao.database.DatabaseStatement; 11 | 12 | import com.adm.dictionary.bean.WordBean; 13 | 14 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 15 | /** 16 | * DAO for table "WORD_BEAN". 17 | */ 18 | public class WordBeanDao extends AbstractDao { 19 | 20 | public static final String TABLENAME = "WORD_BEAN"; 21 | 22 | /** 23 | * Properties of entity WordBean.
24 | * Can be used for QueryBuilder and for referencing column names. 25 | */ 26 | public static class Properties { 27 | public final static Property Id = new Property(0, Long.class, "id", true, "_id"); 28 | public final static Property Name = new Property(1, String.class, "name", false, "NAME"); 29 | public final static Property En_sympol = new Property(2, String.class, "en_sympol", false, "EN_SYMPOL"); 30 | public final static Property Am_symbol = new Property(3, String.class, "am_symbol", false, "AM_SYMBOL"); 31 | public final static Property En_mp3 = new Property(4, String.class, "en_mp3", false, "EN_MP3"); 32 | public final static Property Am_mp3 = new Property(5, String.class, "am_mp3", false, "AM_MP3"); 33 | public final static Property GroupName = new Property(6, String.class, "groupName", false, "GROUP_NAME"); 34 | public final static Property Done = new Property(7, boolean.class, "done", false, "DONE"); 35 | } 36 | 37 | private DaoSession daoSession; 38 | 39 | 40 | public WordBeanDao(DaoConfig config) { 41 | super(config); 42 | } 43 | 44 | public WordBeanDao(DaoConfig config, DaoSession daoSession) { 45 | super(config, daoSession); 46 | this.daoSession = daoSession; 47 | } 48 | 49 | /** Creates the underlying database table. */ 50 | public static void createTable(Database db, boolean ifNotExists) { 51 | String constraint = ifNotExists? "IF NOT EXISTS ": ""; 52 | db.execSQL("CREATE TABLE " + constraint + "\"WORD_BEAN\" (" + // 53 | "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id 54 | "\"NAME\" TEXT," + // 1: name 55 | "\"EN_SYMPOL\" TEXT," + // 2: en_sympol 56 | "\"AM_SYMBOL\" TEXT," + // 3: am_symbol 57 | "\"EN_MP3\" TEXT," + // 4: en_mp3 58 | "\"AM_MP3\" TEXT," + // 5: am_mp3 59 | "\"GROUP_NAME\" TEXT," + // 6: groupName 60 | "\"DONE\" INTEGER NOT NULL );"); // 7: done 61 | } 62 | 63 | /** Drops the underlying database table. */ 64 | public static void dropTable(Database db, boolean ifExists) { 65 | String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"WORD_BEAN\""; 66 | db.execSQL(sql); 67 | } 68 | 69 | @Override 70 | protected final void bindValues(DatabaseStatement stmt, WordBean entity) { 71 | stmt.clearBindings(); 72 | 73 | Long id = entity.getId(); 74 | if (id != null) { 75 | stmt.bindLong(1, id); 76 | } 77 | 78 | String name = entity.getName(); 79 | if (name != null) { 80 | stmt.bindString(2, name); 81 | } 82 | 83 | String en_sympol = entity.getEn_sympol(); 84 | if (en_sympol != null) { 85 | stmt.bindString(3, en_sympol); 86 | } 87 | 88 | String am_symbol = entity.getAm_symbol(); 89 | if (am_symbol != null) { 90 | stmt.bindString(4, am_symbol); 91 | } 92 | 93 | String en_mp3 = entity.getEn_mp3(); 94 | if (en_mp3 != null) { 95 | stmt.bindString(5, en_mp3); 96 | } 97 | 98 | String am_mp3 = entity.getAm_mp3(); 99 | if (am_mp3 != null) { 100 | stmt.bindString(6, am_mp3); 101 | } 102 | 103 | String groupName = entity.getGroupName(); 104 | if (groupName != null) { 105 | stmt.bindString(7, groupName); 106 | } 107 | stmt.bindLong(8, entity.getDone() ? 1L: 0L); 108 | } 109 | 110 | @Override 111 | protected final void bindValues(SQLiteStatement stmt, WordBean entity) { 112 | stmt.clearBindings(); 113 | 114 | Long id = entity.getId(); 115 | if (id != null) { 116 | stmt.bindLong(1, id); 117 | } 118 | 119 | String name = entity.getName(); 120 | if (name != null) { 121 | stmt.bindString(2, name); 122 | } 123 | 124 | String en_sympol = entity.getEn_sympol(); 125 | if (en_sympol != null) { 126 | stmt.bindString(3, en_sympol); 127 | } 128 | 129 | String am_symbol = entity.getAm_symbol(); 130 | if (am_symbol != null) { 131 | stmt.bindString(4, am_symbol); 132 | } 133 | 134 | String en_mp3 = entity.getEn_mp3(); 135 | if (en_mp3 != null) { 136 | stmt.bindString(5, en_mp3); 137 | } 138 | 139 | String am_mp3 = entity.getAm_mp3(); 140 | if (am_mp3 != null) { 141 | stmt.bindString(6, am_mp3); 142 | } 143 | 144 | String groupName = entity.getGroupName(); 145 | if (groupName != null) { 146 | stmt.bindString(7, groupName); 147 | } 148 | stmt.bindLong(8, entity.getDone() ? 1L: 0L); 149 | } 150 | 151 | @Override 152 | protected final void attachEntity(WordBean entity) { 153 | super.attachEntity(entity); 154 | entity.__setDaoSession(daoSession); 155 | } 156 | 157 | @Override 158 | public Long readKey(Cursor cursor, int offset) { 159 | return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); 160 | } 161 | 162 | @Override 163 | public WordBean readEntity(Cursor cursor, int offset) { 164 | WordBean entity = new WordBean( // 165 | cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id 166 | cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name 167 | cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // en_sympol 168 | cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // am_symbol 169 | cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // en_mp3 170 | cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // am_mp3 171 | cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // groupName 172 | cursor.getShort(offset + 7) != 0 // done 173 | ); 174 | return entity; 175 | } 176 | 177 | @Override 178 | public void readEntity(Cursor cursor, WordBean entity, int offset) { 179 | entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); 180 | entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); 181 | entity.setEn_sympol(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); 182 | entity.setAm_symbol(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); 183 | entity.setEn_mp3(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); 184 | entity.setAm_mp3(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5)); 185 | entity.setGroupName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6)); 186 | entity.setDone(cursor.getShort(offset + 7) != 0); 187 | } 188 | 189 | @Override 190 | protected final Long updateKeyAfterInsert(WordBean entity, long rowId) { 191 | entity.setId(rowId); 192 | return rowId; 193 | } 194 | 195 | @Override 196 | public Long getKey(WordBean entity) { 197 | if(entity != null) { 198 | return entity.getId(); 199 | } else { 200 | return null; 201 | } 202 | } 203 | 204 | @Override 205 | public boolean hasKey(WordBean entity) { 206 | return entity.getId() != null; 207 | } 208 | 209 | @Override 210 | protected final boolean isEntityUpdateable() { 211 | return true; 212 | } 213 | 214 | } 215 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/ChineseSearchActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.content.Intent; 4 | import android.media.MediaPlayer; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.View; 8 | import android.widget.AdapterView; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.ImageView; 11 | import android.widget.ListView; 12 | import android.widget.TextView; 13 | 14 | import com.adm.dictionary.base.BaseActivity; 15 | import com.adm.dictionary.bean.ChineseBean; 16 | import com.adm.dictionary.http.HttpMethods; 17 | 18 | import java.io.IOException; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import com.adm.dictionary.bean.ChineseBean.Symbol.Parts.Means; 23 | 24 | import rx.android.schedulers.AndroidSchedulers; 25 | import rx.functions.Action1; 26 | import rx.schedulers.Schedulers; 27 | 28 | /** 29 | * 搜索中文的结果页 30 | * Created by Administrator on 2016/10/19. 31 | */ 32 | public class ChineseSearchActivity extends BaseActivity { 33 | 34 | private String searchStr; 35 | private TextView name, duyin; 36 | private ImageView voice; 37 | private ListView lv; 38 | private List meanings; 39 | private ArrayAdapter adapter; 40 | private MediaPlayer mp; 41 | 42 | 43 | @Override 44 | protected void onCreate(@Nullable Bundle savedInstanceState) { 45 | super.onCreate(savedInstanceState); 46 | setContentView(R.layout.activity_chinese_search); 47 | searchStr = getIntent().getStringExtra("searchStr"); 48 | initView(); 49 | HttpMethods.getInstance().searchChinese(searchStr).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 50 | @Override 51 | public void call(final ChineseBean chineseBean) { 52 | name.setText(chineseBean.getWord_name()); 53 | String duyinStr = chineseBean.getSymbols().get(0).getWord_symbol(); 54 | if (duyinStr != null && !duyinStr.equals("")) { 55 | duyin.setText(duyinStr); 56 | } else { 57 | duyin.setVisibility(View.GONE); 58 | voice.setVisibility(View.GONE); 59 | } 60 | if (chineseBean.getSymbols().get(0).getParts() != null) { 61 | List means = chineseBean.getSymbols().get(0).getParts().get(0).getMeans(); 62 | for (Means mean : means) { 63 | meanings.add(mean.getWord_mean()); 64 | } 65 | }else{ 66 | showToast("暂无搜索结果"); 67 | } 68 | adapter.notifyDataSetChanged(); 69 | //播放音频 70 | voice.setOnClickListener(new View.OnClickListener() { 71 | @Override 72 | public void onClick(View v) { 73 | if (chineseBean.getSymbols().get(0).getSymbol_mp3() == null || chineseBean.getSymbols().get(0).getSymbol_mp3().equals("")) { 74 | showToast("暂无匹配资源"); 75 | return; 76 | } 77 | mp.reset(); 78 | try { 79 | mp.setDataSource(chineseBean.getSymbols().get(0).getSymbol_mp3()); 80 | } catch (IOException e) { 81 | e.printStackTrace(); 82 | } 83 | mp.prepareAsync(); 84 | } 85 | }); 86 | } 87 | }); 88 | } 89 | 90 | @Override 91 | public void initView() { 92 | name = findTextViewById(R.id.act_chinese_name); 93 | duyin = findTextViewById(R.id.act_chinese_duyin); 94 | voice = findImageViewById(R.id.act_chinese_voice); 95 | lv = (ListView) findViewById(R.id.act_chinese_lv); 96 | meanings = new ArrayList<>(); 97 | adapter = new ArrayAdapter<>(this, R.layout.text_history, meanings); 98 | lv.setAdapter(adapter); 99 | mp = new MediaPlayer(); 100 | mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 101 | @Override 102 | public void onPrepared(MediaPlayer mp) { 103 | mp.start(); 104 | } 105 | }); 106 | lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 107 | @Override 108 | public void onItemClick(AdapterView parent, View view, int position, long id) { 109 | Intent intent = new Intent(ChineseSearchActivity.this, EnglishSearchActivity.class); 110 | intent.putExtra("searchStr", meanings.get(position)); 111 | startActivity(intent); 112 | } 113 | }); 114 | } 115 | 116 | @Override 117 | protected void onDestroy() { 118 | super.onDestroy(); 119 | if (mp.isPlaying()) { 120 | mp.stop(); 121 | } 122 | mp.release(); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/DanCiBenActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.Gravity; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.BaseAdapter; 11 | import android.widget.Button; 12 | import android.widget.CheckBox; 13 | import android.widget.CompoundButton; 14 | import android.widget.LinearLayout; 15 | import android.widget.ListView; 16 | import android.widget.TextView; 17 | 18 | import com.adm.dictionary.app.MyApp; 19 | import com.adm.dictionary.base.BaseActivity; 20 | import com.adm.dictionary.bean.WordBean; 21 | import com.adm.dictionary.util.SharedPreUtil; 22 | import com.zhl.cbdialog.CBDialogBuilder; 23 | 24 | import org.greenrobot.greendao.rx.RxDao; 25 | import org.greenrobot.greendao.rx.RxQuery; 26 | 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | import rx.android.schedulers.AndroidSchedulers; 31 | import rx.functions.Action1; 32 | 33 | /** 34 | * 单词本Activity 35 | * Created by Administrator on 2016/10/25. 36 | */ 37 | public class DanCiBenActivity extends BaseActivity { 38 | 39 | private ListView lv; 40 | private List list; 41 | private Button edit, add; 42 | private boolean editMode; 43 | private DanCiAdapter adapter; 44 | private RxDao dao; 45 | private Dialog dialog; 46 | private List planList; 47 | private int position = -1; 48 | 49 | @Override 50 | protected void onCreate(@Nullable Bundle savedInstanceState) { 51 | super.onCreate(savedInstanceState); 52 | setContentView(R.layout.activity_danciben); 53 | initView(); 54 | setListener(); 55 | getData(); 56 | } 57 | 58 | /** 59 | * 从数据库中获取单词本 60 | */ 61 | private void getData() { 62 | dao = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().rx(); 63 | RxQuery query = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().queryBuilder().rx(); 64 | query.list().observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1>() { 65 | @Override 66 | public void call(List wordBeen) { 67 | list.addAll(wordBeen); 68 | adapter.notifyDataSetChanged(); 69 | } 70 | }); 71 | } 72 | 73 | /** 74 | * 设置监听事件 75 | */ 76 | private void setListener() { 77 | edit.setOnClickListener(new View.OnClickListener() { 78 | @Override 79 | public void onClick(View v) { 80 | add.setVisibility(View.VISIBLE); 81 | for (WordBean bean : list) { 82 | bean.setChecked(false); 83 | } 84 | editMode = true; 85 | adapter.notifyDataSetChanged(); 86 | } 87 | }); 88 | 89 | add.setOnClickListener(new View.OnClickListener() { 90 | @Override 91 | public void onClick(View v) { 92 | add.setVisibility(View.GONE); 93 | editMode = false; 94 | adapter.notifyDataSetChanged(); 95 | addToPlan(); 96 | 97 | } 98 | }); 99 | 100 | } 101 | 102 | /** 103 | * 添加到复习计划 104 | */ 105 | private void addToPlan() { 106 | planList = SharedPreUtil.getGroup(this, "group"); 107 | 108 | if (planList == null) { 109 | showToast("暂无计划,赶紧去添加吧~"); 110 | return; 111 | } 112 | String[] items = new String[planList.size()]; 113 | dialog = new CBDialogBuilder(this, CBDialogBuilder.DIALOG_STYLE_NORMAL).showConfirmButton(true).setTitle("选择计划").showIcon(false).setItems(planList.toArray(items), new CBDialogBuilder.onDialogItemClickListener() { 114 | @Override 115 | public void onDialogItemClick(CBDialogBuilder.DialogItemAdapter ItemAdapter, Context context, CBDialogBuilder dialogbuilder, Dialog dialog, int position) { 116 | //选择item的事件 117 | DanCiBenActivity.this.position = position; 118 | } 119 | }).setButtonClickListener(true, new CBDialogBuilder.onDialogbtnClickListener() { 120 | @Override 121 | public void onDialogbtnClick(Context context, Dialog dialog, int whichBtn) { 122 | //确认按钮的事件 123 | if (position == -1) { 124 | showToast("请选择计划~"); 125 | return; 126 | } 127 | insertDataBase(); 128 | } 129 | }).create(); 130 | dialog.show(); 131 | 132 | } 133 | 134 | /** 135 | * 加入复习计划到数据库 136 | */ 137 | private void insertDataBase() { 138 | for (WordBean bean : list) { 139 | if (bean.isChecked()) { 140 | bean.setGroupName(planList.get(position)); 141 | } 142 | } 143 | dao.updateInTx(list).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1>() { 144 | @Override 145 | public void call(Iterable wordBeen) { 146 | showToast("添加计划列表成功"); 147 | position = -1;// 148 | } 149 | }); 150 | } 151 | 152 | @Override 153 | public void initView() { 154 | edit = findButById(R.id.act_danciben_edit); 155 | add = findButById(R.id.act_danciben_but); 156 | lv = (ListView) findViewById(R.id.act_danciben_lv); 157 | TextView emptyView = new TextView(this); 158 | emptyView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); 159 | emptyView.setText("单词本空空如也,快去搜索添加吧~"); 160 | emptyView.setGravity(Gravity.CENTER); 161 | emptyView.setVisibility(View.GONE); 162 | ((ViewGroup) lv.getParent()).addView(emptyView); 163 | lv.setEmptyView(emptyView); 164 | list = new ArrayList<>(); 165 | adapter = new DanCiAdapter(); 166 | lv.setAdapter(adapter); 167 | } 168 | 169 | 170 | class DanCiAdapter extends BaseAdapter { 171 | 172 | @Override 173 | public int getCount() { 174 | return list.size(); 175 | } 176 | 177 | @Override 178 | public Object getItem(int position) { 179 | return list.get(position); 180 | } 181 | 182 | @Override 183 | public long getItemId(int position) { 184 | return position; 185 | } 186 | 187 | @Override 188 | public View getView(int position, View v, ViewGroup parent) { 189 | ViewHolder vh; 190 | if (v == null) { 191 | v = View.inflate(DanCiBenActivity.this, R.layout.item_danci, null); 192 | vh = new ViewHolder(); 193 | vh.name = (TextView) v.findViewById(R.id.item_danci_name); 194 | vh.symbol = (TextView) v.findViewById(R.id.item_danci_symbol); 195 | vh.meaning = (TextView) v.findViewById(R.id.item_danci_meaning); 196 | vh.checkBox = (CheckBox) v.findViewById(R.id.item_danci_check); 197 | vh.del = (TextView) v.findViewById(R.id.item_danci_del); 198 | v.setTag(vh); 199 | } else { 200 | vh = (ViewHolder) v.getTag(); 201 | } 202 | final WordBean bean = list.get(position); 203 | vh.name.setText(bean.getName()); 204 | vh.symbol.setText("[英]" + bean.getEn_sympol() + "/[美]" + bean.getAm_symbol()); 205 | StringBuilder builder = new StringBuilder(); 206 | for (int i = 0; i < bean.getParts().size(); i++) { 207 | builder.append(bean.getParts().get(i).getPart()).append(" ").append(bean.getParts().get(i).getMeans()).append("\r\n"); 208 | } 209 | vh.meaning.setText(builder.toString()); 210 | vh.checkBox.setChecked(bean.isChecked()); 211 | if (editMode) { 212 | vh.checkBox.setVisibility(View.VISIBLE); 213 | } else { 214 | vh.checkBox.setVisibility(View.GONE); 215 | } 216 | vh.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 217 | @Override 218 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 219 | bean.setChecked(isChecked); 220 | } 221 | }); 222 | vh.del.setOnClickListener(new View.OnClickListener() { 223 | @Override 224 | public void onClick(View v) { 225 | dao.delete(bean).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 226 | @Override 227 | public void call(Void aVoid) { 228 | showToast("移除成功"); 229 | list.remove(bean); 230 | notifyDataSetChanged(); 231 | } 232 | }); 233 | } 234 | }); 235 | 236 | return v; 237 | } 238 | 239 | class ViewHolder { 240 | TextView name, symbol, meaning, del; 241 | CheckBox checkBox; 242 | } 243 | } 244 | 245 | 246 | @Override 247 | public void onBackPressed() { 248 | if (editMode) { 249 | add.setVisibility(View.GONE); 250 | editMode = false; 251 | adapter.notifyDataSetChanged(); 252 | } else { 253 | super.onBackPressed(); 254 | } 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/DictionaryActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.database.Cursor; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.BaseAdapter; 10 | import android.widget.ListView; 11 | import android.widget.TextView; 12 | 13 | import com.adm.dictionary.base.BaseActivity; 14 | import com.adm.dictionary.bean.DictionaryBean; 15 | import com.adm.dictionary.util.FileUtil; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | /** 21 | * 本地词典Activity 22 | * Created by Administrator on 2016/10/27. 23 | */ 24 | public class DictionaryActivity extends BaseActivity { 25 | 26 | 27 | private ListView lv; 28 | private SQLiteDatabase db; 29 | private List list; 30 | private DictAdapter adapter; 31 | 32 | @Override 33 | protected void onCreate(@Nullable Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_dictionary); 36 | String dbName = getFilesDir().getAbsolutePath() + "/dictionary.db"; 37 | db = FileUtil.openDatabase(this, dbName); 38 | initView(); 39 | setUpData(); 40 | } 41 | 42 | /** 43 | * 获取数据绑定到控件上 44 | */ 45 | private void setUpData() { 46 | Cursor c = db.query("t_words", null, null, null, null, null, null, null); 47 | list = new ArrayList<>(); 48 | while (c.moveToNext()) { 49 | DictionaryBean bean = new DictionaryBean(c.getString(0), c.getString(1)); 50 | list.add(bean); 51 | } 52 | c.close(); 53 | adapter = new DictAdapter(); 54 | lv.setAdapter(adapter); 55 | } 56 | 57 | @Override 58 | public void initView() { 59 | lv = (ListView) findViewById(R.id.act_dict_lv); 60 | } 61 | 62 | 63 | class DictAdapter extends BaseAdapter { 64 | 65 | @Override 66 | public int getCount() { 67 | return list.size(); 68 | } 69 | 70 | @Override 71 | public Object getItem(int position) { 72 | return list.get(position); 73 | } 74 | 75 | @Override 76 | public long getItemId(int position) { 77 | return position; 78 | } 79 | 80 | @Override 81 | public View getView(int position, View v, ViewGroup parent) { 82 | ViewHolder vh = null; 83 | if (v == null) { 84 | v = View.inflate(DictionaryActivity.this, R.layout.item_dictionary, null); 85 | vh = new ViewHolder(); 86 | vh.english = (TextView) v.findViewById(R.id.item_dict_english); 87 | vh.chinese = (TextView) v.findViewById(R.id.item_dict_chinese); 88 | v.setTag(vh); 89 | } else { 90 | vh = (ViewHolder) v.getTag(); 91 | } 92 | vh.english.setText(list.get(position).getEnglish()); 93 | vh.chinese.setText(list.get(position).getChinese()); 94 | return v; 95 | } 96 | 97 | class ViewHolder { 98 | TextView english, chinese; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/EnglishSearchActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.media.MediaPlayer; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | import android.widget.LinearLayout; 10 | import android.widget.TextView; 11 | 12 | import com.adm.dictionary.app.MyApp; 13 | import com.adm.dictionary.base.BaseActivity; 14 | import com.adm.dictionary.bean.EnglishBean; 15 | import com.adm.dictionary.bean.Part; 16 | import com.adm.dictionary.bean.WordBean; 17 | import com.adm.dictionary.dao.WordBeanDao; 18 | import com.adm.dictionary.http.HttpMethods; 19 | 20 | import org.greenrobot.greendao.rx.RxDao; 21 | import org.greenrobot.greendao.rx.RxQuery; 22 | 23 | import java.io.IOException; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | import rx.Subscriber; 28 | import rx.android.schedulers.AndroidSchedulers; 29 | import rx.functions.Action1; 30 | import rx.schedulers.Schedulers; 31 | 32 | /** 33 | * 搜索英文的结果页 34 | * Created by Administrator on 2016/10/19. 35 | */ 36 | public class EnglishSearchActivity extends BaseActivity { 37 | 38 | private String searchStr; 39 | private TextView name, ukDuyin, usDuyin; 40 | private LinearLayout parts; 41 | private ImageView ukVoice, usVoice, star; 42 | private MediaPlayer mp; 43 | private RxQuery query; 44 | private RxDao dao; 45 | private RxDao partDao; 46 | private String wordName; 47 | private boolean collectState; 48 | public WordBean wordBean; 49 | private EnglishBean englishBean; 50 | 51 | @Override 52 | protected void onCreate(@Nullable Bundle savedInstanceState) { 53 | super.onCreate(savedInstanceState); 54 | setContentView(R.layout.activity_english_search); 55 | searchStr = getIntent().getStringExtra("searchStr"); 56 | initView(); 57 | HttpMethods.getInstance().searchEnglish(searchStr).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Subscriber() { 58 | 59 | @Override 60 | public void onCompleted() { 61 | 62 | } 63 | 64 | @Override 65 | public void onError(Throwable e) { 66 | Log.e("error", e.getLocalizedMessage()); 67 | } 68 | 69 | @Override 70 | public void onNext(EnglishBean englishBean) { 71 | setUpData(englishBean); 72 | EnglishSearchActivity.this.englishBean = englishBean; 73 | } 74 | }); 75 | 76 | } 77 | 78 | /** 79 | * 将数据显示到控件上 80 | * 81 | * @param englishBean 82 | */ 83 | private void setUpData(EnglishBean englishBean) { 84 | if (englishBean.getWord_name() == null || englishBean.getWord_name().equals("")) { 85 | showToast("没有您想要的结果哦"); 86 | return; 87 | } 88 | wordName = englishBean.getWord_name(); 89 | queryResult(); 90 | name.setText(englishBean.getWord_name()); 91 | final EnglishBean.Symbols symbols = englishBean.getSymbols().get(0); 92 | ukDuyin.setText("[英] " + symbols.getPh_en()); 93 | usDuyin.setText("[美] " + symbols.getPh_am()); 94 | //播放音频 95 | ukVoice.setOnClickListener(new View.OnClickListener() { 96 | @Override 97 | public void onClick(View v) { 98 | if (symbols.getPh_en_mp3() == null || symbols.getPh_en_mp3().equals("")) { 99 | showToast("暂无匹配资源"); 100 | return; 101 | } 102 | mp.reset(); 103 | try { 104 | mp.setDataSource(symbols.getPh_en_mp3()); 105 | } catch (IOException e) { 106 | e.printStackTrace(); 107 | } 108 | mp.prepareAsync(); 109 | } 110 | }); 111 | usVoice.setOnClickListener(new View.OnClickListener() { 112 | @Override 113 | public void onClick(View v) { 114 | if (symbols.getPh_am_mp3() == null || symbols.getPh_am_mp3().equals("")) { 115 | showToast("暂无匹配资源"); 116 | return; 117 | } 118 | mp.reset(); 119 | try { 120 | mp.setDataSource(symbols.getPh_am_mp3()); 121 | } catch (IOException e) { 122 | e.printStackTrace(); 123 | } 124 | mp.prepareAsync(); 125 | } 126 | }); 127 | for (int i = 0; i < symbols.getParts().size(); i++) { 128 | View v = View.inflate(this, R.layout.text_means, null); 129 | TextView part = (TextView) v.findViewById(R.id.part); 130 | TextView means = (TextView) v.findViewById(R.id.means); 131 | part.setText(symbols.getParts().get(i).getPart()); 132 | StringBuilder sb = new StringBuilder(); 133 | for (int j = 0; j < symbols.getParts().get(i).getMeans().size(); j++) { 134 | if (j < symbols.getParts().get(i).getMeans().size() - 1) { 135 | sb.append(symbols.getParts().get(i).getMeans().get(j)).append(";").append("\r\n"); 136 | } else { 137 | sb.append(symbols.getParts().get(i).getMeans().get(j)); 138 | } 139 | } 140 | means.setText(sb.toString()); 141 | parts.addView(v); 142 | } 143 | 144 | 145 | } 146 | 147 | private void queryResult() { 148 | query = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().queryBuilder().where(WordBeanDao.Properties.Name.eq(wordName)).rx(); 149 | query.list().observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1>() { 150 | 151 | 152 | @Override 153 | public void call(List wordBeen) { 154 | Log.e("query", wordBeen.toString()); 155 | if (wordBeen == null || wordBeen.size() == 0) { 156 | collectState = false; 157 | star.setImageResource(R.drawable.staroff); 158 | } else { 159 | wordBean = wordBeen.get(0); 160 | collectState = true; 161 | star.setImageResource(R.drawable.staron); 162 | } 163 | } 164 | }); 165 | } 166 | 167 | @Override 168 | public void initView() { 169 | dao = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().rx(); 170 | partDao = ((MyApp) getApplication()).getDaoSession().getPartDao().rx(); 171 | name = findTextViewById(R.id.act_english_name); 172 | ukDuyin = findTextViewById(R.id.act_english_ukduyin); 173 | usDuyin = findTextViewById(R.id.act_english_usduyin); 174 | ukVoice = findImageViewById(R.id.act_english_ukvoice); 175 | usVoice = findImageViewById(R.id.act_english_usvoice); 176 | parts = findLinById(R.id.act_english_lin); 177 | star = findImageViewById(R.id.act_english_star); 178 | mp = new MediaPlayer(); 179 | mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 180 | @Override 181 | public void onPrepared(MediaPlayer mp) { 182 | mp.start(); 183 | } 184 | }); 185 | star.setOnClickListener(new View.OnClickListener() { 186 | @Override 187 | public void onClick(View v) { 188 | if (collectState) { 189 | dao.deleteByKey(wordBean.getId()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 190 | @Override 191 | public void call(Void aVoid) { 192 | partDao.deleteInTx(wordBean.getParts()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 193 | @Override 194 | public void call(Void aVoid) { 195 | showToast("移除成功"); 196 | collectState = false; 197 | star.setImageResource(R.drawable.staroff); 198 | } 199 | }); 200 | } 201 | }); 202 | } else { 203 | final WordBean word = new WordBean(); 204 | word.setName(englishBean.getWord_name()); 205 | word.setAm_symbol(englishBean.getSymbols().get(0).getPh_am()); 206 | word.setEn_sympol(englishBean.getSymbols().get(0).getPh_en()); 207 | word.setAm_mp3(englishBean.getSymbols().get(0).getPh_am_mp3()); 208 | word.setEn_mp3(englishBean.getSymbols().get(0).getPh_en_mp3()); 209 | dao.insert(word).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 210 | @Override 211 | public void call(WordBean wordBean) { 212 | EnglishSearchActivity.this.wordBean = wordBean; 213 | List parts = englishBean.getSymbols().get(0).getParts(); 214 | final List addParts = word.getParts(); 215 | for (int i = 0; i < parts.size(); i++) { 216 | Part part = new Part(null, wordBean.getId(), parts.get(i).getPart(), parts.get(i).getMeans().toString()); 217 | addParts.add(part); 218 | } 219 | partDao.insertInTx(addParts).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1>() { 220 | @Override 221 | public void call(Iterable parts) { 222 | showToast("添加成功"); 223 | collectState = true; 224 | star.setImageResource(R.drawable.staron); 225 | } 226 | }); 227 | 228 | } 229 | }); 230 | 231 | } 232 | } 233 | }); 234 | } 235 | 236 | @Override 237 | protected void onDestroy() { 238 | super.onDestroy(); 239 | if (mp.isPlaying()) { 240 | mp.stop(); 241 | } 242 | mp.release(); 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/FaXianFragment.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.KeyEvent; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.view.inputmethod.EditorInfo; 12 | import android.view.inputmethod.InputMethodManager; 13 | import android.widget.AdapterView; 14 | import android.widget.ArrayAdapter; 15 | import android.widget.Button; 16 | import android.widget.EditText; 17 | import android.widget.GridView; 18 | import android.widget.TextView; 19 | import android.widget.Toast; 20 | 21 | import com.adm.dictionary.base.BaseFragment; 22 | import com.adm.dictionary.util.HttpUtil; 23 | import com.adm.dictionary.util.SharedPreUtil; 24 | 25 | import java.util.ArrayList; 26 | import java.util.List; 27 | 28 | /** 29 | * 发现Fragment 30 | * Created by Administrator on 2016/10/18. 31 | */ 32 | public class FaXianFragment extends BaseFragment { 33 | 34 | 35 | private static String HISTORY_KEY = "history"; 36 | private View v; 37 | private EditText et; 38 | private TextView tv; 39 | private GridView gv; 40 | private List histories = new ArrayList<>(); 41 | private ArrayAdapter adapter; 42 | private Button clear; 43 | 44 | @Nullable 45 | @Override 46 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 47 | v = inflater.inflate(R.layout.frag_faxian, null); 48 | initView(); 49 | getHistory(); 50 | return v; 51 | } 52 | 53 | /** 54 | * 获取搜索历史 55 | */ 56 | private void getHistory() { 57 | List data = SharedPreUtil.getList(getActivity(), "history"); 58 | if (data != null) { 59 | histories.addAll(data); 60 | } 61 | } 62 | 63 | @Override 64 | public void initView() { 65 | clear = findButById(v, R.id.frag_fa_clear); 66 | et = findEtbyId(v, R.id.frag_fa_et); 67 | tv = findTextViewbyId(v, R.id.frag_fa_tv); 68 | gv = (GridView) v.findViewById(R.id.frag_fa_gv); 69 | 70 | /** 71 | * 清空历史 72 | */ 73 | clear.setOnClickListener(new View.OnClickListener() { 74 | @Override 75 | public void onClick(View v) { 76 | if (histories == null || histories.size() == 0) { 77 | Toast.makeText(getActivity(), "暂无搜索历史", Toast.LENGTH_SHORT).show(); 78 | return; 79 | } 80 | SharedPreUtil.clearHistory(getActivity()); 81 | histories.clear(); 82 | adapter.notifyDataSetChanged(); 83 | } 84 | }); 85 | 86 | /** 87 | * 搜索事件 88 | */ 89 | et.setOnEditorActionListener(new TextView.OnEditorActionListener() { 90 | @Override 91 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 92 | if(!HttpUtil.isNetworkAvailable(getActivity())){ 93 | showToast("当前网络不可用"); 94 | return false; 95 | } 96 | if (actionId == EditorInfo.IME_ACTION_SEARCH) { 97 | String searchStr = et.getText().toString().trim(); 98 | search(searchStr); 99 | } 100 | return false; 101 | } 102 | }); 103 | /** 104 | * 长句翻译 105 | */ 106 | tv.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View v) { 109 | startActivity(new Intent(getActivity(), SentenceTranslateActivity.class)); 110 | } 111 | }); 112 | adapter = new ArrayAdapter<>(getActivity(), R.layout.text_his, histories); 113 | gv.setAdapter(adapter); 114 | gv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 115 | @Override 116 | public void onItemClick(AdapterView parent, View view, int position, long id) { 117 | search(histories.get(position)); 118 | } 119 | }); 120 | } 121 | 122 | private void search(String searchStr) { 123 | if (searchStr.equals("")) { 124 | showToast("请输入文本"); 125 | return; 126 | } 127 | if (searchStr.contains(" ")) { 128 | showToast("搜索词中不允许空格哦~"); 129 | return; 130 | } 131 | if (histories.contains(searchStr)) { 132 | histories.remove(searchStr); 133 | histories.add(searchStr); 134 | } else { 135 | histories.add(searchStr); 136 | } 137 | adapter.notifyDataSetChanged(); 138 | SharedPreUtil.saveHistory(getActivity(), HISTORY_KEY, histories); 139 | ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)). 140 | hideSoftInputFromWindow(et.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 141 | et.setText(""); 142 | Intent intent = new Intent(); 143 | intent.putExtra("searchStr", searchStr); 144 | int length = (searchStr.charAt(0) + "").getBytes().length; 145 | if (length == 1) { 146 | intent.setClass(getActivity(), EnglishSearchActivity.class); 147 | } else if (length == 3) { 148 | intent.setClass(getActivity(), ChineseSearchActivity.class); 149 | } 150 | startActivity(intent); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.graphics.Color; 4 | import android.os.Bundle; 5 | import android.support.v4.app.Fragment; 6 | import android.support.v4.app.FragmentManager; 7 | import android.support.v4.app.FragmentPagerAdapter; 8 | import android.support.v4.view.ViewPager; 9 | import android.view.View; 10 | import android.widget.ImageView; 11 | import android.widget.LinearLayout; 12 | import android.widget.TextView; 13 | 14 | import com.adm.dictionary.base.BaseActivity; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class MainActivity extends BaseActivity implements View.OnClickListener { 20 | 21 | private LinearLayout lin1, lin2, lin3; 22 | private ViewPager viewpager; 23 | private ImageView imgs[]; 24 | private TextView tvs[]; 25 | private int imgId[] = new int[]{R.mipmap.tuijianon, R.mipmap.faxianon, R.mipmap.wodeon, R.mipmap.tuijianoff, R.mipmap.faxianoff, R.mipmap.wodeoff}; 26 | private List fragments = new ArrayList<>(); 27 | private MyPagerAdapter pagerAdapter; 28 | 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | setContentView(R.layout.activity_main); 34 | initView(); 35 | setListener(); 36 | } 37 | 38 | /** 39 | * 设置监听事件 40 | */ 41 | private void setListener() { 42 | lin1.setOnClickListener(this); 43 | lin2.setOnClickListener(this); 44 | lin3.setOnClickListener(this); 45 | } 46 | 47 | /** 48 | * 初始化控件 49 | */ 50 | @Override 51 | public void initView() { 52 | lin1 = findLinById(R.id.act_main_lin1); 53 | lin2 = findLinById(R.id.act_main_lin2); 54 | lin3 = findLinById(R.id.act_main_lin3); 55 | ImageView img1 = findImageViewById(R.id.act_main_img1); 56 | ImageView img2 = findImageViewById(R.id.act_main_img2); 57 | ImageView img3 = findImageViewById(R.id.act_main_img3); 58 | TextView tv1 = findTextViewById(R.id.act_main_tv1); 59 | TextView tv2 = findTextViewById(R.id.act_main_tv2); 60 | TextView tv3 = findTextViewById(R.id.act_main_tv3); 61 | viewpager = (ViewPager) findViewById(R.id.act_main_vp); 62 | fragments.add(new TuijianFragment()); 63 | fragments.add(new FaXianFragment()); 64 | fragments.add(new WoDeFragment()); 65 | imgs = new ImageView[]{img1, img2, img3}; 66 | tvs = new TextView[]{tv1, tv2, tv3}; 67 | pagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); 68 | viewpager.setAdapter(pagerAdapter); 69 | viewpager.setOffscreenPageLimit(3); 70 | /** 71 | * 设置ViewPager的滑动事件 72 | */ 73 | viewpager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 74 | @Override 75 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 76 | 77 | } 78 | 79 | @Override 80 | public void onPageSelected(int position) { 81 | setItem(position); 82 | } 83 | 84 | @Override 85 | public void onPageScrollStateChanged(int state) { 86 | 87 | } 88 | }); 89 | } 90 | 91 | /** 92 | * 设置监听事件 93 | * 94 | * @param v 95 | */ 96 | @Override 97 | public void onClick(View v) { 98 | switch (v.getId()) { 99 | case R.id.act_main_lin1: 100 | setItem(0); 101 | viewpager.setCurrentItem(0); 102 | break; 103 | case R.id.act_main_lin2: 104 | setItem(1); 105 | viewpager.setCurrentItem(1); 106 | break; 107 | case R.id.act_main_lin3: 108 | setItem(2); 109 | viewpager.setCurrentItem(2); 110 | break; 111 | } 112 | } 113 | 114 | /** 115 | * 设置显示的页面 116 | * 117 | * @param index 下标 118 | */ 119 | private void setItem(int index) { 120 | for (int i = 0; i < 3; i++) { 121 | if (i == index) { 122 | imgs[i].setImageResource(imgId[i]); 123 | tvs[i].setTextColor(Color.parseColor("#D74B25")); 124 | } else { 125 | imgs[i].setImageResource(imgId[i + 3]); 126 | tvs[i].setTextColor(Color.parseColor("#515151")); 127 | } 128 | } 129 | } 130 | 131 | class MyPagerAdapter extends FragmentPagerAdapter { 132 | 133 | public MyPagerAdapter(FragmentManager fm) { 134 | super(fm); 135 | } 136 | 137 | @Override 138 | public Fragment getItem(int position) { 139 | return fragments.get(position); 140 | } 141 | 142 | @Override 143 | public int getCount() { 144 | return 3; 145 | } 146 | } 147 | 148 | } 149 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/PlanActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.app.Dialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Bundle; 7 | import android.support.annotation.Nullable; 8 | import android.support.v7.widget.CardView; 9 | import android.view.Gravity; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.widget.AdapterView; 13 | import android.widget.BaseAdapter; 14 | import android.widget.Button; 15 | import android.widget.EditText; 16 | import android.widget.LinearLayout; 17 | import android.widget.ListView; 18 | import android.widget.TextView; 19 | 20 | import com.adm.dictionary.app.MyApp; 21 | import com.adm.dictionary.base.BaseActivity; 22 | import com.adm.dictionary.bean.PlanCount; 23 | import com.adm.dictionary.bean.WordBean; 24 | import com.adm.dictionary.dao.WordBeanDao; 25 | import com.adm.dictionary.util.SharedPreUtil; 26 | import com.zhl.cbdialog.CBDialogBuilder; 27 | 28 | import org.greenrobot.greendao.rx.RxQuery; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.Random; 33 | 34 | /** 35 | * 复习计划列表 36 | * Created by Administrator on 2016/10/26. 37 | */ 38 | public class PlanActivity extends BaseActivity { 39 | 40 | private ListView lv; 41 | private Button add; 42 | private List plans; 43 | private Random random; 44 | private static String GROUP_KEY = "group"; 45 | private PlanAdapter adapter; 46 | private Dialog dialog; 47 | private List counts; 48 | private WordBeanDao dao; 49 | 50 | @Override 51 | protected void onCreate(@Nullable Bundle savedInstanceState) { 52 | super.onCreate(savedInstanceState); 53 | setContentView(R.layout.activity_planlist); 54 | dao = ((MyApp) getApplication()).getDaoSession().getWordBeanDao(); 55 | initView(); 56 | setUpData(); 57 | } 58 | 59 | private void setUpData() { 60 | 61 | List list = SharedPreUtil.getGroup(this, GROUP_KEY); 62 | plans = new ArrayList<>(); 63 | counts = new ArrayList<>(); 64 | if (list != null) { 65 | plans.addAll(list); 66 | for (String str : plans) { 67 | long a = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().queryBuilder().where(WordBeanDao.Properties.GroupName.eq(str)).buildCount().count(); 68 | long b = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().queryBuilder().where(WordBeanDao.Properties.GroupName.eq(str)). 69 | where(WordBeanDao.Properties.Done.eq(true)).buildCount().count(); 70 | counts.add(new PlanCount(a, b)); 71 | } 72 | } 73 | adapter = new PlanAdapter(); 74 | lv.setAdapter(adapter); 75 | } 76 | 77 | @Override 78 | public void initView() { 79 | random = new Random(); 80 | lv = (ListView) findViewById(R.id.act_plan_lv); 81 | TextView emptyView = new TextView(this); 82 | emptyView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT)); 83 | emptyView.setText("复习计划空空如也,快去添加吧~"); 84 | emptyView.setGravity(Gravity.CENTER); 85 | emptyView.setVisibility(View.GONE); 86 | ((ViewGroup) lv.getParent()).addView(emptyView); 87 | lv.setEmptyView(emptyView); 88 | add = findButById(R.id.act_plan_add); 89 | //添加计划事件 90 | add.setOnClickListener(new View.OnClickListener() { 91 | @Override 92 | public void onClick(View v) { 93 | if (dialog != null) { 94 | dialog.show(); 95 | } 96 | } 97 | }); 98 | View v = View.inflate(this, R.layout.view_et, null); 99 | final EditText et = (EditText) v.findViewById(R.id.et); 100 | dialog = new CBDialogBuilder(this, CBDialogBuilder.DIALOG_STYLE_NORMAL).setTitle("新建").showIcon(false).setButtonClickListener(true, new CBDialogBuilder.onDialogbtnClickListener() { 101 | @Override 102 | public void onDialogbtnClick(Context context, Dialog dialog, int whichBtn) { 103 | String name = et.getText().toString().trim(); 104 | if (name.equals("")) { 105 | showToast("请输入计划名称"); 106 | return; 107 | } 108 | if (plans.contains(name)) { 109 | showToast("计划已经存在"); 110 | return; 111 | } 112 | et.setText(""); 113 | plans.add(name); 114 | SharedPreUtil.saveGroup(PlanActivity.this, GROUP_KEY, plans); 115 | counts.add(new PlanCount(0, 0)); 116 | adapter.notifyDataSetChanged(); 117 | } 118 | }).setView(v).create(); 119 | 120 | lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 121 | @Override 122 | public void onItemClick(AdapterView parent, View view, int position, long id) { 123 | if (counts.get(position).getTotal() == 0) { 124 | showToast("快去单词本添加单词吧~"); 125 | return; 126 | } 127 | if (counts.get(position).getTotal() == counts.get(position).getDone()) { 128 | showToast("该计划已完成,自动删除"); 129 | //将数据库中的done改为false 130 | List beans = dao.queryBuilder().where(WordBeanDao.Properties.GroupName.eq(plans.get(position))).build().list(); 131 | for (WordBean bean : beans) { 132 | bean.setDone(false); 133 | } 134 | dao.updateInTx(beans); 135 | plans.remove(position); 136 | counts.remove(position); 137 | SharedPreUtil.saveGroup(PlanActivity.this, "group", plans); 138 | adapter.notifyDataSetChanged(); 139 | return; 140 | } 141 | Intent intent = new Intent(PlanActivity.this, PlanPracticeActivity.class); 142 | intent.putExtra("groupName", plans.get(position)); 143 | startActivity(intent); 144 | } 145 | }); 146 | } 147 | 148 | class PlanAdapter extends BaseAdapter { 149 | 150 | @Override 151 | public int getCount() { 152 | return plans.size(); 153 | } 154 | 155 | @Override 156 | public Object getItem(int position) { 157 | return plans.get(position); 158 | } 159 | 160 | @Override 161 | public long getItemId(int position) { 162 | return position; 163 | } 164 | 165 | @Override 166 | public View getView(int position, View v, ViewGroup parent) { 167 | ViewHolder vh = null; 168 | 169 | if (v == null) { 170 | v = View.inflate(PlanActivity.this, R.layout.item_plan, null); 171 | vh = new ViewHolder(); 172 | vh.cv = (CardView) v.findViewById(R.id.item_plan_cv); 173 | vh.name = (TextView) v.findViewById(R.id.item_plan_name); 174 | vh.des = (TextView) v.findViewById(R.id.item_plan_des); 175 | v.setTag(vh); 176 | } else { 177 | vh = (ViewHolder) v.getTag(); 178 | } 179 | 180 | int ranColor = 0xff000000 | random.nextInt(0x00ffffff); 181 | vh.cv.setCardBackgroundColor(ranColor); 182 | vh.name.setText(plans.get(position)); 183 | vh.des.setText("共" + counts.get(position).getTotal() + "个,已完成" + counts.get(position).getDone() + "个"); 184 | return v; 185 | } 186 | 187 | class ViewHolder { 188 | TextView name, des; 189 | CardView cv; 190 | } 191 | } 192 | 193 | 194 | @Override 195 | protected void onResume() { 196 | super.onResume(); 197 | setUpData(); 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/PlanPracticeActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.view.ViewPager; 6 | import android.view.View; 7 | import android.widget.Button; 8 | 9 | import com.adm.dictionary.app.MyApp; 10 | import com.adm.dictionary.base.BaseActivity; 11 | import com.adm.dictionary.bean.WordBean; 12 | import com.adm.dictionary.dao.WordBeanDao; 13 | import com.adm.dictionary.view.CardPagerAdapter; 14 | import com.adm.dictionary.view.ShadowTransformer; 15 | 16 | import org.greenrobot.greendao.rx.RxQuery; 17 | 18 | import java.util.List; 19 | 20 | import rx.android.schedulers.AndroidSchedulers; 21 | import rx.functions.Action1; 22 | 23 | /** 24 | * 复习单词的界面 25 | * Created by Administrator on 2016/10/27. 26 | */ 27 | public class PlanPracticeActivity extends BaseActivity { 28 | 29 | private ViewPager vp; 30 | private CardPagerAdapter adapter; 31 | private ShadowTransformer transformer; 32 | private RxQuery query; 33 | private List list; 34 | private String groupName; 35 | private int position; 36 | private WordBeanDao dao; 37 | private Button remember, unremember; 38 | 39 | @Override 40 | protected void onCreate(@Nullable Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | setContentView(R.layout.activity_plan_practice); 43 | groupName = getIntent().getStringExtra("groupName"); 44 | initView(); 45 | } 46 | 47 | @Override 48 | public void initView() { 49 | vp = (ViewPager) findViewById(R.id.act_prac_vp); 50 | remember = findButById(R.id.act_prac_remember); 51 | unremember = findButById(R.id.act_prac_unremember); 52 | dao = ((MyApp) getApplication()).getDaoSession().getWordBeanDao(); 53 | query = ((MyApp) getApplication()).getDaoSession().getWordBeanDao().queryBuilder().where(WordBeanDao.Properties.GroupName.eq(groupName)) 54 | .where(WordBeanDao.Properties.Done.eq("false")).rx(); 55 | query.list().observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1>() { 56 | @Override 57 | public void call(List wordBeen) { 58 | list = wordBeen; 59 | adapter = new CardPagerAdapter(list); 60 | transformer = new ShadowTransformer(vp, adapter); 61 | transformer.enableScaling(true); 62 | vp.setAdapter(adapter); 63 | vp.setPageTransformer(false, transformer); 64 | } 65 | }); 66 | vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 67 | @Override 68 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 69 | } 70 | 71 | @Override 72 | public void onPageSelected(int position) { 73 | PlanPracticeActivity.this.position = position; 74 | } 75 | 76 | @Override 77 | public void onPageScrollStateChanged(int state) { 78 | } 79 | }); 80 | 81 | remember.setOnClickListener(new View.OnClickListener() { 82 | @Override 83 | public void onClick(View v) { 84 | WordBean bean = list.get(position); 85 | bean.setDone(true); 86 | dao.update(bean); 87 | if (position != list.size() - 1) { 88 | vp.setCurrentItem(position + 1); 89 | } else { 90 | // 最后一个界面的时候 关闭 91 | showToast("本次复习结束,继续努力"); 92 | finish(); 93 | } 94 | } 95 | }); 96 | unremember.setOnClickListener(new View.OnClickListener() { 97 | @Override 98 | public void onClick(View v) { 99 | if (position != list.size() - 1) { 100 | vp.setCurrentItem(position + 1); 101 | } else { 102 | showToast("本次复习结束,继续努力"); 103 | finish(); 104 | } 105 | } 106 | }); 107 | } 108 | 109 | 110 | @Override 111 | protected void onDestroy() { 112 | super.onDestroy(); 113 | adapter.releaseMp(); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/SentenceTranslateActivity.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.View; 7 | import android.view.inputmethod.InputMethodManager; 8 | import android.widget.Button; 9 | import android.widget.EditText; 10 | import android.widget.TextView; 11 | 12 | import com.adm.dictionary.base.BaseActivity; 13 | import com.adm.dictionary.bean.SentenceBean; 14 | import com.adm.dictionary.http.HttpMethods; 15 | 16 | import rx.android.schedulers.AndroidSchedulers; 17 | import rx.functions.Action1; 18 | import rx.schedulers.Schedulers; 19 | 20 | /** 21 | * Created by Administrator on 2016/10/19. 22 | */ 23 | public class SentenceTranslateActivity extends BaseActivity { 24 | 25 | private EditText et; 26 | 27 | private Button but; 28 | 29 | private TextView tv; 30 | 31 | 32 | @Override 33 | protected void onCreate(@Nullable Bundle savedInstanceState) { 34 | super.onCreate(savedInstanceState); 35 | setContentView(R.layout.activity_sentence); 36 | initView(); 37 | 38 | but.setOnClickListener(new View.OnClickListener() { 39 | @Override 40 | public void onClick(View v) { 41 | ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)). 42 | hideSoftInputFromWindow(et.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); 43 | String str = et.getText().toString().trim(); 44 | if (et.equals("")) { 45 | showToast("请输入内容"); 46 | return; 47 | } 48 | HttpMethods.getInstance().sentenceTransLate(str).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 49 | @Override 50 | public void call(SentenceBean sentenceBean) { 51 | tv.setText(sentenceBean.getTranslation().get(0)); 52 | } 53 | }); 54 | } 55 | }); 56 | } 57 | 58 | @Override 59 | public void initView() { 60 | et = findEtnById(R.id.act_sentence_et); 61 | but = findButById(R.id.act_sentence_but); 62 | tv = findTextViewById(R.id.act_sentence_tv); 63 | } 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/TuijianFragment.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.media.MediaPlayer; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.adm.dictionary.base.BaseFragment; 13 | import com.adm.dictionary.bean.EveryDayWords; 14 | import com.adm.dictionary.http.HttpMethods; 15 | import com.adm.dictionary.util.HttpUtil; 16 | import com.bumptech.glide.Glide; 17 | 18 | import java.io.IOException; 19 | 20 | import rx.android.schedulers.AndroidSchedulers; 21 | import rx.functions.Action1; 22 | import rx.schedulers.Schedulers; 23 | 24 | /** 25 | * 推荐Fragment 26 | * Created by Administrator on 2016/10/18. 27 | */ 28 | public class TuijianFragment extends BaseFragment { 29 | 30 | private View v; 31 | private ImageView img, voice; 32 | private TextView content1, content2, des; 33 | private MediaPlayer mp; 34 | 35 | @Nullable 36 | @Override 37 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 38 | v = inflater.inflate(R.layout.frag_tuijian, null); 39 | initView(); 40 | getData(); 41 | return v; 42 | } 43 | 44 | private void getData() { 45 | if(!HttpUtil.isNetworkAvailable(getActivity())){ 46 | showToast("当前网络不可用"); 47 | voice.setVisibility(View.GONE); 48 | return; 49 | } 50 | 51 | HttpMethods.getInstance().getEveryDayWords().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { 52 | @Override 53 | public void call(final EveryDayWords everyDayWords) { 54 | content1.setText(everyDayWords.getContent()); 55 | content2.setText(everyDayWords.getNote()); 56 | des.setText(" " + everyDayWords.getTranslation()); 57 | Glide.with(getActivity()).load(everyDayWords.getPicture2()).into(img); 58 | voice.setOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | mp.reset(); 62 | try { 63 | mp.setDataSource(everyDayWords.getTts()); 64 | } catch (IOException e) { 65 | e.printStackTrace(); 66 | } 67 | mp.prepareAsync(); 68 | } 69 | }); 70 | } 71 | }); 72 | } 73 | 74 | @Override 75 | public void initView() { 76 | img = findImageViewbyId(v, R.id.frag_tui_img); 77 | voice = findImageViewbyId(v, R.id.frag_tui_voice); 78 | content1 = findTextViewbyId(v, R.id.frag_tui_content1); 79 | content2 = findTextViewbyId(v, R.id.frag_tui_content2); 80 | des = findTextViewbyId(v, R.id.frag_tui_des); 81 | mp = new MediaPlayer(); 82 | 83 | mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 84 | @Override 85 | public void onPrepared(MediaPlayer mp) { 86 | mp.start(); 87 | } 88 | }); 89 | } 90 | 91 | @Override 92 | public void onDestroy() { 93 | super.onDestroy(); 94 | if (mp.isPlaying()) { 95 | mp.stop(); 96 | } 97 | mp.release(); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/dictionary/WoDeFragment.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.dictionary; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.TextView; 10 | 11 | import com.adm.dictionary.base.BaseFragment; 12 | 13 | /** 14 | * Created by Administrator on 2016/10/18. 15 | */ 16 | public class WoDeFragment extends BaseFragment { 17 | 18 | private View v; 19 | private TextView frag_my_danciben, frag_my_plan, frag_my_dict; 20 | 21 | @Nullable 22 | @Override 23 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 24 | v = inflater.inflate(R.layout.frag_wode, null); 25 | initView(); 26 | return v; 27 | } 28 | 29 | @Override 30 | public void initView() { 31 | frag_my_danciben = findTextViewbyId(v, R.id.frag_my_danciben); 32 | frag_my_plan = findTextViewbyId(v, R.id.frag_my_plan); 33 | frag_my_dict = findTextViewbyId(v, R.id.frag_my_dict); 34 | frag_my_danciben.setOnClickListener(new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | startActivity(new Intent(getActivity(), DanCiBenActivity.class)); 38 | } 39 | }); 40 | frag_my_plan.setOnClickListener(new View.OnClickListener() { 41 | @Override 42 | public void onClick(View v) { 43 | startActivity(new Intent(getActivity(), PlanActivity.class)); 44 | } 45 | }); 46 | frag_my_dict.setOnClickListener(new View.OnClickListener() { 47 | @Override 48 | public void onClick(View v) { 49 | startActivity(new Intent(getActivity(), DictionaryActivity.class)); 50 | } 51 | }); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/http/ApiService.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.http; 2 | 3 | import com.adm.dictionary.bean.ChineseBean; 4 | import com.adm.dictionary.bean.EnglishBean; 5 | import com.adm.dictionary.bean.SentenceBean; 6 | import com.adm.dictionary.bean.EveryDayWords; 7 | 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Query; 10 | import rx.Observable; 11 | 12 | 13 | /** 14 | * 所有的网络请求方法 15 | * Created by Administrator on 2016/10/14. 16 | */ 17 | public interface ApiService { 18 | /** 19 | * 查询句子的方法 20 | * @param keyfrom 申请值 21 | * @param key 申请值 22 | * @param type 固定为data 23 | * @param doctype json/xml 24 | * @param version 固定为1.1 25 | * @param q 查询句子 26 | * @return 句子Bean 27 | */ 28 | @GET("/openapi.do") 29 | Observable sentenceTransLate(@Query("keyfrom") String keyfrom, @Query("key") String key, @Query("type") String type, @Query("doctype") 30 | String doctype, @Query("version") String version, @Query("q") String q); 31 | 32 | /** 33 | * 查询每日一句 34 | * @return 每日一句信息 35 | */ 36 | @GET("/dsapi") 37 | Observable getEveryDayWords(); 38 | 39 | /** 40 | * 查询英文 41 | * @param w 单词 42 | * @param key 申请的key 43 | * @param type json/xml 44 | * @return 英文bean 45 | */ 46 | @GET("/api/dictionary.php") 47 | Observable englishSearch(@Query("w") String w,@Query("key") String key,@Query("type") String type); 48 | 49 | /** 50 | * 查询中文 51 | * @param w 单词 52 | * @param key 申请的key 53 | * @param type json/xml 54 | * @return 中文Bean 55 | */ 56 | @GET("/api/dictionary.php") 57 | Observable chineseSearch(@Query("w") String w, @Query("key") String key, @Query("type") String type); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/http/Constants.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.http; 2 | 3 | /** 4 | * Created by Administrator on 2016/10/17. 5 | */ 6 | public class Constants { 7 | 8 | public static String KEYFROM = "dancizhushou00";//5425BFA77E53C82A6E0F30E888941BBE 9 | 10 | public static String KEY = "2102848981"; 11 | 12 | public static String CIBAKEY = "5425BFA77E53C82A6E0F30E888941BBE"; 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/http/HttpMethods.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.http; 2 | 3 | import com.adm.dictionary.bean.ChineseBean; 4 | import com.adm.dictionary.bean.EnglishBean; 5 | import com.adm.dictionary.bean.SentenceBean; 6 | import com.adm.dictionary.bean.EveryDayWords; 7 | 8 | import okhttp3.OkHttpClient; 9 | import okhttp3.logging.HttpLoggingInterceptor; 10 | import retrofit2.Retrofit; 11 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 12 | import retrofit2.converter.gson.GsonConverterFactory; 13 | import rx.Observable; 14 | 15 | /** 16 | * Created by Administrator on 2016/10/14. 17 | */ 18 | public class HttpMethods { 19 | 20 | private static HttpMethods instance; 21 | 22 | /** 23 | * 翻译句子 24 | */ 25 | private ApiService service1; 26 | /** 27 | * 每日一句 28 | */ 29 | private ApiService service2; 30 | /** 31 | * 翻译单词 32 | */ 33 | private ApiService service3; 34 | 35 | 36 | private HttpMethods() { 37 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); 38 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); 39 | OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build(); 40 | Retrofit retrofit1 = new Retrofit.Builder() 41 | .client(client) 42 | .baseUrl("http://fanyi.youdao.com") 43 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 44 | .addConverterFactory(GsonConverterFactory.create()) 45 | .build(); 46 | Retrofit retrofit2 = new Retrofit.Builder() 47 | .client(client) 48 | .baseUrl("http://open.iciba.com") 49 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 50 | .addConverterFactory(GsonConverterFactory.create()) 51 | .build(); 52 | Retrofit retrofit3 = new Retrofit.Builder() 53 | .client(client) 54 | .baseUrl("http://dict-co.iciba.com") 55 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 56 | .addConverterFactory(GsonConverterFactory.create()) 57 | .build(); 58 | service1 = retrofit1.create(ApiService.class); 59 | service2 = retrofit2.create(ApiService.class); 60 | service3 = retrofit3.create(ApiService.class); 61 | } 62 | 63 | public static HttpMethods getInstance() { 64 | if (instance == null) { 65 | synchronized (HttpMethods.class) { 66 | if (instance == null) { 67 | instance = new HttpMethods(); 68 | } 69 | } 70 | } 71 | return instance; 72 | } 73 | 74 | public Observable sentenceTransLate(String q) { 75 | return service1.sentenceTransLate(Constants.KEYFROM, Constants.KEY, "data", "json", "1.1", q); 76 | } 77 | public Observable getEveryDayWords(){ 78 | return service2.getEveryDayWords(); 79 | } 80 | 81 | public Observable searchEnglish(String w){ 82 | return service3.englishSearch(w,Constants.CIBAKEY,"json"); 83 | } 84 | public Observable searchChinese(String w){ 85 | return service3.chineseSearch(w,Constants.CIBAKEY,"json"); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.util; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | 6 | import java.io.File; 7 | import java.io.FileNotFoundException; 8 | import java.io.FileOutputStream; 9 | import java.io.IOException; 10 | import java.io.InputStream; 11 | 12 | /** 13 | * Created by Administrator on 2016/10/17. 14 | */ 15 | public class FileUtil { 16 | 17 | public static SQLiteDatabase openDatabase(Context context,String dbfile) { 18 | try { 19 | File file = new File(dbfile); 20 | if (!file.exists()) { 21 | InputStream is = context.getAssets().open("dictionary.db"); 22 | FileOutputStream fos = new FileOutputStream(dbfile); 23 | byte[] buffer = new byte[1024]; 24 | int count = -1; 25 | while ((count = is.read(buffer)) != -1) { 26 | fos.write(buffer, 0, count); 27 | fos.flush(); 28 | } 29 | fos.close(); 30 | is.close(); 31 | } 32 | SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null); 33 | return db; 34 | } catch (FileNotFoundException e) { 35 | e.printStackTrace(); 36 | } catch (IOException e) { 37 | e.printStackTrace(); 38 | } 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/util/HttpUtil.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.util; 2 | 3 | import android.content.Context; 4 | import android.net.ConnectivityManager; 5 | import android.net.NetworkInfo; 6 | 7 | /** 8 | * 检测网络类 9 | * Created by Administrator on 2016/11/24. 10 | */ 11 | public class HttpUtil { 12 | /** 13 | * 检测当的网络(WLAN、3G/2G)状态 14 | * 15 | * @param context Context 16 | * @return true 表示网络可用 17 | */ 18 | public static boolean isNetworkAvailable(Context context) { 19 | ConnectivityManager connectivity = (ConnectivityManager) context 20 | .getSystemService(Context.CONNECTIVITY_SERVICE); 21 | if (connectivity != null) { 22 | NetworkInfo info = connectivity.getActiveNetworkInfo(); 23 | if (info != null && info.isConnected()) { 24 | // 当前网络是连接的 25 | if (info.getState() == NetworkInfo.State.CONNECTED) { 26 | // 当前所连接的网络可用 27 | return true; 28 | } 29 | } 30 | } 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/util/SharedPreUtil.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.widget.Toast; 6 | 7 | import com.google.gson.Gson; 8 | 9 | import java.util.Arrays; 10 | import java.util.List; 11 | 12 | /** 13 | * Created by Administrator on 2016/10/19. 14 | */ 15 | public class SharedPreUtil { 16 | 17 | //存储的sharedpreferences文件名 18 | private static final String FILE_NAME = "history"; 19 | private static final String FILE_NAME_GROUP = "group"; 20 | private static Gson gson = new Gson(); 21 | 22 | /** 23 | * 保存数据到文件 24 | * 25 | * @param context 26 | * @param key 27 | * @param data 28 | */ 29 | public static void saveHistory(Context context, String key, Object data) { 30 | 31 | String type = data.getClass().getSimpleName(); 32 | SharedPreferences sharedPreferences = context 33 | .getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); 34 | SharedPreferences.Editor editor = sharedPreferences.edit(); 35 | 36 | if ("Integer".equals(type)) { 37 | editor.putInt(key, (Integer) data); 38 | } else if ("Boolean".equals(type)) { 39 | editor.putBoolean(key, (Boolean) data); 40 | } else if ("String".equals(type)) { 41 | editor.putString(key, (String) data); 42 | } else if ("Float".equals(type)) { 43 | editor.putFloat(key, (Float) data); 44 | } else if ("Long".equals(type)) { 45 | editor.putLong(key, (Long) data); 46 | } else { 47 | String object = gson.toJson(data); 48 | editor.putString(key, object); 49 | } 50 | editor.commit(); 51 | } 52 | 53 | /** 54 | * 从文件中读取历史集合 55 | * 56 | * @param context 57 | * @param key 58 | * @return 59 | */ 60 | public static List getList(Context context, String key) { 61 | SharedPreferences sharedPreferences = context.getSharedPreferences 62 | (FILE_NAME, Context.MODE_PRIVATE); 63 | String listStr = sharedPreferences.getString(key, null); 64 | List list = gson.fromJson(listStr, List.class); 65 | return list; 66 | } 67 | 68 | /** 69 | * 清空搜索历史 70 | * 71 | * @param context 72 | */ 73 | public static void clearHistory(Context context) { 74 | SharedPreferences sharedPreferences = context.getSharedPreferences 75 | (FILE_NAME, Context.MODE_PRIVATE); 76 | sharedPreferences.edit().clear().commit(); 77 | Toast.makeText(context, "清除成功", Toast.LENGTH_SHORT).show(); 78 | 79 | } 80 | 81 | /** 82 | * 保存分组信息 83 | * 84 | * @param context 85 | * @param key 86 | * @param data 87 | */ 88 | public static void saveGroup(Context context, String key, List data) { 89 | SharedPreferences sharedPreferences = context 90 | .getSharedPreferences(FILE_NAME_GROUP, Context.MODE_PRIVATE); 91 | SharedPreferences.Editor editor = sharedPreferences.edit(); 92 | String group = gson.toJson(data); 93 | editor.putString(key, group); 94 | editor.commit(); 95 | } 96 | 97 | /** 98 | * 获取分组信息 99 | * 100 | * @param context 101 | * @param key 102 | * @return 103 | */ 104 | public static List getGroup(Context context, String key) { 105 | SharedPreferences sharedPreferences = context 106 | .getSharedPreferences(FILE_NAME_GROUP, Context.MODE_PRIVATE); 107 | String group = sharedPreferences.getString(key, ""); 108 | List data = gson.fromJson(group, List.class); 109 | return data; 110 | } 111 | } 112 | 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/view/CardAdapter.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.view; 2 | 3 | 4 | import android.support.v7.widget.CardView; 5 | 6 | public interface CardAdapter { 7 | 8 | int MAX_ELEVATION_FACTOR = 8; 9 | 10 | float getBaseElevation(); 11 | 12 | CardView getCardViewAt(int position); 13 | 14 | int getCount(); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/view/CardPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.view; 2 | 3 | import android.media.MediaPlayer; 4 | import android.support.v4.view.PagerAdapter; 5 | import android.support.v7.widget.CardView; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.Button; 10 | import android.widget.TextView; 11 | 12 | import com.adm.dictionary.bean.WordBean; 13 | import com.adm.dictionary.dictionary.R; 14 | 15 | import java.io.IOException; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class CardPagerAdapter extends PagerAdapter implements CardAdapter { 20 | 21 | private List mViews; 22 | private List mData; 23 | private float mBaseElevation; 24 | private MediaPlayer mp; 25 | 26 | public CardPagerAdapter(List mData) { 27 | this.mData = mData; 28 | mViews = new ArrayList<>(); 29 | mp = new MediaPlayer(); 30 | mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 31 | @Override 32 | public void onPrepared(MediaPlayer mp) { 33 | mp.start(); 34 | } 35 | }); 36 | for (int i = 0; i < mData.size(); i++) { 37 | mViews.add(null); 38 | } 39 | } 40 | 41 | public float getBaseElevation() { 42 | return mBaseElevation; 43 | } 44 | 45 | @Override 46 | public CardView getCardViewAt(int position) { 47 | return mViews.get(position); 48 | } 49 | 50 | @Override 51 | public int getCount() { 52 | return mData.size(); 53 | } 54 | 55 | @Override 56 | public boolean isViewFromObject(View view, Object object) { 57 | return view == object; 58 | } 59 | 60 | @Override 61 | public Object instantiateItem(ViewGroup container, int position) { 62 | View view = LayoutInflater.from(container.getContext()) 63 | .inflate(R.layout.adapter, container, false); 64 | container.addView(view); 65 | CardView cardView = (CardView) view.findViewById(R.id.cardView); 66 | 67 | if (mBaseElevation == 0) { 68 | mBaseElevation = cardView.getCardElevation(); 69 | } 70 | cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR); 71 | initData(view, position); 72 | mViews.set(position, cardView); 73 | return view; 74 | } 75 | 76 | /** 77 | * 讲数据添加到控件上 78 | * 79 | * @param view 80 | * @param position 81 | */ 82 | private void initData(View view, final int position) { 83 | TextView title = (TextView) view.findViewById(R.id.item_prac_name); 84 | TextView ukduyin = (TextView) view.findViewById(R.id.item_prac_ukduyin); 85 | TextView usduyin = (TextView) view.findViewById(R.id.item_prac_usduyin); 86 | Button ukvoice = (Button) view.findViewById(R.id.item_prac_ukvoice); 87 | Button usvoice = (Button) view.findViewById(R.id.item_prac_usvoice); 88 | final TextView but = (TextView) view.findViewById(R.id.item_prac_but); 89 | final TextView meaning = (TextView) view.findViewById(R.id.item_prac_meaning); 90 | title.setText(mData.get(position).getName()); 91 | ukduyin.setText("[美]" + mData.get(position).getEn_sympol()); 92 | usduyin.setText("[英]" + mData.get(position).getAm_symbol()); 93 | StringBuilder builder = new StringBuilder(); 94 | for (int i = 0; i < mData.get(position).getParts().size(); i++) { 95 | builder.append(mData.get(position).getParts().get(i).getPart()).append(" ").append(mData.get(position).getParts().get(i).getMeans()).append("\r\n"); 96 | } 97 | meaning.setText(builder.toString()); 98 | but.setOnClickListener(new View.OnClickListener() { 99 | @Override 100 | public void onClick(View v) { 101 | but.setVisibility(View.INVISIBLE); 102 | meaning.setVisibility(View.VISIBLE); 103 | } 104 | }); 105 | ukvoice.setOnClickListener(new View.OnClickListener() { 106 | @Override 107 | public void onClick(View v) { 108 | if (mData.get(position).getEn_mp3() == null || mData.get(position).getEn_mp3().equals("")) { 109 | return; 110 | } 111 | mp.reset(); 112 | try { 113 | mp.setDataSource(mData.get(position).getEn_mp3()); 114 | } catch (IOException e) { 115 | e.printStackTrace(); 116 | } 117 | mp.prepareAsync(); 118 | } 119 | }); 120 | usvoice.setOnClickListener(new View.OnClickListener() { 121 | @Override 122 | public void onClick(View v) { 123 | if (mData.get(position).getAm_mp3() == null || mData.get(position).getAm_mp3().equals("")) { 124 | return; 125 | } 126 | mp.reset(); 127 | try { 128 | mp.setDataSource(mData.get(position).getAm_mp3()); 129 | } catch (IOException e) { 130 | e.printStackTrace(); 131 | } 132 | mp.prepareAsync(); 133 | } 134 | }); 135 | } 136 | 137 | @Override 138 | public void destroyItem(ViewGroup container, int position, Object object) { 139 | container.removeView((View) object); 140 | mViews.set(position, null); 141 | } 142 | 143 | 144 | public void releaseMp() { 145 | if (mp.isPlaying()) { 146 | mp.stop(); 147 | } 148 | mp.release(); 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/view/ShadowTransformer.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.view; 2 | 3 | import android.support.v4.view.ViewPager; 4 | import android.support.v7.widget.CardView; 5 | import android.view.View; 6 | 7 | 8 | public class ShadowTransformer implements ViewPager.OnPageChangeListener, ViewPager.PageTransformer { 9 | 10 | private ViewPager mViewPager; 11 | private CardAdapter mAdapter; 12 | private float mLastOffset; 13 | private boolean mScalingEnabled; 14 | 15 | public ShadowTransformer(ViewPager viewPager, CardAdapter adapter) { 16 | mViewPager = viewPager; 17 | viewPager.addOnPageChangeListener(this); 18 | mAdapter = adapter; 19 | } 20 | 21 | public void enableScaling(boolean enable) { 22 | if (mScalingEnabled && !enable) { 23 | // shrink main card 24 | CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); 25 | if (currentCard != null) { 26 | currentCard.animate().scaleY(1); 27 | currentCard.animate().scaleX(1); 28 | } 29 | }else if(!mScalingEnabled && enable){ 30 | // grow main card 31 | CardView currentCard = mAdapter.getCardViewAt(mViewPager.getCurrentItem()); 32 | if (currentCard != null) { 33 | currentCard.animate().scaleY(1.1f); 34 | currentCard.animate().scaleX(1.1f); 35 | } 36 | } 37 | 38 | mScalingEnabled = enable; 39 | } 40 | 41 | @Override 42 | public void transformPage(View page, float position) { 43 | 44 | } 45 | 46 | @Override 47 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 48 | int realCurrentPosition; 49 | int nextPosition; 50 | float baseElevation = mAdapter.getBaseElevation(); 51 | float realOffset; 52 | boolean goingLeft = mLastOffset > positionOffset; 53 | 54 | // If we're going backwards, onPageScrolled receives the last position 55 | // instead of the current one 56 | if (goingLeft) { 57 | realCurrentPosition = position + 1; 58 | nextPosition = position; 59 | realOffset = 1 - positionOffset; 60 | } else { 61 | nextPosition = position + 1; 62 | realCurrentPosition = position; 63 | realOffset = positionOffset; 64 | } 65 | 66 | // Avoid crash on overscroll 67 | if (nextPosition > mAdapter.getCount() - 1 68 | || realCurrentPosition > mAdapter.getCount() - 1) { 69 | return; 70 | } 71 | 72 | CardView currentCard = mAdapter.getCardViewAt(realCurrentPosition); 73 | 74 | // This might be null if a fragment is being used 75 | // and the views weren't created yet 76 | if (currentCard != null) { 77 | if (mScalingEnabled) { 78 | currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset))); 79 | currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset))); 80 | } 81 | currentCard.setCardElevation((baseElevation + baseElevation 82 | * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset))); 83 | } 84 | 85 | CardView nextCard = mAdapter.getCardViewAt(nextPosition); 86 | 87 | // We might be scrolling fast enough so that the next (or previous) card 88 | // was already destroyed or a fragment might not have been created yet 89 | if (nextCard != null) { 90 | if (mScalingEnabled) { 91 | nextCard.setScaleX((float) (1 + 0.1 * (realOffset))); 92 | nextCard.setScaleY((float) (1 + 0.1 * (realOffset))); 93 | } 94 | nextCard.setCardElevation((baseElevation + baseElevation 95 | * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset))); 96 | } 97 | 98 | mLastOffset = positionOffset; 99 | } 100 | 101 | @Override 102 | public void onPageSelected(int position) { 103 | 104 | } 105 | 106 | @Override 107 | public void onPageScrollStateChanged(int state) { 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /app/src/main/java/com/adm/dictionary/view/XCRoundRectImageView.java: -------------------------------------------------------------------------------- 1 | package com.adm.dictionary.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.Bitmap.Config; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.graphics.PorterDuff.Mode; 10 | import android.graphics.PorterDuffXfermode; 11 | import android.graphics.Rect; 12 | import android.graphics.drawable.BitmapDrawable; 13 | import android.graphics.drawable.Drawable; 14 | import android.util.AttributeSet; 15 | import android.widget.ImageView; 16 | 17 | /** 18 | * 自定义的圆角矩形ImageView,可以直接当组件在布局中使用。 19 | * 20 | * @author caizhiming 21 | */ 22 | public class XCRoundRectImageView extends ImageView { 23 | 24 | private Paint paint; 25 | 26 | public XCRoundRectImageView(Context context) { 27 | this(context, null); 28 | } 29 | 30 | public XCRoundRectImageView(Context context, AttributeSet attrs) { 31 | this(context, attrs, 0); 32 | } 33 | 34 | public XCRoundRectImageView(Context context, AttributeSet attrs, int defStyle) { 35 | super(context, attrs, defStyle); 36 | paint = new Paint(); 37 | } 38 | 39 | /** 40 | * 绘制圆角矩形图片 41 | * 42 | * @author caizhiming 43 | */ 44 | @Override 45 | protected void onDraw(Canvas canvas) { 46 | 47 | Drawable drawable = getDrawable(); 48 | if (null != drawable) { 49 | Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); 50 | Bitmap b = getRoundBitmap(bitmap, 20); 51 | final Rect rectSrc = new Rect(0, 0, b.getWidth(), b.getHeight()); 52 | final Rect rectDest = new Rect(0, 0, getWidth(), getHeight()); 53 | paint.reset(); 54 | canvas.drawBitmap(b, rectSrc, rectDest, paint); 55 | 56 | } else { 57 | super.onDraw(canvas); 58 | } 59 | } 60 | 61 | /** 62 | * 获取圆角矩形图片方法 63 | * 64 | * @param bitmap 65 | * @param roundPx,一般设置成14 66 | * @return Bitmap 67 | * @author caizhiming 68 | */ 69 | private Bitmap getRoundBitmap(Bitmap bitmap, int roundPx) { 70 | Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), 71 | bitmap.getHeight(), Config.ARGB_8888); 72 | Canvas canvas = new Canvas(output); 73 | 74 | final int color = 0xff424242; 75 | 76 | final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); 77 | final RectF rectF = new RectF(rect); 78 | paint.setAntiAlias(true); 79 | canvas.drawARGB(0, 0, 0, 0); 80 | paint.setColor(color); 81 | int x = bitmap.getWidth(); 82 | 83 | canvas.drawRoundRect(rectF, roundPx, roundPx, paint); 84 | paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); 85 | canvas.drawBitmap(bitmap, rect, rect, paint); 86 | return output; 87 | 88 | 89 | } 90 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/add_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/add_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/banner1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/banner1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/banner2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/banner2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/banner3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/banner3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/dictionary.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/dictionary.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/edit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/edit_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/edit_pressed.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/staroff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/staroff.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/staron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/staron.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/voice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/voice.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/voice_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yuanhongliang/Dictionary/20553bf22866f03c6f33c98412bf3c8960132178/app/src/main/res/drawable-xhdpi/voice_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/add_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/but_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/clear_history.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/edit_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/his_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_bookmark_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/remember.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/translate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/unremember.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/voice_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_chinese_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | 24 | 25 | 33 | 34 | 35 | 40 | 41 | 48 | 49 | 50 | 51 | 58 | 59 | 66 | 67 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_danciben.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 20 | 21 |