Commit 3b4c9b45dcee48059eab3d343ebc378cc4642e9c
0 parents
Exists in
master
create the project of LianHanZi
Showing
93 changed files
with
3686 additions
and
0 deletions
Show diff stats
MiaohongEntry/.gitignore
| File was created | 1 | *.iml | |
| 2 | .gradle | ||
| 3 | /local.properties | ||
| 4 | /.idea/workspace.xml | ||
| 5 | /.idea/libraries | ||
| 6 | .DS_Store | ||
| 7 | /build | ||
| 8 | /captures | ||
| 9 | .externalNativeBuild | ||
| 10 |
MiaohongEntry/.idea/compiler.xml
| File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <project version="4"> | ||
| 3 | <component name="CompilerConfiguration"> | ||
| 4 | <resourceExtensions /> | ||
| 5 | <wildcardResourcePatterns> | ||
| 6 | <entry name="!?*.java" /> | ||
| 7 | <entry name="!?*.form" /> | ||
| 8 | <entry name="!?*.class" /> | ||
| 9 | <entry name="!?*.groovy" /> | ||
| 10 | <entry name="!?*.scala" /> | ||
| 11 | <entry name="!?*.flex" /> | ||
| 12 | <entry name="!?*.kt" /> | ||
| 13 | <entry name="!?*.clj" /> | ||
| 14 | <entry name="!?*.aj" /> | ||
| 15 | </wildcardResourcePatterns> | ||
| 16 | <annotationProcessing> | ||
| 17 | <profile default="true" name="Default" enabled="false"> | ||
| 18 | <processorPath useClasspath="true" /> | ||
| 19 | </profile> | ||
| 20 | </annotationProcessing> | ||
| 21 | </component> | ||
| 22 | </project> |
MiaohongEntry/.idea/copyright/profiles_settings.xml
| File was created | 1 | <component name="CopyrightManager"> | |
| 2 | <settings default="" /> | ||
| 3 | </component> |
MiaohongEntry/.idea/gradle.xml
| File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <project version="4"> | ||
| 3 | <component name="GradleSettings"> | ||
| 4 | <option name="linkedExternalProjectsSettings"> | ||
| 5 | <GradleProjectSettings> | ||
| 6 | <option name="distributionType" value="DEFAULT_WRAPPED" /> | ||
| 7 | <option name="externalProjectPath" value="$PROJECT_DIR$" /> | ||
| 8 | <option name="modules"> | ||
| 9 | <set> | ||
| 10 | <option value="$PROJECT_DIR$" /> | ||
| 11 | <option value="$PROJECT_DIR$/app" /> | ||
| 12 | </set> | ||
| 13 | </option> | ||
| 14 | <option name="resolveModulePerSourceSet" value="false" /> | ||
| 15 | </GradleProjectSettings> | ||
| 16 | </option> | ||
| 17 | </component> | ||
| 18 | </project> |
MiaohongEntry/.idea/misc.xml
| File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <project version="4"> | ||
| 3 | <component name="EntryPointsManager"> | ||
| 4 | <entry_points version="2.0" /> | ||
| 5 | </component> | ||
| 6 | <component name="NullableNotNullManager"> | ||
| 7 | <option name="myDefaultNullable" value="android.support.annotation.Nullable" /> | ||
| 8 | <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> | ||
| 9 | <option name="myNullables"> | ||
| 10 | <value> | ||
| 11 | <list size="4"> | ||
| 12 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> | ||
| 13 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> | ||
| 14 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> | ||
| 15 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> | ||
| 16 | </list> | ||
| 17 | </value> | ||
| 18 | </option> | ||
| 19 | <option name="myNotNulls"> | ||
| 20 | <value> | ||
| 21 | <list size="4"> | ||
| 22 | <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> | ||
| 23 | <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> | ||
| 24 | <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> | ||
| 25 | <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> | ||
| 26 | </list> | ||
| 27 | </value> | ||
| 28 | </option> | ||
| 29 | </component> | ||
| 30 | <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | ||
| 31 | <OptionsSetting value="true" id="Add" /> | ||
| 32 | <OptionsSetting value="true" id="Remove" /> | ||
| 33 | <OptionsSetting value="true" id="Checkout" /> | ||
| 34 | <OptionsSetting value="true" id="Update" /> | ||
| 35 | <OptionsSetting value="true" id="Status" /> | ||
| 36 | <OptionsSetting value="true" id="Edit" /> | ||
| 37 | <ConfirmationsSetting value="0" id="Add" /> | ||
| 38 | <ConfirmationsSetting value="0" id="Remove" /> | ||
| 39 | </component> | ||
| 40 | <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> | ||
| 41 | <output url="file://$PROJECT_DIR$/build/classes" /> | ||
| 42 | </component> | ||
| 43 | <component name="ProjectType"> | ||
| 44 | <option name="id" value="Android" /> | ||
| 45 | </component> | ||
| 46 | </project> |
MiaohongEntry/.idea/modules.xml
| File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <project version="4"> | ||
| 3 | <component name="ProjectModuleManager"> | ||
| 4 | <modules> | ||
| 5 | <module fileurl="file://$PROJECT_DIR$/MiaohongEntry.iml" filepath="$PROJECT_DIR$/MiaohongEntry.iml" /> | ||
| 6 | <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> | ||
| 7 | </modules> | ||
| 8 | </component> | ||
| 9 | </project> |
MiaohongEntry/.idea/runConfigurations.xml
| File was created | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | <project version="4"> | ||
| 3 | <component name="RunConfigurationProducerService"> | ||
| 4 | <option name="ignoredProducers"> | ||
| 5 | <set> | ||
| 6 | <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" /> | ||
| 7 | <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" /> | ||
| 8 | <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" /> | ||
| 9 | </set> | ||
| 10 | </option> | ||
| 11 | </component> | ||
| 12 | </project> |
MiaohongEntry/app/.gitignore
| File was created | 1 | /build | |
| 2 |
MiaohongEntry/app/build.gradle
| File was created | 1 | apply plugin: 'com.android.application' | |
| 2 | |||
| 3 | android { | ||
| 4 | compileSdkVersion 26 | ||
| 5 | buildToolsVersion "26.0.2" | ||
| 6 | defaultConfig { | ||
| 7 | applicationId "com.hjx.miaohongentry" | ||
| 8 | minSdkVersion 17 | ||
| 9 | targetSdkVersion 26 | ||
| 10 | versionCode 2 | ||
| 11 | versionName "1.0.1" | ||
| 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
| 13 | } | ||
| 14 | buildTypes { | ||
| 15 | release { | ||
| 16 | minifyEnabled false | ||
| 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
| 18 | } | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | dependencies { | ||
| 23 | compile fileTree(include: ['*.jar'], dir: 'libs') | ||
| 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
| 25 | exclude group: 'com.android.support', module: 'support-annotations' | ||
| 26 | }) | ||
| 27 | compile files('src/main/libs/pinyin4j-2.5.0.jar') | ||
| 28 | compile 'com.android.support:appcompat-v7:26.+' | ||
| 29 | compile 'com.android.support.constraint:constraint-layout:1.0.2' | ||
| 30 | compile 'com.android.support:support-v4:26.+' | ||
| 31 | compile 'com.tencent.bugly:crashreport:latest.release' | ||
| 32 | testCompile 'junit:junit:4.12' | ||
| 33 | } | ||
| 34 |
MiaohongEntry/app/proguard-rules.pro
| File was created | 1 | # Add project specific ProGuard rules here. | |
| 2 | # By default, the flags in this file are appended to flags specified | ||
| 3 | # in C:\Users\l\AppData\Local\Android\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 | |||
| 19 | # Uncomment this to preserve the line number information for | ||
| 20 | # debugging stack traces. | ||
| 21 | #-keepattributes SourceFile,LineNumberTable | ||
| 22 | |||
| 23 | # If you keep the line number information, uncomment this to | ||
| 24 | # hide the original source file name. | ||
| 25 | #-renamesourcefileattribute SourceFile | ||
| 26 |
MiaohongEntry/app/src/androidTest/java/com/hjx/miaohongentry/ExampleInstrumentedTest.java
| File was created | 1 | package com.hjx.miaohongentry; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.support.test.InstrumentationRegistry; | ||
| 5 | import android.support.test.runner.AndroidJUnit4; | ||
| 6 | |||
| 7 | import org.junit.Test; | ||
| 8 | import org.junit.runner.RunWith; | ||
| 9 | |||
| 10 | import static org.junit.Assert.*; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Instrumentation test, which will execute on an Android device. | ||
| 14 | * | ||
| 15 | * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
| 16 | */ | ||
| 17 | @RunWith(AndroidJUnit4.class) | ||
| 18 | public class ExampleInstrumentedTest { | ||
| 19 | @Test | ||
| 20 | public void useAppContext() throws Exception { | ||
| 21 | // Context of the app under test. | ||
| 22 | Context appContext = InstrumentationRegistry.getTargetContext(); | ||
| 23 | |||
| 24 | assertEquals("com.hjx.miaohongentry", appContext.getPackageName()); | ||
| 25 | } | ||
| 26 | } | ||
| 27 |
MiaohongEntry/app/src/main/AndroidManifest.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | package="com.hjx.miaohongentry"> | ||
| 4 | |||
| 5 | <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
| 6 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
| 7 | <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> | ||
| 8 | <uses-permission android:name="android.permission.INTERNET" /> | ||
| 9 | |||
| 10 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> | ||
| 11 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| 12 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 13 | <uses-permission android:name="android.permission.READ_LOGS" /> | ||
| 14 | |||
| 15 | <application | ||
| 16 | android:allowBackup="true" | ||
| 17 | android:icon="@mipmap/ic_launcher" | ||
| 18 | android:label="@string/app_name" | ||
| 19 | android:roundIcon="@mipmap/ic_launcher_round" | ||
| 20 | android:supportsRtl="true" | ||
| 21 | android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"> | ||
| 22 | <activity | ||
| 23 | android:name=".activity.MainActivity" | ||
| 24 | android:screenOrientation="landscape"> | ||
| 25 | <intent-filter> | ||
| 26 | <action android:name="android.intent.action.MAIN" /> | ||
| 27 | |||
| 28 | <category android:name="android.intent.category.LAUNCHER" /> | ||
| 29 | </intent-filter> | ||
| 30 | </activity> | ||
| 31 | <activity | ||
| 32 | android:name=".activity.ChooseBookActivity" | ||
| 33 | android:configChanges="orientation|keyboardHidden|screenSize" | ||
| 34 | android:screenOrientation="landscape" | ||
| 35 | android:theme="@style/translucent"> | ||
| 36 | |||
| 37 | </activity> | ||
| 38 | |||
| 39 | <activity android:name=".activity.WordActivity" | ||
| 40 | android:windowSoftInputMode="adjustUnspecified|stateHidden" | ||
| 41 | android:configChanges="orientation|keyboardHidden|screenSize"> | ||
| 42 | |||
| 43 | </activity> | ||
| 44 | <service | ||
| 45 | android:name=".update.DownloadService" | ||
| 46 | android:enabled="true"> | ||
| 47 | </service> | ||
| 48 | </application> | ||
| 49 | |||
| 50 | </manifest> |
MiaohongEntry/app/src/main/assets/mh.db
No preview for this file type
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/activity/ChooseBookActivity.java
| File was created | 1 | package com.hjx.miaohongentry.activity; | |
| 2 | |||
| 3 | import android.app.Activity; | ||
| 4 | import android.content.Intent; | ||
| 5 | import android.os.Bundle; | ||
| 6 | import android.view.View; | ||
| 7 | import android.view.WindowManager; | ||
| 8 | import android.widget.AdapterView; | ||
| 9 | import android.widget.Button; | ||
| 10 | import android.widget.ListView; | ||
| 11 | |||
| 12 | import com.hjx.miaohongentry.R; | ||
| 13 | import com.hjx.miaohongentry.adapter.BookListAdapter; | ||
| 14 | import com.hjx.miaohongentry.bean.BookInfo; | ||
| 15 | import com.hjx.miaohongentry.db.MHDataManager; | ||
| 16 | import com.hjx.miaohongentry.util.Constants; | ||
| 17 | |||
| 18 | import java.util.ArrayList; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * An example full-screen activity that shows and hides the system UI (i.e. | ||
| 22 | * status bar and navigation/system bar) with user interaction. | ||
| 23 | */ | ||
| 24 | public class ChooseBookActivity extends Activity { | ||
| 25 | |||
| 26 | |||
| 27 | private ListView listView; | ||
| 28 | private BookListAdapter adapter; | ||
| 29 | private ArrayList<BookInfo> bookList; | ||
| 30 | private int curIndex; | ||
| 31 | private Button okBtn; | ||
| 32 | public static final int RESULT_CODE_CHOOSE_SECCESS = 0x01; | ||
| 33 | |||
| 34 | @Override | ||
| 35 | protected void onCreate(Bundle savedInstanceState) { | ||
| 36 | super.onCreate(savedInstanceState); | ||
| 37 | getWindow().setFlags(WindowManager.LayoutParams. FLAG_FULLSCREEN , WindowManager.LayoutParams. FLAG_FULLSCREEN); | ||
| 38 | setContentView(R.layout.activity_choose_book); | ||
| 39 | curIndex = getIntent().getIntExtra("idx",0); | ||
| 40 | okBtn = (Button)findViewById(R.id.btn_ok); | ||
| 41 | listView = (ListView) findViewById(R.id.lv_book_list); | ||
| 42 | bookList = MHDataManager.getList(Constants.MH_DATABASE_PATH); | ||
| 43 | adapter = new BookListAdapter(this,bookList); | ||
| 44 | adapter.setSelectItem(curIndex); | ||
| 45 | listView.setAdapter(adapter); | ||
| 46 | listView.setSelection(curIndex); | ||
| 47 | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
| 48 | @Override | ||
| 49 | public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { | ||
| 50 | curIndex = i; | ||
| 51 | adapter.setSelectItem(curIndex); | ||
| 52 | } | ||
| 53 | }); | ||
| 54 | okBtn.setOnClickListener(new View.OnClickListener() { | ||
| 55 | @Override | ||
| 56 | public void onClick(View view) { | ||
| 57 | BookInfo bookInfo = bookList.get(curIndex); | ||
| 58 | Intent mIntent = new Intent(); | ||
| 59 | mIntent.putExtra("id",bookInfo.get_id()); | ||
| 60 | mIntent.putExtra("press", bookInfo.getPress()); | ||
| 61 | mIntent.putExtra("reactos", bookInfo.getReactOS()); | ||
| 62 | mIntent.putExtra("grade", bookInfo.getGrade()); | ||
| 63 | // ่ฎพ็ฝฎ็ปๆ๏ผๅนถ่ฟ่กไผ ้ | ||
| 64 | setResult(RESULT_CODE_CHOOSE_SECCESS, mIntent); | ||
| 65 | finish(); | ||
| 66 | } | ||
| 67 | }); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | |||
| 72 | |||
| 73 | } | ||
| 74 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/activity/InitCallback.java
| File was created | 1 | package com.hjx.miaohongentry.activity; | |
| 2 | |||
| 3 | import java.io.IOException; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * Created by l on 2018/2/6. | ||
| 7 | */ | ||
| 8 | |||
| 9 | public interface InitCallback { | ||
| 10 | void onError(IOException e); | ||
| 11 | void onSucess(); | ||
| 12 | } | ||
| 13 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/activity/MainActivity.java
| File was created | 1 | package com.hjx.miaohongentry.activity; | |
| 2 | |||
| 3 | import android.Manifest; | ||
| 4 | import android.app.Activity; | ||
| 5 | import android.content.Intent; | ||
| 6 | import android.content.pm.PackageManager; | ||
| 7 | import android.media.MediaPlayer; | ||
| 8 | import android.os.Environment; | ||
| 9 | import android.support.v4.app.ActivityCompat; | ||
| 10 | import android.os.Bundle; | ||
| 11 | import android.view.View; | ||
| 12 | import android.widget.Button; | ||
| 13 | import android.widget.ImageButton; | ||
| 14 | import android.widget.TextView; | ||
| 15 | |||
| 16 | import com.hjx.miaohongentry.R; | ||
| 17 | import com.hjx.miaohongentry.db.MHDataManager; | ||
| 18 | import com.hjx.miaohongentry.update.UpdateChecker; | ||
| 19 | import com.hjx.miaohongentry.util.Constants; | ||
| 20 | import com.hjx.miaohongentry.util.SpUtils; | ||
| 21 | import com.hjx.miaohongentry.util.StatisUtils; | ||
| 22 | import com.tencent.bugly.crashreport.CrashReport; | ||
| 23 | |||
| 24 | import java.io.File; | ||
| 25 | import java.io.FileDescriptor; | ||
| 26 | import java.io.IOException; | ||
| 27 | import java.io.RandomAccessFile; | ||
| 28 | |||
| 29 | public class MainActivity extends Activity { | ||
| 30 | |||
| 31 | private static final int REQUEST_EXTERNAL_STORAGE = 0x99; | ||
| 32 | private Button startBtn; | ||
| 33 | private ImageButton chooseBtn; | ||
| 34 | private final int REQUEST_CODE_CHOOSE_BOOK = 0x01; | ||
| 35 | private TextView bookTextView; | ||
| 36 | private String bookInfo; | ||
| 37 | private TextView tv_write_time; | ||
| 38 | private TextView tv_today_num; | ||
| 39 | private TextView tv_total_num; | ||
| 40 | |||
| 41 | private static String[] PERMISSIONS_STORAGE = { | ||
| 42 | Manifest.permission.READ_EXTERNAL_STORAGE, | ||
| 43 | Manifest.permission.WRITE_EXTERNAL_STORAGE}; | ||
| 44 | |||
| 45 | public static void verifyStoragePermissions(Activity activity) { | ||
| 46 | // Check if we have write permission | ||
| 47 | int permission = ActivityCompat.checkSelfPermission(activity, | ||
| 48 | Manifest.permission.WRITE_EXTERNAL_STORAGE); | ||
| 49 | |||
| 50 | if (permission != PackageManager.PERMISSION_GRANTED) { | ||
| 51 | // We don't have permission so prompt the user | ||
| 52 | ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE, | ||
| 53 | REQUEST_EXTERNAL_STORAGE); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | private void initView(){ | ||
| 58 | startBtn = (Button) findViewById(R.id.btn_start); | ||
| 59 | startBtn.setOnClickListener(new View.OnClickListener() { | ||
| 60 | @Override | ||
| 61 | public void onClick(View view) { | ||
| 62 | Intent intent = new Intent(MainActivity.this, WordActivity.class); | ||
| 63 | intent.putExtra("bookInfo",bookInfo); | ||
| 64 | startActivity(intent); | ||
| 65 | } | ||
| 66 | }); | ||
| 67 | chooseBtn = (ImageButton)findViewById(R.id.btn_choose); | ||
| 68 | chooseBtn.setOnClickListener(new View.OnClickListener() { | ||
| 69 | @Override | ||
| 70 | public void onClick(View view) { | ||
| 71 | int idx = SpUtils.getInt(MainActivity.this,Constants.SP_BOOK_CHOSEN_ID,0); | ||
| 72 | Intent intent = new Intent(MainActivity.this, ChooseBookActivity.class); | ||
| 73 | intent.putExtra("idx",idx); | ||
| 74 | startActivityForResult(intent,REQUEST_CODE_CHOOSE_BOOK); | ||
| 75 | } | ||
| 76 | }); | ||
| 77 | bookTextView = (TextView)findViewById(R.id.tv_publish_name); | ||
| 78 | bookInfo = SpUtils.getString(this,Constants.SP_BOOK_CHOSEN_INFO,"ไบบๆฐๆ่ฒๅบ็็คพ#ไธๅนด็บง#ไธๅ"); | ||
| 79 | if(!bookInfo.isEmpty()){ | ||
| 80 | String info[] = bookInfo.split("#"); | ||
| 81 | if(info.length == 3){ | ||
| 82 | String bookStr = info[1] + info[2] + " " + info[0]; | ||
| 83 | bookTextView.setText(bookStr); | ||
| 84 | } | ||
| 85 | } | ||
| 86 | |||
| 87 | tv_write_time = findViewById(R.id.write_time); | ||
| 88 | tv_today_num = findViewById(R.id.today_num); | ||
| 89 | tv_total_num = findViewById(R.id.total_num); | ||
| 90 | showStatisView(); | ||
| 91 | } | ||
| 92 | |||
| 93 | private void showStatisView(){ | ||
| 94 | if(!StatisUtils.isToday(this)){ | ||
| 95 | StatisUtils.setTodayNum(this,0); | ||
| 96 | StatisUtils.setTodayTime(this,0); | ||
| 97 | StatisUtils.setToday(this); | ||
| 98 | } | ||
| 99 | tv_total_num.setText(""+ StatisUtils.getTotalNum(this)); | ||
| 100 | tv_today_num.setText(""+ StatisUtils.getTodayNum(this)); | ||
| 101 | long mills = StatisUtils.getTodayTime(this); | ||
| 102 | long min = mills / (1000 * 60); | ||
| 103 | long sec = (mills - ( min * 60 * 1000)) / 1000; | ||
| 104 | tv_write_time.setText(min + "ๅ" + sec + "็ง"); | ||
| 105 | |||
| 106 | } | ||
| 107 | |||
| 108 | private void testSound(){ | ||
| 109 | MediaPlayer mPlayer = new MediaPlayer(); | ||
| 110 | try { | ||
| 111 | RandomAccessFile mRandomAccessFile = new RandomAccessFile( | ||
| 112 | Environment.getExternalStorageDirectory().getPath() + File.separator | ||
| 113 | // + "1.mp3", | ||
| 114 | + "DICTSOUND.BIN", "r"); | ||
| 115 | FileDescriptor mFileDescriptor = null; | ||
| 116 | mFileDescriptor = mRandomAccessFile.getFD(); | ||
| 117 | mPlayer.reset(); | ||
| 118 | mPlayer.setDataSource(mFileDescriptor, 122295042, 3027/*mRandomAccessFile.length()*/); | ||
| 119 | mPlayer.prepare(); | ||
| 120 | mPlayer.start(); | ||
| 121 | mRandomAccessFile.close(); | ||
| 122 | } catch (IOException e) { | ||
| 123 | e.printStackTrace(); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | @Override | ||
| 128 | protected void onCreate(Bundle savedInstanceState) { | ||
| 129 | super.onCreate(savedInstanceState); | ||
| 130 | verifyStoragePermissions(this); | ||
| 131 | CrashReport.initCrashReport(getApplicationContext(), "9c92cf01b2", false); | ||
| 132 | setContentView(R.layout.activity_main); | ||
| 133 | initView(); | ||
| 134 | MHDataManager.initDB(this, new InitCallback() { | ||
| 135 | @Override | ||
| 136 | public void onError(IOException e) { | ||
| 137 | |||
| 138 | } | ||
| 139 | |||
| 140 | @Override | ||
| 141 | public void onSucess() { | ||
| 142 | |||
| 143 | } | ||
| 144 | }); | ||
| 145 | updateVersion(); | ||
| 146 | } | ||
| 147 | |||
| 148 | private void saveBookInfo( String bookStr){ | ||
| 149 | SpUtils.putString(MainActivity.this, Constants.SP_BOOK_CHOSEN_INFO,bookStr); | ||
| 150 | } | ||
| 151 | |||
| 152 | private void saveBookIdx(String id ){ | ||
| 153 | try { | ||
| 154 | int idx = Integer.parseInt(id); | ||
| 155 | SpUtils.putInt(MainActivity.this, Constants.SP_BOOK_CHOSEN_ID,idx); | ||
| 156 | } catch (NumberFormatException e) { | ||
| 157 | e.printStackTrace(); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | @Override | ||
| 162 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
| 163 | |||
| 164 | switch (requestCode) { | ||
| 165 | case REQUEST_CODE_CHOOSE_BOOK: | ||
| 166 | if(resultCode == ChooseBookActivity.RESULT_CODE_CHOOSE_SECCESS){ | ||
| 167 | String id = data.getStringExtra("id"); | ||
| 168 | String press = data.getStringExtra("press"); | ||
| 169 | String grade = data.getStringExtra("grade"); | ||
| 170 | String reactos = data.getStringExtra("reactos"); | ||
| 171 | String bookStr = grade + reactos + " " + press; | ||
| 172 | bookTextView.setText(bookStr); | ||
| 173 | bookInfo = press + "#" + grade + "#" + reactos; | ||
| 174 | saveBookInfo(bookInfo); | ||
| 175 | saveBookIdx(id); | ||
| 176 | } | ||
| 177 | break; | ||
| 178 | default: | ||
| 179 | break; | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | @Override | ||
| 184 | protected void onResume(){ | ||
| 185 | super.onResume(); | ||
| 186 | showStatisView(); | ||
| 187 | } | ||
| 188 | |||
| 189 | private void updateVersion(){ | ||
| 190 | UpdateChecker checker = new UpdateChecker(this); | ||
| 191 | checker.checkForUpdates(); | ||
| 192 | } | ||
| 193 | |||
| 194 | |||
| 195 | |||
| 196 | } | ||
| 197 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/activity/WordActivity.java
| File was created | 1 | package com.hjx.miaohongentry.activity; | |
| 2 | |||
| 3 | import android.app.Activity; | ||
| 4 | import android.app.ProgressDialog; | ||
| 5 | import android.content.Intent; | ||
| 6 | import android.os.Bundle; | ||
| 7 | import android.os.Handler; | ||
| 8 | import android.os.Message; | ||
| 9 | import android.support.annotation.IdRes; | ||
| 10 | import android.view.LayoutInflater; | ||
| 11 | import android.view.View; | ||
| 12 | import android.view.ViewGroup; | ||
| 13 | import android.widget.Button; | ||
| 14 | import android.widget.EditText; | ||
| 15 | import android.widget.ImageButton; | ||
| 16 | import android.widget.LinearLayout; | ||
| 17 | import android.widget.ListAdapter; | ||
| 18 | import android.widget.ListView; | ||
| 19 | import android.widget.RadioButton; | ||
| 20 | import android.widget.RadioGroup; | ||
| 21 | import android.widget.RelativeLayout; | ||
| 22 | import android.widget.TextView; | ||
| 23 | |||
| 24 | import com.hjx.miaohongentry.R; | ||
| 25 | import com.hjx.miaohongentry.adapter.RowWordListAdapter; | ||
| 26 | import com.hjx.miaohongentry.bean.BookInfo; | ||
| 27 | import com.hjx.miaohongentry.bean.RowWord; | ||
| 28 | import com.hjx.miaohongentry.bean.TitleWord; | ||
| 29 | import com.hjx.miaohongentry.db.MHDataManager; | ||
| 30 | import com.hjx.miaohongentry.util.DeviceUtils; | ||
| 31 | import com.hjx.miaohongentry.util.SpanTextViewUtils; | ||
| 32 | import com.hjx.miaohongentry.util.StatisUtils; | ||
| 33 | |||
| 34 | import java.util.List; | ||
| 35 | |||
| 36 | public class WordActivity extends Activity { | ||
| 37 | |||
| 38 | private RelativeLayout rl_two_type; | ||
| 39 | private Button btn_one_type; | ||
| 40 | private BookInfo bookInfo; | ||
| 41 | private List<String> tableTypes; | ||
| 42 | private RadioGroup radioGroup; | ||
| 43 | private RadioButton rb_left; | ||
| 44 | private RadioButton rb_right; | ||
| 45 | private LinearLayout ll_word_group; | ||
| 46 | private ImageButton backBtn; | ||
| 47 | private EditText et_search; | ||
| 48 | private ImageButton btn_search; | ||
| 49 | |||
| 50 | private List<TitleWord> titleWords_left; | ||
| 51 | private List<TitleWord> titleWords_right; | ||
| 52 | private final static int GET_TITLE_WORD_FINISH = 1; | ||
| 53 | protected ProgressDialog progressDialog = null; | ||
| 54 | public static final int REQUEST_CODE_MIAO_HONG = 0x01; | ||
| 55 | |||
| 56 | private Handler handler = new Handler() { | ||
| 57 | public void handleMessage(android.os.Message msg) { | ||
| 58 | super.handleMessage(msg); | ||
| 59 | switch (msg.what) { | ||
| 60 | case GET_TITLE_WORD_FINISH: | ||
| 61 | updateTableTypeView(); | ||
| 62 | showWordGroup(titleWords_left); | ||
| 63 | dismissProgressDialog(); | ||
| 64 | break; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | }; | ||
| 68 | |||
| 69 | @Override | ||
| 70 | protected void onCreate(Bundle savedInstanceState) { | ||
| 71 | super.onCreate(savedInstanceState); | ||
| 72 | setContentView(R.layout.activity_word); | ||
| 73 | initData(); | ||
| 74 | initView(); | ||
| 75 | showProgressDialog("ๆญฃๅจๅ ่ฝฝ..."); | ||
| 76 | } | ||
| 77 | |||
| 78 | private void initData(){ | ||
| 79 | |||
| 80 | String infoStr = getIntent().getStringExtra("bookInfo"); | ||
| 81 | String info[] = infoStr.split("#"); | ||
| 82 | bookInfo = new BookInfo("0",info[0],info[1],info[2]); | ||
| 83 | new Thread() { | ||
| 84 | public void run() { | ||
| 85 | |||
| 86 | tableTypes = MHDataManager.getTableTypes(bookInfo.getPress(),bookInfo.getGrade(),bookInfo.getReactOS()); | ||
| 87 | titleWords_left = MHDataManager.getTitleWords(bookInfo.getPress(),bookInfo.getGrade(),bookInfo.getReactOS(),tableTypes.get(0)); | ||
| 88 | for(TitleWord titleWord : titleWords_left){ | ||
| 89 | List<RowWord> rowWords = MHDataManager.getRowWords(bookInfo,tableTypes.get(0),titleWord); | ||
| 90 | titleWord.setRowWordList(rowWords); | ||
| 91 | } | ||
| 92 | if(tableTypes.size() > 1){ | ||
| 93 | titleWords_right = MHDataManager.getTitleWords(bookInfo.getPress(),bookInfo.getGrade(),bookInfo.getReactOS(),tableTypes.get(1)); | ||
| 94 | for(TitleWord titleWord : titleWords_right){ | ||
| 95 | List<RowWord> rowWords = MHDataManager.getRowWords(bookInfo,tableTypes.get(1),titleWord); | ||
| 96 | titleWord.setRowWordList(rowWords); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | Message msg = new Message(); | ||
| 100 | msg.what = GET_TITLE_WORD_FINISH; | ||
| 101 | handler.sendMessage(msg); | ||
| 102 | } | ||
| 103 | }.start(); | ||
| 104 | |||
| 105 | } | ||
| 106 | |||
| 107 | |||
| 108 | private void initView(){ | ||
| 109 | backBtn = findViewById(R.id.btn_back); | ||
| 110 | backBtn.setOnClickListener(new View.OnClickListener() { | ||
| 111 | @Override | ||
| 112 | public void onClick(View view) { | ||
| 113 | finish(); | ||
| 114 | } | ||
| 115 | }); | ||
| 116 | et_search = findViewById(R.id.et_search); | ||
| 117 | btn_search = findViewById(R.id.btn_search); | ||
| 118 | btn_search.setOnClickListener(new View.OnClickListener() { | ||
| 119 | @Override | ||
| 120 | public void onClick(View view) { | ||
| 121 | String searchStr = et_search.getText().toString(); | ||
| 122 | if(!searchStr.isEmpty()){ | ||
| 123 | SpanTextViewUtils.gotoMiaohong(WordActivity.this, searchStr); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | }); | ||
| 127 | initTableTypeView(); | ||
| 128 | |||
| 129 | } | ||
| 130 | |||
| 131 | private void initTableTypeView(){ | ||
| 132 | btn_one_type = findViewById(R.id.btn_one_type); | ||
| 133 | rl_two_type = findViewById(R.id.rl_two_type); | ||
| 134 | rb_left = findViewById(R.id.rb_left); | ||
| 135 | rb_right = findViewById(R.id.rb_right); | ||
| 136 | radioGroup = findViewById(R.id.rg_type); | ||
| 137 | } | ||
| 138 | |||
| 139 | private void updateTableTypeView(){ | ||
| 140 | if(tableTypes.size() > 1){ | ||
| 141 | btn_one_type.setVisibility(View.GONE); | ||
| 142 | rl_two_type.setVisibility(View.VISIBLE); | ||
| 143 | rb_left.setText(tableTypes.get(0).replace("๏ผไธ๏ผ","1").replace("๏ผไบ๏ผ","2")); | ||
| 144 | rb_right.setText(tableTypes.get(1).replace("๏ผไธ๏ผ","1").replace("๏ผไบ๏ผ","2")); | ||
| 145 | radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | ||
| 146 | @Override | ||
| 147 | public void onCheckedChanged(RadioGroup radioGroup, @IdRes int i) { | ||
| 148 | ll_word_group.removeAllViews(); | ||
| 149 | if(i == R.id.rb_left){ | ||
| 150 | showWordGroup(titleWords_left); | ||
| 151 | }else{ | ||
| 152 | showWordGroup(titleWords_right); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | }); | ||
| 156 | |||
| 157 | }else{ | ||
| 158 | btn_one_type.setVisibility(View.VISIBLE); | ||
| 159 | rl_two_type.setVisibility(View.GONE); | ||
| 160 | btn_one_type.setText(tableTypes.get(0)); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | private void showWordGroup(List<TitleWord> titleWords ){ | ||
| 164 | ll_word_group = findViewById(R.id.ll_word_group); | ||
| 165 | for (TitleWord titleWord : titleWords){ | ||
| 166 | ll_word_group.addView(getTitleWordView(titleWord)); | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | public View getTitleWordView(TitleWord titleWord ) { | ||
| 171 | View view = LayoutInflater.from(this).inflate( | ||
| 172 | R.layout.view_title_word, null); | ||
| 173 | TextView tvTitle = view.findViewById(R.id.tv_title); | ||
| 174 | tvTitle.setText(titleWord.getTitle()); | ||
| 175 | ListView listView = view.findViewById(R.id.row_list); | ||
| 176 | listView.setEnabled(false); | ||
| 177 | view.setFocusable(true); | ||
| 178 | view.setFocusableInTouchMode(true); | ||
| 179 | RowWordListAdapter adapter = new RowWordListAdapter(this,titleWord.getRowWordList()); | ||
| 180 | listView.setAdapter(adapter); | ||
| 181 | setListViewHeightBasedOnChildren(listView); | ||
| 182 | return view; | ||
| 183 | } | ||
| 184 | |||
| 185 | public void setListViewHeightBasedOnChildren(ListView listView) { | ||
| 186 | // ่ทๅListViewๅฏนๅบ็Adapter | ||
| 187 | ListAdapter listAdapter = listView.getAdapter(); | ||
| 188 | if (listAdapter == null) { | ||
| 189 | return; | ||
| 190 | } | ||
| 191 | |||
| 192 | int px = DeviceUtils.dip2px(this,1.0f); | ||
| 193 | |||
| 194 | int totalHeight = 0; | ||
| 195 | for (int i = 0, len = listAdapter.getCount(); i < len; i++) { | ||
| 196 | // listAdapter.getCount()่ฟๅๆฐๆฎ้กน็ๆฐ็ฎ | ||
| 197 | View listItem = listAdapter.getView(i, null, listView); | ||
| 198 | // ่ฎก็ฎๅญ้กนView ็ๅฎฝ้ซ | ||
| 199 | int w = View.MeasureSpec.makeMeasureSpec(0, | ||
| 200 | View.MeasureSpec.UNSPECIFIED); | ||
| 201 | int h = View.MeasureSpec.makeMeasureSpec(0, | ||
| 202 | View.MeasureSpec.UNSPECIFIED); | ||
| 203 | |||
| 204 | listItem.measure(w, h); | ||
| 205 | // ็ป่ฎกๆๆๅญ้กน็ๆป้ซๅบฆ | ||
| 206 | totalHeight += listItem.getMeasuredHeight(); | ||
| 207 | |||
| 208 | if(totalHeight + (listView.getDividerHeight() * (i - 1)) >1000){ | ||
| 209 | break; | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 213 | ViewGroup.LayoutParams params = listView.getLayoutParams(); | ||
| 214 | params.height = totalHeight+ (listView.getDividerHeight() * (listAdapter.getCount() - 1)); | ||
| 215 | |||
| 216 | |||
| 217 | // listView.getDividerHeight()่ทๅๅญ้กน้ดๅ้็ฌฆๅ ็จ็้ซๅบฆ | ||
| 218 | // params.heightๆๅๅพๅฐๆดไธชListViewๅฎๆดๆพ็คบ้่ฆ็้ซๅบฆ | ||
| 219 | listView.setLayoutParams(params); | ||
| 220 | } | ||
| 221 | |||
| 222 | |||
| 223 | public void showProgressDialog( final String message){ | ||
| 224 | |||
| 225 | runOnUiThread(new Runnable() { | ||
| 226 | @Override | ||
| 227 | public void run() { | ||
| 228 | if (progressDialog == null) { | ||
| 229 | progressDialog = new ProgressDialog(WordActivity.this); | ||
| 230 | } | ||
| 231 | if(progressDialog.isShowing()) { | ||
| 232 | progressDialog.dismiss(); | ||
| 233 | } | ||
| 234 | |||
| 235 | progressDialog.setMessage(message); | ||
| 236 | progressDialog.setCanceledOnTouchOutside(false); | ||
| 237 | progressDialog.show(); | ||
| 238 | } | ||
| 239 | }); | ||
| 240 | } | ||
| 241 | |||
| 242 | |||
| 243 | /**้่ๅ ่ฝฝ่ฟๅบฆ | ||
| 244 | */ | ||
| 245 | public void dismissProgressDialog() { | ||
| 246 | runOnUiThread(new Runnable() { | ||
| 247 | @Override | ||
| 248 | public void run() { | ||
| 249 | //ๆๅคๆญๅๅจrunOnUiThreadๅค้ขๅฏผ่ดๆๆถdismissๆ ๆ๏ผๅฏ่ฝไธๅ็บฟ็จๅคๆญprogressDialog.isShowing()็ปๆไธไธ่ด | ||
| 250 | if(progressDialog == null || progressDialog.isShowing() == false){ | ||
| 251 | return; | ||
| 252 | } | ||
| 253 | progressDialog.dismiss(); | ||
| 254 | } | ||
| 255 | }); | ||
| 256 | } | ||
| 257 | |||
| 258 | @Override | ||
| 259 | protected void onResume(){ | ||
| 260 | super.onResume(); | ||
| 261 | long enter_mills = StatisUtils.getEnterMiaohongTime(this); | ||
| 262 | if(enter_mills != 0){ | ||
| 263 | long now_mills = System.currentTimeMillis(); | ||
| 264 | long diff_mills = now_mills - enter_mills; | ||
| 265 | if(diff_mills > 0){ | ||
| 266 | long save_mills = StatisUtils.getTodayTime(WordActivity.this) + diff_mills; | ||
| 267 | StatisUtils.setTodayTime(WordActivity.this,save_mills); | ||
| 268 | } | ||
| 269 | StatisUtils.setEnterMiaohongTime(this, 0); | ||
| 270 | } | ||
| 271 | } | ||
| 272 | |||
| 273 | |||
| 274 | @Override | ||
| 275 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | ||
| 276 | |||
| 277 | switch (requestCode) { | ||
| 278 | case REQUEST_CODE_MIAO_HONG: | ||
| 279 | if(resultCode == 0){ | ||
| 280 | |||
| 281 | long now_mills = System.currentTimeMillis(); | ||
| 282 | long enter_mills = StatisUtils.getEnterMiaohongTime(WordActivity.this); | ||
| 283 | long diff_mills = now_mills - enter_mills; | ||
| 284 | if(diff_mills > 0){ | ||
| 285 | long save_mills = StatisUtils.getTodayTime(WordActivity.this) + diff_mills; | ||
| 286 | StatisUtils.setTodayTime(WordActivity.this,save_mills); | ||
| 287 | } | ||
| 288 | } | ||
| 289 | break; | ||
| 290 | default: | ||
| 291 | break; | ||
| 292 | } | ||
| 293 | } | ||
| 294 | |||
| 295 | } | ||
| 296 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/adapter/BookListAdapter.java
| File was created | 1 | package com.hjx.miaohongentry.adapter; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.view.LayoutInflater; | ||
| 5 | import android.view.View; | ||
| 6 | import android.view.ViewGroup; | ||
| 7 | import android.widget.BaseAdapter; | ||
| 8 | import android.widget.TextView; | ||
| 9 | |||
| 10 | import com.hjx.miaohongentry.R; | ||
| 11 | import com.hjx.miaohongentry.bean.BookInfo; | ||
| 12 | |||
| 13 | import java.util.ArrayList; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * Created by l on 2018/2/2. | ||
| 17 | */ | ||
| 18 | |||
| 19 | public class BookListAdapter extends BaseAdapter { | ||
| 20 | |||
| 21 | private Context mContext; | ||
| 22 | private ArrayList<BookInfo> mList = null; | ||
| 23 | private int selectItem = 0; | ||
| 24 | |||
| 25 | public BookListAdapter(Context mContext, ArrayList<BookInfo> mList) { | ||
| 26 | this.mContext = mContext; | ||
| 27 | this.mList = mList; | ||
| 28 | } | ||
| 29 | |||
| 30 | @Override | ||
| 31 | public int getCount() { | ||
| 32 | return mList == null ? 0 : mList.size(); | ||
| 33 | } | ||
| 34 | |||
| 35 | @Override | ||
| 36 | public Object getItem(int position) { | ||
| 37 | return mList.get(position); | ||
| 38 | } | ||
| 39 | |||
| 40 | @Override | ||
| 41 | public long getItemId(int i) { | ||
| 42 | return i; | ||
| 43 | } | ||
| 44 | |||
| 45 | @Override | ||
| 46 | public View getView(int position, View convertView, ViewGroup viewGroup) { | ||
| 47 | ViewHolder mViewHolder = null; | ||
| 48 | int textColor = R.color.colorFontBlack; | ||
| 49 | if (convertView == null) { | ||
| 50 | convertView = LayoutInflater.from(mContext).inflate( | ||
| 51 | R.layout.choose_book_list_item, null); | ||
| 52 | |||
| 53 | mViewHolder = new ViewHolder(); | ||
| 54 | mViewHolder.tv_grade = (TextView) convertView | ||
| 55 | .findViewById(R.id.choose_book_list_item_grade); | ||
| 56 | mViewHolder.tv_reactos = (TextView) convertView | ||
| 57 | .findViewById(R.id.choose_book_list_item_reactos); | ||
| 58 | mViewHolder.tv_press = (TextView) convertView | ||
| 59 | .findViewById(R.id.choose_book_list_item_press); | ||
| 60 | convertView.setTag(mViewHolder); | ||
| 61 | } else { | ||
| 62 | mViewHolder = (ViewHolder) convertView.getTag(); | ||
| 63 | } | ||
| 64 | |||
| 65 | BookInfo detailInfo = (BookInfo) getItem(position); | ||
| 66 | |||
| 67 | if (detailInfo != null) { | ||
| 68 | mViewHolder.tv_grade.setText(detailInfo.getGrade()); | ||
| 69 | mViewHolder.tv_reactos.setText(detailInfo.getReactOS()); | ||
| 70 | mViewHolder.tv_press.setText(detailInfo.getPress()); | ||
| 71 | } | ||
| 72 | |||
| 73 | if (position == selectItem) { | ||
| 74 | textColor = R.color.colorFontGreen; | ||
| 75 | } | ||
| 76 | mViewHolder.tv_grade.setTextColor(mContext.getResources().getColor(textColor)); | ||
| 77 | mViewHolder.tv_reactos.setTextColor(mContext.getResources().getColor(textColor)); | ||
| 78 | mViewHolder.tv_press.setTextColor(mContext.getResources().getColor(textColor)); | ||
| 79 | return convertView; | ||
| 80 | } | ||
| 81 | |||
| 82 | public static class ViewHolder { | ||
| 83 | public TextView tv_grade; | ||
| 84 | public TextView tv_reactos; | ||
| 85 | public TextView tv_press; | ||
| 86 | } | ||
| 87 | |||
| 88 | public void setSelectItem(int selectItem) { | ||
| 89 | this.selectItem = selectItem; | ||
| 90 | notifyDataSetChanged(); | ||
| 91 | } | ||
| 92 | |||
| 93 | public void setSelectItem(BookInfo bookInfo){ | ||
| 94 | if (bookInfo == null) { | ||
| 95 | return; | ||
| 96 | } | ||
| 97 | |||
| 98 | for(int i = 0; i < mList.size(); i++){ | ||
| 99 | BookInfo kBookInfo = mList.get(i); | ||
| 100 | if(bookInfo.get_id().equals(kBookInfo.get_id())){ | ||
| 101 | selectItem = i; | ||
| 102 | notifyDataSetChanged(); | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | |||
| 108 | public int getSelectItem() { | ||
| 109 | return this.selectItem; | ||
| 110 | } | ||
| 111 | |||
| 112 | } | ||
| 113 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/adapter/RowWordListAdapter.java
| File was created | 1 | package com.hjx.miaohongentry.adapter; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.view.LayoutInflater; | ||
| 5 | import android.view.View; | ||
| 6 | import android.view.ViewGroup; | ||
| 7 | import android.widget.BaseAdapter; | ||
| 8 | import android.widget.TextView; | ||
| 9 | |||
| 10 | import com.hjx.miaohongentry.R; | ||
| 11 | import com.hjx.miaohongentry.bean.RowWord; | ||
| 12 | import com.hjx.miaohongentry.ui.FixGridLayout; | ||
| 13 | import com.hjx.miaohongentry.util.SpanTextViewUtils; | ||
| 14 | |||
| 15 | import java.util.List; | ||
| 16 | |||
| 17 | /** | ||
| 18 | * Created by l on 2018/2/5. | ||
| 19 | */ | ||
| 20 | |||
| 21 | public class RowWordListAdapter extends BaseAdapter{ | ||
| 22 | |||
| 23 | private Context mContext; | ||
| 24 | private List<RowWord> mList = null; | ||
| 25 | |||
| 26 | public RowWordListAdapter(Context mContext, List<RowWord> mList) { | ||
| 27 | this.mContext = mContext; | ||
| 28 | this.mList = mList; | ||
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | @Override | ||
| 33 | public int getCount() { | ||
| 34 | return mList == null ? 0 : mList.size(); | ||
| 35 | } | ||
| 36 | |||
| 37 | @Override | ||
| 38 | public Object getItem(int position) { | ||
| 39 | return mList.get(position); | ||
| 40 | } | ||
| 41 | |||
| 42 | @Override | ||
| 43 | public long getItemId(int i) { | ||
| 44 | return i; | ||
| 45 | } | ||
| 46 | |||
| 47 | @Override | ||
| 48 | public View getView(int position, View convertView, ViewGroup viewGroup) { | ||
| 49 | ViewHolder mViewHolder = null; | ||
| 50 | if (convertView == null) { | ||
| 51 | convertView = LayoutInflater.from(mContext).inflate( | ||
| 52 | R.layout.row_word_list_item, null); | ||
| 53 | mViewHolder = new ViewHolder(); | ||
| 54 | mViewHolder.tv_row_idx = convertView.findViewById(R.id.row_idx); | ||
| 55 | mViewHolder.ll_row_word = convertView.findViewById(R.id.ll_row_word); | ||
| 56 | convertView.setTag(mViewHolder); | ||
| 57 | } else { | ||
| 58 | mViewHolder = (ViewHolder) convertView.getTag(); | ||
| 59 | } | ||
| 60 | |||
| 61 | RowWord rowWord = (RowWord) getItem(position); | ||
| 62 | if (rowWord != null) { | ||
| 63 | if(!rowWord.getOrderNum().isEmpty()){ | ||
| 64 | mViewHolder.tv_row_idx.setText(rowWord.getOrderNum() + "."); | ||
| 65 | } | ||
| 66 | String rowStr = rowWord.getRowStr(); | ||
| 67 | char rowChar[] = rowStr.toCharArray(); | ||
| 68 | mViewHolder.ll_row_word.removeAllViews(); | ||
| 69 | for (int i = 0; i < rowChar.length; i++){ | ||
| 70 | mViewHolder.ll_row_word.addView(getWordView(rowChar[i])); | ||
| 71 | } | ||
| 72 | } | ||
| 73 | return convertView; | ||
| 74 | } | ||
| 75 | |||
| 76 | private TextView getWordView( char word ){ | ||
| 77 | TextView tv = (TextView) LayoutInflater.from(mContext).inflate( | ||
| 78 | R.layout.word_text_view, null); | ||
| 79 | tv.setPadding(10,10,10,10); | ||
| 80 | tv.setText(""+word); | ||
| 81 | tv.setOnClickListener(new View.OnClickListener() { | ||
| 82 | @Override | ||
| 83 | public void onClick(View view) { | ||
| 84 | SpanTextViewUtils.gotoMiaohong(mContext,((TextView)view).getText().toString()); | ||
| 85 | } | ||
| 86 | }); | ||
| 87 | return tv; | ||
| 88 | } | ||
| 89 | |||
| 90 | public static class ViewHolder { | ||
| 91 | public TextView tv_row_idx; | ||
| 92 | public FixGridLayout ll_row_word; | ||
| 93 | } | ||
| 94 | } | ||
| 95 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/bean/AppVersion.java
| File was created | 1 | package com.hjx.miaohongentry.bean; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2017/7/8. | ||
| 5 | */ | ||
| 6 | |||
| 7 | public class AppVersion { | ||
| 8 | |||
| 9 | private int versionCode; | ||
| 10 | private String versionName; | ||
| 11 | private String url; | ||
| 12 | private String msg; | ||
| 13 | private boolean isForceUpdate; | ||
| 14 | |||
| 15 | public void setVersionCode( String versionCode){ | ||
| 16 | this.versionCode = Integer.parseInt(versionCode); ; | ||
| 17 | } | ||
| 18 | |||
| 19 | public int getVersionCode(){ | ||
| 20 | return versionCode; | ||
| 21 | } | ||
| 22 | |||
| 23 | public void setVersionName(String versionName){ | ||
| 24 | this.versionName = versionName; | ||
| 25 | } | ||
| 26 | |||
| 27 | public String getVersionName(){ | ||
| 28 | return versionName; | ||
| 29 | } | ||
| 30 | |||
| 31 | public void setURL(String url){ | ||
| 32 | this.url = url; | ||
| 33 | } | ||
| 34 | |||
| 35 | public String getURL(){ | ||
| 36 | return url; | ||
| 37 | } | ||
| 38 | |||
| 39 | public void setMsg(String msg){ | ||
| 40 | this.msg = msg; | ||
| 41 | } | ||
| 42 | |||
| 43 | public String getMsg(){ | ||
| 44 | return msg; | ||
| 45 | } | ||
| 46 | |||
| 47 | public void setForceUpdate(boolean isForceUpdate){ | ||
| 48 | this.isForceUpdate = isForceUpdate; | ||
| 49 | } | ||
| 50 | |||
| 51 | public boolean isForceUpdate(){ | ||
| 52 | return isForceUpdate; | ||
| 53 | } | ||
| 54 | } | ||
| 55 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/bean/BookInfo.java
| File was created | 1 | package com.hjx.miaohongentry.bean; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2018/2/2. | ||
| 5 | */ | ||
| 6 | |||
| 7 | public class BookInfo { | ||
| 8 | |||
| 9 | private String _id; //bookid | ||
| 10 | |||
| 11 | private String press; //ๅบ็็คพ | ||
| 12 | |||
| 13 | private String grade; //ๅนด็บง | ||
| 14 | |||
| 15 | private String reactOS; //ไธไธๅ | ||
| 16 | |||
| 17 | public BookInfo(){ | ||
| 18 | |||
| 19 | } | ||
| 20 | |||
| 21 | public BookInfo( String id, String press, String grade, String reactOS){ | ||
| 22 | this._id = id; | ||
| 23 | this.press = press; | ||
| 24 | this.grade = grade; | ||
| 25 | this.reactOS = reactOS; | ||
| 26 | } | ||
| 27 | |||
| 28 | public String getPress() { | ||
| 29 | return press; | ||
| 30 | } | ||
| 31 | |||
| 32 | public void setPress(String press) { | ||
| 33 | this.press = press; | ||
| 34 | } | ||
| 35 | |||
| 36 | public String getGrade() { | ||
| 37 | return grade; | ||
| 38 | } | ||
| 39 | |||
| 40 | public void setGrade(String grade) { | ||
| 41 | this.grade = grade; | ||
| 42 | } | ||
| 43 | |||
| 44 | public String getReactOS() { | ||
| 45 | return reactOS; | ||
| 46 | } | ||
| 47 | |||
| 48 | public void setReactOS(String reactOS) { | ||
| 49 | this.reactOS = reactOS; | ||
| 50 | } | ||
| 51 | |||
| 52 | public String get_id() { | ||
| 53 | return _id; | ||
| 54 | } | ||
| 55 | |||
| 56 | public void set_id(String _id) { | ||
| 57 | this._id = _id; | ||
| 58 | } | ||
| 59 | } | ||
| 60 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/bean/RowWord.java
| File was created | 1 | package com.hjx.miaohongentry.bean; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2018/2/3. | ||
| 5 | */ | ||
| 6 | |||
| 7 | public class RowWord { | ||
| 8 | |||
| 9 | private String orderNum; | ||
| 10 | private String rowStr; | ||
| 11 | |||
| 12 | public RowWord(){ | ||
| 13 | |||
| 14 | } | ||
| 15 | |||
| 16 | public RowWord(String orderNum, String rowStr){ | ||
| 17 | |||
| 18 | this.orderNum = orderNum; | ||
| 19 | this.rowStr = rowStr; | ||
| 20 | } | ||
| 21 | |||
| 22 | public String getOrderNum() { | ||
| 23 | return orderNum; | ||
| 24 | } | ||
| 25 | |||
| 26 | public void setOrderNum(String orderNum) { | ||
| 27 | this.orderNum = orderNum; | ||
| 28 | } | ||
| 29 | |||
| 30 | public String getRowStr() { | ||
| 31 | return rowStr; | ||
| 32 | } | ||
| 33 | |||
| 34 | public void setRowStr(String rowStr) { | ||
| 35 | this.rowStr = rowStr; | ||
| 36 | } | ||
| 37 | } | ||
| 38 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/bean/TitleWord.java
| File was created | 1 | package com.hjx.miaohongentry.bean; | |
| 2 | |||
| 3 | |||
| 4 | import java.util.List; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * Created by l on 2018/2/3. | ||
| 8 | */ | ||
| 9 | |||
| 10 | public class TitleWord { | ||
| 11 | |||
| 12 | private String serialNumber; | ||
| 13 | |||
| 14 | private String title; | ||
| 15 | |||
| 16 | private List<RowWord> rowWordList; | ||
| 17 | |||
| 18 | public TitleWord(){ | ||
| 19 | |||
| 20 | } | ||
| 21 | |||
| 22 | public TitleWord(String serialNumber, String title,List<RowWord> rowWordList ){ | ||
| 23 | this.serialNumber = serialNumber; | ||
| 24 | this.title = title; | ||
| 25 | this.rowWordList = rowWordList; | ||
| 26 | } | ||
| 27 | |||
| 28 | public String getSerialNumber() { | ||
| 29 | return serialNumber; | ||
| 30 | } | ||
| 31 | |||
| 32 | public void setSerialNumber(String serialNumber) { | ||
| 33 | this.serialNumber = serialNumber; | ||
| 34 | } | ||
| 35 | |||
| 36 | public String getTitle() { | ||
| 37 | return title; | ||
| 38 | } | ||
| 39 | |||
| 40 | public void setTitle(String title) { | ||
| 41 | this.title = title; | ||
| 42 | } | ||
| 43 | |||
| 44 | public List<RowWord> getRowWordList() { | ||
| 45 | return rowWordList; | ||
| 46 | } | ||
| 47 | |||
| 48 | public void setRowWordList(List<RowWord> rowWordList) { | ||
| 49 | this.rowWordList = rowWordList; | ||
| 50 | } | ||
| 51 | } | ||
| 52 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/builder/JSONBuilder.java
| File was created | 1 | ||
| 2 | package com.hjx.miaohongentry.builder; | ||
| 3 | |||
| 4 | import org.json.JSONException; | ||
| 5 | import org.json.JSONObject; | ||
| 6 | |||
| 7 | |||
| 8 | public abstract class JSONBuilder<T> { | ||
| 9 | |||
| 10 | protected String root; | ||
| 11 | |||
| 12 | public JSONBuilder(){ | ||
| 13 | root = ""; | ||
| 14 | } | ||
| 15 | |||
| 16 | /** | ||
| 17 | * Sets root of the JSON params, useful when building object in joins | ||
| 18 | * | ||
| 19 | * @param root | ||
| 20 | */ | ||
| 21 | public void setRoot(String root){ | ||
| 22 | this.root = root; | ||
| 23 | } | ||
| 24 | |||
| 25 | public abstract T build(JSONObject jsonObject) throws JSONException; | ||
| 26 | } | ||
| 27 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/builder/UpdateInfoBuilder.java
| File was created | 1 | package com.hjx.miaohongentry.builder; | |
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | |||
| 6 | import com.hjx.miaohongentry.bean.AppVersion; | ||
| 7 | |||
| 8 | import org.json.JSONException; | ||
| 9 | import org.json.JSONObject; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * Created by l on 2017/7/8. | ||
| 13 | */ | ||
| 14 | |||
| 15 | public class UpdateInfoBuilder extends JSONBuilder<AppVersion> { | ||
| 16 | @Override | ||
| 17 | public AppVersion build(JSONObject jsonObject) throws JSONException { | ||
| 18 | |||
| 19 | try { | ||
| 20 | AppVersion info = new AppVersion(); | ||
| 21 | info.setVersionName(jsonObject.getString(root+"version_name")); | ||
| 22 | info.setVersionCode(jsonObject.getString(root+"versioncode")); | ||
| 23 | info.setMsg(jsonObject.getString(root+"msg")); | ||
| 24 | info.setURL(jsonObject.getString(root+"url")); | ||
| 25 | String update = jsonObject.getString(root+"forceupdate"); | ||
| 26 | if(update.equalsIgnoreCase("false")){ | ||
| 27 | info.setForceUpdate(false); | ||
| 28 | }else{ | ||
| 29 | info.setForceUpdate(true); | ||
| 30 | } | ||
| 31 | |||
| 32 | return info; | ||
| 33 | } catch (JSONException e) { | ||
| 34 | e.printStackTrace(); | ||
| 35 | return null; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/db/MHDataManager.java
| File was created | 1 | package com.hjx.miaohongentry.db; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.database.Cursor; | ||
| 5 | import android.database.sqlite.SQLiteDatabase; | ||
| 6 | |||
| 7 | import com.hjx.miaohongentry.activity.InitCallback; | ||
| 8 | import com.hjx.miaohongentry.bean.BookInfo; | ||
| 9 | import com.hjx.miaohongentry.bean.RowWord; | ||
| 10 | import com.hjx.miaohongentry.bean.TitleWord; | ||
| 11 | import com.hjx.miaohongentry.util.Constants; | ||
| 12 | |||
| 13 | import java.io.File; | ||
| 14 | import java.io.FileOutputStream; | ||
| 15 | import java.io.IOException; | ||
| 16 | import java.io.InputStream; | ||
| 17 | import java.util.ArrayList; | ||
| 18 | import java.util.List; | ||
| 19 | |||
| 20 | /** | ||
| 21 | * Created by l on 2018/2/2. | ||
| 22 | */ | ||
| 23 | |||
| 24 | public class MHDataManager { | ||
| 25 | |||
| 26 | public static ArrayList<BookInfo> getList(String dataPath){ | ||
| 27 | SQLiteDatabase mDB = null; | ||
| 28 | List<BookInfo> mList = new ArrayList<BookInfo>(); | ||
| 29 | Cursor mCursor = null; | ||
| 30 | |||
| 31 | mDB = SQLiteDatabase.openDatabase(dataPath, null, | ||
| 32 | SQLiteDatabase.OPEN_READONLY); | ||
| 33 | mCursor = mDB.rawQuery("select DISTINCT * from " + MHDataTable.DATA_BOOK_TABLE_NAME,null); | ||
| 34 | if (mCursor != null) { | ||
| 35 | int count = 0; | ||
| 36 | while (mCursor.moveToNext()) { | ||
| 37 | BookInfo tDetailInfo = getBookInfo(mCursor,count); | ||
| 38 | mList.add(tDetailInfo); | ||
| 39 | count++; | ||
| 40 | } | ||
| 41 | mCursor.close(); | ||
| 42 | } | ||
| 43 | |||
| 44 | mDB.close(); | ||
| 45 | |||
| 46 | return (ArrayList<BookInfo>) mList; | ||
| 47 | } | ||
| 48 | |||
| 49 | |||
| 50 | private static BookInfo getBookInfo(Cursor mCursor, int idx) { | ||
| 51 | BookInfo bookInfo = new BookInfo(); | ||
| 52 | String _id = null; | ||
| 53 | String press = null; | ||
| 54 | String grade = null; | ||
| 55 | String reactOS = null; | ||
| 56 | if (mCursor != null){ | ||
| 57 | try { | ||
| 58 | _id = "" + idx; | ||
| 59 | press = mCursor.getString(mCursor | ||
| 60 | .getColumnIndex(MHDataTable.PRESS)); | ||
| 61 | grade = mCursor.getString(mCursor | ||
| 62 | .getColumnIndex(MHDataTable.GRADE_NAME)); | ||
| 63 | reactOS = mCursor.getString(mCursor | ||
| 64 | .getColumnIndex(MHDataTable.REACTOS)); | ||
| 65 | }catch (Exception e){ | ||
| 66 | e.printStackTrace(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | bookInfo.set_id(_id); | ||
| 70 | bookInfo.setPress(press); | ||
| 71 | bookInfo.setGrade(grade); | ||
| 72 | bookInfo.setReactOS(reactOS); | ||
| 73 | return bookInfo; | ||
| 74 | } | ||
| 75 | |||
| 76 | public static List<String> getTableTypes(String press, String grade_name, String reactOS ){ | ||
| 77 | |||
| 78 | SQLiteDatabase mDB = null; | ||
| 79 | List<String> mList = new ArrayList<String>(); | ||
| 80 | Cursor mCursor = null; | ||
| 81 | |||
| 82 | mDB = SQLiteDatabase.openDatabase(Constants.MH_DATABASE_PATH, null, | ||
| 83 | SQLiteDatabase.OPEN_READONLY); | ||
| 84 | mCursor = mDB.rawQuery("select DISTINCT " + MHDataTable.TABLE_TYPE + " from " + MHDataTable.DATA_WORD_TABLE_NAME | ||
| 85 | + " WHERE "+ MHDataTable.PRESS + " = ? and " + MHDataTable.GRADE_NAME + " = ? and " + MHDataTable.REACTOS + " = ?", | ||
| 86 | new String[] { press, grade_name, reactOS}); | ||
| 87 | if (mCursor != null) { | ||
| 88 | while (mCursor.moveToNext()) { | ||
| 89 | String type = mCursor.getString(mCursor | ||
| 90 | .getColumnIndex(MHDataTable.TABLE_TYPE)); | ||
| 91 | mList.add(type); | ||
| 92 | } | ||
| 93 | mCursor.close(); | ||
| 94 | } | ||
| 95 | |||
| 96 | mDB.close(); | ||
| 97 | return mList; | ||
| 98 | } | ||
| 99 | |||
| 100 | public static List<TitleWord> getTitleWords(String press, String grade_name, String reactOS, String table_type ){ | ||
| 101 | |||
| 102 | SQLiteDatabase mDB = null; | ||
| 103 | List<TitleWord> mList = new ArrayList<TitleWord>(); | ||
| 104 | Cursor mCursor = null; | ||
| 105 | |||
| 106 | mDB = SQLiteDatabase.openDatabase(Constants.MH_DATABASE_PATH, null, | ||
| 107 | SQLiteDatabase.OPEN_READONLY); | ||
| 108 | mCursor = mDB.rawQuery("select DISTINCT " + MHDataTable.SERIAL_NUMBER + ", " + MHDataTable.TITLE | ||
| 109 | + " from " + MHDataTable.DATA_WORD_TABLE_NAME + " WHERE "+ MHDataTable.PRESS + " = ? and " | ||
| 110 | + MHDataTable.GRADE_NAME + " = ? and " + MHDataTable.REACTOS + " = ? and " | ||
| 111 | + MHDataTable.TABLE_TYPE + " = ?", | ||
| 112 | new String[] { press, grade_name, reactOS, table_type}); | ||
| 113 | |||
| 114 | if (mCursor != null) { | ||
| 115 | while (mCursor.moveToNext()) { | ||
| 116 | String serial_number = mCursor.getString(mCursor | ||
| 117 | .getColumnIndex(MHDataTable.SERIAL_NUMBER)); | ||
| 118 | String title = mCursor.getString(mCursor | ||
| 119 | .getColumnIndex(MHDataTable.TITLE)); | ||
| 120 | TitleWord titleWord = new TitleWord(); | ||
| 121 | titleWord.setSerialNumber(serial_number); | ||
| 122 | titleWord.setTitle(title); | ||
| 123 | mList.add(titleWord); | ||
| 124 | } | ||
| 125 | mCursor.close(); | ||
| 126 | } | ||
| 127 | |||
| 128 | mDB.close(); | ||
| 129 | return mList; | ||
| 130 | } | ||
| 131 | |||
| 132 | public static List<RowWord> getRowWords(BookInfo book, String table_type, TitleWord titleWord){ | ||
| 133 | |||
| 134 | SQLiteDatabase mDB = null; | ||
| 135 | List<RowWord> mList = new ArrayList<RowWord>(); | ||
| 136 | Cursor mCursor = null; | ||
| 137 | |||
| 138 | mDB = SQLiteDatabase.openDatabase(Constants.MH_DATABASE_PATH, null, | ||
| 139 | SQLiteDatabase.OPEN_READONLY); | ||
| 140 | mCursor = mDB.rawQuery("select DISTINCT " + MHDataTable.ORDER_NUMBER + ", " + MHDataTable.NEW_WORD | ||
| 141 | + " from " + MHDataTable.DATA_WORD_TABLE_NAME + " WHERE "+ MHDataTable.PRESS + " = ? and " | ||
| 142 | + MHDataTable.GRADE_NAME + " = ? and " + MHDataTable.REACTOS + " = ? and " | ||
| 143 | + MHDataTable.TABLE_TYPE + " = ? and " + MHDataTable.SERIAL_NUMBER + " = ? and " | ||
| 144 | + MHDataTable.TITLE + " = ?", | ||
| 145 | new String[] { book.getPress(), book.getGrade(), book.getReactOS(), table_type, | ||
| 146 | titleWord.getSerialNumber(), titleWord.getTitle()}); | ||
| 147 | |||
| 148 | if (mCursor != null) { | ||
| 149 | while (mCursor.moveToNext()) { | ||
| 150 | String order_number = mCursor.getString(mCursor | ||
| 151 | .getColumnIndex(MHDataTable.ORDER_NUMBER)); | ||
| 152 | String row_word = mCursor.getString(mCursor | ||
| 153 | .getColumnIndex(MHDataTable.NEW_WORD)); | ||
| 154 | RowWord rowWord = new RowWord(); | ||
| 155 | rowWord.setOrderNum(order_number); | ||
| 156 | rowWord.setRowStr(row_word); | ||
| 157 | mList.add(rowWord); | ||
| 158 | } | ||
| 159 | mCursor.close(); | ||
| 160 | } | ||
| 161 | |||
| 162 | mDB.close(); | ||
| 163 | return mList; | ||
| 164 | } | ||
| 165 | |||
| 166 | |||
| 167 | public static void initDB(final Context context, final InitCallback callback){ | ||
| 168 | new Thread(new Runnable() { | ||
| 169 | @Override | ||
| 170 | public void run() { | ||
| 171 | String databaseFilename = Constants.MH_DATABASE_DIR_PATH + "/mh.db"; | ||
| 172 | File dir = new File(Constants.MH_DATABASE_DIR_PATH); | ||
| 173 | if (!dir.exists()) | ||
| 174 | dir.mkdir(); | ||
| 175 | if (!(new File(databaseFilename)).exists()) { | ||
| 176 | try { | ||
| 177 | // InputStream is = context.getResources().openRawResource(R.raw.address); | ||
| 178 | InputStream is = context.getResources().getAssets().open("mh.db"); | ||
| 179 | FileOutputStream fos = new FileOutputStream(databaseFilename); | ||
| 180 | byte[] buffer = new byte[2048]; | ||
| 181 | int i = 0; | ||
| 182 | while ((i = is.read(buffer)) > 0) { | ||
| 183 | fos.write(buffer, 0, i); | ||
| 184 | } | ||
| 185 | fos.flush(); | ||
| 186 | fos.close(); | ||
| 187 | is.close(); | ||
| 188 | } catch (IOException e) { | ||
| 189 | new File(databaseFilename).delete(); | ||
| 190 | callback.onError(e); | ||
| 191 | return; | ||
| 192 | } | ||
| 193 | } | ||
| 194 | callback.onSucess(); | ||
| 195 | } | ||
| 196 | }).run(); | ||
| 197 | } | ||
| 198 | } | ||
| 199 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/db/MHDataTable.java
| File was created | 1 | package com.hjx.miaohongentry.db; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2018/2/2. | ||
| 5 | */ | ||
| 6 | |||
| 7 | public class MHDataTable { | ||
| 8 | |||
| 9 | public static final String DATA_NAME = "mh.db"; | ||
| 10 | |||
| 11 | public static final String DATA_BOOK_TABLE_NAME = "chinese_basics"; | ||
| 12 | |||
| 13 | public static final String DATA_WORD_TABLE_NAME = "practice_chinese"; | ||
| 14 | |||
| 15 | public static final int DATA_VERSION = 1; | ||
| 16 | |||
| 17 | public static final String STR_ID = "_id"; | ||
| 18 | |||
| 19 | public static final String PRESS = "press"; | ||
| 20 | |||
| 21 | public static final String VERSION = "version"; | ||
| 22 | |||
| 23 | public static final String GRADE_NAME = "grade_name"; | ||
| 24 | |||
| 25 | public static final String REACTOS = "ReactOS"; | ||
| 26 | |||
| 27 | public static final String[] BOOK_COLUMNS = new String[] { | ||
| 28 | PRESS, | ||
| 29 | VERSION, | ||
| 30 | GRADE_NAME, | ||
| 31 | REACTOS, | ||
| 32 | }; | ||
| 33 | |||
| 34 | public static final String TABLE_TYPE = "table_type"; | ||
| 35 | |||
| 36 | public static final String TITLE = "title"; | ||
| 37 | |||
| 38 | public static final String SERIAL_NUMBER = "serial_number"; | ||
| 39 | |||
| 40 | public static final String ORDER_NUMBER = "order_number"; | ||
| 41 | |||
| 42 | public static final String NEW_WORD = "new_word"; | ||
| 43 | |||
| 44 | } | ||
| 45 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/http/MHGetApi.java
| File was created | 1 | package com.hjx.miaohongentry.http; | |
| 2 | |||
| 3 | |||
| 4 | import com.hjx.miaohongentry.bean.AppVersion; | ||
| 5 | |||
| 6 | /** | ||
| 7 | * Created by l on 2017/7/1. | ||
| 8 | */ | ||
| 9 | |||
| 10 | public interface MHGetApi { | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Get the update informatuon of the vertion | ||
| 14 | * <br><br> | ||
| 15 | * http://boss.hjx.com/general/release/version | ||
| 16 | * @return the update informatuon | ||
| 17 | * @throws Exception | ||
| 18 | */ | ||
| 19 | AppVersion getUpdateInfo(String pid, String appName) throws Exception; | ||
| 20 | |||
| 21 | |||
| 22 | } | ||
| 23 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/http/MHGetApiImp.java
| File was created | 1 | package com.hjx.miaohongentry.http; | |
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | import com.hjx.miaohongentry.bean.AppVersion; | ||
| 6 | import com.hjx.miaohongentry.builder.UpdateInfoBuilder; | ||
| 7 | |||
| 8 | import org.json.JSONArray; | ||
| 9 | import org.json.JSONObject; | ||
| 10 | |||
| 11 | import java.io.BufferedReader; | ||
| 12 | import java.io.IOException; | ||
| 13 | import java.io.InputStream; | ||
| 14 | import java.io.InputStreamReader; | ||
| 15 | import java.io.UnsupportedEncodingException; | ||
| 16 | import java.net.HttpURLConnection; | ||
| 17 | import java.net.MalformedURLException; | ||
| 18 | import java.net.ProtocolException; | ||
| 19 | import java.net.URL; | ||
| 20 | |||
| 21 | /** | ||
| 22 | * Created by l on 2017/7/1. | ||
| 23 | */ | ||
| 24 | |||
| 25 | public class MHGetApiImp implements MHGetApi { | ||
| 26 | |||
| 27 | |||
| 28 | private String doGet(String query) throws Exception { | ||
| 29 | String path = "http://boss.hjx.com"+ query; | ||
| 30 | try { | ||
| 31 | URL url = new URL(path); | ||
| 32 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
| 33 | connection.setConnectTimeout(5000); | ||
| 34 | connection.setRequestMethod("GET"); | ||
| 35 | //่ทๅพ็ปๆ็ | ||
| 36 | int responseCode = connection.getResponseCode(); | ||
| 37 | if(responseCode ==200){ | ||
| 38 | //่ฏทๆฑๆๅ ่ทๅพ่ฟๅ็ๆต | ||
| 39 | InputStream is = connection.getInputStream(); | ||
| 40 | return InputStream2String(is); | ||
| 41 | }else { | ||
| 42 | //่ฏทๆฑๅคฑ่ดฅ | ||
| 43 | return null; | ||
| 44 | } | ||
| 45 | } catch (MalformedURLException e) { | ||
| 46 | e.printStackTrace(); | ||
| 47 | } catch (ProtocolException e) { | ||
| 48 | e.printStackTrace(); | ||
| 49 | } catch (IOException e) { | ||
| 50 | e.printStackTrace(); | ||
| 51 | } | ||
| 52 | return null; | ||
| 53 | |||
| 54 | |||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | public AppVersion getUpdateInfo(String pid, String appName) throws Exception { | ||
| 59 | |||
| 60 | String jsonStr = doGet("/general/release/version?pid="+pid+"&appName="+appName); | ||
| 61 | JSONArray jsonArray = new JSONArray(jsonStr); | ||
| 62 | for (int i = 0; i < jsonArray.length(); i++){ | ||
| 63 | JSONObject jsonObject = jsonArray.getJSONObject(i); | ||
| 64 | UpdateInfoBuilder builder = new UpdateInfoBuilder(); | ||
| 65 | return builder.build(jsonObject); | ||
| 66 | } | ||
| 67 | return null; | ||
| 68 | } | ||
| 69 | |||
| 70 | public static String InputStream2String(InputStream in) { | ||
| 71 | InputStreamReader reader = null; | ||
| 72 | try { | ||
| 73 | reader = new InputStreamReader(in, "UTF-8"); | ||
| 74 | } catch (UnsupportedEncodingException e1) { | ||
| 75 | e1.printStackTrace(); | ||
| 76 | } | ||
| 77 | BufferedReader br = new BufferedReader(reader); | ||
| 78 | StringBuilder sb = new StringBuilder(); | ||
| 79 | String line = ""; | ||
| 80 | try { | ||
| 81 | while ((line = br.readLine()) != null) { | ||
| 82 | sb.append(line); | ||
| 83 | } | ||
| 84 | } catch (IOException e) { | ||
| 85 | e.printStackTrace(); | ||
| 86 | } | ||
| 87 | return sb.toString(); | ||
| 88 | } | ||
| 89 | } | ||
| 90 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/ui/FixGridLayout.java
| File was created | 1 | package com.hjx.miaohongentry.ui; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.content.res.TypedArray; | ||
| 5 | import android.util.AttributeSet; | ||
| 6 | import android.view.View; | ||
| 7 | import android.view.ViewGroup; | ||
| 8 | |||
| 9 | import com.hjx.miaohongentry.R; | ||
| 10 | |||
| 11 | import java.util.ArrayList; | ||
| 12 | import java.util.List; | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Created by l on 2018/2/5. | ||
| 16 | */ | ||
| 17 | |||
| 18 | public class FixGridLayout extends ViewGroup { | ||
| 19 | |||
| 20 | private Type mType; | ||
| 21 | private List<WarpLine> mWarpLineGroup; | ||
| 22 | |||
| 23 | public FixGridLayout(Context context) { | ||
| 24 | this(context, null); | ||
| 25 | } | ||
| 26 | |||
| 27 | public FixGridLayout(Context context, AttributeSet attrs) { | ||
| 28 | this(context, attrs, R.style.WarpLinearLayoutDefault); | ||
| 29 | } | ||
| 30 | |||
| 31 | public FixGridLayout(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 32 | super(context, attrs, defStyleAttr); | ||
| 33 | mType = new Type(context, attrs); | ||
| 34 | } | ||
| 35 | |||
| 36 | @Override | ||
| 37 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
| 38 | int withMode = MeasureSpec.getMode(widthMeasureSpec); | ||
| 39 | int withSize = MeasureSpec.getSize(widthMeasureSpec); | ||
| 40 | int heightMode = MeasureSpec.getMode(heightMeasureSpec); | ||
| 41 | int heightSize = MeasureSpec.getSize(heightMeasureSpec); | ||
| 42 | int with = 0; | ||
| 43 | int height = 0; | ||
| 44 | int childCount = getChildCount(); | ||
| 45 | /** | ||
| 46 | * ๅจ่ฐ็จchildViewใgetMeasreไนๅๅฟ ้กปๅ ่ฐ็จ่ฏฅ่กไปฃ็ ๏ผ็จไบๅฏนๅญViewๅคงๅฐ็ๆต้ | ||
| 47 | */ | ||
| 48 | measureChildren(widthMeasureSpec, heightMeasureSpec); | ||
| 49 | /** | ||
| 50 | * ่ฎก็ฎๅฎฝๅบฆ | ||
| 51 | */ | ||
| 52 | switch (withMode) { | ||
| 53 | case MeasureSpec.EXACTLY: | ||
| 54 | with = withSize; | ||
| 55 | break; | ||
| 56 | case MeasureSpec.AT_MOST: | ||
| 57 | for (int i = 0; i < childCount; i++) { | ||
| 58 | if (i != 0) { | ||
| 59 | with += mType.horizontal_Space; | ||
| 60 | } | ||
| 61 | with += getChildAt(i).getMeasuredWidth(); | ||
| 62 | } | ||
| 63 | with += getPaddingLeft() + getPaddingRight(); | ||
| 64 | with = with > withSize ? withSize : with; | ||
| 65 | break; | ||
| 66 | case MeasureSpec.UNSPECIFIED: | ||
| 67 | for (int i = 0; i < childCount; i++) { | ||
| 68 | if (i != 0) { | ||
| 69 | with += mType.horizontal_Space; | ||
| 70 | } | ||
| 71 | with += getChildAt(i).getMeasuredWidth(); | ||
| 72 | } | ||
| 73 | with += getPaddingLeft() + getPaddingRight(); | ||
| 74 | break; | ||
| 75 | default: | ||
| 76 | with = withSize; | ||
| 77 | break; | ||
| 78 | |||
| 79 | } | ||
| 80 | /** | ||
| 81 | * ๆ นๆฎ่ฎก็ฎๅบ็ๅฎฝๅบฆ๏ผ่ฎก็ฎๅบๆ้่ฆ็่กๆฐ | ||
| 82 | */ | ||
| 83 | WarpLine warpLine = new WarpLine(); | ||
| 84 | /** | ||
| 85 | * ไธ่ฝๅคๅจๅฎไนๅฑๆงๆถๅๅงๅ๏ผๅ ไธบonMeasureๆนๆณไผๅคๆฌก่ฐ็จ | ||
| 86 | */ | ||
| 87 | mWarpLineGroup = new ArrayList<WarpLine>(); | ||
| 88 | for (int i = 0; i < childCount; i++) { | ||
| 89 | if (warpLine.lineWidth + getChildAt(i).getMeasuredWidth() + mType.horizontal_Space > with) { | ||
| 90 | if (warpLine.lineView.size() == 0) { | ||
| 91 | warpLine.addView(getChildAt(i)); | ||
| 92 | mWarpLineGroup.add(warpLine); | ||
| 93 | warpLine = new WarpLine(); | ||
| 94 | } else { | ||
| 95 | mWarpLineGroup.add(warpLine); | ||
| 96 | warpLine = new WarpLine(); | ||
| 97 | warpLine.addView(getChildAt(i)); | ||
| 98 | } | ||
| 99 | } else { | ||
| 100 | warpLine.addView(getChildAt(i)); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | /** | ||
| 104 | * ๆทปๅ ๆๅไธ่ก | ||
| 105 | */ | ||
| 106 | if (warpLine.lineView.size() > 0 && !mWarpLineGroup.contains(warpLine)) { | ||
| 107 | mWarpLineGroup.add(warpLine); | ||
| 108 | } | ||
| 109 | /** | ||
| 110 | * ่ฎก็ฎๅฎฝๅบฆ | ||
| 111 | */ | ||
| 112 | height = getPaddingTop() + getPaddingBottom(); | ||
| 113 | for (int i = 0; i < mWarpLineGroup.size(); i++) { | ||
| 114 | if (i != 0) { | ||
| 115 | height += mType.vertical_Space; | ||
| 116 | } | ||
| 117 | height += mWarpLineGroup.get(i).height; | ||
| 118 | } | ||
| 119 | switch (heightMode) { | ||
| 120 | case MeasureSpec.EXACTLY: | ||
| 121 | height = heightSize; | ||
| 122 | break; | ||
| 123 | case MeasureSpec.AT_MOST: | ||
| 124 | height = height > heightSize ? heightSize : height; | ||
| 125 | break; | ||
| 126 | case MeasureSpec.UNSPECIFIED: | ||
| 127 | break; | ||
| 128 | default: | ||
| 129 | break; | ||
| 130 | } | ||
| 131 | setMeasuredDimension(with, height); | ||
| 132 | } | ||
| 133 | |||
| 134 | @Override | ||
| 135 | protected void onLayout(boolean changed, int l, int t, int r, int b) { | ||
| 136 | t = getPaddingTop(); | ||
| 137 | for (int i = 0; i < mWarpLineGroup.size(); i++) { | ||
| 138 | int left = getPaddingLeft(); | ||
| 139 | WarpLine warpLine = mWarpLineGroup.get(i); | ||
| 140 | int lastWidth = getMeasuredWidth() - warpLine.lineWidth; | ||
| 141 | for (int j = 0; j < warpLine.lineView.size(); j++) { | ||
| 142 | View view = warpLine.lineView.get(j); | ||
| 143 | if (isFull()) {//้่ฆๅ ๆปกๅฝๅ่กๆถ | ||
| 144 | view.layout(left, t, left + view.getMeasuredWidth() + lastWidth / warpLine.lineView.size(), t + view.getMeasuredHeight()); | ||
| 145 | left += view.getMeasuredWidth() + mType.horizontal_Space + lastWidth / warpLine.lineView.size(); | ||
| 146 | } else { | ||
| 147 | switch (getGrivate()) { | ||
| 148 | case 0://ๅณๅฏน้ฝ | ||
| 149 | view.layout(left + lastWidth, t, left + lastWidth + view.getMeasuredWidth(), t + view.getMeasuredHeight()); | ||
| 150 | break; | ||
| 151 | case 2://ๅฑ ไธญๅฏน้ฝ | ||
| 152 | view.layout(left + lastWidth / 2, t, left + lastWidth / 2 + view.getMeasuredWidth(), t + view.getMeasuredHeight()); | ||
| 153 | break; | ||
| 154 | default://ๅทฆๅฏน้ฝ | ||
| 155 | view.layout(left, t, left + view.getMeasuredWidth(), t + view.getMeasuredHeight()); | ||
| 156 | break; | ||
| 157 | } | ||
| 158 | left += view.getMeasuredWidth() + mType.horizontal_Space; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | t += warpLine.height + mType.vertical_Space; | ||
| 162 | } | ||
| 163 | } | ||
| 164 | |||
| 165 | /** | ||
| 166 | * ็จไบๅญๆพไธ่กๅญView | ||
| 167 | */ | ||
| 168 | private final class WarpLine { | ||
| 169 | private List<View> lineView = new ArrayList<View>(); | ||
| 170 | /** | ||
| 171 | * ๅฝๅ่กไธญๆ้่ฆๅ ็จ็ๅฎฝๅบฆ | ||
| 172 | */ | ||
| 173 | private int lineWidth = getPaddingLeft() + getPaddingRight(); | ||
| 174 | /** | ||
| 175 | * ่ฏฅ่กViewไธญๆ้่ฆๅ ็จ็ๆๅคง้ซๅบฆ | ||
| 176 | */ | ||
| 177 | private int height = 0; | ||
| 178 | |||
| 179 | private void addView(View view) { | ||
| 180 | if (lineView.size() != 0) { | ||
| 181 | lineWidth += mType.horizontal_Space; | ||
| 182 | } | ||
| 183 | height = height > view.getMeasuredHeight() ? height : view.getMeasuredHeight(); | ||
| 184 | lineWidth += view.getMeasuredWidth(); | ||
| 185 | lineView.add(view); | ||
| 186 | } | ||
| 187 | } | ||
| 188 | |||
| 189 | /** | ||
| 190 | * ๅฏนๆ ทๅผ็ๅๅงๅ | ||
| 191 | */ | ||
| 192 | private final static class Type { | ||
| 193 | /* | ||
| 194 | *ๅฏน้ฝๆนๅผ right 0๏ผleft 1๏ผcenter 2 | ||
| 195 | */ | ||
| 196 | private int grivate; | ||
| 197 | /** | ||
| 198 | * ๆฐดๅนณ้ด่ท,ๅไฝpx | ||
| 199 | */ | ||
| 200 | private float horizontal_Space; | ||
| 201 | /** | ||
| 202 | * ๅ็ด้ด่ท,ๅไฝpx | ||
| 203 | */ | ||
| 204 | private float vertical_Space; | ||
| 205 | /** | ||
| 206 | * ๆฏๅฆ่ชๅจๅกซๆปก | ||
| 207 | */ | ||
| 208 | private boolean isFull; | ||
| 209 | |||
| 210 | Type(Context context, AttributeSet attrs) { | ||
| 211 | if (attrs == null) { | ||
| 212 | return; | ||
| 213 | } | ||
| 214 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WarpLinearLayout); | ||
| 215 | grivate = typedArray.getInt(R.styleable.WarpLinearLayout_grivate, grivate); | ||
| 216 | horizontal_Space = typedArray.getDimension(R.styleable.WarpLinearLayout_horizontal_Space, horizontal_Space); | ||
| 217 | vertical_Space = typedArray.getDimension(R.styleable.WarpLinearLayout_vertical_Space, vertical_Space); | ||
| 218 | isFull = typedArray.getBoolean(R.styleable.WarpLinearLayout_isFull, isFull); | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | public int getGrivate() { | ||
| 223 | return mType.grivate; | ||
| 224 | } | ||
| 225 | |||
| 226 | public float getHorizontal_Space() { | ||
| 227 | return mType.horizontal_Space; | ||
| 228 | } | ||
| 229 | |||
| 230 | public float getVertical_Space() { | ||
| 231 | return mType.vertical_Space; | ||
| 232 | } | ||
| 233 | |||
| 234 | public boolean isFull() { | ||
| 235 | return mType.isFull; | ||
| 236 | } | ||
| 237 | |||
| 238 | public void setGrivate(int grivate) { | ||
| 239 | mType.grivate = grivate; | ||
| 240 | } | ||
| 241 | |||
| 242 | public void setHorizontal_Space(float horizontal_Space) { | ||
| 243 | mType.horizontal_Space = horizontal_Space; | ||
| 244 | } | ||
| 245 | |||
| 246 | public void setVertical_Space(float vertical_Space) { | ||
| 247 | mType.vertical_Space = vertical_Space; | ||
| 248 | } | ||
| 249 | |||
| 250 | public void setIsFull(boolean isFull) { | ||
| 251 | mType.isFull = isFull; | ||
| 252 | } | ||
| 253 | |||
| 254 | /** | ||
| 255 | * ๆฏ่กๅญView็ๅฏน้ฝๆนๅผ | ||
| 256 | */ | ||
| 257 | public final static class Gravite { | ||
| 258 | public final static int RIGHT = 0; | ||
| 259 | public final static int LEFT = 1; | ||
| 260 | public final static int CENTER = 2; | ||
| 261 | } | ||
| 262 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/ui/WordListView.java
| File was created | 1 | package com.hjx.miaohongentry.ui; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | import android.util.AttributeSet; | ||
| 5 | import android.widget.ListView; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Created by l on 2018/2/6. | ||
| 9 | */ | ||
| 10 | |||
| 11 | public class WordListView extends ListView { | ||
| 12 | |||
| 13 | public WordListView(Context context) { | ||
| 14 | super(context); | ||
| 15 | } | ||
| 16 | |||
| 17 | public WordListView(Context context, AttributeSet attrs) { | ||
| 18 | super(context, attrs); | ||
| 19 | } | ||
| 20 | |||
| 21 | public WordListView(Context context, AttributeSet attrs, int defStyleAttr) { | ||
| 22 | super(context, attrs, defStyleAttr); | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | @Override | ||
| 27 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | ||
| 28 | int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, | ||
| 29 | MeasureSpec.AT_MOST); | ||
| 30 | super.onMeasure(widthMeasureSpec, expandSpec); | ||
| 31 | } | ||
| 32 | } | ||
| 33 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/update/DownloadService.java
| File was created | 1 | package com.hjx.miaohongentry.update; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2017/7/17. | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | import android.app.IntentService; | ||
| 9 | import android.content.Intent; | ||
| 10 | import android.os.Bundle; | ||
| 11 | import android.os.ResultReceiver; | ||
| 12 | |||
| 13 | import java.io.BufferedInputStream; | ||
| 14 | import java.io.FileOutputStream; | ||
| 15 | import java.io.IOException; | ||
| 16 | import java.io.InputStream; | ||
| 17 | import java.io.OutputStream; | ||
| 18 | import java.net.URL; | ||
| 19 | import java.net.URLConnection; | ||
| 20 | |||
| 21 | public class DownloadService extends IntentService { | ||
| 22 | public static final int UPDATE_PROGRESS = 8344; | ||
| 23 | public DownloadService() { | ||
| 24 | super("DownloadService"); | ||
| 25 | } | ||
| 26 | @Override | ||
| 27 | protected void onHandleIntent(Intent intent) { | ||
| 28 | String urlToDownload = intent.getStringExtra("url"); | ||
| 29 | String fileDestination = intent.getStringExtra("dest"); | ||
| 30 | ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver"); | ||
| 31 | try { | ||
| 32 | URL url = new URL(urlToDownload); | ||
| 33 | URLConnection connection = url.openConnection(); | ||
| 34 | connection.connect(); | ||
| 35 | // this will be useful so that you can show a typical 0-100% progress bar | ||
| 36 | int fileLength = connection.getContentLength(); | ||
| 37 | // download the file | ||
| 38 | InputStream input = new BufferedInputStream(connection.getInputStream()); | ||
| 39 | OutputStream output = new FileOutputStream(fileDestination); | ||
| 40 | byte data[] = new byte[100]; | ||
| 41 | long total = 0; | ||
| 42 | int count; | ||
| 43 | while ((count = input.read(data)) != -1) { | ||
| 44 | total += count; | ||
| 45 | // publishing the progress.... | ||
| 46 | Bundle resultData = new Bundle(); | ||
| 47 | resultData.putInt("progress" ,(int) (total * 100 / fileLength)); | ||
| 48 | receiver.send(UPDATE_PROGRESS, resultData); | ||
| 49 | output.write(data, 0, count); | ||
| 50 | } | ||
| 51 | output.flush(); | ||
| 52 | output.close(); | ||
| 53 | input.close(); | ||
| 54 | } catch (IOException e) { | ||
| 55 | e.printStackTrace(); | ||
| 56 | } | ||
| 57 | Bundle resultData = new Bundle(); | ||
| 58 | resultData.putInt("progress" ,100); | ||
| 59 | receiver.send(UPDATE_PROGRESS, resultData); | ||
| 60 | } | ||
| 61 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/update/UpdateChecker.java
| File was created | 1 | package com.hjx.miaohongentry.update; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2017/7/17. | ||
| 5 | */ | ||
| 6 | |||
| 7 | import android.app.Activity; | ||
| 8 | import android.app.AlertDialog; | ||
| 9 | import android.app.ProgressDialog; | ||
| 10 | import android.content.Context; | ||
| 11 | import android.content.DialogInterface; | ||
| 12 | import android.content.Intent; | ||
| 13 | import android.content.pm.PackageInfo; | ||
| 14 | import android.content.pm.PackageManager; | ||
| 15 | import android.net.Uri; | ||
| 16 | import android.os.Bundle; | ||
| 17 | import android.os.Environment; | ||
| 18 | import android.os.Handler; | ||
| 19 | import android.os.Message; | ||
| 20 | import android.os.ResultReceiver; | ||
| 21 | import android.util.Log; | ||
| 22 | |||
| 23 | |||
| 24 | import com.hjx.miaohongentry.bean.AppVersion; | ||
| 25 | import com.hjx.miaohongentry.http.MHGetApiImp; | ||
| 26 | |||
| 27 | import java.io.File; | ||
| 28 | |||
| 29 | public class UpdateChecker { | ||
| 30 | private static final String TAG = "UpdateChecker"; | ||
| 31 | private Context mContext; | ||
| 32 | //ๆฃๆฅ็ๆฌไฟกๆฏ็็บฟ็จ | ||
| 33 | private Thread mThread; | ||
| 34 | |||
| 35 | private AppVersion mAppVersion; | ||
| 36 | //ไธ่ฝฝapk็ๅฏน่ฏๆก | ||
| 37 | private ProgressDialog mProgressDialog; | ||
| 38 | |||
| 39 | private File apkFile; | ||
| 40 | |||
| 41 | |||
| 42 | public UpdateChecker(Context context) { | ||
| 43 | mContext = context; | ||
| 44 | // instantiate it within the onCreate method | ||
| 45 | mProgressDialog = new ProgressDialog(context); | ||
| 46 | mProgressDialog.setMessage("ๆญฃๅจไธ่ฝฝ"); | ||
| 47 | mProgressDialog.setIndeterminate(false); | ||
| 48 | mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); | ||
| 49 | mProgressDialog.setCancelable(true); | ||
| 50 | mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { | ||
| 51 | @Override | ||
| 52 | public void onCancel(DialogInterface dialog) { | ||
| 53 | |||
| 54 | } | ||
| 55 | }); | ||
| 56 | mProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | ||
| 57 | @Override | ||
| 58 | public void onDismiss(DialogInterface dialog) { | ||
| 59 | // TODO Auto-generated method stub | ||
| 60 | |||
| 61 | } | ||
| 62 | }); | ||
| 63 | } | ||
| 64 | |||
| 65 | public void checkForUpdates() { | ||
| 66 | |||
| 67 | final Handler handler = new Handler(){ | ||
| 68 | public void handleMessage(Message msg) { | ||
| 69 | if (msg.what == 1) { | ||
| 70 | mAppVersion = (AppVersion) msg.obj; | ||
| 71 | try{ | ||
| 72 | int versionCode = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode; | ||
| 73 | if (mAppVersion.getVersionCode() > versionCode) { | ||
| 74 | if(mAppVersion.isForceUpdate()){ | ||
| 75 | showForceUpdateDialog(); | ||
| 76 | }else{ | ||
| 77 | showUpdateDialog(); | ||
| 78 | } | ||
| 79 | } else { | ||
| 80 | //Toast.makeText(mContext, "ๅทฒ็ปๆฏๆๆฐ็ๆฌ", Toast.LENGTH_SHORT).show(); | ||
| 81 | } | ||
| 82 | }catch (PackageManager.NameNotFoundException ignored) { | ||
| 83 | // | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | }; | ||
| 88 | |||
| 89 | mThread = new Thread() { | ||
| 90 | @Override | ||
| 91 | public void run() { | ||
| 92 | //if (isNetworkAvailable(mContext)) { | ||
| 93 | try { | ||
| 94 | MHGetApiImp imp = new MHGetApiImp(); | ||
| 95 | String pkgName = mContext.getPackageName(); | ||
| 96 | |||
| 97 | PackageInfo pkg = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0); | ||
| 98 | // String appName = pkg.applicationInfo.loadLabel(mContext.getPackageManager()).toString(); | ||
| 99 | String appName = "็ปๆฑๅญ"; | ||
| 100 | AppVersion appVersion = imp.getUpdateInfo(pkgName,appName); | ||
| 101 | if(appVersion != null){ | ||
| 102 | Message msg = new Message(); | ||
| 103 | msg.what = 1; | ||
| 104 | msg.obj = appVersion; | ||
| 105 | handler.sendMessage(msg); | ||
| 106 | }else { | ||
| 107 | Log.e(TAG, "can't get app update json"); | ||
| 108 | } | ||
| 109 | |||
| 110 | }catch (Exception e){ | ||
| 111 | e.printStackTrace(); | ||
| 112 | } | ||
| 113 | |||
| 114 | } | ||
| 115 | }; | ||
| 116 | mThread.start(); | ||
| 117 | } | ||
| 118 | |||
| 119 | private void showForceUpdateDialog() { | ||
| 120 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); | ||
| 121 | |||
| 122 | //builder.setIcon(R.drawable.icon); | ||
| 123 | builder.setTitle("ๅ็บงๆ็คบ"); | ||
| 124 | builder.setMessage(mAppVersion.getMsg()); | ||
| 125 | builder.setPositiveButton("็ฐๅจๅ็บง", | ||
| 126 | new DialogInterface.OnClickListener() { | ||
| 127 | public void onClick(DialogInterface dialog, int whichButton) { | ||
| 128 | downLoadApk(); | ||
| 129 | } | ||
| 130 | }); | ||
| 131 | builder.setNegativeButton("้ๅบ", | ||
| 132 | new DialogInterface.OnClickListener() { | ||
| 133 | public void onClick(DialogInterface dialog, int whichButton) { | ||
| 134 | ((Activity)mContext).finish(); | ||
| 135 | } | ||
| 136 | }); | ||
| 137 | builder.setCancelable(false); | ||
| 138 | builder.show(); | ||
| 139 | } | ||
| 140 | |||
| 141 | private void showUpdateDialog() { | ||
| 142 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext); | ||
| 143 | //builder.setIcon(R.drawable.icon); | ||
| 144 | builder.setTitle("ๅ็บงๆ็คบ"); | ||
| 145 | builder.setMessage(mAppVersion.getMsg()); | ||
| 146 | builder.setPositiveButton("ไธ่ฝฝ", | ||
| 147 | new DialogInterface.OnClickListener() { | ||
| 148 | public void onClick(DialogInterface dialog, int whichButton) { | ||
| 149 | downLoadApk(); | ||
| 150 | } | ||
| 151 | }); | ||
| 152 | builder.setNegativeButton("ๅฟฝ็ฅ", | ||
| 153 | new DialogInterface.OnClickListener() { | ||
| 154 | public void onClick(DialogInterface dialog, int whichButton) { | ||
| 155 | |||
| 156 | } | ||
| 157 | }); | ||
| 158 | builder.show(); | ||
| 159 | } | ||
| 160 | |||
| 161 | private void downLoadApk() { | ||
| 162 | String apkUrl = mAppVersion.getURL(); | ||
| 163 | String dir = mContext.getExternalFilesDir( "apk").getAbsolutePath(); | ||
| 164 | File folder = Environment.getExternalStoragePublicDirectory(dir); | ||
| 165 | if(folder.exists() && folder.isDirectory()) { | ||
| 166 | //do nothing | ||
| 167 | }else { | ||
| 168 | folder.mkdirs(); | ||
| 169 | } | ||
| 170 | String filename = apkUrl.substring(apkUrl.lastIndexOf("/"),apkUrl.length()); | ||
| 171 | String destinationFilePath = dir + "/" + filename; | ||
| 172 | apkFile = new File(destinationFilePath); | ||
| 173 | if(mAppVersion.isForceUpdate()){ | ||
| 174 | mProgressDialog.setCancelable(false); | ||
| 175 | } | ||
| 176 | mProgressDialog.show(); | ||
| 177 | Intent intent = new Intent(mContext, DownloadService.class); | ||
| 178 | intent.putExtra("url", apkUrl); | ||
| 179 | intent.putExtra("dest", destinationFilePath); | ||
| 180 | intent.putExtra("receiver", new DownloadReceiver(new Handler())); | ||
| 181 | mContext.startService(intent); | ||
| 182 | } | ||
| 183 | |||
| 184 | private class DownloadReceiver extends ResultReceiver { | ||
| 185 | public DownloadReceiver(Handler handler) { | ||
| 186 | super(handler); | ||
| 187 | } | ||
| 188 | @Override | ||
| 189 | protected void onReceiveResult(int resultCode, Bundle resultData) { | ||
| 190 | super.onReceiveResult(resultCode, resultData); | ||
| 191 | if (resultCode == DownloadService.UPDATE_PROGRESS) { | ||
| 192 | int progress = resultData.getInt("progress"); | ||
| 193 | mProgressDialog.setProgress(progress); | ||
| 194 | if (progress == 100) { | ||
| 195 | mProgressDialog.dismiss(); | ||
| 196 | //ๅฆๆๆฒกๆ่ฎพ็ฝฎSDCardๅๆ้๏ผๆ่ ๆฒกๆsdcard,apkๆไปถไฟๅญๅจๅ ๅญไธญ๏ผ้่ฆๆไบๆ้ๆ่ฝๅฎ่ฃ | ||
| 197 | String[] command = {"chmod","777",apkFile.toString()}; | ||
| 198 | try{ | ||
| 199 | ProcessBuilder builder = new ProcessBuilder(command); | ||
| 200 | builder.start(); | ||
| 201 | Intent intent = new Intent(Intent.ACTION_VIEW); | ||
| 202 | intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive"); | ||
| 203 | mContext.startActivity(intent); | ||
| 204 | }catch (Exception e){ | ||
| 205 | e.printStackTrace(); | ||
| 206 | } | ||
| 207 | } | ||
| 208 | } | ||
| 209 | } | ||
| 210 | } | ||
| 211 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/util/Constants.java
| File was created | 1 | package com.hjx.miaohongentry.util; | |
| 2 | |||
| 3 | import android.os.Environment; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * Created by l on 2018/2/3. | ||
| 7 | */ | ||
| 8 | |||
| 9 | public class Constants { | ||
| 10 | |||
| 11 | public final static String SP_BOOK_CHOSEN_INFO = "book_info"; | ||
| 12 | public final static String SP_BOOK_CHOSEN_ID = "book_idx"; | ||
| 13 | public final static String PACKAGE_NAME = "com.hjx.miaohongentry"; | ||
| 14 | public final static String MH_DATABASE_DIR_PATH = "/sdcard/"+PACKAGE_NAME; | ||
| 15 | public final static String MH_DATABASE_PATH = "/sdcard/"+PACKAGE_NAME+"/mh.db"; | ||
| 16 | |||
| 17 | public final static String SP_STATIS_WRITE_TOTAL = "write_total"; | ||
| 18 | public final static String SP_STATIS_WRITE_NUM_TODAY = "write_num_today"; | ||
| 19 | public final static String SP_STATIS_WRITE_TIME_TODAY = "write_time_today"; | ||
| 20 | public final static String SP_STATIS_DATE_TODAY = "today"; | ||
| 21 | |||
| 22 | public final static String SP_STATIS_ENTER_APP_TIMR = "enter_time"; | ||
| 23 | } | ||
| 24 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/util/DeviceUtils.java
| File was created | 1 | /* | |
| 2 | * Copyright (C) 2013 Peng fei Pan <sky@xiaopan.me> | ||
| 3 | * | ||
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | * you may not use this file except in compliance with the License. | ||
| 6 | * You may obtain a copy of the License at | ||
| 7 | * | ||
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | * | ||
| 10 | * Unless required by applicable law or agreed to in writing, software | ||
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | * See the License for the specific language governing permissions and | ||
| 14 | * limitations under the License. | ||
| 15 | */ | ||
| 16 | |||
| 17 | package com.hjx.miaohongentry.util; | ||
| 18 | |||
| 19 | import android.annotation.TargetApi; | ||
| 20 | import android.content.Context; | ||
| 21 | import android.graphics.Point; | ||
| 22 | import android.os.Build; | ||
| 23 | import android.util.TypedValue; | ||
| 24 | import android.view.Display; | ||
| 25 | import android.view.WindowManager; | ||
| 26 | |||
| 27 | /** | ||
| 28 | * ่ฎพๅคๅทฅๅ ท็ฎฑ๏ผๆไพไธ่ฎพๅค็กฌไปถ็ธๅ ณ็ๅทฅๅ ทๆนๆณ | ||
| 29 | */ | ||
| 30 | public class DeviceUtils { | ||
| 31 | |||
| 32 | /** | ||
| 33 | * ่ทๅๅฑๅนๅฐบๅฏธ | ||
| 34 | */ | ||
| 35 | @SuppressWarnings("deprecation") | ||
| 36 | @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) | ||
| 37 | public static Point getScreenSize(Context context){ | ||
| 38 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); | ||
| 39 | Display display = windowManager.getDefaultDisplay(); | ||
| 40 | if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2){ | ||
| 41 | return new Point(display.getWidth(), display.getHeight()); | ||
| 42 | }else{ | ||
| 43 | Point point = new Point(); | ||
| 44 | display.getSize(point); | ||
| 45 | return point; | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | public static int dip2px(Context context, float dpValue) { | ||
| 50 | final float scale = context.getResources().getDisplayMetrics().density; | ||
| 51 | return (int) (dpValue * scale + 0.5f); | ||
| 52 | } | ||
| 53 | |||
| 54 | /** | ||
| 55 | * dp่ฝฌpx | ||
| 56 | * | ||
| 57 | * @param context ไธไธๆ | ||
| 58 | * @param dpVal dpๅผ | ||
| 59 | * @return result in px | ||
| 60 | */ | ||
| 61 | public static int dp2px(Context context, float dpVal) { | ||
| 62 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, | ||
| 63 | dpVal, context.getResources().getDisplayMetrics()); | ||
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 | * sp่ฝฌpx | ||
| 68 | * | ||
| 69 | * @param context ไธไธๆ | ||
| 70 | * @param spVal spๅผ | ||
| 71 | * @return result in px | ||
| 72 | */ | ||
| 73 | public static int sp2px(Context context, float spVal) { | ||
| 74 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, | ||
| 75 | spVal, context.getResources().getDisplayMetrics()); | ||
| 76 | } | ||
| 77 | |||
| 78 | /** | ||
| 79 | * px่ฝฌdp | ||
| 80 | * | ||
| 81 | * @param context ไธไธๆ | ||
| 82 | * @param pxVal pxๅผ | ||
| 83 | * @return result in dp | ||
| 84 | */ | ||
| 85 | public static float px2dp(Context context, float pxVal) { | ||
| 86 | final float scale = context.getResources().getDisplayMetrics().density; | ||
| 87 | return (pxVal / scale); | ||
| 88 | } | ||
| 89 | |||
| 90 | /** | ||
| 91 | * px่ฝฌsp | ||
| 92 | * | ||
| 93 | * @param context ไธไธๆ | ||
| 94 | * @param pxVal pxๅผ | ||
| 95 | * @return result in sp | ||
| 96 | */ | ||
| 97 | public static float px2sp(Context context, float pxVal) { | ||
| 98 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity); | ||
| 99 | } | ||
| 100 | |||
| 101 | |||
| 102 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/util/SpUtils.java
| File was created | 1 | package com.hjx.miaohongentry.util; | |
| 2 | |||
| 3 | /** | ||
| 4 | * Created by l on 2017/7/20. | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | import android.content.Context; | ||
| 9 | import android.content.SharedPreferences; | ||
| 10 | |||
| 11 | /** | ||
| 12 | * SharedPreferenceๆไฝ็ฑป | ||
| 13 | */ | ||
| 14 | public class SpUtils { | ||
| 15 | private static final String spFileName = "app"; | ||
| 16 | |||
| 17 | |||
| 18 | public static String getString(Context context, String strKey) { | ||
| 19 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 20 | spFileName, Context.MODE_PRIVATE); | ||
| 21 | String result = setPreferences.getString(strKey, ""); | ||
| 22 | return result; | ||
| 23 | } | ||
| 24 | |||
| 25 | public static String getString(Context context, String strKey, | ||
| 26 | String strDefault) { | ||
| 27 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 28 | spFileName, Context.MODE_PRIVATE); | ||
| 29 | String result = setPreferences.getString(strKey, strDefault); | ||
| 30 | return result; | ||
| 31 | } | ||
| 32 | |||
| 33 | public static void putString(Context context, String strKey, String strData) { | ||
| 34 | SharedPreferences activityPreferences = context.getSharedPreferences( | ||
| 35 | spFileName, Context.MODE_PRIVATE); | ||
| 36 | SharedPreferences.Editor editor = activityPreferences.edit(); | ||
| 37 | editor.putString(strKey, strData); | ||
| 38 | editor.commit(); | ||
| 39 | } | ||
| 40 | |||
| 41 | public static Boolean getBoolean(Context context, String strKey) { | ||
| 42 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 43 | spFileName, Context.MODE_PRIVATE); | ||
| 44 | Boolean result = setPreferences.getBoolean(strKey, false); | ||
| 45 | return result; | ||
| 46 | } | ||
| 47 | |||
| 48 | public static Boolean getBoolean(Context context, String strKey, | ||
| 49 | Boolean strDefault) { | ||
| 50 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 51 | spFileName, Context.MODE_PRIVATE); | ||
| 52 | Boolean result = setPreferences.getBoolean(strKey, strDefault); | ||
| 53 | return result; | ||
| 54 | } | ||
| 55 | |||
| 56 | |||
| 57 | public static void putBoolean(Context context, String strKey, | ||
| 58 | Boolean strData) { | ||
| 59 | SharedPreferences activityPreferences = context.getSharedPreferences( | ||
| 60 | spFileName, Context.MODE_PRIVATE); | ||
| 61 | SharedPreferences.Editor editor = activityPreferences.edit(); | ||
| 62 | editor.putBoolean(strKey, strData); | ||
| 63 | editor.commit(); | ||
| 64 | } | ||
| 65 | |||
| 66 | public static int getInt(Context context, String strKey) { | ||
| 67 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 68 | spFileName, Context.MODE_PRIVATE); | ||
| 69 | int result = setPreferences.getInt(strKey, -1); | ||
| 70 | return result; | ||
| 71 | } | ||
| 72 | |||
| 73 | public static int getInt(Context context, String strKey, int strDefault) { | ||
| 74 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 75 | spFileName, Context.MODE_PRIVATE); | ||
| 76 | int result = setPreferences.getInt(strKey, strDefault); | ||
| 77 | return result; | ||
| 78 | } | ||
| 79 | |||
| 80 | public static void putInt(Context context, String strKey, int strData) { | ||
| 81 | SharedPreferences activityPreferences = context.getSharedPreferences( | ||
| 82 | spFileName, Context.MODE_PRIVATE); | ||
| 83 | SharedPreferences.Editor editor = activityPreferences.edit(); | ||
| 84 | editor.putInt(strKey, strData); | ||
| 85 | editor.commit(); | ||
| 86 | } | ||
| 87 | |||
| 88 | public static long getLong(Context context, String strKey) { | ||
| 89 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 90 | spFileName, Context.MODE_PRIVATE); | ||
| 91 | long result = setPreferences.getLong(strKey, -1); | ||
| 92 | return result; | ||
| 93 | } | ||
| 94 | |||
| 95 | public static long getLong(Context context, String strKey, long strDefault) { | ||
| 96 | SharedPreferences setPreferences = context.getSharedPreferences( | ||
| 97 | spFileName, Context.MODE_PRIVATE); | ||
| 98 | long result = setPreferences.getLong(strKey, strDefault); | ||
| 99 | return result; | ||
| 100 | } | ||
| 101 | |||
| 102 | public static void putLong(Context context, String strKey, long strData) { | ||
| 103 | SharedPreferences activityPreferences = context.getSharedPreferences( | ||
| 104 | spFileName, Context.MODE_PRIVATE); | ||
| 105 | SharedPreferences.Editor editor = activityPreferences.edit(); | ||
| 106 | editor.putLong(strKey, strData); | ||
| 107 | editor.commit(); | ||
| 108 | } | ||
| 109 | } |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/util/SpanTextViewUtils.java
| File was created | 1 | package com.hjx.miaohongentry.util; | |
| 2 | |||
| 3 | import java.util.Timer; | ||
| 4 | import java.util.TimerTask; | ||
| 5 | import java.util.concurrent.ExecutorService; | ||
| 6 | import java.util.concurrent.Executors; | ||
| 7 | import java.util.regex.Matcher; | ||
| 8 | import java.util.regex.Pattern; | ||
| 9 | |||
| 10 | import net.sourceforge.pinyin4j.PinyinHelper; | ||
| 11 | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; | ||
| 12 | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; | ||
| 13 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; | ||
| 14 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; | ||
| 15 | |||
| 16 | import android.app.Activity; | ||
| 17 | import android.app.AlertDialog; | ||
| 18 | import android.app.Dialog; | ||
| 19 | import android.content.ComponentName; | ||
| 20 | import android.content.Context; | ||
| 21 | import android.content.Intent; | ||
| 22 | import android.graphics.Color; | ||
| 23 | import android.graphics.drawable.AnimationDrawable; | ||
| 24 | import android.provider.Settings; | ||
| 25 | import android.text.style.ForegroundColorSpan; | ||
| 26 | import android.view.LayoutInflater; | ||
| 27 | import android.view.View; | ||
| 28 | import android.view.View.OnClickListener; | ||
| 29 | import android.widget.ImageButton; | ||
| 30 | import android.widget.ImageView; | ||
| 31 | import android.widget.RelativeLayout; | ||
| 32 | import android.widget.Toast; | ||
| 33 | |||
| 34 | import com.hjx.miaohongentry.activity.WordActivity; | ||
| 35 | |||
| 36 | |||
| 37 | public class SpanTextViewUtils { | ||
| 38 | |||
| 39 | public static long lastTime;// ไธไธๆฌก็นๅปๆถ้ด | ||
| 40 | public static long currentTime;// ่ฟไธๆฌก็นๅปๆถ้ด | ||
| 41 | |||
| 42 | private static View contentView; | ||
| 43 | private static Dialog dialog; | ||
| 44 | private static AnimationDrawable mAnimationDrawable; | ||
| 45 | |||
| 46 | public static ForegroundColorSpan mForegroundColorSpan = new ForegroundColorSpan(Color.CYAN); | ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | /** | ||
| 51 | * ่ฟๅ ฅๆ็บขๅบ็จ adb shell am force-stop air.com.wyt.HanZiMiaoHong | ||
| 52 | * | ||
| 53 | * @param context | ||
| 54 | * @param character | ||
| 55 | * ้่ฆๆ็บข็ๆฑๅญ | ||
| 56 | */ | ||
| 57 | public static void gotoMiaohong(Context context, String character) { | ||
| 58 | // ไธไธชๅญ็ๆ ๅตไธ๏ผ่ฟๅ ฅๆ็บข | ||
| 59 | String pinyins = converterToSpell(character); | ||
| 60 | String py = pinyins.split(",")[0].trim(); | ||
| 61 | boolean isCharacter = false; | ||
| 62 | Pattern p = Pattern.compile("[\\u4e00-\\u9fa5]"); | ||
| 63 | Matcher m = p.matcher(character); | ||
| 64 | while (m.find()) { | ||
| 65 | isCharacter = true; | ||
| 66 | } | ||
| 67 | if (isCharacter) {// ่ฏญๆ็ง็ฎไธๆฏๆฑๅญๆ่ทณ | ||
| 68 | //&& Constants.OPENFLAG == 0//่ฏญๆ็ง็ฎไธ | ||
| 69 | Intent intent = new Intent(); | ||
| 70 | ComponentName cn = new ComponentName("air.com.wyt.HanZiMiaoHong", "air.com.wyt.HanZiMiaoHong.AppEntry"); | ||
| 71 | intent.setComponent(cn); | ||
| 72 | // ๆ็บขไผ ๅ ฅ่งๅ๏ผๆฑๅญ&_ๆผ้ณ | ||
| 73 | intent.putExtra("type", character.trim() + "&_" + py.trim()); | ||
| 74 | try { | ||
| 75 | // ((Activity)context).startActivityForResult(intent, WordActivity.REQUEST_CODE_MIAO_HONG); | ||
| 76 | context.startActivity(intent); | ||
| 77 | } catch (Exception e) { | ||
| 78 | Toast.makeText(context, "ๆชๅฎ่ฃ ๆฑๅญๆ็บข๏ผ", | ||
| 79 | Toast.LENGTH_SHORT).show(); | ||
| 80 | // return; | ||
| 81 | //ToastUtil.showLong(context, context.getResources().getString(R.string.apk_none_hanzimiaohong)); | ||
| 82 | } | ||
| 83 | StatisUtils.setEnterMiaohongTime(context, System.currentTimeMillis()); | ||
| 84 | StatisUtils.addTotalNum(context); | ||
| 85 | int count = StatisUtils.getTodayNum(context); | ||
| 86 | count ++; | ||
| 87 | StatisUtils.setTodayNum(context,count); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | /** | ||
| 92 | * ๆฑๅญ่ฝฌๆขไฝๆฑ่ฏญๅ จๆผ๏ผ่ฑๆๅญ็ฌฆไธๅ๏ผ็นๆฎๅญ็ฌฆไธขๅคฑ | ||
| 93 | * ๆฏๆๅค้ณๅญ๏ผ็ๆๆนๅผๅฆ๏ผ้ๅฝๅ:zhongdangcen,zhongdangcan,chongdangcen | ||
| 94 | * ,chongdangshen,zhongdangshen,chongdangcan๏ผ | ||
| 95 | * | ||
| 96 | * @param chines | ||
| 97 | * ๆฑๅญ | ||
| 98 | * @return ๆผ้ณ | ||
| 99 | */ | ||
| 100 | public static String converterToSpell(String chines) { | ||
| 101 | StringBuffer pinyinName = new StringBuffer(); | ||
| 102 | char[] nameChar = chines.toCharArray(); | ||
| 103 | HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat(); | ||
| 104 | defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); | ||
| 105 | defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | ||
| 106 | for (int i = 0; i < nameChar.length; i++) { | ||
| 107 | if (nameChar[i] > 128) { | ||
| 108 | try { | ||
| 109 | // ๅๅพๅฝๅๆฑๅญ็ๆๆๅ จๆผ | ||
| 110 | String[] strs = PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat); | ||
| 111 | if (strs != null) { | ||
| 112 | for (int j = 0; j < strs.length; j++) { | ||
| 113 | pinyinName.append(strs[j]); | ||
| 114 | if (j != strs.length - 1) { | ||
| 115 | pinyinName.append(","); | ||
| 116 | } | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } catch (BadHanyuPinyinOutputFormatCombination e) { | ||
| 120 | e.printStackTrace(); | ||
| 121 | } | ||
| 122 | } else { | ||
| 123 | pinyinName.append(nameChar[i]); | ||
| 124 | } | ||
| 125 | pinyinName.append(" "); | ||
| 126 | } | ||
| 127 | return pinyinName.toString(); | ||
| 128 | } | ||
| 129 | |||
| 130 | public static ExecutorService executorService = Executors.newFixedThreadPool(5); | ||
| 131 | |||
| 132 | |||
| 133 | |||
| 134 | private static void startAnimation() { | ||
| 135 | if (mAnimationDrawable != null) { | ||
| 136 | mAnimationDrawable.start(); | ||
| 137 | Timer mytimer = new Timer(); | ||
| 138 | TimerTask mytt = new TimerTask() { | ||
| 139 | |||
| 140 | @Override | ||
| 141 | public void run() { | ||
| 142 | |||
| 143 | stopAnimation(); | ||
| 144 | } | ||
| 145 | }; | ||
| 146 | mytimer.schedule(mytt, 1000); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | |||
| 150 | public static void stopAnimation() { | ||
| 151 | if (mAnimationDrawable != null) { | ||
| 152 | mAnimationDrawable.stop(); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | } | ||
| 157 |
MiaohongEntry/app/src/main/java/com/hjx/miaohongentry/util/StatisUtils.java
| File was created | 1 | package com.hjx.miaohongentry.util; | |
| 2 | |||
| 3 | import android.content.Context; | ||
| 4 | |||
| 5 | import java.text.SimpleDateFormat; | ||
| 6 | import java.util.Date; | ||
| 7 | |||
| 8 | /** | ||
| 9 | * Created by l on 2018/2/6. | ||
| 10 | */ | ||
| 11 | |||
| 12 | public class StatisUtils { | ||
| 13 | |||
| 14 | public static void addTotalNum(Context context){ | ||
| 15 | int num = SpUtils.getInt(context,Constants.SP_STATIS_WRITE_TOTAL,0); | ||
| 16 | num ++; | ||
| 17 | SpUtils.putInt(context,Constants.SP_STATIS_WRITE_TOTAL,num); | ||
| 18 | } | ||
| 19 | |||
| 20 | public static int getTotalNum(Context context){ | ||
| 21 | int num = SpUtils.getInt(context,Constants.SP_STATIS_WRITE_TOTAL,0); | ||
| 22 | return num; | ||
| 23 | } | ||
| 24 | |||
| 25 | public static void setToday(Context context){ | ||
| 26 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 27 | Date now = new Date(); | ||
| 28 | String now_date = format.format(now); | ||
| 29 | SpUtils.putString(context,Constants.SP_STATIS_DATE_TODAY,now_date); | ||
| 30 | } | ||
| 31 | |||
| 32 | public static boolean isToday(Context context){ | ||
| 33 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); | ||
| 34 | Date now = new Date(); | ||
| 35 | String now_date = format.format(now); | ||
| 36 | String sp_today = SpUtils.getString(context,Constants.SP_STATIS_DATE_TODAY,""); | ||
| 37 | if(now_date.equals(sp_today)){ | ||
| 38 | return true; | ||
| 39 | }else{ | ||
| 40 | return false; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | public static int getTodayNum(Context context){ | ||
| 45 | int num = SpUtils.getInt(context,Constants.SP_STATIS_WRITE_NUM_TODAY,0); | ||
| 46 | return num; | ||
| 47 | } | ||
| 48 | |||
| 49 | public static long getTodayTime(Context context){ | ||
| 50 | long time = SpUtils.getLong(context,Constants.SP_STATIS_WRITE_TIME_TODAY,0); | ||
| 51 | return time; | ||
| 52 | } | ||
| 53 | |||
| 54 | public static void setTodayTime(Context context, long time){ | ||
| 55 | SpUtils.putLong(context,Constants.SP_STATIS_WRITE_TIME_TODAY,time); | ||
| 56 | } | ||
| 57 | |||
| 58 | public static void setTodayNum(Context context, int num){ | ||
| 59 | SpUtils.putInt(context,Constants.SP_STATIS_WRITE_NUM_TODAY,num); | ||
| 60 | } | ||
| 61 | |||
| 62 | public static void setEnterMiaohongTime(Context context,long mills){ | ||
| 63 | SpUtils.putLong(context,Constants.SP_STATIS_ENTER_APP_TIMR,mills); | ||
| 64 | } | ||
| 65 | |||
| 66 | public static long getEnterMiaohongTime(Context context){ | ||
| 67 | long mills = SpUtils.getLong(context,Constants.SP_STATIS_ENTER_APP_TIMR,0); | ||
| 68 | return mills; | ||
| 69 | } | ||
| 70 | } | ||
| 71 |
MiaohongEntry/app/src/main/libs/pinyin4j-2.5.0.jar
No preview for this file type
MiaohongEntry/app/src/main/res/drawable/dash_line.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | android:shape="line" > | ||
| 4 | |||
| 5 | <!--็บฟๅฎฝไธบdashWith๏ผ็บฟไน้ด็ฉบ้dashGap๏ผdashGap=0dpๆถ๏ผๆฏๅฎ็บฟ --> | ||
| 6 | <stroke | ||
| 7 | android:dashGap="1dip" | ||
| 8 | android:dashWidth="3dip" | ||
| 9 | android:width="1dip" | ||
| 10 | android:color="@color/colorLineYellow" /> | ||
| 11 | |||
| 12 | <!-- ่็บฟ้ซๅบฆ --> | ||
| 13 | <size android:height="1dip" /> | ||
| 14 | |||
| 15 | </shape> |
MiaohongEntry/app/src/main/res/drawable/radio_table_type_left.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <item | ||
| 4 | android:state_checked="false" | ||
| 5 | android:drawable="@mipmap/btn_left" /> | ||
| 6 | <item | ||
| 7 | android:state_checked="true" | ||
| 8 | android:drawable="@mipmap/btn_left_sel" /> | ||
| 9 | </selector> |
MiaohongEntry/app/src/main/res/drawable/radio_table_type_right.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <item | ||
| 4 | android:state_checked="false" | ||
| 5 | android:drawable="@mipmap/btn_right" /> | ||
| 6 | <item | ||
| 7 | android:state_checked="true" | ||
| 8 | android:drawable="@mipmap/btn_right_sel" /> | ||
| 9 | </selector> |
MiaohongEntry/app/src/main/res/drawable/shape_corner.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <shape xmlns:android="http://schemas.android.com/apk/res/android"> | ||
| 3 | <solid android:color="#ffffc73e" /> | ||
| 4 | <corners android:topLeftRadius="20dp" | ||
| 5 | android:topRightRadius="20dp" | ||
| 6 | android:bottomRightRadius="20dp" | ||
| 7 | android:bottomLeftRadius="20dp"/> | ||
| 8 | <stroke android:width="1dp" android:color="#ffeab029" /> | ||
| 9 | </shape> |
MiaohongEntry/app/src/main/res/layout/activity_choose_book.xml
| File was created | 1 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | xmlns:tools="http://schemas.android.com/tools" | ||
| 3 | android:layout_width="match_parent" | ||
| 4 | android:layout_height="match_parent" | ||
| 5 | tools:context="com.hjx.miaohongentry.activity.ChooseBookActivity"> | ||
| 6 | |||
| 7 | <RelativeLayout | ||
| 8 | android:layout_width="400dp" | ||
| 9 | android:layout_height="600dp" | ||
| 10 | android:layout_centerVertical="true" | ||
| 11 | android:layout_centerHorizontal="true" | ||
| 12 | android:background="@mipmap/choose_book_bg"> | ||
| 13 | |||
| 14 | <LinearLayout | ||
| 15 | android:id="@+id/ll_choose_book" | ||
| 16 | android:layout_width="wrap_content" | ||
| 17 | android:layout_height="wrap_content" | ||
| 18 | android:layout_marginTop="70dp" | ||
| 19 | android:orientation="vertical"> | ||
| 20 | <ListView | ||
| 21 | android:id="@+id/lv_book_list" | ||
| 22 | android:layout_width="wrap_content" | ||
| 23 | android:layout_height="450dp"> | ||
| 24 | |||
| 25 | </ListView> | ||
| 26 | |||
| 27 | <Button | ||
| 28 | android:id="@+id/btn_ok" | ||
| 29 | android:layout_width="wrap_content" | ||
| 30 | android:layout_height="wrap_content" | ||
| 31 | android:layout_marginTop="20dp" | ||
| 32 | android:background="@mipmap/btn_ok" | ||
| 33 | android:layout_centerHorizontal="true" | ||
| 34 | android:layout_gravity="center" | ||
| 35 | android:text="็กฎๅฎ" | ||
| 36 | android:gravity="center" | ||
| 37 | android:textColor="@color/colorWhite" | ||
| 38 | android:textSize="28sp"/> | ||
| 39 | |||
| 40 | </LinearLayout> | ||
| 41 | |||
| 42 | |||
| 43 | |||
| 44 | </RelativeLayout> | ||
| 45 | |||
| 46 | </RelativeLayout> | ||
| 47 |
MiaohongEntry/app/src/main/res/layout/activity_main.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | android:layout_width="match_parent" | ||
| 5 | android:layout_height="match_parent" | ||
| 6 | android:background="@mipmap/bg" | ||
| 7 | tools:context="com.hjx.miaohongentry.activity.MainActivity"> | ||
| 8 | |||
| 9 | |||
| 10 | <LinearLayout | ||
| 11 | android:layout_width="wrap_content" | ||
| 12 | android:layout_height="wrap_content" | ||
| 13 | android:orientation="horizontal"> | ||
| 14 | |||
| 15 | <RelativeLayout | ||
| 16 | android:layout_width="wrap_content" | ||
| 17 | android:layout_height="wrap_content"> | ||
| 18 | |||
| 19 | <ImageView | ||
| 20 | android:id="@+id/iv_head" | ||
| 21 | android:layout_width="wrap_content" | ||
| 22 | android:layout_height="wrap_content" | ||
| 23 | android:layout_marginTop="30dp" | ||
| 24 | android:layout_marginLeft="30dp" | ||
| 25 | android:layout_marginRight="20dp" | ||
| 26 | android:src="@mipmap/head_icon"/> | ||
| 27 | |||
| 28 | <ImageView | ||
| 29 | android:layout_width="wrap_content" | ||
| 30 | android:layout_height="wrap_content" | ||
| 31 | android:layout_marginTop="-14dp" | ||
| 32 | android:layout_marginLeft="30dp" | ||
| 33 | android:layout_below="@+id/iv_head" | ||
| 34 | android:src ="@mipmap/cloud"/> | ||
| 35 | </RelativeLayout> | ||
| 36 | |||
| 37 | |||
| 38 | <LinearLayout | ||
| 39 | android:layout_width="wrap_content" | ||
| 40 | android:layout_height="wrap_content" | ||
| 41 | android:layout_gravity="center" | ||
| 42 | android:layout_marginTop="10dp" | ||
| 43 | android:orientation="vertical"> | ||
| 44 | <LinearLayout | ||
| 45 | android:layout_width="wrap_content" | ||
| 46 | android:layout_height="wrap_content" | ||
| 47 | android:orientation="horizontal" | ||
| 48 | android:visibility="gone"> | ||
| 49 | <TextView | ||
| 50 | android:layout_width="wrap_content" | ||
| 51 | android:layout_height="wrap_content" | ||
| 52 | android:textColor="@color/colorFontBlack" | ||
| 53 | android:textSize="15sp" | ||
| 54 | android:text="ๅๅพทๅ" /> | ||
| 55 | |||
| 56 | <TextView | ||
| 57 | android:layout_width="wrap_content" | ||
| 58 | android:layout_height="wrap_content" | ||
| 59 | android:layout_marginLeft="10dp" | ||
| 60 | android:textColor="@color/colorFontBlack" | ||
| 61 | android:textSize="15sp" | ||
| 62 | android:text="2ๅนด็บง" /> | ||
| 63 | </LinearLayout> | ||
| 64 | |||
| 65 | <LinearLayout | ||
| 66 | android:layout_width="wrap_content" | ||
| 67 | android:layout_height="wrap_content" | ||
| 68 | android:layout_marginTop="10dp" | ||
| 69 | android:orientation="horizontal"> | ||
| 70 | <TextView | ||
| 71 | android:layout_width="wrap_content" | ||
| 72 | android:layout_height="wrap_content" | ||
| 73 | android:textColor="@color/colorFontBlack" | ||
| 74 | android:textSize="15sp" | ||
| 75 | android:text="็ดฏ่ฎก็ปๅญ" /> | ||
| 76 | |||
| 77 | <TextView | ||
| 78 | android:id="@+id/total_num" | ||
| 79 | android:layout_width="wrap_content" | ||
| 80 | android:layout_height="wrap_content" | ||
| 81 | android:textColor="@color/colorFontBlue" | ||
| 82 | android:textSize="15sp" | ||
| 83 | android:text="2" /> | ||
| 84 | |||
| 85 | <TextView | ||
| 86 | android:layout_width="wrap_content" | ||
| 87 | android:layout_height="wrap_content" | ||
| 88 | android:layout_marginLeft="10dp" | ||
| 89 | android:textColor="@color/colorFontBlack" | ||
| 90 | android:textSize="15sp" | ||
| 91 | android:text="ไปๆฅ็ปๅญ" /> | ||
| 92 | |||
| 93 | <TextView | ||
| 94 | android:id="@+id/today_num" | ||
| 95 | android:layout_width="wrap_content" | ||
| 96 | android:layout_height="wrap_content" | ||
| 97 | android:textColor="@color/colorFontBlue" | ||
| 98 | android:textSize="15sp" | ||
| 99 | android:text="2" /> | ||
| 100 | </LinearLayout> | ||
| 101 | |||
| 102 | </LinearLayout> | ||
| 103 | </LinearLayout> | ||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | |||
| 108 | <RelativeLayout | ||
| 109 | android:id="@+id/rl_pie_chat" | ||
| 110 | android:layout_width="wrap_content" | ||
| 111 | android:layout_height="wrap_content" | ||
| 112 | android:layout_centerVertical="true" | ||
| 113 | android:layout_centerHorizontal="true"> | ||
| 114 | |||
| 115 | <ImageView | ||
| 116 | android:id="@+id/iv_pie_chat" | ||
| 117 | android:layout_width="wrap_content" | ||
| 118 | android:layout_height="wrap_content" | ||
| 119 | android:src="@mipmap/pie_chat"/> | ||
| 120 | |||
| 121 | <LinearLayout | ||
| 122 | android:layout_width="wrap_content" | ||
| 123 | android:layout_height="wrap_content" | ||
| 124 | android:layout_centerVertical="true" | ||
| 125 | android:layout_centerHorizontal="true" | ||
| 126 | android:orientation="vertical"> | ||
| 127 | <TextView | ||
| 128 | android:layout_width="wrap_content" | ||
| 129 | android:layout_height="wrap_content" | ||
| 130 | android:layout_gravity="center" | ||
| 131 | android:textColor="@color/colorFontBlack" | ||
| 132 | android:textSize="25sp" | ||
| 133 | android:text="ๅทฒ็ป"/> | ||
| 134 | <TextView | ||
| 135 | android:id="@+id/write_time" | ||
| 136 | android:layout_width="wrap_content" | ||
| 137 | android:layout_height="wrap_content" | ||
| 138 | android:layout_marginTop="6dp" | ||
| 139 | android:textColor="@color/colorFontRed" | ||
| 140 | android:textSize="29sp" | ||
| 141 | android:text="3ๅ31็ง"/> | ||
| 142 | </LinearLayout> | ||
| 143 | |||
| 144 | </RelativeLayout> | ||
| 145 | |||
| 146 | |||
| 147 | <LinearLayout | ||
| 148 | android:layout_width="wrap_content" | ||
| 149 | android:layout_height="wrap_content" | ||
| 150 | android:layout_centerHorizontal="true" | ||
| 151 | android:layout_above="@+id/rl_pie_chat" | ||
| 152 | android:layout_marginBottom="16dp" | ||
| 153 | android:orientation="vertical"> | ||
| 154 | <TextView | ||
| 155 | android:id="@+id/tv_publish_name" | ||
| 156 | android:layout_width="wrap_content" | ||
| 157 | android:layout_height="wrap_content" | ||
| 158 | android:textColor="@color/colorFontBlack" | ||
| 159 | android:textSize="20sp" | ||
| 160 | android:layout_gravity="center" | ||
| 161 | android:text="ไธๅนด็บงไธๅ ไบบๆฐๆ่ฒๅบ็็คพ" /> | ||
| 162 | |||
| 163 | <TextView | ||
| 164 | android:layout_width="wrap_content" | ||
| 165 | android:layout_height="wrap_content" | ||
| 166 | android:layout_marginTop="10dp" | ||
| 167 | android:textColor="@color/colorFontBlack" | ||
| 168 | android:textSize="20sp" | ||
| 169 | android:layout_gravity="center" | ||
| 170 | android:text="ๆฏๆฅ็ปๅญ10ๅ้" /> | ||
| 171 | </LinearLayout> | ||
| 172 | |||
| 173 | <Button | ||
| 174 | android:id="@+id/btn_start" | ||
| 175 | android:layout_width="wrap_content" | ||
| 176 | android:layout_height="wrap_content" | ||
| 177 | android:layout_below="@+id/rl_pie_chat" | ||
| 178 | android:layout_centerHorizontal="true" | ||
| 179 | android:layout_marginTop="25dp" | ||
| 180 | android:text = "ๅผๅง็ปๅญ" | ||
| 181 | android:textSize="25sp" | ||
| 182 | android:textColor="@color/colorWhite" | ||
| 183 | android:background="@mipmap/btn_start"/> | ||
| 184 | |||
| 185 | <ImageButton | ||
| 186 | android:id="@+id/btn_choose" | ||
| 187 | android:layout_width="wrap_content" | ||
| 188 | android:layout_height="wrap_content" | ||
| 189 | android:src="@mipmap/btn_change_books" | ||
| 190 | android:layout_alignParentRight="true" | ||
| 191 | android:layout_marginTop="10dp" | ||
| 192 | android:layout_marginRight="30dp" | ||
| 193 | android:background="@null"/> | ||
| 194 | |||
| 195 | <ImageButton | ||
| 196 | android:id="@+id/btn_rank" | ||
| 197 | android:layout_width="wrap_content" | ||
| 198 | android:layout_height="wrap_content" | ||
| 199 | android:src="@mipmap/btn_rank" | ||
| 200 | android:layout_toLeftOf="@id/btn_choose" | ||
| 201 | android:layout_marginTop="10dp" | ||
| 202 | android:layout_marginRight="50dp" | ||
| 203 | android:background="@null" | ||
| 204 | android:visibility="gone"/> | ||
| 205 | |||
| 206 | </RelativeLayout> | ||
| 207 |
MiaohongEntry/app/src/main/res/layout/activity_word.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | android:layout_width="match_parent" | ||
| 6 | android:layout_height="match_parent" | ||
| 7 | android:background="@mipmap/bg" | ||
| 8 | tools:context="com.hjx.miaohongentry.activity.WordActivity"> | ||
| 9 | |||
| 10 | <ImageButton | ||
| 11 | android:id="@+id/btn_back" | ||
| 12 | android:layout_width="wrap_content" | ||
| 13 | android:layout_height="wrap_content" | ||
| 14 | android:layout_margin="30dp" | ||
| 15 | android:background="@null" | ||
| 16 | android:src="@mipmap/btn_back"/> | ||
| 17 | |||
| 18 | <LinearLayout | ||
| 19 | android:layout_width="match_parent" | ||
| 20 | android:layout_height="wrap_content"> | ||
| 21 | <LinearLayout | ||
| 22 | android:layout_width="0dp" | ||
| 23 | android:layout_height="wrap_content" | ||
| 24 | android:gravity="center" | ||
| 25 | android:layout_weight="1"> | ||
| 26 | <ImageView | ||
| 27 | android:layout_width="wrap_content" | ||
| 28 | android:layout_height="wrap_content" | ||
| 29 | android:layout_marginTop="20dp" | ||
| 30 | android:layout_marginLeft="20dp" | ||
| 31 | android:src="@mipmap/balloon"/> | ||
| 32 | </LinearLayout> | ||
| 33 | <LinearLayout | ||
| 34 | android:layout_width="0dp" | ||
| 35 | android:layout_height="wrap_content" | ||
| 36 | android:layout_weight="1"> | ||
| 37 | </LinearLayout> | ||
| 38 | </LinearLayout> | ||
| 39 | |||
| 40 | |||
| 41 | <RelativeLayout | ||
| 42 | android:layout_width="wrap_content" | ||
| 43 | android:layout_height="wrap_content" | ||
| 44 | android:layout_marginTop="70dp" | ||
| 45 | android:orientation="horizontal"> | ||
| 46 | |||
| 47 | <LinearLayout | ||
| 48 | android:id="@+id/ll_word" | ||
| 49 | android:layout_width="wrap_content" | ||
| 50 | android:layout_height="wrap_content" | ||
| 51 | android:layout_centerInParent="true" | ||
| 52 | android:layout_alignParentRight="true" | ||
| 53 | android:layout_marginRight="10dp" | ||
| 54 | android:orientation="vertical" | ||
| 55 | android:background="@mipmap/word_bg"> | ||
| 56 | |||
| 57 | <Button | ||
| 58 | android:id="@+id/btn_one_type" | ||
| 59 | android:layout_width="wrap_content" | ||
| 60 | android:layout_height="wrap_content" | ||
| 61 | android:layout_gravity="center" | ||
| 62 | android:layout_marginTop="50dp" | ||
| 63 | android:background="@mipmap/btn_type" | ||
| 64 | android:textColor="@color/colorWhite" | ||
| 65 | android:textSize="17sp" | ||
| 66 | android:text="่ฏๅญ่กจ" | ||
| 67 | android:visibility="invisible"/> | ||
| 68 | |||
| 69 | <RelativeLayout | ||
| 70 | android:id="@+id/rl_two_type" | ||
| 71 | android:layout_width="wrap_content" | ||
| 72 | android:layout_height="wrap_content" | ||
| 73 | android:layout_gravity="center" | ||
| 74 | android:layout_marginTop="50dp" | ||
| 75 | android:visibility="invisible"> | ||
| 76 | |||
| 77 | <ImageView | ||
| 78 | android:layout_width="wrap_content" | ||
| 79 | android:layout_height="wrap_content" | ||
| 80 | android:layout_centerHorizontal="true" | ||
| 81 | android:layout_centerVertical="true" | ||
| 82 | android:src="@mipmap/word_switch_bg"/> | ||
| 83 | |||
| 84 | <RadioGroup | ||
| 85 | android:id="@+id/rg_type" | ||
| 86 | android:layout_centerHorizontal="true" | ||
| 87 | android:layout_centerVertical="true" | ||
| 88 | android:orientation="horizontal" | ||
| 89 | android:layout_width="wrap_content" | ||
| 90 | android:layout_height="wrap_content"> | ||
| 91 | |||
| 92 | <RadioButton | ||
| 93 | android:id="@+id/rb_left" | ||
| 94 | android:layout_marginRight="1dp" | ||
| 95 | android:layout_width="wrap_content" | ||
| 96 | android:layout_height="wrap_content" | ||
| 97 | android:button="@null" | ||
| 98 | android:background="@drawable/radio_table_type_left" | ||
| 99 | android:textColor="@color/colorWhite" | ||
| 100 | android:checked="true" | ||
| 101 | android:textSize="17sp" | ||
| 102 | android:gravity="center" | ||
| 103 | android:text="่ฏๅญ่กจ"/> | ||
| 104 | <RadioButton | ||
| 105 | android:id="@+id/rb_right" | ||
| 106 | android:layout_marginLeft="1dp" | ||
| 107 | android:layout_width="wrap_content" | ||
| 108 | android:layout_height="wrap_content" | ||
| 109 | android:button="@null" | ||
| 110 | android:background="@drawable/radio_table_type_right" | ||
| 111 | android:textColor="@color/colorWhite" | ||
| 112 | android:textSize="17sp" | ||
| 113 | android:gravity="center" | ||
| 114 | android:text="ๅๅญ่กจ"/> | ||
| 115 | </RadioGroup> | ||
| 116 | </RelativeLayout> | ||
| 117 | |||
| 118 | <LinearLayout | ||
| 119 | android:layout_width="match_parent" | ||
| 120 | android:layout_height="wrap_content" | ||
| 121 | android:layout_marginTop="20dp" | ||
| 122 | android:layout_marginBottom="50dp" | ||
| 123 | android:paddingLeft="80dp" | ||
| 124 | android:paddingRight="100dp"> | ||
| 125 | <ScrollView | ||
| 126 | android:layout_width="match_parent" | ||
| 127 | android:layout_height="wrap_content"> | ||
| 128 | |||
| 129 | <LinearLayout | ||
| 130 | android:id="@+id/ll_word_group" | ||
| 131 | android:layout_width="match_parent" | ||
| 132 | android:layout_height="wrap_content" | ||
| 133 | android:orientation="vertical"> | ||
| 134 | |||
| 135 | </LinearLayout> | ||
| 136 | |||
| 137 | </ScrollView> | ||
| 138 | </LinearLayout> | ||
| 139 | |||
| 140 | |||
| 141 | </LinearLayout> | ||
| 142 | <ImageView | ||
| 143 | android:id="@+id/iv_plane" | ||
| 144 | android:layout_width="wrap_content" | ||
| 145 | android:layout_height="wrap_content" | ||
| 146 | android:layout_marginLeft="0dp" | ||
| 147 | android:layout_centerInParent="true" | ||
| 148 | android:layout_alignParentLeft="true" | ||
| 149 | android:src="@mipmap/plane"/> | ||
| 150 | </RelativeLayout> | ||
| 151 | |||
| 152 | |||
| 153 | <RelativeLayout | ||
| 154 | android:layout_width="260dp" | ||
| 155 | android:layout_height="wrap_content" | ||
| 156 | android:layout_marginTop="30dp" | ||
| 157 | android:paddingTop="5dp" | ||
| 158 | android:paddingBottom="5dp" | ||
| 159 | android:layout_alignParentRight="true" | ||
| 160 | android:layout_marginRight="40dp" | ||
| 161 | android:background="@drawable/shape_corner"> | ||
| 162 | |||
| 163 | <EditText | ||
| 164 | android:id="@+id/et_search" | ||
| 165 | android:layout_width="100dp" | ||
| 166 | android:layout_height="wrap_content" | ||
| 167 | android:layout_marginLeft="30dp" | ||
| 168 | android:layout_centerVertical="true" | ||
| 169 | android:maxLength="1" | ||
| 170 | android:singleLine="true" | ||
| 171 | android:hint="่ฏทๆ็ดขๅ ณ้ฎๅญ" | ||
| 172 | android:textColorHint="@color/colorWhite" | ||
| 173 | android:textSize="15sp" | ||
| 174 | android:textColor="@color/colorWhite" | ||
| 175 | android:background="@null"/> | ||
| 176 | |||
| 177 | <ImageButton | ||
| 178 | android:id="@+id/btn_search" | ||
| 179 | android:layout_width="wrap_content" | ||
| 180 | android:layout_height="wrap_content" | ||
| 181 | android:layout_marginRight="10dp" | ||
| 182 | android:layout_alignParentRight="true" | ||
| 183 | android:background="@mipmap/btn_search"/> | ||
| 184 | </RelativeLayout> | ||
| 185 | |||
| 186 | |||
| 187 | </RelativeLayout> | ||
| 188 |
MiaohongEntry/app/src/main/res/layout/choose_book_list_item.xml
| File was created | 1 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 2 | android:layout_width="match_parent" | ||
| 3 | android:layout_height="wrap_content" | ||
| 4 | android:orientation="horizontal"> | ||
| 5 | |||
| 6 | <LinearLayout | ||
| 7 | android:layout_width="0dp" | ||
| 8 | android:layout_weight="1" | ||
| 9 | android:layout_height="wrap_content" | ||
| 10 | android:paddingTop="2dp" | ||
| 11 | android:paddingBottom="2dp" | ||
| 12 | android:layout_marginLeft="20dp" | ||
| 13 | android:layout_marginRight="50dp" | ||
| 14 | android:gravity="center"> | ||
| 15 | <TextView | ||
| 16 | android:id="@+id/choose_book_list_item_grade" | ||
| 17 | android:layout_width="wrap_content" | ||
| 18 | android:layout_height="wrap_content" | ||
| 19 | android:singleLine="true" | ||
| 20 | android:layout_gravity="center_vertical" | ||
| 21 | android:textColor="@color/colorFontBlack" | ||
| 22 | android:textSize="20sp" | ||
| 23 | android:text="123"/> | ||
| 24 | |||
| 25 | <TextView | ||
| 26 | android:id="@+id/choose_book_list_item_reactos" | ||
| 27 | android:layout_width="wrap_content" | ||
| 28 | android:layout_height="wrap_content" | ||
| 29 | android:singleLine="true" | ||
| 30 | android:layout_gravity="center_vertical" | ||
| 31 | android:textColor="@color/colorFontBlack" | ||
| 32 | android:textSize="20sp" | ||
| 33 | android:text="123"/> | ||
| 34 | </LinearLayout> | ||
| 35 | |||
| 36 | <LinearLayout | ||
| 37 | android:layout_width="0dp" | ||
| 38 | android:layout_weight="1" | ||
| 39 | android:paddingTop="2dp" | ||
| 40 | android:paddingBottom="2dp" | ||
| 41 | android:layout_height="wrap_content" | ||
| 42 | android:gravity="center"> | ||
| 43 | <TextView | ||
| 44 | android:id="@+id/choose_book_list_item_press" | ||
| 45 | android:layout_width="wrap_content" | ||
| 46 | android:layout_height="wrap_content" | ||
| 47 | android:singleLine="true" | ||
| 48 | android:layout_gravity="center" | ||
| 49 | android:textColor="@color/colorFontBlack" | ||
| 50 | android:textSize="20sp" | ||
| 51 | android:text="123"/> | ||
| 52 | </LinearLayout> | ||
| 53 | |||
| 54 | </LinearLayout> |
MiaohongEntry/app/src/main/res/layout/row_word_list_item.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 4 | android:orientation="horizontal" | ||
| 5 | android:layout_width="match_parent" | ||
| 6 | android:layout_height="wrap_content"> | ||
| 7 | |||
| 8 | <ImageView | ||
| 9 | android:layout_width="wrap_content" | ||
| 10 | android:layout_height="wrap_content" | ||
| 11 | android:layout_marginRight="9dp" | ||
| 12 | android:layout_marginTop="15dp" | ||
| 13 | android:layout_marginBottom="15dp" | ||
| 14 | android:src="@mipmap/row_tag" | ||
| 15 | android:visibility="invisible"/> | ||
| 16 | |||
| 17 | <TextView | ||
| 18 | android:id="@+id/row_idx" | ||
| 19 | android:layout_width="wrap_content" | ||
| 20 | android:layout_height="wrap_content" | ||
| 21 | android:layout_marginRight="12dp" | ||
| 22 | android:layout_marginTop="8dp" | ||
| 23 | android:layout_marginBottom="10dp" | ||
| 24 | android:text="1." | ||
| 25 | android:textSize="22sp" | ||
| 26 | android:textColor="@color/colorFontBlack"/> | ||
| 27 | |||
| 28 | <com.hjx.miaohongentry.ui.FixGridLayout | ||
| 29 | android:id="@+id/ll_row_word" | ||
| 30 | android:layout_width="match_parent" | ||
| 31 | android:layout_height="wrap_content" | ||
| 32 | app:grivate="left" | ||
| 33 | app:horizontal_Space="10dp" | ||
| 34 | app:isFull="false" | ||
| 35 | app:vertical_Space="6dp"> | ||
| 36 | |||
| 37 | </com.hjx.miaohongentry.ui.FixGridLayout> | ||
| 38 | |||
| 39 | </LinearLayout> |
MiaohongEntry/app/src/main/res/layout/view_title_word.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | android:orientation="vertical" android:layout_width="match_parent" | ||
| 4 | android:layout_height="wrap_content"> | ||
| 5 | |||
| 6 | <TextView | ||
| 7 | android:id="@+id/tv_title" | ||
| 8 | android:layout_width="wrap_content" | ||
| 9 | android:layout_height="wrap_content" | ||
| 10 | android:text="่ฏๅญ" | ||
| 11 | android:textColor="@color/colorFontBlack" | ||
| 12 | android:textSize="21sp"/> | ||
| 13 | |||
| 14 | <LinearLayout | ||
| 15 | android:layout_width="match_parent" | ||
| 16 | android:layout_height="wrap_content"> | ||
| 17 | <ListView | ||
| 18 | android:id="@+id/row_list" | ||
| 19 | android:layout_width="match_parent" | ||
| 20 | android:layout_height="wrap_content" | ||
| 21 | android:divider="@drawable/dash_line" | ||
| 22 | android:layerType="software" | ||
| 23 | android:dividerHeight="2dip" > | ||
| 24 | |||
| 25 | </ListView> | ||
| 26 | |||
| 27 | </LinearLayout> | ||
| 28 | |||
| 29 | </LinearLayout> |
MiaohongEntry/app/src/main/res/layout/word_text_view.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | android:layout_width="wrap_content" | ||
| 4 | android:layout_height="wrap_content" | ||
| 5 | android:layout_marginRight="20dp" | ||
| 6 | android:textSize="22sp" | ||
| 7 | android:textColor="@color/colorFontYellow"> | ||
| 8 | </TextView> |
MiaohongEntry/app/src/main/res/mipmap-hdpi/balloon.png
22.1 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/bg.png
123 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_back.png
7.59 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_change_books.png
25.6 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_left.png
2.41 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_left_sel.png
2.72 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_ok.png
6.27 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_rank.png
27 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_right.png
2.39 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_right_sel.png
2.69 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_search.png
2.53 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_start.png
7.36 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/btn_type.png
4.51 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/choose_book_bg.png
8.07 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/cloud.png
2.37 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/head_icon.png
17.8 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/ic_launcher.png
7.11 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
4.11 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/pie_chat.png
42.5 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/plane.png
104 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/row_tag.png
2.45 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/word_bg.png
388 KB
MiaohongEntry/app/src/main/res/mipmap-hdpi/word_switch_bg.png
3 KB
MiaohongEntry/app/src/main/res/mipmap-mdpi/ic_launcher.png
2.15 KB
MiaohongEntry/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
2.5 KB
MiaohongEntry/app/src/main/res/mipmap-xhdpi/ic_launcher.png
7.11 KB
MiaohongEntry/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
5.97 KB
MiaohongEntry/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
7.11 KB
MiaohongEntry/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
9.82 KB
MiaohongEntry/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
7.11 KB
MiaohongEntry/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
14.4 KB
MiaohongEntry/app/src/main/res/values/attrs.xml
| File was created | 1 | <resources> | |
| 2 | |||
| 3 | <!-- Declare custom theme attributes that allow changing which styles are | ||
| 4 | used for button bars depending on the API level. | ||
| 5 | ?android:attr/buttonBarStyle is new as of API 11 so this is | ||
| 6 | necessary to support previous API levels. --> | ||
| 7 | <declare-styleable name="ButtonBarContainerTheme"> | ||
| 8 | <attr name="metaButtonBarStyle" format="reference" /> | ||
| 9 | <attr name="metaButtonBarButtonStyle" format="reference" /> | ||
| 10 | </declare-styleable> | ||
| 11 | |||
| 12 | <declare-styleable name="WarpLinearLayout"> | ||
| 13 | <attr name="grivate" format="enum"><!--ๅฏน้ฝๆนๅผ !--> | ||
| 14 | <enum name="right" value="0"></enum> | ||
| 15 | <enum name="left" value="1"></enum> | ||
| 16 | <enum name="center" value="2"></enum> | ||
| 17 | </attr> | ||
| 18 | <attr name="horizontal_Space" format="dimension"></attr> | ||
| 19 | <attr name="vertical_Space" format="dimension"></attr> | ||
| 20 | <attr name="isFull" format="boolean"></attr> | ||
| 21 | </declare-styleable> | ||
| 22 | </resources> | ||
| 23 |
MiaohongEntry/app/src/main/res/values/colors.xml
| File was created | 1 | <?xml version="1.0" encoding="utf-8"?> | |
| 2 | <resources> | ||
| 3 | <color name="colorPrimary">#3F51B5</color> | ||
| 4 | <color name="colorPrimaryDark">#303F9F</color> | ||
| 5 | <color name="colorAccent">#FF4081</color> | ||
| 6 | <color name="colorWhite">#FFFFFF</color> | ||
| 7 | <color name="colorFontBlack">#FF333333</color> | ||
| 8 | <color name="colorFontRed">#FFe96565</color> | ||
| 9 | <color name="colorFontBlue">#FF1296fc</color> | ||
| 10 | <color name="colorFontGreen">#FF1c9925</color> | ||
| 11 | <color name="colorFontYellow">#FFbd6701</color> | ||
| 12 | <color name="colorLineYellow">#FFc4aa6c</color> | ||
| 13 | |||
| 14 | <color name="black_overlay">#66000000</color> | ||
| 15 | <color name="translucent_background">#90000000</color> | ||
| 16 | </resources> | ||
| 17 |
MiaohongEntry/app/src/main/res/values/strings.xml
| File was created | 1 | <resources> | |
| 2 | <string name="app_name">็ปๆฑๅญ</string> | ||
| 3 | |||
| 4 | <string name="title_activity_choose_book">ChooseBookActivity</string> | ||
| 5 | <string name="dummy_button">Dummy Button</string> | ||
| 6 | <string name="dummy_content">DUMMY\nCONTENT</string> | ||
| 7 | </resources> | ||
| 8 |
MiaohongEntry/app/src/main/res/values/styles.xml
| File was created | 1 | <resources> | |
| 2 | |||
| 3 | <!-- Base application theme. --> | ||
| 4 | <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | ||
| 5 | <!-- Customize your theme here. --> | ||
| 6 | <item name="colorPrimary">@color/colorPrimary</item> | ||
| 7 | <item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
| 8 | <item name="colorAccent">@color/colorAccent</item> | ||
| 9 | </style> | ||
| 10 | |||
| 11 | <style name="FullscreenTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen"> | ||
| 12 | <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item> | ||
| 13 | <item name="android:windowActionBarOverlay">true</item> | ||
| 14 | <item name="android:windowBackground">@null</item> | ||
| 15 | <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item> | ||
| 16 | <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item> | ||
| 17 | </style> | ||
| 18 | |||
| 19 | <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar"> | ||
| 20 | <item name="android:background">@color/black_overlay</item> | ||
| 21 | </style> | ||
| 22 | |||
| 23 | <style name="translucent"> | ||
| 24 | <item name="android:windowNoTitle">true</item> | ||
| 25 | <item name="android:windowBackground">@color/translucent_background</item> | ||
| 26 | <item name="android:windowIsTranslucent">true</item> | ||
| 27 | <item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item> | ||
| 28 | </style> | ||
| 29 | |||
| 30 | <style name="WarpLinearLayoutDefault"> | ||
| 31 | <item name="grivate">left</item> | ||
| 32 | <item name="horizontal_Space">20dp</item> | ||
| 33 | <item name="vertical_Space">20dp</item> | ||
| 34 | <item name="isFull">false</item> | ||
| 35 | </style> | ||
| 36 | </resources> | ||
| 37 |
MiaohongEntry/app/src/test/java/com/hjx/miaohongentry/ExampleUnitTest.java
| File was created | 1 | package com.hjx.miaohongentry; | |
| 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 <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
| 11 | */ | ||
| 12 | public class ExampleUnitTest { | ||
| 13 | @Test | ||
| 14 | public void addition_isCorrect() throws Exception { | ||
| 15 | assertEquals(4, 2 + 2); | ||
| 16 | } | ||
| 17 | } |
MiaohongEntry/build.gradle
| File was created | 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| 2 | |||
| 3 | buildscript { | ||
| 4 | repositories { | ||
| 5 | jcenter() | ||
| 6 | } | ||
| 7 | dependencies { | ||
| 8 | classpath 'com.android.tools.build:gradle:2.3.2' | ||
| 9 | |||
| 10 | // NOTE: Do not place your application dependencies here; they belong | ||
| 11 | // in the individual module build.gradle files | ||
| 12 | } | ||
| 13 | } | ||
| 14 | |||
| 15 | allprojects { | ||
| 16 | repositories { | ||
| 17 | jcenter() | ||
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | task clean(type: Delete) { | ||
| 22 | delete rootProject.buildDir | ||
| 23 | } | ||
| 24 |
MiaohongEntry/gradle.properties
| File was created | 1 | # Project-wide Gradle settings. | |
| 2 | |||
| 3 | # IDE (e.g. Android Studio) users: | ||
| 4 | # Gradle settings configured through the IDE *will override* | ||
| 5 | # any settings specified in this file. | ||
| 6 | |||
| 7 | # For more details on how to configure your build environment visit | ||
| 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html | ||
| 9 | |||
| 10 | # Specifies the JVM arguments used for the daemon process. | ||
| 11 | # The setting is particularly useful for tweaking memory settings. | ||
| 12 | org.gradle.jvmargs=-Xmx1536m | ||
| 13 | |||
| 14 | # When configured, Gradle will run in incubating parallel mode. | ||
| 15 | # This option should only be used with decoupled projects. More details, visit | ||
| 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
| 17 | # org.gradle.parallel=true | ||
| 18 |
MiaohongEntry/gradle/wrapper/gradle-wrapper.jar
No preview for this file type
MiaohongEntry/gradle/wrapper/gradle-wrapper.properties
| File was created | 1 | #Tue Jan 23 19:37:02 CST 2018 | |
| 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-3.3-all.zip | ||
| 7 |
MiaohongEntry/gradlew
| File was created | 1 | #!/usr/bin/env bash | |
| 2 | |||
| 3 | ############################################################################## | ||
| 4 | ## | ||
| 5 | ## Gradle start up script for UN*X | ||
| 6 | ## | ||
| 7 | ############################################################################## | ||
| 8 | |||
| 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
| 10 | DEFAULT_JVM_OPTS="" | ||
| 11 | |||
| 12 | APP_NAME="Gradle" | ||
| 13 | APP_BASE_NAME=`basename "$0"` | ||
| 14 | |||
| 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. | ||
| 16 | MAX_FD="maximum" | ||
| 17 | |||
| 18 | warn ( ) { | ||
| 19 | echo "$*" | ||
| 20 | } | ||
| 21 | |||
| 22 | die ( ) { | ||
| 23 | echo | ||
| 24 | echo "$*" | ||
| 25 | echo | ||
| 26 | exit 1 | ||
| 27 | } | ||
| 28 | |||
| 29 | # OS specific support (must be 'true' or 'false'). | ||
| 30 | cygwin=false | ||
| 31 | msys=false | ||
| 32 | darwin=false | ||
| 33 | case "`uname`" in | ||
| 34 | CYGWIN* ) | ||
| 35 | cygwin=true | ||
| 36 | ;; | ||
| 37 | Darwin* ) | ||
| 38 | darwin=true | ||
| 39 | ;; | ||
| 40 | MINGW* ) | ||
| 41 | msys=true | ||
| 42 | ;; | ||
| 43 | esac | ||
| 44 | |||
| 45 | # Attempt to set APP_HOME | ||
| 46 | # Resolve links: $0 may be a link | ||
| 47 | PRG="$0" | ||
| 48 | # Need this for relative symlinks. | ||
| 49 | while [ -h "$PRG" ] ; do | ||
| 50 | ls=`ls -ld "$PRG"` | ||
| 51 | link=`expr "$ls" : '.*-> \(.*\)$'` | ||
| 52 | if expr "$link" : '/.*' > /dev/null; then | ||
| 53 | PRG="$link" | ||
| 54 | else | ||
| 55 | PRG=`dirname "$PRG"`"/$link" | ||
| 56 | fi | ||
| 57 | done | ||
| 58 | SAVED="`pwd`" | ||
| 59 | cd "`dirname \"$PRG\"`/" >/dev/null | ||
| 60 | APP_HOME="`pwd -P`" | ||
| 61 | cd "$SAVED" >/dev/null | ||
| 62 | |||
| 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar | ||
| 64 | |||
| 65 | # Determine the Java command to use to start the JVM. | ||
| 66 | if [ -n "$JAVA_HOME" ] ; then | ||
| 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
| 68 | # IBM's JDK on AIX uses strange locations for the executables | ||
| 69 | JAVACMD="$JAVA_HOME/jre/sh/java" | ||
| 70 | else | ||
| 71 | JAVACMD="$JAVA_HOME/bin/java" | ||
| 72 | fi | ||
| 73 | if [ ! -x "$JAVACMD" ] ; then | ||
| 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | ||
| 75 | |||
| 76 | Please set the JAVA_HOME variable in your environment to match the | ||
| 77 | location of your Java installation." | ||
| 78 | fi | ||
| 79 | else | ||
| 80 | JAVACMD="java" | ||
| 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
| 82 | |||
| 83 | Please set the JAVA_HOME variable in your environment to match the | ||
| 84 | location of your Java installation." | ||
| 85 | fi | ||
| 86 | |||
| 87 | # Increase the maximum file descriptors if we can. | ||
| 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then | ||
| 89 | MAX_FD_LIMIT=`ulimit -H -n` | ||
| 90 | if [ $? -eq 0 ] ; then | ||
| 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | ||
| 92 | MAX_FD="$MAX_FD_LIMIT" | ||
| 93 | fi | ||
| 94 | ulimit -n $MAX_FD | ||
| 95 | if [ $? -ne 0 ] ; then | ||
| 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" | ||
| 97 | fi | ||
| 98 | else | ||
| 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" | ||
| 100 | fi | ||
| 101 | fi | ||
| 102 | |||
| 103 | # For Darwin, add options to specify how the application appears in the dock | ||
| 104 | if $darwin; then | ||
| 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" | ||
| 106 | fi | ||
| 107 | |||
| 108 | # For Cygwin, switch paths to Windows format before running java | ||
| 109 | if $cygwin ; then | ||
| 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` | ||
| 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | ||
| 112 | JAVACMD=`cygpath --unix "$JAVACMD"` | ||
| 113 | |||
| 114 | # We build the pattern for arguments to be converted via cygpath | ||
| 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | ||
| 116 | SEP="" | ||
| 117 | for dir in $ROOTDIRSRAW ; do | ||
| 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" | ||
| 119 | SEP="|" | ||
| 120 | done | ||
| 121 | OURCYGPATTERN="(^($ROOTDIRS))" | ||
| 122 | # Add a user-defined pattern to the cygpath arguments | ||
| 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then | ||
| 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | ||
| 125 | fi | ||
| 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh | ||
| 127 | i=0 | ||
| 128 | for arg in "$@" ; do | ||
| 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | ||
| 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | ||
| 131 | |||
| 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | ||
| 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | ||
| 134 | else | ||
| 135 | eval `echo args$i`="\"$arg\"" | ||
| 136 | fi | ||
| 137 | i=$((i+1)) | ||
| 138 | done | ||
| 139 | case $i in | ||
| 140 | (0) set -- ;; | ||
| 141 | (1) set -- "$args0" ;; | ||
| 142 | (2) set -- "$args0" "$args1" ;; | ||
| 143 | (3) set -- "$args0" "$args1" "$args2" ;; | ||
| 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | ||
| 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | ||
| 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | ||
| 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | ||
| 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | ||
| 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | ||
| 150 | esac | ||
| 151 | fi | ||
| 152 | |||
| 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules | ||
| 154 | function splitJvmOpts() { | ||
| 155 | JVM_OPTS=("$@") | ||
| 156 | } | ||
| 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS | ||
| 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" | ||
| 159 | |||
| 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" | ||
| 161 |
MiaohongEntry/gradlew.bat
| File was created | 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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
| 12 | set DEFAULT_JVM_OPTS= | ||
| 13 | |||
| 14 | set DIRNAME=%~dp0 | ||
| 15 | if "%DIRNAME%" == "" set DIRNAME=. | ||
| 16 | set APP_BASE_NAME=%~n0 | ||
| 17 | set APP_HOME=%DIRNAME% | ||
| 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 Windowz variants | ||
| 50 | |||
| 51 | if not "%OS%" == "Windows_NT" goto win9xME_args | ||
| 52 | if "%@eval[2+2]" == "4" goto 4NT_args | ||
| 53 | |||
| 54 | :win9xME_args | ||
| 55 | @rem Slurp the command line arguments. | ||
| 56 | set CMD_LINE_ARGS= | ||
| 57 | set _SKIP=2 | ||
| 58 | |||
| 59 | :win9xME_args_slurp | ||
| 60 | if "x%~1" == "x" goto execute | ||
| 61 | |||
| 62 | set CMD_LINE_ARGS=%* | ||
| 63 | goto execute | ||
| 64 | |||
| 65 | :4NT_args | ||
| 66 | @rem Get arguments from the 4NT Shell from JP Software | ||
| 67 | set CMD_LINE_ARGS=%$ | ||
| 68 | |||
| 69 | :execute | ||
| 70 | @rem Setup the command line | ||
| 71 | |||
| 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
| 73 | |||
| 74 | @rem Execute Gradle | ||
| 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% | ||
| 76 | |||
| 77 | :end | ||
| 78 | @rem End local scope for the variables with windows NT shell | ||
| 79 | if "%ERRORLEVEL%"=="0" goto mainEnd | ||
| 80 | |||
| 81 | :fail | ||
| 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
| 83 | rem the _cmd.exe /c_ return code! | ||
| 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
| 85 | exit /b 1 | ||
| 86 | |||
| 87 | :mainEnd | ||
| 88 | if "%OS%"=="Windows_NT" endlocal | ||
| 89 | |||
| 90 | :omega | ||
| 91 |
MiaohongEntry/settings.gradle
| File was created | 1 | include ':app' | |
| 2 |