├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── values │ │ │ │ ├── ids.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable │ │ │ │ ├── ic_add_white_24dp.xml │ │ │ │ ├── ic_chevron_right_black_24dp.xml │ │ │ │ ├── ic_delete_forever_black_24dp.xml │ │ │ │ ├── ic_search_black_24dp.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── menu │ │ │ │ └── main_menu.xml │ │ │ ├── navigation │ │ │ │ └── navigation.xml │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_words.xml │ │ │ │ ├── fragment_add.xml │ │ │ │ ├── cell_normal.xml │ │ │ │ ├── cell_card.xml │ │ │ │ ├── cell_normal_2.xml │ │ │ │ └── cell_card_2.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── words │ │ │ │ ├── WordDao.java │ │ │ │ ├── WordViewModel.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── Word.java │ │ │ │ ├── WordDatabase.java │ │ │ │ ├── WordRepository.java │ │ │ │ ├── AddFragment.java │ │ │ │ ├── MyAdapter.java │ │ │ │ └── WordsFragment.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── words │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── example │ │ └── words │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── README.md ├── .idea ├── encodings.xml ├── misc.xml ├── runConfigurations.xml ├── gradle.xml ├── codeStyles │ └── Project.xml └── dbnavigator.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Words-Step-4-Done 2 | Source code for video tutorials of "Android 基础教程" on bilibili.com [longway777](https://space.bilibili.com/137860026) 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/longway777/Words-Step-4/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Words 3 | 4 | 5 | Hello blank fragment 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 02 03:14:38 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_white_24dp.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_chevron_right_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/example/words/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_delete_forever_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/main_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 11 | 17 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/example/words/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.InstrumentationRegistry; 6 | import androidx.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getTargetContext(); 24 | 25 | assertEquals("com.example.roombasic", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/words/WordDao.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.room.Dao; 5 | import androidx.room.Delete; 6 | import androidx.room.Insert; 7 | import androidx.room.Query; 8 | import androidx.room.Update; 9 | 10 | import java.util.List; 11 | 12 | @Dao // Database access object 13 | public interface WordDao { 14 | @Insert 15 | void insertWords(Word... words); 16 | 17 | @Update 18 | void updateWords(Word... words); 19 | 20 | @Delete 21 | void deleteWords(Word... words); 22 | 23 | @Query("DELETE FROM WORD") 24 | void deleteAllWords(); 25 | 26 | @Query("SELECT * FROM WORD ORDER BY ID DESC") 27 | //List getAllWords(); 28 | LiveData>getAllWordsLive(); 29 | 30 | @Query("SELECT * FROM WORD WHERE english_word LIKE :pattern ORDER BY ID DESC") 31 | LiveData>findWordsWithPattern(String pattern); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/navigation/navigation.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 20 | 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_words.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 19 | 20 | 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/words/WordViewModel.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import android.app.Application; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.lifecycle.AndroidViewModel; 7 | import androidx.lifecycle.LiveData; 8 | 9 | import java.util.List; 10 | 11 | public class WordViewModel extends AndroidViewModel { 12 | private WordRepository wordRepository; 13 | public WordViewModel(@NonNull Application application) { 14 | super(application); 15 | wordRepository = new WordRepository(application); 16 | } 17 | 18 | LiveData> getAllWordsLive() { 19 | return wordRepository.getAllWordsLive(); 20 | } 21 | LiveData> findWordsWithPattern(String patten) { 22 | return wordRepository.findWordsWithPattern(patten); 23 | } 24 | 25 | void insertWords(Word... words) { 26 | wordRepository.insertWords(words); 27 | } 28 | void updateWords(Word... words) { 29 | wordRepository.updateWords(words); 30 | } 31 | void deleteWords(Word... words) { 32 | wordRepository.deleteWords(words); 33 | } 34 | void deleteAllWords() { 35 | wordRepository.deleteAllWords(); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/words/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.view.inputmethod.InputMethodManager; 6 | 7 | import androidx.appcompat.app.AppCompatActivity; 8 | import androidx.navigation.NavController; 9 | import androidx.navigation.Navigation; 10 | import androidx.navigation.ui.NavigationUI; 11 | 12 | public class MainActivity extends AppCompatActivity { 13 | private NavController navController; 14 | 15 | 16 | @Override 17 | protected void onCreate(Bundle savedInstanceState) { 18 | super.onCreate(savedInstanceState); 19 | setContentView(R.layout.activity_main); 20 | navController = Navigation.findNavController(findViewById(R.id.fragment)); 21 | NavigationUI.setupActionBarWithNavController(this,navController); 22 | 23 | } 24 | 25 | 26 | 27 | @Override 28 | public void onBackPressed() { 29 | super.onBackPressed(); 30 | navController.navigateUp(); 31 | } 32 | 33 | @Override 34 | public boolean onSupportNavigateUp() { 35 | InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE); 36 | imm.hideSoftInputFromWindow(findViewById(R.id.fragment).getWindowToken(),0); 37 | navController.navigateUp(); 38 | return super.onSupportNavigateUp(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.example.words" 7 | minSdkVersion 19 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 12 | android.defaultConfig.vectorDrawables.useSupportLibrary = true 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | implementation fileTree(dir: 'libs', include: ['*.jar']) 24 | implementation 'androidx.appcompat:appcompat:1.0.2' 25 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 26 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 27 | testImplementation 'junit:junit:4.12' 28 | androidTestImplementation 'androidx.test:runner:1.2.0' 29 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 30 | 31 | def room_version = "2.2.0-alpha01" 32 | 33 | implementation "androidx.room:room-runtime:$room_version" 34 | annotationProcessor "androidx.room:room-compiler:$room_version" 35 | // For Kotlin use kapt instead of annotationProcessor 36 | 37 | 38 | // Test helpers 39 | testImplementation "androidx.room:room-testing:$room_version" 40 | implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' 41 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 42 | implementation 'androidx.cardview:cardview:1.0.0' 43 | implementation 'androidx.navigation:navigation-fragment:2.0.0' 44 | implementation 'androidx.navigation:navigation-ui:2.1.0' 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/words/Word.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import androidx.room.ColumnInfo; 4 | import androidx.room.Entity; 5 | import androidx.room.PrimaryKey; 6 | 7 | @Entity 8 | public class Word { 9 | @PrimaryKey(autoGenerate = true) 10 | private int id; 11 | 12 | @ColumnInfo(name = "english_word") 13 | private String word; 14 | @ColumnInfo(name = "chinese_meaning") 15 | private String chineseMeaning; 16 | 17 | @ColumnInfo(name = "chinese_invisible") 18 | private boolean chineseInvisible; 19 | 20 | boolean isChineseInvisible() { 21 | return chineseInvisible; 22 | } 23 | 24 | void setChineseInvisible(boolean chineseInvisible) { 25 | this.chineseInvisible = chineseInvisible; 26 | } 27 | // @ColumnInfo(name = "foo_data") 28 | // private boolean foo; 29 | // @ColumnInfo(name = "bar_data") 30 | // private boolean bar; 31 | // 32 | // public boolean isBar() { 33 | // return bar; 34 | // } 35 | // 36 | // public void setBar(boolean bar) { 37 | // this.bar = bar; 38 | // } 39 | // 40 | // public boolean isFoo() { 41 | // return foo; 42 | // } 43 | // 44 | // public void setFoo(boolean foo) { 45 | // this.foo = foo; 46 | // } 47 | 48 | public Word(String word, String chineseMeaning) { 49 | this.word = word; 50 | this.chineseMeaning = chineseMeaning; 51 | } 52 | 53 | public int getId() { 54 | return id; 55 | } 56 | 57 | public void setId(int id) { 58 | this.id = id; 59 | } 60 | 61 | public String getWord() { 62 | return word; 63 | } 64 | 65 | public void setWord(String word) { 66 | this.word = word; 67 | } 68 | 69 | String getChineseMeaning() { 70 | return chineseMeaning; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/words/WordDatabase.java: -------------------------------------------------------------------------------- 1 | package com.example.words; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.annotation.NonNull; 6 | import androidx.room.Database; 7 | import androidx.room.Room; 8 | import androidx.room.RoomDatabase; 9 | import androidx.room.migration.Migration; 10 | import androidx.sqlite.db.SupportSQLiteDatabase; 11 | 12 | //singleton 13 | @Database(entities = {Word.class},version = 5,exportSchema = false) 14 | public abstract class WordDatabase extends RoomDatabase { 15 | private static WordDatabase INSTANCE; 16 | static synchronized WordDatabase getDatabase(Context context) { 17 | if (INSTANCE == null) { 18 | INSTANCE = Room.databaseBuilder(context.getApplicationContext(),WordDatabase.class,"word_database") 19 | //.fallbackToDestructiveMigration() 20 | .addMigrations(MIGRATION_4_5) 21 | .build(); 22 | } 23 | return INSTANCE; 24 | } 25 | public abstract WordDao getWordDao(); 26 | 27 | static final Migration MIGRATION_2_3 = new Migration(2,3) { 28 | @Override 29 | public void migrate(@NonNull SupportSQLiteDatabase database) { 30 | database.execSQL("ALTER TABLE word ADD COLUMN bar_data INTEGER NOT NULL DEFAULT 1"); 31 | } 32 | }; 33 | 34 | static final Migration MIGRATION_3_4 = new Migration(3,4) { 35 | @Override 36 | public void migrate(@NonNull SupportSQLiteDatabase database) { 37 | database.execSQL("CREATE TABLE word_temp (id INTEGER PRIMARY KEY NOT NULL ,english_word TEXT," + 38 | "chinese_meaning TEXT)"); 39 | database.execSQL("INSERT INTO word_temp (id,english_word,chinese_meaning) " + 40 | "SELECT id,english_word,chinese_meaning FROM word"); 41 | database.execSQL("DROP TABLE word"); 42 | database.execSQL("ALTER TABLE word_temp RENAME to word"); 43 | } 44 | }; 45 | 46 | private static final Migration MIGRATION_4_5 = new Migration(4,5) { 47 | @Override 48 | public void migrate(@NonNull SupportSQLiteDatabase database) { 49 | database.execSQL("ALTER TABLE word ADD COLUMN chinese_invisible INTEGER NOT NULL DEFAULT 0"); 50 | } 51 | }; 52 | } 53 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_add.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 | 36 | 37 | 49 | 50 |