commit
04cb229e58
@ -0,0 +1,8 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
@ -0,0 +1 @@
|
||||
MonkeyBook
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,3 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/basemvplib" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<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">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/MonkeyBook.iml" filepath="$PROJECT_DIR$/MonkeyBook.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/basemvplib/basemvplib.iml" filepath="$PROJECT_DIR$/basemvplib/basemvplib.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
/build
|
@ -0,0 +1,111 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'org.greenrobot.greendao'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
buildToolsVersion '25.0.0'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.monke.monkeybook"
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 25
|
||||
versionCode 6
|
||||
versionName "1.2.1"
|
||||
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "debug"]
|
||||
}
|
||||
|
||||
productFlavors{
|
||||
baidu {
|
||||
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "baidu"]
|
||||
}
|
||||
pyger{
|
||||
manifestPlaceholders = [UMENG_CHANNEL_VALUE: "pyger"]
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
config {
|
||||
keyAlias 'monkeybook'
|
||||
keyPassword 'zqh19931118'
|
||||
storeFile file('D:/WorkSpace/Android/PersonalKey/Monke_keystore.jks')
|
||||
storePassword 'zqh19931118'
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
buildConfigField "boolean", "IS_RELEASE", "true"
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = output.outputFile
|
||||
if (outputFile != null && outputFile.name.endsWith('.apk')) {
|
||||
//这里修改apk文件名
|
||||
def fileName = APP_NAME +"_"+"${variant.productFlavors[0].name}"+ "_v" + defaultConfig.versionName + "(" + defaultConfig.versionCode + ").apk"
|
||||
output.outputFile = new File(outputFile.parent, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
debug {
|
||||
buildConfigField "boolean", "IS_RELEASE", "false"
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
// signingConfig signingConfigs.config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories{
|
||||
flatDir{
|
||||
dirs 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile(name: 'autoupdatesdk-release', ext: 'aar')
|
||||
compile 'com.android.support:appcompat-v7:25.1.0'
|
||||
compile 'com.android.support:design:25.1.0'
|
||||
compile 'com.android.support:cardview-v7:25.1.0'
|
||||
compile 'com.android.support:support-compat:25.1.0'
|
||||
compile project(':basemvplib')
|
||||
//GreenDao
|
||||
compile 'org.greenrobot:greendao:3.0.1'
|
||||
compile 'org.greenrobot:greendao-generator:3.0.0'
|
||||
//JSOUP
|
||||
compile 'org.jsoup:jsoup:1.10.2'
|
||||
//沉浸式状态栏
|
||||
compile 'com.zhangmonke:ImmerseLayout:1.1.1'
|
||||
//ProgressBar
|
||||
compile 'com.zhangmonke:MProgressBar:1.0.1'
|
||||
//Glide
|
||||
compile 'com.github.bumptech.glide:glide:3.7.0'
|
||||
//AutofitTextView
|
||||
compile 'me.grantland:autofittextview:0.2.1'
|
||||
//删除粒子效果
|
||||
compile 'tyrantgit:explosionfield:1.0.1'
|
||||
//View简易动画
|
||||
compile 'com.daimajia.easing:library:2.0@aar'
|
||||
compile 'com.daimajia.androidanimations:library:2.2@aar'
|
||||
//CircleImageView
|
||||
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||
//SwitchButton
|
||||
compile 'com.kyleduo.switchbutton:library:1.4.4'
|
||||
compile 'com.victor:lib:1.0.4'
|
||||
compile files('libs/commons-codec-1.10-sources.jar')
|
||||
compile files('libs/juniversalchardet-1.0.3.jar')
|
||||
compile files('libs/umeng-analytics-v6.1.1.jar')
|
||||
compile files('libs/utdid4all-1.0.4.jar')
|
||||
}
|
||||
|
||||
greendao {
|
||||
schemaVersion 1
|
||||
daoPackage 'com.monke.monkeybook.dao'
|
||||
targetGenDir 'src/main/java'
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,13 @@
|
||||
package com.monke.monkeybook;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.monke.monkeybook">
|
||||
|
||||
<application
|
||||
android:name=".MApplication"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/CAppTheme"
|
||||
tools:replace="android:theme">
|
||||
<activity
|
||||
android:name=".view.impl.WelcomeActivity"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".view.impl.MainActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".view.impl.SearchActivity"
|
||||
android:configChanges="locale|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/CAppTransparentTheme"
|
||||
android:windowSoftInputMode="stateHidden|adjustPan" />
|
||||
|
||||
<service android:name=".service.DownloadService" />
|
||||
|
||||
<activity
|
||||
android:name=".view.impl.LibraryActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/CAppTransparentTheme" />
|
||||
<activity
|
||||
android:name=".view.impl.ChoiceBookActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".view.impl.BookDetailActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/CAppTransparentTheme" />
|
||||
<activity
|
||||
android:name=".view.impl.ReadBookActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"></action>
|
||||
<category android:name="android.intent.category.DEFAULT"></category>
|
||||
<data android:mimeType="text/plain"></data>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".view.impl.ImportBookActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/CAppTransparentTheme" />
|
||||
|
||||
<meta-data
|
||||
android:name="BDAPPID"
|
||||
android:value="@string/baidu_app_id" />
|
||||
<meta-data
|
||||
android:name="BDAPPKEY"
|
||||
android:value="@string/baidu_app_key" />
|
||||
|
||||
<meta-data
|
||||
android:name="UMENG_CHANNEL_VALUE"
|
||||
android:value="${UMENG_CHANNEL_VALUE}" />
|
||||
|
||||
<provider
|
||||
android:name="android.support.v4.content.FileProvider"
|
||||
android:authorities="${applicationId}.fileprovider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/bdp_update_filepaths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="8"></uses-sdk>
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
</manifest>
|
@ -0,0 +1,34 @@
|
||||
package com.monke.monkeybook;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BitIntentDataManager {
|
||||
public static Map<String,Object> bigData;
|
||||
|
||||
private static BitIntentDataManager instance = null;
|
||||
|
||||
public static BitIntentDataManager getInstance(){
|
||||
if(instance == null){
|
||||
synchronized (BitIntentDataManager.class){
|
||||
if(instance == null){
|
||||
instance = new BitIntentDataManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private BitIntentDataManager(){
|
||||
bigData = new HashMap<>();
|
||||
}
|
||||
public Object getData(String key){
|
||||
return bigData.get(key);
|
||||
}
|
||||
public void putData(String key,Object data){
|
||||
bigData.put(key,data);
|
||||
}
|
||||
public void cleanData(String key){
|
||||
bigData.remove(key);
|
||||
}
|
||||
}
|
@ -0,0 +1,124 @@
|
||||
package com.monke.monkeybook;
|
||||
|
||||
import com.monke.monkeybook.base.observer.SimpleObserver;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class ErrorAnalyContentManager {
|
||||
private ErrorAnalyContentManager(){
|
||||
|
||||
}
|
||||
private static ErrorAnalyContentManager instance;
|
||||
|
||||
public static ErrorAnalyContentManager getInstance(){
|
||||
if(instance == null){
|
||||
synchronized (ErrorAnalyContentManager.class){
|
||||
if(instance == null){
|
||||
instance = new ErrorAnalyContentManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void writeNewErrorUrl(final String url){
|
||||
Observable.create(new ObservableOnSubscribe<Boolean>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Boolean> e) throws Exception {
|
||||
String filePath = MApplication.getInstance().getExternalFilesDir("").getPath();
|
||||
File dir = new File(filePath);
|
||||
if(!dir.exists()){
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File file2 = new File(filePath,"ErrorAnalyUrlsDetail.txt");
|
||||
if(!file2.exists()) {
|
||||
file2.createNewFile();
|
||||
}
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(file2,true);
|
||||
fileOutputStream2.write((url+" \r\n").getBytes());
|
||||
fileOutputStream2.flush();
|
||||
fileOutputStream2.close();
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
File file1 = new File(filePath,"ErrorAnalyUrls.txt");
|
||||
if(!file1.exists()) {
|
||||
file1.createNewFile();
|
||||
}
|
||||
FileInputStream inputStream = new FileInputStream(file1);
|
||||
byte[] bytes = new byte[1024];
|
||||
ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream();
|
||||
while (inputStream.read(bytes) != -1) {
|
||||
arrayOutputStream.write(bytes, 0, bytes.length);
|
||||
}
|
||||
inputStream.close();
|
||||
arrayOutputStream.close();
|
||||
String content = new String(arrayOutputStream.toByteArray());
|
||||
if(!content.contains(url.substring(0,url.indexOf('/',8)))){
|
||||
FileOutputStream fileOutputStream1 = new FileOutputStream(file1,true);
|
||||
fileOutputStream1.write((url.substring(0,url.indexOf('/',8))+" \r\n").getBytes());
|
||||
fileOutputStream1.flush();
|
||||
fileOutputStream1.close();
|
||||
}
|
||||
e.onNext(true);
|
||||
e.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SimpleObserver<Boolean>() {
|
||||
@Override
|
||||
public void onNext(Boolean value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void writeMayByNetError(final String url){
|
||||
Observable.create(new ObservableOnSubscribe<Boolean>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<Boolean> e) throws Exception {
|
||||
String filePath = MApplication.getInstance().getExternalFilesDir("").getPath();
|
||||
File dir = new File(filePath);
|
||||
if(!dir.exists()){
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File file = new File(filePath,"ErrorNetUrl.txt");
|
||||
if(!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
FileOutputStream fileOutputStream2 = new FileOutputStream(file,true);
|
||||
fileOutputStream2.write((url+" \r\n").getBytes());
|
||||
fileOutputStream2.flush();
|
||||
fileOutputStream2.close();
|
||||
e.onNext(true);
|
||||
e.onComplete();
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SimpleObserver<Boolean>() {
|
||||
@Override
|
||||
public void onNext(Boolean value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.monke.monkeybook;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.monke.monkeybook.service.DownloadService;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
public class MApplication extends Application {
|
||||
|
||||
private static MApplication instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
if (BuildConfig.IS_RELEASE) {
|
||||
String channel = "debug";
|
||||
try {
|
||||
ApplicationInfo appInfo = getPackageManager()
|
||||
.getApplicationInfo(getPackageName(),
|
||||
PackageManager.GET_META_DATA);
|
||||
channel = appInfo.metaData.getString("UMENG_CHANNEL_VALUE");
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
MobclickAgent.startWithConfigure(new MobclickAgent.UMAnalyticsConfig(this, getString(R.string.umeng_key), channel, MobclickAgent.EScenarioType.E_UM_NORMAL, true));
|
||||
}
|
||||
instance = this;
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
}
|
||||
|
||||
public static MApplication getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package com.monke.monkeybook;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import com.monke.monkeybook.utils.DensityUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReadBookControl {
|
||||
public static final int DEFAULT_TEXT = 2;
|
||||
public static final int DEFAULT_BG = 1;
|
||||
|
||||
private static List<Map<String,Integer>> textKind;
|
||||
private static List<Map<String,Integer>> textDrawable;
|
||||
|
||||
private int textSize;
|
||||
private int textExtra;
|
||||
private int textColor;
|
||||
private int textBackground;
|
||||
|
||||
private int textKindIndex = DEFAULT_TEXT;
|
||||
private int textDrawableIndex = DEFAULT_BG;
|
||||
|
||||
private Boolean canClickTurn = true;
|
||||
private Boolean canKeyTurn = true;
|
||||
|
||||
private SharedPreferences preference;
|
||||
|
||||
private static ReadBookControl readBookControl;
|
||||
|
||||
public static ReadBookControl getInstance(){
|
||||
if(readBookControl == null){
|
||||
synchronized (ReadBookControl.class){
|
||||
if(readBookControl == null){
|
||||
readBookControl = new ReadBookControl();
|
||||
}
|
||||
}
|
||||
}
|
||||
return readBookControl;
|
||||
}
|
||||
private ReadBookControl(){
|
||||
if(null == textKind){
|
||||
textKind = new ArrayList<>();
|
||||
Map<String,Integer> temp1 = new HashMap<>();
|
||||
temp1.put("textSize", 14);
|
||||
temp1.put("textExtra", DensityUtil.dp2px(MApplication.getInstance(),6.5f));
|
||||
textKind.add(temp1);
|
||||
|
||||
Map<String,Integer> temp2 = new HashMap<>();
|
||||
temp2.put("textSize", 16);
|
||||
temp2.put("textExtra", DensityUtil.dp2px(MApplication.getInstance(),8));
|
||||
textKind.add(temp2);
|
||||
|
||||
Map<String,Integer> temp3 = new HashMap<>();
|
||||
temp3.put("textSize", 17);
|
||||
temp3.put("textExtra", DensityUtil.dp2px(MApplication.getInstance(),9));
|
||||
textKind.add(temp3);
|
||||
|
||||
Map<String,Integer> temp4 = new HashMap<>();
|
||||
temp4.put("textSize", 20);
|
||||
temp4.put("textExtra", DensityUtil.dp2px(MApplication.getInstance(),11));
|
||||
textKind.add(temp4);
|
||||
|
||||
Map<String,Integer> temp5 = new HashMap<>();
|
||||
temp5.put("textSize", 22);
|
||||
temp5.put("textExtra", DensityUtil.dp2px(MApplication.getInstance(),13));
|
||||
textKind.add(temp5);
|
||||
}
|
||||
if(null == textDrawable){
|
||||
textDrawable = new ArrayList<>();
|
||||
Map<String,Integer> temp1 = new HashMap<>();
|
||||
temp1.put("textColor",Color.parseColor("#3E3D3B"));
|
||||
temp1.put("textBackground",R.drawable.shape_bg_readbook_white);
|
||||
textDrawable.add(temp1);
|
||||
|
||||
Map<String,Integer> temp2 = new HashMap<>();
|
||||
temp2.put("textColor",Color.parseColor("#5E432E"));
|
||||
temp2.put("textBackground",R.drawable.bg_readbook_yellow);
|
||||
textDrawable.add(temp2);
|
||||
|
||||
Map<String,Integer> temp3 = new HashMap<>();
|
||||
temp3.put("textColor",Color.parseColor("#22482C"));
|
||||
temp3.put("textBackground",R.drawable.bg_readbook_green);
|
||||
textDrawable.add(temp3);
|
||||
|
||||
Map<String,Integer> temp4 = new HashMap<>();
|
||||
temp4.put("textColor",Color.parseColor("#808080"));
|
||||
temp4.put("textBackground",R.drawable.bg_readbook_black);
|
||||
textDrawable.add(temp4);
|
||||
}
|
||||
preference = MApplication.getInstance().getSharedPreferences("CONFIG", 0);
|
||||
this.textKindIndex = preference.getInt("textKindIndex",DEFAULT_TEXT);
|
||||
this.textSize = textKind.get(textKindIndex).get("textSize");
|
||||
this.textExtra = textKind.get(textKindIndex).get("textExtra");
|
||||
this.textDrawableIndex = preference.getInt("textDrawableIndex",DEFAULT_BG);
|
||||
this.textColor = textDrawable.get(textDrawableIndex).get("textColor");
|
||||
this.textBackground = textDrawable.get(textDrawableIndex).get("textBackground");
|
||||
|
||||
this.canClickTurn = preference.getBoolean("canClickTurn",true);
|
||||
this.canKeyTurn = preference.getBoolean("canClickTurn",true);
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public int getTextExtra() {
|
||||
return textExtra;
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return textColor;
|
||||
}
|
||||
|
||||
public int getTextBackground() {
|
||||
return textBackground;
|
||||
}
|
||||
|
||||
public int getTextKindIndex() {
|
||||
return textKindIndex;
|
||||
}
|
||||
|
||||
public void setTextKindIndex(int textKindIndex) {
|
||||
this.textKindIndex = textKindIndex;
|
||||
SharedPreferences.Editor editor = preference.edit();
|
||||
editor.putInt("textKindIndex",textKindIndex);
|
||||
editor.commit();
|
||||
this.textSize = textKind.get(textKindIndex).get("textSize");
|
||||
this.textExtra = textKind.get(textKindIndex).get("textExtra");
|
||||
}
|
||||
|
||||
public int getTextDrawableIndex() {
|
||||
return textDrawableIndex;
|
||||
}
|
||||
|
||||
public void setTextDrawableIndex(int textDrawableIndex) {
|
||||
this.textDrawableIndex = textDrawableIndex;
|
||||
SharedPreferences.Editor editor = preference.edit();
|
||||
editor.putInt("textDrawableIndex",textDrawableIndex);
|
||||
editor.commit();
|
||||
this.textColor = textDrawable.get(textDrawableIndex).get("textColor");
|
||||
this.textBackground = textDrawable.get(textDrawableIndex).get("textBackground");
|
||||
}
|
||||
|
||||
public static List<Map<String, Integer>> getTextKind() {
|
||||
return textKind;
|
||||
}
|
||||
|
||||
public static List<Map<String, Integer>> getTextDrawable() {
|
||||
return textDrawable;
|
||||
}
|
||||
|
||||
public Boolean getCanKeyTurn() {
|
||||
return canKeyTurn;
|
||||
}
|
||||
|
||||
public void setCanKeyTurn(Boolean canKeyTurn) {
|
||||
this.canKeyTurn = canKeyTurn;
|
||||
SharedPreferences.Editor editor = preference.edit();
|
||||
editor.putBoolean("canKeyTurn",canKeyTurn);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
public Boolean getCanClickTurn() {
|
||||
return canClickTurn;
|
||||
}
|
||||
|
||||
public void setCanClickTurn(Boolean canClickTurn) {
|
||||
this.canClickTurn = canClickTurn;
|
||||
SharedPreferences.Editor editor = preference.edit();
|
||||
editor.putBoolean("canClickTurn",canClickTurn);
|
||||
editor.commit();
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.monke.monkeybook.base;
|
||||
|
||||
import com.monke.basemvplib.IPresenter;
|
||||
import com.monke.basemvplib.impl.BaseActivity;
|
||||
import com.umeng.analytics.MobclickAgent;
|
||||
|
||||
public abstract class MBaseActivity<T extends IPresenter> extends BaseActivity<T>{
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
MobclickAgent.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
MobclickAgent.onPause(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.monke.monkeybook.base.observer;
|
||||
|
||||
import com.monke.monkeybook.utils.NetworkUtil;
|
||||
|
||||
public class SimpleObserClass<T> {
|
||||
private int code;
|
||||
private T t;
|
||||
|
||||
public SimpleObserClass(T t){
|
||||
this(t,NetworkUtil.SUCCESS);
|
||||
}
|
||||
|
||||
public SimpleObserClass(T t,int code){
|
||||
this.t = t;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Boolean success(){
|
||||
return code == NetworkUtil.SUCCESS;
|
||||
}
|
||||
|
||||
public T getT() {
|
||||
return t;
|
||||
}
|
||||
|
||||
public void setT(T t) {
|
||||
this.t = t;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.monke.monkeybook.base.observer;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
public abstract class SimpleObserver<T> implements Observer<T> {
|
||||
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Transient;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 书本缓存内容
|
||||
*/
|
||||
@Entity
|
||||
public class BookContentBean implements Parcelable{
|
||||
@Id
|
||||
private String durChapterUrl; //对应BookInfoBean noteUrl;
|
||||
|
||||
private int durChapterIndex; //当前章节 (包括番外)
|
||||
|
||||
private String durCapterContent; //当前章节内容
|
||||
|
||||
private String tag; //来源 某个网站/本地
|
||||
|
||||
@Transient
|
||||
private Boolean isRight = true;
|
||||
|
||||
@Transient
|
||||
private List<String> lineContent = new ArrayList<>();
|
||||
|
||||
@Transient
|
||||
private float lineSize;
|
||||
|
||||
public BookContentBean(){
|
||||
|
||||
}
|
||||
|
||||
public float getLineSize() {
|
||||
return lineSize;
|
||||
}
|
||||
|
||||
public void setLineSize(float lineSize) {
|
||||
this.lineSize = lineSize;
|
||||
}
|
||||
|
||||
protected BookContentBean(Parcel in) {
|
||||
durChapterUrl = in.readString();
|
||||
durChapterIndex = in.readInt();
|
||||
durCapterContent = in.readString();
|
||||
tag = in.readString();
|
||||
lineContent = in.createStringArrayList();
|
||||
isRight = in.readByte()!=0;
|
||||
}
|
||||
|
||||
@Generated(hash = 1355824386)
|
||||
public BookContentBean(String durChapterUrl, int durChapterIndex,
|
||||
String durCapterContent, String tag) {
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
this.durCapterContent = durCapterContent;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(durChapterUrl);
|
||||
dest.writeInt(durChapterIndex);
|
||||
dest.writeString(durCapterContent);
|
||||
dest.writeString(tag);
|
||||
dest.writeStringList(lineContent);
|
||||
dest.writeByte((byte) (isRight ? 1 : 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public static final Creator<BookContentBean> CREATOR = new Creator<BookContentBean>() {
|
||||
@Override
|
||||
public BookContentBean createFromParcel(Parcel in) {
|
||||
return new BookContentBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookContentBean[] newArray(int size) {
|
||||
return new BookContentBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getDurChapterUrl() {
|
||||
return durChapterUrl;
|
||||
}
|
||||
|
||||
public void setDurChapterUrl(String durChapterUrl) {
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
}
|
||||
|
||||
public int getDurChapterIndex() {
|
||||
return durChapterIndex;
|
||||
}
|
||||
|
||||
public void setDurChapterIndex(int durChapterIndex) {
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
}
|
||||
|
||||
public String getDurCapterContent() {
|
||||
return durCapterContent;
|
||||
}
|
||||
|
||||
public void setDurCapterContent(String durCapterContent) {
|
||||
this.durCapterContent = durCapterContent;
|
||||
if(durCapterContent==null || durCapterContent.length()==0)
|
||||
this.isRight = false;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public List<String> getLineContent() {
|
||||
return lineContent;
|
||||
}
|
||||
|
||||
public void setLineContent(List<String> lineContent) {
|
||||
this.lineContent = lineContent;
|
||||
}
|
||||
|
||||
public Boolean getRight() {
|
||||
return isRight;
|
||||
}
|
||||
|
||||
public void setRight(Boolean right) {
|
||||
isRight = right;
|
||||
}
|
||||
}
|
@ -0,0 +1,212 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Transient;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 书本信息
|
||||
*/
|
||||
@Entity
|
||||
public class BookInfoBean implements Parcelable,Cloneable{
|
||||
|
||||
@Transient
|
||||
public static final long REFRESH_DUR = 10*60*1000;
|
||||
|
||||
private String name; //小说名
|
||||
|
||||
private String tag;
|
||||
|
||||
@Id
|
||||
private String noteUrl; //如果是来源网站 则小说根地址 /如果是本地 则是小说本地MD5
|
||||
|
||||
private String chapterUrl; //章节目录地址
|
||||
|
||||
@Transient
|
||||
private List<ChapterListBean> chapterlist = new ArrayList<>(); //章节列表
|
||||
|
||||
private long finalRefreshData; //章节最后更新时间
|
||||
|
||||
private String coverUrl; //小说封面
|
||||
|
||||
private String author;//作者
|
||||
|
||||
private String introduce; //简介
|
||||
|
||||
private String origin; //来源
|
||||
|
||||
public BookInfoBean(){
|
||||
|
||||
}
|
||||
|
||||
protected BookInfoBean(Parcel in) {
|
||||
name = in.readString();
|
||||
tag = in.readString();
|
||||
noteUrl = in.readString();
|
||||
chapterUrl = in.readString();
|
||||
chapterlist = in.createTypedArrayList(ChapterListBean.CREATOR);
|
||||
finalRefreshData = in.readLong();
|
||||
coverUrl = in.readString();
|
||||
author = in.readString();
|
||||
introduce = in.readString();
|
||||
origin = in.readString();
|
||||
}
|
||||
|
||||
@Generated(hash = 1627552162)
|
||||
public BookInfoBean(String name, String tag, String noteUrl, String chapterUrl,
|
||||
long finalRefreshData, String coverUrl, String author, String introduce,
|
||||
String origin) {
|
||||
this.name = name;
|
||||
this.tag = tag;
|
||||
this.noteUrl = noteUrl;
|
||||
this.chapterUrl = chapterUrl;
|
||||
this.finalRefreshData = finalRefreshData;
|
||||
this.coverUrl = coverUrl;
|
||||
this.author = author;
|
||||
this.introduce = introduce;
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(name);
|
||||
dest.writeString(tag);
|
||||
dest.writeString(noteUrl);
|
||||
dest.writeString(chapterUrl);
|
||||
dest.writeTypedList(chapterlist);
|
||||
dest.writeLong(finalRefreshData);
|
||||
dest.writeString(coverUrl);
|
||||
dest.writeString(author);
|
||||
dest.writeString(introduce);
|
||||
dest.writeString(origin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public static final Creator<BookInfoBean> CREATOR = new Creator<BookInfoBean>() {
|
||||
@Override
|
||||
public BookInfoBean createFromParcel(Parcel in) {
|
||||
return new BookInfoBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookInfoBean[] newArray(int size) {
|
||||
return new BookInfoBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getNoteUrl() {
|
||||
return noteUrl;
|
||||
}
|
||||
|
||||
public void setNoteUrl(String noteUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
}
|
||||
|
||||
public String getChapterUrl() {
|
||||
return chapterUrl;
|
||||
}
|
||||
|
||||
public void setChapterUrl(String chapterUrl) {
|
||||
this.chapterUrl = chapterUrl;
|
||||
}
|
||||
|
||||
public List<ChapterListBean> getChapterlist() {
|
||||
return chapterlist;
|
||||
}
|
||||
|
||||
public void setChapterlist(List<ChapterListBean> chapterlist) {
|
||||
this.chapterlist = chapterlist;
|
||||
}
|
||||
public void addChapterlist(List<ChapterListBean> chapterlist){
|
||||
this.chapterlist.addAll(chapterlist);
|
||||
}
|
||||
|
||||
public long getFinalRefreshData() {
|
||||
return finalRefreshData;
|
||||
}
|
||||
|
||||
public void setFinalRefreshData(long finalRefreshData) {
|
||||
this.finalRefreshData = finalRefreshData;
|
||||
}
|
||||
|
||||
public String getCoverUrl() {
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getIntroduce() {
|
||||
return introduce;
|
||||
}
|
||||
|
||||
public void setIntroduce(String introduce) {
|
||||
this.introduce = introduce;
|
||||
}
|
||||
|
||||
public String getOrigin() {
|
||||
return this.origin;
|
||||
}
|
||||
|
||||
public void setOrigin(String origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
BookInfoBean bookInfoBean = (BookInfoBean) super.clone();
|
||||
bookInfoBean.name = new String(name);
|
||||
bookInfoBean.tag = new String(tag);
|
||||
bookInfoBean.noteUrl = new String(noteUrl);
|
||||
bookInfoBean.chapterUrl = new String(chapterUrl);
|
||||
bookInfoBean.coverUrl = new String(coverUrl);
|
||||
bookInfoBean.author = new String(author);
|
||||
bookInfoBean.introduce = new String(introduce);
|
||||
bookInfoBean.origin = new String(origin);
|
||||
if(chapterlist!=null){
|
||||
List<ChapterListBean> newList = new ArrayList<>();
|
||||
Iterator<ChapterListBean> iterator = chapterlist.iterator();
|
||||
while(iterator.hasNext()){
|
||||
newList.add((ChapterListBean) iterator.next().clone());
|
||||
}
|
||||
bookInfoBean.setChapterlist(newList);
|
||||
}
|
||||
return bookInfoBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,144 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import com.monke.monkeybook.widget.contentswitchview.BookContentView;
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
import org.greenrobot.greendao.annotation.Transient;
|
||||
|
||||
/**
|
||||
* 书架item Bean
|
||||
*/
|
||||
|
||||
@Entity
|
||||
public class BookShelfBean implements Parcelable,Cloneable{
|
||||
@Transient
|
||||
public static final long REFRESH_TIME = 5*60*1000; //更新时间间隔 至少
|
||||
@Transient
|
||||
public static final String LOCAL_TAG = "loc_book";
|
||||
|
||||
@Id
|
||||
private String noteUrl; //对应BookInfoBean noteUrl;
|
||||
|
||||
private int durChapter; //当前章节 (包括番外)
|
||||
|
||||
private int durChapterPage = BookContentView.DURPAGEINDEXBEGIN; // 当前章节位置 用页码
|
||||
|
||||
private long finalDate; //最后阅读时间
|
||||
|
||||
private String tag;
|
||||
|
||||
@Transient
|
||||
private BookInfoBean bookInfoBean = new BookInfoBean();
|
||||
|
||||
public BookShelfBean(){
|
||||
|
||||
}
|
||||
|
||||
protected BookShelfBean(Parcel in) {
|
||||
noteUrl = in.readString();
|
||||
durChapter = in.readInt();
|
||||
durChapterPage = in.readInt();
|
||||
finalDate = in.readLong();
|
||||
tag = in.readString();
|
||||
bookInfoBean = in.readParcelable(BookInfoBean.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Generated(hash = 2028192361)
|
||||
public BookShelfBean(String noteUrl, int durChapter, int durChapterPage, long finalDate,
|
||||
String tag) {
|
||||
this.noteUrl = noteUrl;
|
||||
this.durChapter = durChapter;
|
||||
this.durChapterPage = durChapterPage;
|
||||
this.finalDate = finalDate;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(noteUrl);
|
||||
dest.writeInt(durChapter);
|
||||
dest.writeInt(durChapterPage);
|
||||
dest.writeLong(finalDate);
|
||||
dest.writeString(tag);
|
||||
dest.writeParcelable(bookInfoBean, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public static final Creator<BookShelfBean> CREATOR = new Creator<BookShelfBean>() {
|
||||
@Override
|
||||
public BookShelfBean createFromParcel(Parcel in) {
|
||||
return new BookShelfBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookShelfBean[] newArray(int size) {
|
||||
return new BookShelfBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getNoteUrl() {
|
||||
return noteUrl;
|
||||
}
|
||||
|
||||
public void setNoteUrl(String noteUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
}
|
||||
|
||||
public int getDurChapter() {
|
||||
return durChapter;
|
||||
}
|
||||
|
||||
public void setDurChapter(int durChapter) {
|
||||
this.durChapter = durChapter;
|
||||
}
|
||||
|
||||
public int getDurChapterPage() {
|
||||
return durChapterPage;
|
||||
}
|
||||
|
||||
public void setDurChapterPage(int durChapterPage) {
|
||||
this.durChapterPage = durChapterPage;
|
||||
}
|
||||
|
||||
public long getFinalDate() {
|
||||
return finalDate;
|
||||
}
|
||||
|
||||
public void setFinalDate(long finalDate) {
|
||||
this.finalDate = finalDate;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public BookInfoBean getBookInfoBean() {
|
||||
return bookInfoBean;
|
||||
}
|
||||
|
||||
public void setBookInfoBean(BookInfoBean bookInfoBean) {
|
||||
this.bookInfoBean = bookInfoBean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
BookShelfBean bookShelfBean = (BookShelfBean) super.clone();
|
||||
bookShelfBean.noteUrl = new String(noteUrl);
|
||||
bookShelfBean.tag = new String(tag);
|
||||
bookShelfBean.bookInfoBean = (BookInfoBean) bookInfoBean.clone();
|
||||
return bookShelfBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,148 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Transient;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
|
||||
@Entity
|
||||
public class ChapterListBean implements Parcelable,Cloneable{
|
||||
|
||||
private String noteUrl; //对应BookInfoBean noteUrl;
|
||||
|
||||
private int durChapterIndex; //当前章节数
|
||||
@Id
|
||||
private String durChapterUrl; //当前章节对应的文章地址
|
||||
|
||||
private String durChapterName; //当前章节名称
|
||||
|
||||
private String tag;
|
||||
|
||||
private Boolean hasCache = false;
|
||||
@Transient
|
||||
private BookContentBean bookContentBean = new BookContentBean();
|
||||
|
||||
protected ChapterListBean(Parcel in) {
|
||||
noteUrl = in.readString();
|
||||
durChapterIndex = in.readInt();
|
||||
durChapterUrl = in.readString();
|
||||
durChapterName = in.readString();
|
||||
tag = in.readString();
|
||||
bookContentBean = in.readParcelable(BookContentBean.class.getClassLoader());
|
||||
hasCache = in.readByte() != 0;
|
||||
}
|
||||
|
||||
@Generated(hash = 1225922702)
|
||||
public ChapterListBean(String noteUrl, int durChapterIndex, String durChapterUrl,
|
||||
String durChapterName, String tag, Boolean hasCache) {
|
||||
this.noteUrl = noteUrl;
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
this.durChapterName = durChapterName;
|
||||
this.tag = tag;
|
||||
this.hasCache = hasCache;
|
||||
}
|
||||
|
||||
@Generated(hash = 1096893365)
|
||||
public ChapterListBean() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(noteUrl);
|
||||
dest.writeInt(durChapterIndex);
|
||||
dest.writeString(durChapterUrl);
|
||||
dest.writeString(durChapterName);
|
||||
dest.writeString(tag);
|
||||
dest.writeParcelable(bookContentBean, flags);
|
||||
dest.writeByte((byte)(hasCache?1:0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public BookContentBean getBookContentBean() {
|
||||
return bookContentBean;
|
||||
}
|
||||
|
||||
public void setBookContentBean(BookContentBean bookContentBean) {
|
||||
this.bookContentBean = bookContentBean;
|
||||
}
|
||||
|
||||
public Boolean getHasCache() {
|
||||
return this.hasCache;
|
||||
}
|
||||
|
||||
public void setHasCache(Boolean hasCache) {
|
||||
this.hasCache = hasCache;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getDurChapterName() {
|
||||
return this.durChapterName;
|
||||
}
|
||||
|
||||
public void setDurChapterName(String durChapterName) {
|
||||
this.durChapterName = durChapterName;
|
||||
}
|
||||
|
||||
public String getDurChapterUrl() {
|
||||
return this.durChapterUrl;
|
||||
}
|
||||
|
||||
public void setDurChapterUrl(String durChapterUrl) {
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
}
|
||||
|
||||
public int getDurChapterIndex() {
|
||||
return this.durChapterIndex;
|
||||
}
|
||||
|
||||
public void setDurChapterIndex(int durChapterIndex) {
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
}
|
||||
|
||||
public String getNoteUrl() {
|
||||
return this.noteUrl;
|
||||
}
|
||||
|
||||
public void setNoteUrl(String noteUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public static final Creator<ChapterListBean> CREATOR = new Creator<ChapterListBean>() {
|
||||
@Override
|
||||
public ChapterListBean createFromParcel(Parcel in) {
|
||||
return new ChapterListBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChapterListBean[] newArray(int size) {
|
||||
return new ChapterListBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
ChapterListBean chapterListBean = (ChapterListBean) super.clone();
|
||||
chapterListBean.noteUrl = new String(noteUrl);
|
||||
chapterListBean.durChapterUrl = new String(durChapterUrl);
|
||||
chapterListBean.durChapterName = new String(durChapterName);
|
||||
chapterListBean.tag = new String(tag);
|
||||
chapterListBean.hasCache = new Boolean(hasCache);
|
||||
chapterListBean.bookContentBean = new BookContentBean();
|
||||
return chapterListBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Transient;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
|
||||
@Entity
|
||||
public class DownloadChapterBean implements Parcelable {
|
||||
private String noteUrl;
|
||||
|
||||
private int durChapterIndex; //当前章节数
|
||||
@Id
|
||||
private String durChapterUrl; //当前章节对应的文章地址
|
||||
|
||||
private String durChapterName; //当前章节名称
|
||||
|
||||
private String tag;
|
||||
|
||||
private String bookName;
|
||||
|
||||
private String coverUrl; //小说封面
|
||||
|
||||
protected DownloadChapterBean(Parcel in) {
|
||||
noteUrl = in.readString();
|
||||
durChapterIndex = in.readInt();
|
||||
durChapterUrl = in.readString();
|
||||
durChapterName = in.readString();
|
||||
tag = in.readString();
|
||||
bookName = in.readString();
|
||||
coverUrl = in.readString();
|
||||
}
|
||||
|
||||
@Generated(hash = 757008458)
|
||||
public DownloadChapterBean(String noteUrl, int durChapterIndex, String durChapterUrl,
|
||||
String durChapterName, String tag, String bookName, String coverUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
this.durChapterName = durChapterName;
|
||||
this.tag = tag;
|
||||
this.bookName = bookName;
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
@Generated(hash = 301211198)
|
||||
public DownloadChapterBean() {
|
||||
}
|
||||
|
||||
@Transient
|
||||
public static final Creator<DownloadChapterBean> CREATOR = new Creator<DownloadChapterBean>() {
|
||||
@Override
|
||||
public DownloadChapterBean createFromParcel(Parcel in) {
|
||||
return new DownloadChapterBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadChapterBean[] newArray(int size) {
|
||||
return new DownloadChapterBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(noteUrl);
|
||||
dest.writeInt(durChapterIndex);
|
||||
dest.writeString(durChapterUrl);
|
||||
dest.writeString(durChapterName);
|
||||
dest.writeString(tag);
|
||||
dest.writeString(bookName);
|
||||
dest.writeString(coverUrl);
|
||||
}
|
||||
|
||||
public String getNoteUrl() {
|
||||
return noteUrl;
|
||||
}
|
||||
|
||||
public void setNoteUrl(String noteUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
}
|
||||
|
||||
public int getDurChapterIndex() {
|
||||
return durChapterIndex;
|
||||
}
|
||||
|
||||
public void setDurChapterIndex(int durChapterIndex) {
|
||||
this.durChapterIndex = durChapterIndex;
|
||||
}
|
||||
|
||||
public String getDurChapterUrl() {
|
||||
return durChapterUrl;
|
||||
}
|
||||
|
||||
public void setDurChapterUrl(String durChapterUrl) {
|
||||
this.durChapterUrl = durChapterUrl;
|
||||
}
|
||||
|
||||
public String getDurChapterName() {
|
||||
return durChapterName;
|
||||
}
|
||||
|
||||
public void setDurChapterName(String durChapterName) {
|
||||
this.durChapterName = durChapterName;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String bookName) {
|
||||
this.bookName = bookName;
|
||||
}
|
||||
|
||||
public String getCoverUrl() {
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DownloadChapterListBean implements Parcelable {
|
||||
private List<DownloadChapterBean> data;
|
||||
|
||||
public DownloadChapterListBean(List<DownloadChapterBean> result) {
|
||||
this.data = result;
|
||||
}
|
||||
|
||||
protected DownloadChapterListBean(Parcel in) {
|
||||
if(data == null)
|
||||
data = new ArrayList<>();
|
||||
in.readTypedList(data,DownloadChapterBean.CREATOR);
|
||||
}
|
||||
|
||||
public static final Creator<DownloadChapterListBean> CREATOR = new Creator<DownloadChapterListBean>() {
|
||||
@Override
|
||||
public DownloadChapterListBean createFromParcel(Parcel in) {
|
||||
return new DownloadChapterListBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadChapterListBean[] newArray(int size) {
|
||||
return new DownloadChapterListBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
public List<DownloadChapterBean> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(List<DownloadChapterBean> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeTypedList(data);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryBean {
|
||||
private List<LibraryNewBookBean> libraryNewBooks;
|
||||
private List<LibraryKindBookListBean> kindBooks;
|
||||
|
||||
public List<LibraryNewBookBean> getLibraryNewBooks() {
|
||||
return libraryNewBooks;
|
||||
}
|
||||
|
||||
public void setLibraryNewBooks(List<LibraryNewBookBean> libraryNewBooks) {
|
||||
this.libraryNewBooks = libraryNewBooks;
|
||||
}
|
||||
|
||||
public List<LibraryKindBookListBean> getKindBooks() {
|
||||
return kindBooks;
|
||||
}
|
||||
|
||||
public void setKindBooks(List<LibraryKindBookListBean> kindBooks) {
|
||||
this.kindBooks = kindBooks;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryKindBookListBean {
|
||||
private String kindName;
|
||||
private String kindUrl;
|
||||
private List<SearchBookBean> books;
|
||||
|
||||
public String getKindName() {
|
||||
return kindName;
|
||||
}
|
||||
|
||||
public void setKindName(String kindName) {
|
||||
this.kindName = kindName;
|
||||
}
|
||||
|
||||
public List<SearchBookBean> getBooks() {
|
||||
return books;
|
||||
}
|
||||
|
||||
public void setBooks(List<SearchBookBean> books) {
|
||||
this.books = books;
|
||||
}
|
||||
|
||||
public String getKindUrl() {
|
||||
return kindUrl;
|
||||
}
|
||||
|
||||
public void setKindUrl(String kindUrl) {
|
||||
this.kindUrl = kindUrl;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
public class LibraryNewBookBean {
|
||||
private String name;
|
||||
private String url;
|
||||
private String tag;
|
||||
private String orgin;
|
||||
|
||||
public LibraryNewBookBean(String name, String url, String tag, String orgin) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.tag = tag;
|
||||
this.orgin = orgin;
|
||||
}
|
||||
|
||||
public String getOrgin() {
|
||||
return orgin;
|
||||
}
|
||||
|
||||
public void setOrgin(String orgin) {
|
||||
this.orgin = orgin;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
public class LibraryRankBean {
|
||||
private String coverUrl;
|
||||
private String name;
|
||||
private String author;
|
||||
|
||||
public String getCoverUrl() {
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
public class LocBookShelfBean {
|
||||
private Boolean isNew;
|
||||
private BookShelfBean bookShelfBean;
|
||||
|
||||
public LocBookShelfBean(Boolean isNew,BookShelfBean bookShelfBean){
|
||||
this.isNew = isNew;
|
||||
this.bookShelfBean = bookShelfBean;
|
||||
}
|
||||
|
||||
public Boolean getNew() {
|
||||
return isNew;
|
||||
}
|
||||
|
||||
public void setNew(Boolean aNew) {
|
||||
isNew = aNew;
|
||||
}
|
||||
|
||||
public BookShelfBean getBookShelfBean() {
|
||||
return bookShelfBean;
|
||||
}
|
||||
|
||||
public void setBookShelfBean(BookShelfBean bookShelfBean) {
|
||||
this.bookShelfBean = bookShelfBean;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReadBookContentBean {
|
||||
private List<BookContentBean> bookContentList;
|
||||
private int pageIndex;
|
||||
|
||||
public ReadBookContentBean(List<BookContentBean> bookContentList,int pageIndex){
|
||||
this.bookContentList = bookContentList;
|
||||
this.pageIndex = pageIndex;
|
||||
}
|
||||
|
||||
public List<BookContentBean> getBookContentList() {
|
||||
return bookContentList;
|
||||
}
|
||||
|
||||
public void setBookContentList(List<BookContentBean> bookContentList) {
|
||||
this.bookContentList = bookContentList;
|
||||
}
|
||||
|
||||
public int getPageIndex() {
|
||||
return pageIndex;
|
||||
}
|
||||
|
||||
public void setPageIndex(int pageIndex) {
|
||||
this.pageIndex = pageIndex;
|
||||
}
|
||||
}
|
@ -0,0 +1,179 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
public class SearchBookBean implements Parcelable{
|
||||
|
||||
private String noteUrl;
|
||||
|
||||
private String coverUrl;
|
||||
|
||||
private String name;
|
||||
|
||||
private String author;
|
||||
|
||||
private long words;
|
||||
|
||||
private String state;
|
||||
|
||||
private String lastChapter;
|
||||
|
||||
private Boolean isAdd = false;
|
||||
|
||||
private String tag;
|
||||
|
||||
private String kind;
|
||||
|
||||
private String origin;
|
||||
|
||||
private String desc;
|
||||
|
||||
public SearchBookBean(){
|
||||
|
||||
}
|
||||
|
||||
protected SearchBookBean(Parcel in) {
|
||||
noteUrl = in.readString();
|
||||
coverUrl = in.readString();
|
||||
name = in.readString();
|
||||
author = in.readString();
|
||||
words = in.readLong();
|
||||
state = in.readString();
|
||||
lastChapter = in.readString();
|
||||
isAdd = in.readByte() != 0;
|
||||
tag = in.readString();
|
||||
kind = in.readString();
|
||||
origin = in.readString();
|
||||
desc = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeString(noteUrl);
|
||||
dest.writeString(coverUrl);
|
||||
dest.writeString(name);
|
||||
dest.writeString(author);
|
||||
dest.writeLong(words);
|
||||
dest.writeString(state);
|
||||
dest.writeString(lastChapter);
|
||||
dest.writeByte((byte)(isAdd?1:0));
|
||||
dest.writeString(tag);
|
||||
dest.writeString(kind);
|
||||
dest.writeString(origin);
|
||||
dest.writeString(desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<SearchBookBean> CREATOR = new Creator<SearchBookBean>() {
|
||||
@Override
|
||||
public SearchBookBean createFromParcel(Parcel in) {
|
||||
return new SearchBookBean(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchBookBean[] newArray(int size) {
|
||||
return new SearchBookBean[size];
|
||||
}
|
||||
};
|
||||
|
||||
public String getNoteUrl() {
|
||||
return noteUrl;
|
||||
}
|
||||
|
||||
public void setNoteUrl(String noteUrl) {
|
||||
this.noteUrl = noteUrl;
|
||||
}
|
||||
|
||||
public String getCoverUrl() {
|
||||
return coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String coverUrl) {
|
||||
this.coverUrl = coverUrl;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public Boolean getAdd() {
|
||||
return isAdd;
|
||||
}
|
||||
|
||||
public void setAdd(Boolean add) {
|
||||
isAdd = add;
|
||||
}
|
||||
|
||||
public long getWords() {
|
||||
return words;
|
||||
}
|
||||
|
||||
public void setWords(long words) {
|
||||
this.words = words;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getLastChapter() {
|
||||
return lastChapter==null?"":lastChapter;
|
||||
}
|
||||
|
||||
public void setLastChapter(String lastChapter) {
|
||||
this.lastChapter = lastChapter;
|
||||
}
|
||||
|
||||
public String getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public void setKind(String kind) {
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public String getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(String origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
import org.greenrobot.greendao.annotation.Entity;
|
||||
import org.greenrobot.greendao.annotation.Id;
|
||||
import org.greenrobot.greendao.annotation.Unique;
|
||||
import org.greenrobot.greendao.annotation.Generated;
|
||||
|
||||
@Entity
|
||||
public class SearchHistoryBean {
|
||||
@Id(autoincrement = true)
|
||||
private Long id = null;
|
||||
private int type;
|
||||
private String content;
|
||||
private long date;
|
||||
public long getDate() {
|
||||
return this.date;
|
||||
}
|
||||
public void setDate(long date) {
|
||||
this.date = date;
|
||||
}
|
||||
public String getContent() {
|
||||
return this.content;
|
||||
}
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public SearchHistoryBean(int type, String content, long date) {
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
this.date = date;
|
||||
}
|
||||
@Generated(hash = 488115752)
|
||||
public SearchHistoryBean(Long id, int type, String content, long date) {
|
||||
this.id = id;
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
this.date = date;
|
||||
}
|
||||
@Generated(hash = 1570282321)
|
||||
public SearchHistoryBean() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
public class WebChapterBean<T> {
|
||||
private T data;
|
||||
|
||||
private Boolean next;
|
||||
|
||||
public WebChapterBean(T data,Boolean next){
|
||||
this.data = data;
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Boolean getNext() {
|
||||
return next;
|
||||
}
|
||||
|
||||
public void setNext(Boolean next) {
|
||||
this.next = next;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.monke.monkeybook.bean;
|
||||
|
||||
public class WebContentBean {
|
||||
private String url;
|
||||
private String content;
|
||||
|
||||
public WebContentBean(String url,String content){
|
||||
this.url = url;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.monke.monkeybook.common;
|
||||
|
||||
|
||||
public class RxBusTag {
|
||||
|
||||
public final static String HAD_ADD_BOOK = "rxbus_add_book";
|
||||
|
||||
public final static String HAD_REMOVE_BOOK = "rxbus_remove_book";
|
||||
|
||||
public final static String UPDATE_BOOK_PROGRESS = "rxbus_update_book_progress";
|
||||
|
||||
public final static String PAUSE_DOWNLOAD_LISTENER = "rxbus_pause_download_listener";
|
||||
|
||||
public final static String PROGRESS_DOWNLOAD_LISTENER = "rxbus_progress_download_listener";
|
||||
|
||||
public final static String FINISH_DOWNLOAD_LISTENER = "rxbus_finish_download_listener";
|
||||
|
||||
public final static String PAUSE_DOWNLOAD = "rxbus_pause_download";
|
||||
|
||||
public final static String START_DOWNLOAD = "rxbus_start_download";
|
||||
|
||||
public final static String CANCEL_DOWNLOAD = "rxbus_cancel_download";
|
||||
|
||||
public final static String ADD_DOWNLOAD_TASK = "rxbus_add_download_task";
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.monke.monkeybook.common.api;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
public interface IEasouApi {
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookInfo(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> searchBook(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookContent(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getChapterList(@Url String url);
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.monke.monkeybook.common.api;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.Field;
|
||||
import retrofit2.http.FormUrlEncoded;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
public interface IGxwztvApi {
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookInfo(@Url String url);
|
||||
|
||||
@GET("/search.htm")
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> searchBook(@Query("keyword")String content, @Query("pn")int page);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookContent(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getChapterList(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getKindBooks(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getLibraryData(@Url String url);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.monke.monkeybook.common.api;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Headers;
|
||||
import retrofit2.http.Query;
|
||||
import retrofit2.http.Url;
|
||||
|
||||
public interface ILingdiankanshuApi {
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookInfo(@Url String url);
|
||||
|
||||
@GET("/cse/search")
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> searchBook(@Query("q") String content, @Query("p") int page, @Query("s") String time);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getBookContent(@Url String url);
|
||||
|
||||
@GET
|
||||
@Headers({"Accept:text/html,application/xhtml+xml,application/xml",
|
||||
"User-Agent:Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
|
||||
"Accept-Charset:UTF-8",
|
||||
"Keep-Alive:300",
|
||||
"Connection:Keep-Alive",
|
||||
"Cache-Control:no-cache"})
|
||||
Observable<String> getChapterList(@Url String url);
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "BOOK_CONTENT_BEAN".
|
||||
*/
|
||||
public class BookContentBeanDao extends AbstractDao<BookContentBean, String> {
|
||||
|
||||
public static final String TABLENAME = "BOOK_CONTENT_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity BookContentBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property DurChapterUrl = new Property(0, String.class, "durChapterUrl", true, "DUR_CHAPTER_URL");
|
||||
public final static Property DurChapterIndex = new Property(1, int.class, "durChapterIndex", false, "DUR_CHAPTER_INDEX");
|
||||
public final static Property DurCapterContent = new Property(2, String.class, "durCapterContent", false, "DUR_CAPTER_CONTENT");
|
||||
public final static Property Tag = new Property(3, String.class, "tag", false, "TAG");
|
||||
};
|
||||
|
||||
|
||||
public BookContentBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public BookContentBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"BOOK_CONTENT_BEAN\" (" + //
|
||||
"\"DUR_CHAPTER_URL\" TEXT PRIMARY KEY NOT NULL ," + // 0: durChapterUrl
|
||||
"\"DUR_CHAPTER_INDEX\" INTEGER NOT NULL ," + // 1: durChapterIndex
|
||||
"\"DUR_CAPTER_CONTENT\" TEXT," + // 2: durCapterContent
|
||||
"\"TAG\" TEXT);"); // 3: tag
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOK_CONTENT_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, BookContentBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(1, durChapterUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durCapterContent = entity.getDurCapterContent();
|
||||
if (durCapterContent != null) {
|
||||
stmt.bindString(3, durCapterContent);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(4, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, BookContentBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(1, durChapterUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durCapterContent = entity.getDurCapterContent();
|
||||
if (durCapterContent != null) {
|
||||
stmt.bindString(3, durCapterContent);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(4, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookContentBean readEntity(Cursor cursor, int offset) {
|
||||
BookContentBean entity = new BookContentBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // durChapterUrl
|
||||
cursor.getInt(offset + 1), // durChapterIndex
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // durCapterContent
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // tag
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, BookContentBean entity, int offset) {
|
||||
entity.setDurChapterUrl(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
|
||||
entity.setDurChapterIndex(cursor.getInt(offset + 1));
|
||||
entity.setDurCapterContent(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setTag(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String updateKeyAfterInsert(BookContentBean entity, long rowId) {
|
||||
return entity.getDurChapterUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(BookContentBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getDurChapterUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,213 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.BookInfoBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "BOOK_INFO_BEAN".
|
||||
*/
|
||||
public class BookInfoBeanDao extends AbstractDao<BookInfoBean, String> {
|
||||
|
||||
public static final String TABLENAME = "BOOK_INFO_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity BookInfoBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Name = new Property(0, String.class, "name", false, "NAME");
|
||||
public final static Property Tag = new Property(1, String.class, "tag", false, "TAG");
|
||||
public final static Property NoteUrl = new Property(2, String.class, "noteUrl", true, "NOTE_URL");
|
||||
public final static Property ChapterUrl = new Property(3, String.class, "chapterUrl", false, "CHAPTER_URL");
|
||||
public final static Property FinalRefreshData = new Property(4, long.class, "finalRefreshData", false, "FINAL_REFRESH_DATA");
|
||||
public final static Property CoverUrl = new Property(5, String.class, "coverUrl", false, "COVER_URL");
|
||||
public final static Property Author = new Property(6, String.class, "author", false, "AUTHOR");
|
||||
public final static Property Introduce = new Property(7, String.class, "introduce", false, "INTRODUCE");
|
||||
public final static Property Origin = new Property(8, String.class, "origin", false, "ORIGIN");
|
||||
};
|
||||
|
||||
|
||||
public BookInfoBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public BookInfoBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"BOOK_INFO_BEAN\" (" + //
|
||||
"\"NAME\" TEXT," + // 0: name
|
||||
"\"TAG\" TEXT," + // 1: tag
|
||||
"\"NOTE_URL\" TEXT PRIMARY KEY NOT NULL ," + // 2: noteUrl
|
||||
"\"CHAPTER_URL\" TEXT," + // 3: chapterUrl
|
||||
"\"FINAL_REFRESH_DATA\" INTEGER NOT NULL ," + // 4: finalRefreshData
|
||||
"\"COVER_URL\" TEXT," + // 5: coverUrl
|
||||
"\"AUTHOR\" TEXT," + // 6: author
|
||||
"\"INTRODUCE\" TEXT," + // 7: introduce
|
||||
"\"ORIGIN\" TEXT);"); // 8: origin
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOK_INFO_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, BookInfoBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String name = entity.getName();
|
||||
if (name != null) {
|
||||
stmt.bindString(1, name);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(2, tag);
|
||||
}
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(3, noteUrl);
|
||||
}
|
||||
|
||||
String chapterUrl = entity.getChapterUrl();
|
||||
if (chapterUrl != null) {
|
||||
stmt.bindString(4, chapterUrl);
|
||||
}
|
||||
stmt.bindLong(5, entity.getFinalRefreshData());
|
||||
|
||||
String coverUrl = entity.getCoverUrl();
|
||||
if (coverUrl != null) {
|
||||
stmt.bindString(6, coverUrl);
|
||||
}
|
||||
|
||||
String author = entity.getAuthor();
|
||||
if (author != null) {
|
||||
stmt.bindString(7, author);
|
||||
}
|
||||
|
||||
String introduce = entity.getIntroduce();
|
||||
if (introduce != null) {
|
||||
stmt.bindString(8, introduce);
|
||||
}
|
||||
|
||||
String origin = entity.getOrigin();
|
||||
if (origin != null) {
|
||||
stmt.bindString(9, origin);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, BookInfoBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String name = entity.getName();
|
||||
if (name != null) {
|
||||
stmt.bindString(1, name);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(2, tag);
|
||||
}
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(3, noteUrl);
|
||||
}
|
||||
|
||||
String chapterUrl = entity.getChapterUrl();
|
||||
if (chapterUrl != null) {
|
||||
stmt.bindString(4, chapterUrl);
|
||||
}
|
||||
stmt.bindLong(5, entity.getFinalRefreshData());
|
||||
|
||||
String coverUrl = entity.getCoverUrl();
|
||||
if (coverUrl != null) {
|
||||
stmt.bindString(6, coverUrl);
|
||||
}
|
||||
|
||||
String author = entity.getAuthor();
|
||||
if (author != null) {
|
||||
stmt.bindString(7, author);
|
||||
}
|
||||
|
||||
String introduce = entity.getIntroduce();
|
||||
if (introduce != null) {
|
||||
stmt.bindString(8, introduce);
|
||||
}
|
||||
|
||||
String origin = entity.getOrigin();
|
||||
if (origin != null) {
|
||||
stmt.bindString(9, origin);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookInfoBean readEntity(Cursor cursor, int offset) {
|
||||
BookInfoBean entity = new BookInfoBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // name
|
||||
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // tag
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // noteUrl
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // chapterUrl
|
||||
cursor.getLong(offset + 4), // finalRefreshData
|
||||
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // coverUrl
|
||||
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // author
|
||||
cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // introduce
|
||||
cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // origin
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, BookInfoBean entity, int offset) {
|
||||
entity.setName(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
|
||||
entity.setTag(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
|
||||
entity.setNoteUrl(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setChapterUrl(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setFinalRefreshData(cursor.getLong(offset + 4));
|
||||
entity.setCoverUrl(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
|
||||
entity.setAuthor(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
|
||||
entity.setIntroduce(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
|
||||
entity.setOrigin(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String updateKeyAfterInsert(BookInfoBean entity, long rowId) {
|
||||
return entity.getNoteUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(BookInfoBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getNoteUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "BOOK_SHELF_BEAN".
|
||||
*/
|
||||
public class BookShelfBeanDao extends AbstractDao<BookShelfBean, String> {
|
||||
|
||||
public static final String TABLENAME = "BOOK_SHELF_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity BookShelfBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property NoteUrl = new Property(0, String.class, "noteUrl", true, "NOTE_URL");
|
||||
public final static Property DurChapter = new Property(1, int.class, "durChapter", false, "DUR_CHAPTER");
|
||||
public final static Property DurChapterPage = new Property(2, int.class, "durChapterPage", false, "DUR_CHAPTER_PAGE");
|
||||
public final static Property FinalDate = new Property(3, long.class, "finalDate", false, "FINAL_DATE");
|
||||
public final static Property Tag = new Property(4, String.class, "tag", false, "TAG");
|
||||
};
|
||||
|
||||
|
||||
public BookShelfBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public BookShelfBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"BOOK_SHELF_BEAN\" (" + //
|
||||
"\"NOTE_URL\" TEXT PRIMARY KEY NOT NULL ," + // 0: noteUrl
|
||||
"\"DUR_CHAPTER\" INTEGER NOT NULL ," + // 1: durChapter
|
||||
"\"DUR_CHAPTER_PAGE\" INTEGER NOT NULL ," + // 2: durChapterPage
|
||||
"\"FINAL_DATE\" INTEGER NOT NULL ," + // 3: finalDate
|
||||
"\"TAG\" TEXT);"); // 4: tag
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"BOOK_SHELF_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, BookShelfBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapter());
|
||||
stmt.bindLong(3, entity.getDurChapterPage());
|
||||
stmt.bindLong(4, entity.getFinalDate());
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, BookShelfBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapter());
|
||||
stmt.bindLong(3, entity.getDurChapterPage());
|
||||
stmt.bindLong(4, entity.getFinalDate());
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookShelfBean readEntity(Cursor cursor, int offset) {
|
||||
BookShelfBean entity = new BookShelfBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // noteUrl
|
||||
cursor.getInt(offset + 1), // durChapter
|
||||
cursor.getInt(offset + 2), // durChapterPage
|
||||
cursor.getLong(offset + 3), // finalDate
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4) // tag
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, BookShelfBean entity, int offset) {
|
||||
entity.setNoteUrl(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
|
||||
entity.setDurChapter(cursor.getInt(offset + 1));
|
||||
entity.setDurChapterPage(cursor.getInt(offset + 2));
|
||||
entity.setFinalDate(cursor.getLong(offset + 3));
|
||||
entity.setTag(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String updateKeyAfterInsert(BookShelfBean entity, long rowId) {
|
||||
return entity.getNoteUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(BookShelfBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getNoteUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,171 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.ChapterListBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "CHAPTER_LIST_BEAN".
|
||||
*/
|
||||
public class ChapterListBeanDao extends AbstractDao<ChapterListBean, String> {
|
||||
|
||||
public static final String TABLENAME = "CHAPTER_LIST_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity ChapterListBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property NoteUrl = new Property(0, String.class, "noteUrl", false, "NOTE_URL");
|
||||
public final static Property DurChapterIndex = new Property(1, int.class, "durChapterIndex", false, "DUR_CHAPTER_INDEX");
|
||||
public final static Property DurChapterUrl = new Property(2, String.class, "durChapterUrl", true, "DUR_CHAPTER_URL");
|
||||
public final static Property DurChapterName = new Property(3, String.class, "durChapterName", false, "DUR_CHAPTER_NAME");
|
||||
public final static Property Tag = new Property(4, String.class, "tag", false, "TAG");
|
||||
public final static Property HasCache = new Property(5, Boolean.class, "hasCache", false, "HAS_CACHE");
|
||||
};
|
||||
|
||||
|
||||
public ChapterListBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public ChapterListBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"CHAPTER_LIST_BEAN\" (" + //
|
||||
"\"NOTE_URL\" TEXT," + // 0: noteUrl
|
||||
"\"DUR_CHAPTER_INDEX\" INTEGER NOT NULL ," + // 1: durChapterIndex
|
||||
"\"DUR_CHAPTER_URL\" TEXT PRIMARY KEY NOT NULL ," + // 2: durChapterUrl
|
||||
"\"DUR_CHAPTER_NAME\" TEXT," + // 3: durChapterName
|
||||
"\"TAG\" TEXT," + // 4: tag
|
||||
"\"HAS_CACHE\" INTEGER);"); // 5: hasCache
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CHAPTER_LIST_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, ChapterListBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(3, durChapterUrl);
|
||||
}
|
||||
|
||||
String durChapterName = entity.getDurChapterName();
|
||||
if (durChapterName != null) {
|
||||
stmt.bindString(4, durChapterName);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
|
||||
Boolean hasCache = entity.getHasCache();
|
||||
if (hasCache != null) {
|
||||
stmt.bindLong(6, hasCache ? 1L: 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, ChapterListBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(3, durChapterUrl);
|
||||
}
|
||||
|
||||
String durChapterName = entity.getDurChapterName();
|
||||
if (durChapterName != null) {
|
||||
stmt.bindString(4, durChapterName);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
|
||||
Boolean hasCache = entity.getHasCache();
|
||||
if (hasCache != null) {
|
||||
stmt.bindLong(6, hasCache ? 1L: 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChapterListBean readEntity(Cursor cursor, int offset) {
|
||||
ChapterListBean entity = new ChapterListBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // noteUrl
|
||||
cursor.getInt(offset + 1), // durChapterIndex
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // durChapterUrl
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // durChapterName
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // tag
|
||||
cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0 // hasCache
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, ChapterListBean entity, int offset) {
|
||||
entity.setNoteUrl(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
|
||||
entity.setDurChapterIndex(cursor.getInt(offset + 1));
|
||||
entity.setDurChapterUrl(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setDurChapterName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setTag(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
entity.setHasCache(cursor.isNull(offset + 5) ? null : cursor.getShort(offset + 5) != 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String updateKeyAfterInsert(ChapterListBean entity, long rowId) {
|
||||
return entity.getDurChapterUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(ChapterListBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getDurChapterUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDaoMaster;
|
||||
import org.greenrobot.greendao.database.StandardDatabase;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseOpenHelper;
|
||||
import org.greenrobot.greendao.identityscope.IdentityScopeType;
|
||||
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* Master of DAO (schema version 1): knows all DAOs.
|
||||
*/
|
||||
public class DaoMaster extends AbstractDaoMaster {
|
||||
public static final int SCHEMA_VERSION = 1;
|
||||
|
||||
/** Creates underlying database table using DAOs. */
|
||||
public static void createAllTables(Database db, boolean ifNotExists) {
|
||||
BookContentBeanDao.createTable(db, ifNotExists);
|
||||
BookInfoBeanDao.createTable(db, ifNotExists);
|
||||
BookShelfBeanDao.createTable(db, ifNotExists);
|
||||
ChapterListBeanDao.createTable(db, ifNotExists);
|
||||
DownloadChapterBeanDao.createTable(db, ifNotExists);
|
||||
SearchHistoryBeanDao.createTable(db, ifNotExists);
|
||||
}
|
||||
|
||||
/** Drops underlying database table using DAOs. */
|
||||
public static void dropAllTables(Database db, boolean ifExists) {
|
||||
BookContentBeanDao.dropTable(db, ifExists);
|
||||
BookInfoBeanDao.dropTable(db, ifExists);
|
||||
BookShelfBeanDao.dropTable(db, ifExists);
|
||||
ChapterListBeanDao.dropTable(db, ifExists);
|
||||
DownloadChapterBeanDao.dropTable(db, ifExists);
|
||||
SearchHistoryBeanDao.dropTable(db, ifExists);
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: Drops all table on Upgrade! Use only during development.
|
||||
* Convenience method using a {@link DevOpenHelper}.
|
||||
*/
|
||||
public static DaoSession newDevSession(Context context, String name) {
|
||||
Database db = new DevOpenHelper(context, name).getWritableDb();
|
||||
DaoMaster daoMaster = new DaoMaster(db);
|
||||
return daoMaster.newSession();
|
||||
}
|
||||
|
||||
public DaoMaster(SQLiteDatabase db) {
|
||||
this(new StandardDatabase(db));
|
||||
}
|
||||
|
||||
public DaoMaster(Database db) {
|
||||
super(db, SCHEMA_VERSION);
|
||||
registerDaoClass(BookContentBeanDao.class);
|
||||
registerDaoClass(BookInfoBeanDao.class);
|
||||
registerDaoClass(BookShelfBeanDao.class);
|
||||
registerDaoClass(ChapterListBeanDao.class);
|
||||
registerDaoClass(DownloadChapterBeanDao.class);
|
||||
registerDaoClass(SearchHistoryBeanDao.class);
|
||||
}
|
||||
|
||||
public DaoSession newSession() {
|
||||
return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
|
||||
}
|
||||
|
||||
public DaoSession newSession(IdentityScopeType type) {
|
||||
return new DaoSession(db, type, daoConfigMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #createAllTables(Database, boolean)} in {@link #onCreate(Database)} -
|
||||
*/
|
||||
public static abstract class OpenHelper extends DatabaseOpenHelper {
|
||||
public OpenHelper(Context context, String name) {
|
||||
super(context, name, SCHEMA_VERSION);
|
||||
}
|
||||
|
||||
public OpenHelper(Context context, String name, CursorFactory factory) {
|
||||
super(context, name, factory, SCHEMA_VERSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Database db) {
|
||||
Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
|
||||
createAllTables(db, false);
|
||||
}
|
||||
}
|
||||
|
||||
/** WARNING: Drops all table on Upgrade! Use only during development. */
|
||||
public static class DevOpenHelper extends OpenHelper {
|
||||
public DevOpenHelper(Context context, String name) {
|
||||
super(context, name);
|
||||
}
|
||||
|
||||
public DevOpenHelper(Context context, String name, CursorFactory factory) {
|
||||
super(context, name, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(Database db, int oldVersion, int newVersion) {
|
||||
Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
|
||||
dropAllTables(db, true);
|
||||
onCreate(db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.AbstractDaoSession;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.identityscope.IdentityScopeType;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookInfoBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.ChapterListBean;
|
||||
import com.monke.monkeybook.bean.DownloadChapterBean;
|
||||
import com.monke.monkeybook.bean.SearchHistoryBean;
|
||||
|
||||
import com.monke.monkeybook.dao.BookContentBeanDao;
|
||||
import com.monke.monkeybook.dao.BookInfoBeanDao;
|
||||
import com.monke.monkeybook.dao.BookShelfBeanDao;
|
||||
import com.monke.monkeybook.dao.ChapterListBeanDao;
|
||||
import com.monke.monkeybook.dao.DownloadChapterBeanDao;
|
||||
import com.monke.monkeybook.dao.SearchHistoryBeanDao;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @see org.greenrobot.greendao.AbstractDaoSession
|
||||
*/
|
||||
public class DaoSession extends AbstractDaoSession {
|
||||
|
||||
private final DaoConfig bookContentBeanDaoConfig;
|
||||
private final DaoConfig bookInfoBeanDaoConfig;
|
||||
private final DaoConfig bookShelfBeanDaoConfig;
|
||||
private final DaoConfig chapterListBeanDaoConfig;
|
||||
private final DaoConfig downloadChapterBeanDaoConfig;
|
||||
private final DaoConfig searchHistoryBeanDaoConfig;
|
||||
|
||||
private final BookContentBeanDao bookContentBeanDao;
|
||||
private final BookInfoBeanDao bookInfoBeanDao;
|
||||
private final BookShelfBeanDao bookShelfBeanDao;
|
||||
private final ChapterListBeanDao chapterListBeanDao;
|
||||
private final DownloadChapterBeanDao downloadChapterBeanDao;
|
||||
private final SearchHistoryBeanDao searchHistoryBeanDao;
|
||||
|
||||
public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
|
||||
daoConfigMap) {
|
||||
super(db);
|
||||
|
||||
bookContentBeanDaoConfig = daoConfigMap.get(BookContentBeanDao.class).clone();
|
||||
bookContentBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
bookInfoBeanDaoConfig = daoConfigMap.get(BookInfoBeanDao.class).clone();
|
||||
bookInfoBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
bookShelfBeanDaoConfig = daoConfigMap.get(BookShelfBeanDao.class).clone();
|
||||
bookShelfBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
chapterListBeanDaoConfig = daoConfigMap.get(ChapterListBeanDao.class).clone();
|
||||
chapterListBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
downloadChapterBeanDaoConfig = daoConfigMap.get(DownloadChapterBeanDao.class).clone();
|
||||
downloadChapterBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
searchHistoryBeanDaoConfig = daoConfigMap.get(SearchHistoryBeanDao.class).clone();
|
||||
searchHistoryBeanDaoConfig.initIdentityScope(type);
|
||||
|
||||
bookContentBeanDao = new BookContentBeanDao(bookContentBeanDaoConfig, this);
|
||||
bookInfoBeanDao = new BookInfoBeanDao(bookInfoBeanDaoConfig, this);
|
||||
bookShelfBeanDao = new BookShelfBeanDao(bookShelfBeanDaoConfig, this);
|
||||
chapterListBeanDao = new ChapterListBeanDao(chapterListBeanDaoConfig, this);
|
||||
downloadChapterBeanDao = new DownloadChapterBeanDao(downloadChapterBeanDaoConfig, this);
|
||||
searchHistoryBeanDao = new SearchHistoryBeanDao(searchHistoryBeanDaoConfig, this);
|
||||
|
||||
registerDao(BookContentBean.class, bookContentBeanDao);
|
||||
registerDao(BookInfoBean.class, bookInfoBeanDao);
|
||||
registerDao(BookShelfBean.class, bookShelfBeanDao);
|
||||
registerDao(ChapterListBean.class, chapterListBeanDao);
|
||||
registerDao(DownloadChapterBean.class, downloadChapterBeanDao);
|
||||
registerDao(SearchHistoryBean.class, searchHistoryBeanDao);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
bookContentBeanDaoConfig.getIdentityScope().clear();
|
||||
bookInfoBeanDaoConfig.getIdentityScope().clear();
|
||||
bookShelfBeanDaoConfig.getIdentityScope().clear();
|
||||
chapterListBeanDaoConfig.getIdentityScope().clear();
|
||||
downloadChapterBeanDaoConfig.getIdentityScope().clear();
|
||||
searchHistoryBeanDaoConfig.getIdentityScope().clear();
|
||||
}
|
||||
|
||||
public BookContentBeanDao getBookContentBeanDao() {
|
||||
return bookContentBeanDao;
|
||||
}
|
||||
|
||||
public BookInfoBeanDao getBookInfoBeanDao() {
|
||||
return bookInfoBeanDao;
|
||||
}
|
||||
|
||||
public BookShelfBeanDao getBookShelfBeanDao() {
|
||||
return bookShelfBeanDao;
|
||||
}
|
||||
|
||||
public ChapterListBeanDao getChapterListBeanDao() {
|
||||
return chapterListBeanDao;
|
||||
}
|
||||
|
||||
public DownloadChapterBeanDao getDownloadChapterBeanDao() {
|
||||
return downloadChapterBeanDao;
|
||||
}
|
||||
|
||||
public SearchHistoryBeanDao getSearchHistoryBeanDao() {
|
||||
return searchHistoryBeanDao;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.DownloadChapterBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "DOWNLOAD_CHAPTER_BEAN".
|
||||
*/
|
||||
public class DownloadChapterBeanDao extends AbstractDao<DownloadChapterBean, String> {
|
||||
|
||||
public static final String TABLENAME = "DOWNLOAD_CHAPTER_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity DownloadChapterBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property NoteUrl = new Property(0, String.class, "noteUrl", false, "NOTE_URL");
|
||||
public final static Property DurChapterIndex = new Property(1, int.class, "durChapterIndex", false, "DUR_CHAPTER_INDEX");
|
||||
public final static Property DurChapterUrl = new Property(2, String.class, "durChapterUrl", true, "DUR_CHAPTER_URL");
|
||||
public final static Property DurChapterName = new Property(3, String.class, "durChapterName", false, "DUR_CHAPTER_NAME");
|
||||
public final static Property Tag = new Property(4, String.class, "tag", false, "TAG");
|
||||
public final static Property BookName = new Property(5, String.class, "bookName", false, "BOOK_NAME");
|
||||
public final static Property CoverUrl = new Property(6, String.class, "coverUrl", false, "COVER_URL");
|
||||
};
|
||||
|
||||
|
||||
public DownloadChapterBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public DownloadChapterBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"DOWNLOAD_CHAPTER_BEAN\" (" + //
|
||||
"\"NOTE_URL\" TEXT," + // 0: noteUrl
|
||||
"\"DUR_CHAPTER_INDEX\" INTEGER NOT NULL ," + // 1: durChapterIndex
|
||||
"\"DUR_CHAPTER_URL\" TEXT PRIMARY KEY NOT NULL ," + // 2: durChapterUrl
|
||||
"\"DUR_CHAPTER_NAME\" TEXT," + // 3: durChapterName
|
||||
"\"TAG\" TEXT," + // 4: tag
|
||||
"\"BOOK_NAME\" TEXT," + // 5: bookName
|
||||
"\"COVER_URL\" TEXT);"); // 6: coverUrl
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"DOWNLOAD_CHAPTER_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, DownloadChapterBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(3, durChapterUrl);
|
||||
}
|
||||
|
||||
String durChapterName = entity.getDurChapterName();
|
||||
if (durChapterName != null) {
|
||||
stmt.bindString(4, durChapterName);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
|
||||
String bookName = entity.getBookName();
|
||||
if (bookName != null) {
|
||||
stmt.bindString(6, bookName);
|
||||
}
|
||||
|
||||
String coverUrl = entity.getCoverUrl();
|
||||
if (coverUrl != null) {
|
||||
stmt.bindString(7, coverUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, DownloadChapterBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
String noteUrl = entity.getNoteUrl();
|
||||
if (noteUrl != null) {
|
||||
stmt.bindString(1, noteUrl);
|
||||
}
|
||||
stmt.bindLong(2, entity.getDurChapterIndex());
|
||||
|
||||
String durChapterUrl = entity.getDurChapterUrl();
|
||||
if (durChapterUrl != null) {
|
||||
stmt.bindString(3, durChapterUrl);
|
||||
}
|
||||
|
||||
String durChapterName = entity.getDurChapterName();
|
||||
if (durChapterName != null) {
|
||||
stmt.bindString(4, durChapterName);
|
||||
}
|
||||
|
||||
String tag = entity.getTag();
|
||||
if (tag != null) {
|
||||
stmt.bindString(5, tag);
|
||||
}
|
||||
|
||||
String bookName = entity.getBookName();
|
||||
if (bookName != null) {
|
||||
stmt.bindString(6, bookName);
|
||||
}
|
||||
|
||||
String coverUrl = entity.getCoverUrl();
|
||||
if (coverUrl != null) {
|
||||
stmt.bindString(7, coverUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DownloadChapterBean readEntity(Cursor cursor, int offset) {
|
||||
DownloadChapterBean entity = new DownloadChapterBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // noteUrl
|
||||
cursor.getInt(offset + 1), // durChapterIndex
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // durChapterUrl
|
||||
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // durChapterName
|
||||
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // tag
|
||||
cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // bookName
|
||||
cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // coverUrl
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, DownloadChapterBean entity, int offset) {
|
||||
entity.setNoteUrl(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
|
||||
entity.setDurChapterIndex(cursor.getInt(offset + 1));
|
||||
entity.setDurChapterUrl(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setDurChapterName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
|
||||
entity.setTag(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
|
||||
entity.setBookName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
|
||||
entity.setCoverUrl(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final String updateKeyAfterInsert(DownloadChapterBean entity, long rowId) {
|
||||
return entity.getDurChapterUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey(DownloadChapterBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getDurChapterUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,136 @@
|
||||
package com.monke.monkeybook.dao;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteStatement;
|
||||
|
||||
import org.greenrobot.greendao.AbstractDao;
|
||||
import org.greenrobot.greendao.Property;
|
||||
import org.greenrobot.greendao.internal.DaoConfig;
|
||||
import org.greenrobot.greendao.database.Database;
|
||||
import org.greenrobot.greendao.database.DatabaseStatement;
|
||||
|
||||
import com.monke.monkeybook.bean.SearchHistoryBean;
|
||||
|
||||
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
|
||||
/**
|
||||
* DAO for table "SEARCH_HISTORY_BEAN".
|
||||
*/
|
||||
public class SearchHistoryBeanDao extends AbstractDao<SearchHistoryBean, Long> {
|
||||
|
||||
public static final String TABLENAME = "SEARCH_HISTORY_BEAN";
|
||||
|
||||
/**
|
||||
* Properties of entity SearchHistoryBean.<br/>
|
||||
* Can be used for QueryBuilder and for referencing column names.
|
||||
*/
|
||||
public static class Properties {
|
||||
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
|
||||
public final static Property Type = new Property(1, int.class, "type", false, "TYPE");
|
||||
public final static Property Content = new Property(2, String.class, "content", false, "CONTENT");
|
||||
public final static Property Date = new Property(3, long.class, "date", false, "DATE");
|
||||
};
|
||||
|
||||
|
||||
public SearchHistoryBeanDao(DaoConfig config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
public SearchHistoryBeanDao(DaoConfig config, DaoSession daoSession) {
|
||||
super(config, daoSession);
|
||||
}
|
||||
|
||||
/** Creates the underlying database table. */
|
||||
public static void createTable(Database db, boolean ifNotExists) {
|
||||
String constraint = ifNotExists? "IF NOT EXISTS ": "";
|
||||
db.execSQL("CREATE TABLE " + constraint + "\"SEARCH_HISTORY_BEAN\" (" + //
|
||||
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
|
||||
"\"TYPE\" INTEGER NOT NULL ," + // 1: type
|
||||
"\"CONTENT\" TEXT," + // 2: content
|
||||
"\"DATE\" INTEGER NOT NULL );"); // 3: date
|
||||
}
|
||||
|
||||
/** Drops the underlying database table. */
|
||||
public static void dropTable(Database db, boolean ifExists) {
|
||||
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"SEARCH_HISTORY_BEAN\"";
|
||||
db.execSQL(sql);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(DatabaseStatement stmt, SearchHistoryBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
Long id = entity.getId();
|
||||
if (id != null) {
|
||||
stmt.bindLong(1, id);
|
||||
}
|
||||
stmt.bindLong(2, entity.getType());
|
||||
|
||||
String content = entity.getContent();
|
||||
if (content != null) {
|
||||
stmt.bindString(3, content);
|
||||
}
|
||||
stmt.bindLong(4, entity.getDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void bindValues(SQLiteStatement stmt, SearchHistoryBean entity) {
|
||||
stmt.clearBindings();
|
||||
|
||||
Long id = entity.getId();
|
||||
if (id != null) {
|
||||
stmt.bindLong(1, id);
|
||||
}
|
||||
stmt.bindLong(2, entity.getType());
|
||||
|
||||
String content = entity.getContent();
|
||||
if (content != null) {
|
||||
stmt.bindString(3, content);
|
||||
}
|
||||
stmt.bindLong(4, entity.getDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long readKey(Cursor cursor, int offset) {
|
||||
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchHistoryBean readEntity(Cursor cursor, int offset) {
|
||||
SearchHistoryBean entity = new SearchHistoryBean( //
|
||||
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
|
||||
cursor.getInt(offset + 1), // type
|
||||
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // content
|
||||
cursor.getLong(offset + 3) // date
|
||||
);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntity(Cursor cursor, SearchHistoryBean entity, int offset) {
|
||||
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
|
||||
entity.setType(cursor.getInt(offset + 1));
|
||||
entity.setContent(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
|
||||
entity.setDate(cursor.getLong(offset + 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Long updateKeyAfterInsert(SearchHistoryBean entity, long rowId) {
|
||||
entity.setId(rowId);
|
||||
return rowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getKey(SearchHistoryBean entity) {
|
||||
if(entity != null) {
|
||||
return entity.getId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final boolean isEntityUpdateable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.monke.monkeybook.listener;
|
||||
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
|
||||
public interface OnGetChapterListListener {
|
||||
public void success(BookShelfBean bookShelfBean);
|
||||
public void error();
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.LibraryBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.cache.ACache;
|
||||
import com.monke.monkeybook.listener.OnGetChapterListListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface IEasouBookModel {
|
||||
/**
|
||||
* 搜索书籍
|
||||
*/
|
||||
public Observable<List<SearchBookBean>> searchBook(String content, int page, int rankKind);
|
||||
|
||||
/**
|
||||
* 网络请求并解析书籍信息
|
||||
*/
|
||||
public Observable<BookShelfBean> getBookInfo(final BookShelfBean bookShelfBean);
|
||||
|
||||
/**
|
||||
* 网络解析图书目录
|
||||
*/
|
||||
public void getChapterList(final BookShelfBean bookShelfBean, OnGetChapterListListener getChapterListListener);
|
||||
|
||||
/**
|
||||
* 章节缓存
|
||||
*/
|
||||
Observable<BookContentBean> getBookContent(final String durChapterUrl, final int durChapterIndex);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
import com.monke.monkeybook.bean.LibraryBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.cache.ACache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface IGxwztvBookModel extends IStationBookModel {
|
||||
|
||||
public Observable<List<SearchBookBean>> getKindBook(String url, int page);
|
||||
|
||||
/**
|
||||
* 获取主页信息
|
||||
*/
|
||||
public Observable<LibraryBean> getLibraryData(ACache aCache);
|
||||
|
||||
/**
|
||||
* 解析主页数据
|
||||
*/
|
||||
public Observable<LibraryBean> analyLibraryData(String data);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.LocBookShelfBean;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface IImportBookModel {
|
||||
|
||||
Observable<LocBookShelfBean> importBook(File book);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.listener.OnGetChapterListListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface IStationBookModel {
|
||||
|
||||
/**
|
||||
* 搜索书籍
|
||||
*/
|
||||
public Observable<List<SearchBookBean>> searchBook(String content, int page);
|
||||
|
||||
/**
|
||||
* 网络请求并解析书籍信息
|
||||
*/
|
||||
public Observable<BookShelfBean> getBookInfo(final BookShelfBean bookShelfBean);
|
||||
|
||||
/**
|
||||
* 网络解析图书目录
|
||||
*/
|
||||
public void getChapterList(final BookShelfBean bookShelfBean, OnGetChapterListListener getChapterListListener);
|
||||
|
||||
/**
|
||||
* 章节缓存
|
||||
*/
|
||||
Observable<BookContentBean> getBookContent(final String durChapterUrl, final int durChapterIndex);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.listener.OnGetChapterListListener;
|
||||
import java.util.List;
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface IWebBookModel {
|
||||
/**
|
||||
* 网络请求并解析书籍信息
|
||||
*/
|
||||
public Observable<BookShelfBean> getBookInfo(final BookShelfBean bookShelfBean);
|
||||
|
||||
/**
|
||||
* 网络解析图书目录
|
||||
*/
|
||||
public void getChapterList(final BookShelfBean bookShelfBean,OnGetChapterListListener getChapterListListener);
|
||||
|
||||
/**
|
||||
* 章节缓存
|
||||
*/
|
||||
public Observable<BookContentBean> getBookContent(final String durChapterUrl, final int durChapterIndex, String tag);
|
||||
|
||||
/**
|
||||
* 搜索书籍
|
||||
*/
|
||||
public Observable<List<SearchBookBean>> searchBook(String content, int page,int rankKind);
|
||||
|
||||
/**
|
||||
* 获取分类书籍
|
||||
*/
|
||||
public Observable<List<SearchBookBean>> getKindBook(String url,int page);
|
||||
/**
|
||||
* 其他站点资源整合搜索
|
||||
*/
|
||||
public Observable<List<SearchBookBean>> searchOtherBook(String content,int page,String tag);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.monke.monkeybook.model;
|
||||
|
||||
public interface IWebContentModel {
|
||||
|
||||
public String analyBookcontent(String s,String realUrl) throws Exception;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.monke.monkeybook.model.impl;
|
||||
|
||||
import com.monke.monkeybook.model.IWebContentModel;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
||||
public class ContentShulouModelImpl implements IWebContentModel{
|
||||
public static final String TAG = "http://www.shulou.cc";
|
||||
|
||||
public static ContentShulouModelImpl getInstance(){
|
||||
return new ContentShulouModelImpl();
|
||||
}
|
||||
private ContentShulouModelImpl(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String analyBookcontent(String s, String realUrl) throws Exception{
|
||||
Document doc = Jsoup.parse(s);
|
||||
Element contentE = doc.getElementById("content");
|
||||
String contentString = contentE.toString();
|
||||
contentString = contentString.replaceAll(" ", "").replaceAll("\n", "").replaceAll(" ", "").replaceAll("<divid=\"content\">", "").replaceAll("</div>", "").replaceAll("<p></p>","").replaceAll("<br><br>", "\r\n\u3000\u3000");
|
||||
contentString = "\u3000\u3000" + contentString;
|
||||
return contentString;
|
||||
}
|
||||
}
|
@ -0,0 +1,555 @@
|
||||
package com.monke.monkeybook.model.impl;
|
||||
|
||||
import com.monke.basemvplib.impl.BaseModelImpl;
|
||||
import com.monke.monkeybook.ErrorAnalyContentManager;
|
||||
import com.monke.monkeybook.base.observer.SimpleObserver;
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookInfoBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.ChapterListBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.bean.WebChapterBean;
|
||||
import com.monke.monkeybook.common.api.IEasouApi;
|
||||
import com.monke.monkeybook.listener.OnGetChapterListListener;
|
||||
import com.monke.monkeybook.model.IEasouBookModel;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class EasouBookModelImpl extends BaseModelImpl implements IEasouBookModel {
|
||||
public static final String TAG = "http://book.easou.com";
|
||||
|
||||
public static EasouBookModelImpl getInstance() {
|
||||
return new EasouBookModelImpl();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 搜索书籍
|
||||
*/
|
||||
@Override
|
||||
public Observable<List<SearchBookBean>> searchBook(String content, int page, int rankKind) {
|
||||
String temp = "/w/searchNovel/" + content + "_" + rankKind + "_" + page + ".html";
|
||||
return getRetrofitObject(TAG).create(IEasouApi.class).searchBook(temp).flatMap(new Function<String, ObservableSource<List<SearchBookBean>>>() {
|
||||
@Override
|
||||
public ObservableSource<List<SearchBookBean>> apply(String s) throws Exception {
|
||||
return analySearchBook(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Observable<List<SearchBookBean>> analySearchBook(final String s) {
|
||||
return Observable.create(new ObservableOnSubscribe<List<SearchBookBean>>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<List<SearchBookBean>> e) throws Exception {
|
||||
try {
|
||||
Document doc = Jsoup.parse(s);
|
||||
Elements booksE = doc.getElementsByClass("resultContent").get(0).getElementsByTag("li");
|
||||
if (null != booksE && booksE.size() > 1) {
|
||||
List<SearchBookBean> books = new ArrayList<SearchBookBean>();
|
||||
for (Element bookItem : booksE) {
|
||||
SearchBookBean item = new SearchBookBean();
|
||||
item.setTag(TAG);
|
||||
item.setAuthor(bookItem.getElementsByClass("attr").get(0).getElementsByTag("a").get(0).text());
|
||||
item.setKind(bookItem.getElementsByClass("attr").get(0).getElementsByTag("a").get(1).text());
|
||||
item.setState(bookItem.getElementsByTag("span").get(0).text());
|
||||
item.setLastChapter(bookItem.getElementsByClass("lastchapter").get(0).text());
|
||||
item.setOrigin(bookItem.getElementsByClass("source").get(0).text().replaceAll("来源:", ""));
|
||||
item.setName(bookItem.getElementsByClass("name").get(0).getElementsByClass("common").get(0).text());
|
||||
item.setNoteUrl(TAG + bookItem.getElementsByClass("name").get(0).getElementsByClass("common").get(0).attr("href"));
|
||||
item.setCoverUrl(bookItem.getElementsByTag("img").get(0).attr("src"));
|
||||
books.add(item);
|
||||
}
|
||||
e.onNext(books);
|
||||
} else {
|
||||
e.onNext(new ArrayList<SearchBookBean>());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
e.onNext(new ArrayList<SearchBookBean>());
|
||||
}
|
||||
e.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 网络请求并解析书籍信息
|
||||
* return BookShelfBean
|
||||
*/
|
||||
@Override
|
||||
public Observable<BookShelfBean> getBookInfo(final BookShelfBean bookShelfBean) {
|
||||
return getRetrofitObject(TAG).create(IEasouApi.class).getBookInfo(bookShelfBean.getNoteUrl().replace(TAG, "")).flatMap(new Function<String, ObservableSource<BookShelfBean>>() {
|
||||
@Override
|
||||
public ObservableSource<BookShelfBean> apply(String s) throws Exception {
|
||||
return analyBookInfo(s, bookShelfBean);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable<BookShelfBean> analyBookInfo(final String s, final BookShelfBean bookShelfBean) {
|
||||
return Observable.create(new ObservableOnSubscribe<BookShelfBean>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<BookShelfBean> e) throws Exception {
|
||||
bookShelfBean.setTag(TAG);
|
||||
bookShelfBean.setBookInfoBean(analyBookinfo(s, bookShelfBean.getNoteUrl()));
|
||||
e.onNext(bookShelfBean);
|
||||
e.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private BookInfoBean analyBookinfo(String s, String novelUrl) {
|
||||
BookInfoBean bookInfoBean = new BookInfoBean();
|
||||
bookInfoBean.setNoteUrl(novelUrl); //id
|
||||
bookInfoBean.setTag(TAG);
|
||||
Document doc = Jsoup.parse(s);
|
||||
Element resultE = doc.getElementsByClass("content").get(0);
|
||||
String coverUrl = resultE.getElementsByClass("imgShow").get(0).getElementsByTag("img").get(0).attr("src");
|
||||
bookInfoBean.setCoverUrl(coverUrl.startsWith("http") ? coverUrl : (TAG + coverUrl));
|
||||
bookInfoBean.setName(resultE.getElementsByClass("tit").get(1).getElementsByTag("h1").get(0).text());
|
||||
bookInfoBean.setAuthor(resultE.getElementsByClass("author").get(0).getElementsByClass("common").get(0).text());
|
||||
bookInfoBean.setIntroduce("\u3000\u3000" + resultE.getElementsByClass("desc").get(0).text().trim());
|
||||
bookInfoBean.setChapterUrl(TAG + resultE.getElementsByClass("category").get(0).getElementsByTag("a").get(0).attr("href"));
|
||||
bookInfoBean.setOrigin(resultE.getElementsByClass("attribute").get(0).getElementsByClass("source").get(0).getElementsByClass("t").get(0).text());
|
||||
return bookInfoBean;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 网络解析图书目录
|
||||
* return BookShelfBean
|
||||
*/
|
||||
@Override
|
||||
public void getChapterList(final BookShelfBean bookShelfBean, OnGetChapterListListener getChapterListListener) {
|
||||
getChapterListPage(bookShelfBean, getChapterListListener, 1);
|
||||
}
|
||||
|
||||
private void getChapterListPage(final BookShelfBean bookShelfBean, final OnGetChapterListListener getChapterListListener, final int page) {
|
||||
getRetrofitObject(TAG).create(IEasouApi.class).getChapterList(bookShelfBean.getBookInfoBean().getChapterUrl().replace(TAG, "").replace("1_", page + "_")).flatMap(new Function<String, ObservableSource<WebChapterBean<BookShelfBean>>>() {
|
||||
@Override
|
||||
public ObservableSource<WebChapterBean<BookShelfBean>> apply(String s) throws Exception {
|
||||
return analyChapterList(s, bookShelfBean, page == 1 ? true : false);
|
||||
}
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SimpleObserver<WebChapterBean<BookShelfBean>>() {
|
||||
@Override
|
||||
public void onNext(WebChapterBean<BookShelfBean> value) {
|
||||
if (value.getNext()) {
|
||||
getChapterListPage(value.getData(), getChapterListListener, page + 1);
|
||||
} else {
|
||||
if (value.getData().getBookInfoBean().getChapterlist() != null && value.getData().getBookInfoBean().getChapterlist().size() > 0) {
|
||||
for (int i = 0; i < value.getData().getBookInfoBean().getChapterlist().size(); i++) {
|
||||
int temp = i;
|
||||
for (int j = i; j < value.getData().getBookInfoBean().getChapterlist().size(); j++) {
|
||||
if (value.getData().getBookInfoBean().getChapterlist().get(temp).getDurChapterIndex() > value.getData().getBookInfoBean().getChapterlist().get(j).getDurChapterIndex()) {
|
||||
temp = j;
|
||||
}
|
||||
}
|
||||
ChapterListBean tempBean = value.getData().getBookInfoBean().getChapterlist().get(i);
|
||||
value.getData().getBookInfoBean().getChapterlist().set(i, value.getData().getBookInfoBean().getChapterlist().get(temp));
|
||||
value.getData().getBookInfoBean().getChapterlist().set(temp, tempBean);
|
||||
}
|
||||
for (int i = 0; i < value.getData().getBookInfoBean().getChapterlist().size(); i++) {
|
||||
value.getData().getBookInfoBean().getChapterlist().get(i).setDurChapterIndex(i);
|
||||
}
|
||||
}
|
||||
if (getChapterListListener != null) {
|
||||
getChapterListListener.success(value.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
if (getChapterListListener != null) {
|
||||
getChapterListListener.error();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Observable<WebChapterBean<BookShelfBean>> analyChapterList(final String s, final BookShelfBean bookShelfBean, final Boolean isFirstPage) {
|
||||
return Observable.create(new ObservableOnSubscribe<WebChapterBean<BookShelfBean>>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<WebChapterBean<BookShelfBean>> e) throws Exception {
|
||||
bookShelfBean.setTag(TAG);
|
||||
WebChapterBean<List<ChapterListBean>> temp = analyChapterlist(s, bookShelfBean.getNoteUrl(), bookShelfBean.getTag());
|
||||
if (isFirstPage) {
|
||||
bookShelfBean.getBookInfoBean().setChapterlist(temp.getData());
|
||||
} else {
|
||||
bookShelfBean.getBookInfoBean().addChapterlist(temp.getData());
|
||||
}
|
||||
e.onNext(new WebChapterBean<BookShelfBean>(bookShelfBean, temp.getNext()));
|
||||
e.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private WebChapterBean<List<ChapterListBean>> analyChapterlist(String s, String novelUrl, String chapterUrl) {
|
||||
Document doc = Jsoup.parse(s);
|
||||
Element element = doc.getElementsByClass("content").get(0);
|
||||
Elements chapterlist = element.getElementsByClass("category").get(0).getElementsByTag("li");
|
||||
List<ChapterListBean> chapterBeans = new ArrayList<ChapterListBean>();
|
||||
for (int i = 0; i < chapterlist.size(); i++) {
|
||||
ChapterListBean temp = new ChapterListBean();
|
||||
temp.setDurChapterUrl(chapterUrl + chapterlist.get(i).getElementsByTag("a").get(0).attr("href")); //id
|
||||
String name = chapterlist.get(i).getElementsByTag("a").get(0).text();
|
||||
setDurChapterData(i, name, temp);
|
||||
temp.setNoteUrl(novelUrl);
|
||||
temp.setTag(TAG);
|
||||
|
||||
chapterBeans.add(temp);
|
||||
}
|
||||
|
||||
Elements nextE = doc.getElementsByClass("pager").get(0).getElementsByClass("next unable");
|
||||
Boolean next = (nextE == null || nextE.size() <= 0) ? true : false;
|
||||
return new WebChapterBean<List<ChapterListBean>>(chapterBeans, next);
|
||||
}
|
||||
|
||||
private void setDurChapterData(int i, String name, ChapterListBean temp) {
|
||||
try {
|
||||
String regex = "第.{1,7}章";
|
||||
Pattern p = Pattern.compile(regex);
|
||||
Matcher m = p.matcher(name);
|
||||
if (m.find()) {
|
||||
String indexTemp = m.group();
|
||||
indexTemp = indexTemp.replace("第", "").replace("章", "").trim();
|
||||
String regex3 = "[0-9]{1,6}";
|
||||
Pattern p3 = Pattern.compile(regex3);
|
||||
Matcher m3 = p3.matcher(indexTemp);
|
||||
int resultIndex = i;
|
||||
if (m3.matches()) {
|
||||
resultIndex = Integer.parseInt(indexTemp);
|
||||
} else {
|
||||
resultIndex = parse(indexTemp);
|
||||
}
|
||||
temp.setDurChapterIndex(resultIndex);
|
||||
} else {
|
||||
String regex2 = "[0-9]{1,6}\\.";
|
||||
Pattern p2 = Pattern.compile(regex2);
|
||||
Matcher m2 = p2.matcher(name);
|
||||
if (m2.find()) {
|
||||
String indexTemp = m2.group();
|
||||
indexTemp = indexTemp.replaceAll("\\.", "").trim();
|
||||
int resultIndex = Integer.parseInt(indexTemp);
|
||||
temp.setDurChapterIndex(resultIndex);
|
||||
} else {
|
||||
temp.setDurChapterIndex(i);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
temp.setDurChapterIndex(i);
|
||||
}finally {
|
||||
temp.setDurChapterName(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static int parse(String money) {
|
||||
int result = 0;
|
||||
char c = 0;
|
||||
|
||||
boolean flag = Pattern.matches("^.*亿.*万.*$", money);
|
||||
|
||||
for (int i = 0; i < money.length(); i++) {
|
||||
switch (money.charAt(i)) {
|
||||
case '零':
|
||||
break;
|
||||
case '一':
|
||||
c = 1;
|
||||
break;
|
||||
case '二':
|
||||
c = 2;
|
||||
break;
|
||||
case '三':
|
||||
c = 3;
|
||||
break;
|
||||
case '四':
|
||||
c = 4;
|
||||
break;
|
||||
case '五':
|
||||
c = 5;
|
||||
break;
|
||||
case '六':
|
||||
c = 6;
|
||||
break;
|
||||
case '七':
|
||||
c = 7;
|
||||
break;
|
||||
case '八':
|
||||
c = 8;
|
||||
break;
|
||||
case '九':
|
||||
c = 9;
|
||||
break;
|
||||
case '十':
|
||||
result += (c == 0 ? 10 : c * 10);
|
||||
c = 0;
|
||||
break;
|
||||
case '百':
|
||||
result += c * 100;
|
||||
c = 0;
|
||||
break;
|
||||
case '千':
|
||||
result += c * 1000;
|
||||
c = 0;
|
||||
break;
|
||||
case '万':
|
||||
result = (result + c) * 10000;
|
||||
c = 0;
|
||||
break;
|
||||
case '亿':
|
||||
if (flag) {
|
||||
result = (result + c) * 10000;
|
||||
} else {
|
||||
result = (result + c) * 100000000;
|
||||
}
|
||||
c = 0;
|
||||
break;
|
||||
default:
|
||||
c = 0;
|
||||
}
|
||||
|
||||
}
|
||||
if (c != 0)
|
||||
result += c;
|
||||
return result;
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 章节缓存
|
||||
*/
|
||||
@Override
|
||||
public Observable<BookContentBean> getBookContent(final String durChapterUrl, final int durChapterIndex) {
|
||||
return Observable.create(new ObservableOnSubscribe<BookContentBean>() {
|
||||
@Override
|
||||
public void subscribe(final ObservableEmitter<BookContentBean> e) throws Exception {
|
||||
OkHttpClient client = clientBuilder.build();
|
||||
Request.Builder requestBuilder = new Request.Builder().url(durChapterUrl).method("GET", null);
|
||||
requestBuilder.addHeader("Accept", "text/html,application/xhtml+xml,application/xml");
|
||||
requestBuilder.addHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3");
|
||||
requestBuilder.addHeader("Accept-Charset", "UTF-8");
|
||||
requestBuilder.addHeader("Keep-Alive", "300");
|
||||
requestBuilder.addHeader("Cache-Control", "no-cache");
|
||||
requestBuilder.addHeader("Connection", "Keep-Alive");
|
||||
Call mcall = client.newCall(requestBuilder.build());
|
||||
mcall.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException ex) {
|
||||
ex.printStackTrace();
|
||||
if (!e.isDisposed()) {
|
||||
e.onError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String url = response.request().url().toString();
|
||||
BookContentBean bookContentBean = new BookContentBean();
|
||||
try {
|
||||
bookContentBean = choiceAnaly(response, url, durChapterUrl, durChapterIndex);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ErrorAnalyContentManager.getInstance().writeMayByNetError(url);
|
||||
bookContentBean = new BookContentBean();
|
||||
bookContentBean.setDurChapterIndex(durChapterIndex);
|
||||
bookContentBean.setDurChapterUrl(durChapterUrl);
|
||||
bookContentBean.setDurCapterContent(url.substring(0, url.indexOf('/', 8)) + "站点服务器异常");
|
||||
bookContentBean.setTag(TAG);
|
||||
bookContentBean.setRight(false);
|
||||
}
|
||||
if (!e.isDisposed()) {
|
||||
e.onNext(bookContentBean);
|
||||
e.onComplete();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private BookContentBean choiceAnaly(Response response, String url, String durChapterUrl, int durChapterIndex) throws Exception {
|
||||
BookContentBean bookContentBean = new BookContentBean();
|
||||
bookContentBean.setDurChapterIndex(durChapterIndex);
|
||||
bookContentBean.setDurChapterUrl(durChapterUrl);
|
||||
bookContentBean.setTag(TAG);
|
||||
if (url.contains(ContentEasouModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentEasouModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentShulouModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentShulouModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentPbtxtModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentPbtxtModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentXqingdouModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentXqingdouModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentSnwx8ModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentSnwx8ModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content17kModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(Content17kModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content92zwModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(Content92zwModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentSuimengModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentSuimengModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentKewaishuModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentKewaishuModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentWxguanModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentWxguanModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentBaishukuModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentBaishukuModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentAszwModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentAszwModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentXqingdouCCModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentXqingdouCCModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentFuheishuModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
//站点有问题 未完全解析
|
||||
bookContentBean.setDurCapterContent(ContentFuheishuModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentSyzwwModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
//站点有问题 未完全解析
|
||||
bookContentBean.setDurCapterContent(ContentSyzwwModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content630bookCCModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(Content630bookCCModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentBxwx9ModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentBxwx9ModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content44pqModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(Content44pqModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentQzreadModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentQzreadModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentLeduwoModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentLeduwoModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content17duxsModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(Content17duxsModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentDhzwModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentDhzwModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentYb3ModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentYb3ModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentZhulangModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentZhulangModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentRanwenaModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentRanwenaModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentPpxsModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GBK"));
|
||||
bookContentBean.setDurCapterContent(ContentPpxsModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentVodtwModelImpl.TAG)) {
|
||||
String xml = response.body().source().readString(Charset.forName("GB2312"));
|
||||
bookContentBean.setDurCapterContent(ContentVodtwModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentQulaModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentQulaModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(ContentLewen8ModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(ContentLewen8ModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
} else if (url.contains(Content3dllcModelImpl.TAG)) {
|
||||
String xml = response.body().string();
|
||||
bookContentBean.setDurCapterContent(Content3dllcModelImpl.getInstance().analyBookcontent(xml, url));
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
else {
|
||||
byte[] xmlData = response.body().source().readByteArray();
|
||||
String xml = new String(xmlData, "UTF-8");
|
||||
String charset = "UTF-8";
|
||||
try {
|
||||
Document doc = Jsoup.parse(xml);
|
||||
String data = doc.getElementsByTag("head").get(0).getElementsByTag("meta").get(0).attr("content").toUpperCase().trim();
|
||||
if (data.contains("CHARSET")) {
|
||||
data = data.substring(data.indexOf("CHARSET=") + 8);
|
||||
if (data.contains(";")) {
|
||||
data = data.substring(0, data.indexOf(";"));
|
||||
}
|
||||
charset = data;
|
||||
if (!charset.equals("UTF-8")) {
|
||||
xml = new String(xmlData, charset);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
bookContentBean = ContentCommendModelImpl.getInstance().analyBookcontent(bookContentBean, xml, url);
|
||||
}
|
||||
return bookContentBean;
|
||||
}
|
||||
|
||||
/*
|
||||
测试各个网站目录解析
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
EasouBookModelImpl.getInstance().getBookContent("http://www.yb3.cc/5200/3186/7426551.html", 0)
|
||||
.subscribe(new SimpleObserver<BookContentBean>() {
|
||||
@Override
|
||||
public void onNext(BookContentBean value) {
|
||||
value.getRight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
// EasouBookModelImpl.getInstance().setDurChapterData(1,"第42章学习",new ChapterListBean());
|
||||
// EasouBookModelImpl.getInstance().getLibraryData(null)
|
||||
// .subscribe(new SimpleObserver<LibraryBean>() {
|
||||
// @Override
|
||||
// public void onNext(LibraryBean value) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onError(Throwable e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.monke.monkeybook.model.impl;
|
||||
|
||||
import com.monke.monkeybook.bean.BookContentBean;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
import com.monke.monkeybook.listener.OnGetChapterListListener;
|
||||
import com.monke.monkeybook.model.IWebBookModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableEmitter;
|
||||
import io.reactivex.ObservableOnSubscribe;
|
||||
|
||||
public class WebBookModelImpl implements IWebBookModel {
|
||||
|
||||
public static WebBookModelImpl getInstance() {
|
||||
return new WebBookModelImpl();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 网络请求并解析书籍信息
|
||||
* return BookShelfBean
|
||||
*/
|
||||
@Override
|
||||
public Observable<BookShelfBean> getBookInfo(BookShelfBean bookShelfBean) {
|
||||
if (bookShelfBean.getTag().equals(EasouBookModelImpl.TAG)) {
|
||||
return EasouBookModelImpl.getInstance().getBookInfo(bookShelfBean);
|
||||
}
|
||||
else if(bookShelfBean.getTag().equals(GxwztvBookModelImpl.TAG)){
|
||||
return GxwztvBookModelImpl.getInstance().getBookInfo(bookShelfBean);
|
||||
}
|
||||
else if(bookShelfBean.getTag().equals(LingdiankanshuStationBookModelImpl.TAG)){
|
||||
return LingdiankanshuStationBookModelImpl.getInstance().getBookInfo(bookShelfBean);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 网络解析图书目录
|
||||
* return BookShelfBean
|
||||
*/
|
||||
@Override
|
||||
public void getChapterList(final BookShelfBean bookShelfBean, OnGetChapterListListener getChapterListListener) {
|
||||
if (bookShelfBean.getTag().equals(EasouBookModelImpl.TAG)) {
|
||||
EasouBookModelImpl.getInstance().getChapterList(bookShelfBean, getChapterListListener);
|
||||
}
|
||||
else if(bookShelfBean.getTag().equals(GxwztvBookModelImpl.TAG)){
|
||||
GxwztvBookModelImpl.getInstance().getChapterList(bookShelfBean, getChapterListListener);
|
||||
}
|
||||
else if(bookShelfBean.getTag().equals(LingdiankanshuStationBookModelImpl.TAG)){
|
||||
LingdiankanshuStationBookModelImpl.getInstance().getChapterList(bookShelfBean, getChapterListListener);
|
||||
}
|
||||
else{
|
||||
if(getChapterListListener!=null)
|
||||
getChapterListListener.success(bookShelfBean);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* 章节缓存
|
||||
*/
|
||||
@Override
|
||||
public Observable<BookContentBean> getBookContent(String durChapterUrl, int durChapterIndex, String tag) {
|
||||
if (tag.equals(EasouBookModelImpl.TAG)) {
|
||||
return EasouBookModelImpl.getInstance().getBookContent(durChapterUrl, durChapterIndex);
|
||||
}
|
||||
else if(tag.equals(GxwztvBookModelImpl.TAG)){
|
||||
return GxwztvBookModelImpl.getInstance().getBookContent(durChapterUrl, durChapterIndex);
|
||||
}
|
||||
else if(tag.equals(LingdiankanshuStationBookModelImpl.TAG)){
|
||||
return LingdiankanshuStationBookModelImpl.getInstance().getBookContent(durChapterUrl, durChapterIndex);
|
||||
}
|
||||
else
|
||||
return Observable.create(new ObservableOnSubscribe<BookContentBean>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<BookContentBean> e) throws Exception {
|
||||
e.onNext(new BookContentBean());
|
||||
e.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他站点集合搜索
|
||||
*/
|
||||
@Override
|
||||
public Observable<List<SearchBookBean>> searchOtherBook(String content,int page,String tag){
|
||||
if(tag.equals(EasouBookModelImpl.TAG)){
|
||||
return EasouBookModelImpl.getInstance().searchBook(content, page, 0);
|
||||
}
|
||||
else if(tag.equals(GxwztvBookModelImpl.TAG)){
|
||||
return GxwztvBookModelImpl.getInstance().searchBook(content, page);
|
||||
}
|
||||
else if(tag.equals(LingdiankanshuStationBookModelImpl.TAG)){
|
||||
return LingdiankanshuStationBookModelImpl.getInstance().searchBook(content, page);
|
||||
}
|
||||
else{
|
||||
return Observable.create(new ObservableOnSubscribe<List<SearchBookBean>>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<List<SearchBookBean>> e) throws Exception {
|
||||
e.onNext(new ArrayList<SearchBookBean>());
|
||||
e.onComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索书籍 //专用
|
||||
*/
|
||||
@Override
|
||||
public Observable<List<SearchBookBean>> searchBook(String content, int page,int rankKind) {
|
||||
return EasouBookModelImpl.getInstance().searchBook(content, page, rankKind);
|
||||
}
|
||||
/**
|
||||
* 获取分类书籍
|
||||
*/
|
||||
@Override
|
||||
public Observable<List<SearchBookBean>> getKindBook(String url,int page) {
|
||||
return GxwztvBookModelImpl.getInstance().getKindBook(url,page);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.monke.monkeybook.presenter;
|
||||
|
||||
import com.monke.basemvplib.IPresenter;
|
||||
import com.monke.monkeybook.bean.BookShelfBean;
|
||||
import com.monke.monkeybook.bean.SearchBookBean;
|
||||
|
||||
public interface IBookDetailPresenter extends IPresenter{
|
||||
|
||||
public int getOpenfrom();
|
||||
|
||||
public SearchBookBean getSearchBook();
|
||||
|
||||
public BookShelfBean getBookShelf();
|
||||
|
||||
public Boolean getInBookShelf();
|
||||
|
||||
public void getBookShelfInfo();
|
||||
|
||||
public void addToBookShelf();
|
||||
|
||||
public void removeFromBookShelf();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue