Commit 1b88063521ae298e1b8174edee4a43ece80c489c

Authored by Penley
0 parents

init gimiCinema

Showing 54 changed files with 4835 additions and 0 deletions

Too many changes to show.

To preserve performance only 54 of 54+ files are displayed.

  1 +/build
  2 +*.iml
... ...
  1 +apply plugin: 'com.android.application'
  2 +apply plugin: 'com.antfortune.freeline'
  3 +//apply plugin: 'me.tatarka.retrolambda'
  4 +
  5 +def releaseTime = {
  6 + return new Date().format("MM-dd~HH.mm.ss", TimeZone.getTimeZone("GMT+8:00"))
  7 +}
  8 +
  9 +def isWindows = {
  10 + return !(new File('build.gradle').getAbsolutePath().startsWith("/User"))
  11 +}
  12 +
  13 +ext {
  14 + APP_VERSION_CODE = 45;
  15 + APP_VERSION_NAME = "v4.5";
  16 +}
  17 +
  18 +android {
  19 + compileSdkVersion ANDROID_BUILD_COMPILE_SDK_VERSION as int
  20 + buildToolsVersion ANDROID_BUILD_TOOLS_VERSION
  21 +
  22 + lintOptions {
  23 + abortOnError false
  24 + }
  25 +
  26 + freeline {
  27 + hack true
  28 + productFlavor 'QinNing'
  29 + }
  30 +
  31 + compileOptions {
  32 + sourceCompatibility JavaVersion.VERSION_1_7
  33 + targetCompatibility JavaVersion.VERSION_1_7
  34 + }
  35 +
  36 + sourceSets {
  37 + main {
  38 + jniLibs.srcDirs = ['libs']
  39 + }
  40 + }
  41 +
  42 + packagingOptions {
  43 + exclude 'META-INF/DEPENDENCIES'
  44 + exclude 'META-INF/NOTICE'
  45 + exclude 'META-INF/LICENSE'
  46 + exclude 'META-INF/LICENSE.txt'
  47 + exclude 'META-INF/NOTICE.txt'
  48 + exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.xml'
  49 + exclude 'META-INF/maven/com.belerweb/pinyin4j/pom.properties'
  50 + return false
  51 + }
  52 +
  53 + defaultConfig {
  54 + applicationId "com.xgimi.gimicinema"
  55 + minSdkVersion ANDROID_MIN_SDK_VERSION as int
  56 + targetSdkVersion ANDROID_TARGET_SDK_VERSION as int
  57 + versionCode APP_VERSION_CODE
  58 + versionName APP_VERSION_NAME
  59 +
  60 + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  61 +
  62 +// jackOptions {
  63 +// enabled true
  64 +// }
  65 + }
  66 +
  67 + signingConfigs {
  68 + myConfig {
  69 + storeFile file('./debug.keystore')
  70 + storePassword "android"
  71 + keyAlias 'androiddebugkey'
  72 + keyPassword 'android'
  73 + }
  74 + }
  75 + buildTypes {
  76 + release {
  77 + minifyEnabled false
  78 + signingConfig signingConfigs.myConfig
  79 + buildConfigField 'String', 'DEFAULT_IP', "\"192.168.31.202\""
  80 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  81 + }
  82 + debug {
  83 + buildConfigField 'String', 'DEFAULT_IP', "\"192.168.4.215\""
  84 +// buildConfigField 'String', 'MACHINE_TYPE', "\"himedia\"";
  85 +// buildConfigField 'boolean', 'USE_GLIDE', "true";
  86 + manifestPlaceholders = [label: "青柠影咖", icon: "@drawable/ic_luancher", channel: "QNJM"]
  87 + minifyEnabled false
  88 + signingConfig signingConfigs.myConfig
  89 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  90 + jniDebuggable false
  91 + }
  92 + }
  93 + productFlavors {
  94 + ZaiXian {
  95 + buildConfigField 'String', 'MACHINE_TYPE', "\"gimi\""
  96 + buildConfigField 'boolean', 'USE_GLIDE', "false"
  97 + manifestPlaceholders = [label: "在线影院", icon: "@drawable/ic_luancher_zx", channel: "JSZC"]
  98 + }
  99 +
  100 + QinNing {
  101 +// applicationId "com.qnbar.fangtang.cinema"
  102 + buildConfigField 'String', 'MACHINE_TYPE', "\"gimi\""
  103 + buildConfigField 'boolean', 'USE_GLIDE', "false"
  104 + manifestPlaceholders = [label: "青柠影咖", icon: "@drawable/ic_luancher", channel: "QN"]
  105 + }
  106 +
  107 + Himedia {
  108 + buildConfigField 'String', 'MACHINE_TYPE', "\"himedia\"";
  109 + buildConfigField 'boolean', 'USE_GLIDE', "true";
  110 + manifestPlaceholders = [label: "在线影院", icon: "@drawable/ic_luancher_zx", channel: "QN"]
  111 + }
  112 + }
  113 +
  114 + applicationVariants.all { variant ->
  115 + variant.outputs.each { output ->
  116 + def oldFile = output.outputFile
  117 + println "*****" + oldFile + "*****"
  118 +
  119 + if (variant.buildType.name.equals('release')) {
  120 + def fileName = output.outputFile.name.replace(output.outputFile.name,
  121 + variant.productFlavors[0].name + "-${variant.versionCode}-${releaseTime()}.apk")
  122 + output.outputFile = new File(output.outputFile.parent, fileName)
  123 + // release to test folder
  124 + println fileName
  125 +// copyTask()
  126 + }
  127 +// if (variant.buildType.name.equals('debug')) {
  128 +// def fileName = output.outputFile.name.replace(output.outputFile.name,
  129 +// "debug" + variant.productFlavors[0].name + "-${variant.versionCode}-${releaseTime()}.apk")
  130 +// output.outputFile = new File(output.outputFile.parent, fileName)
  131 +// println fileName
  132 +// }
  133 + }
  134 + }
  135 + return false
  136 +}
  137 +
  138 +dependencies {
  139 + compile files('libs/decoder.jar')
  140 + compile files('libs/cinemaLib-1220.jar')
  141 + compile files('libs/glide-3.7.0.jar')
  142 + compile files('libs/greenbluetoothlelib.jar')
  143 +
  144 + compile project(':transitionhelper')
  145 + compile project(':uil')
  146 + compile project(':volley')
  147 + compile project(':pinying')
  148 + compile project(':debug-db')
  149 +
  150 + compile group: 'com.android.support', name: 'support-v4', version: '25.0.1'
  151 + compile group: 'com.android.support', name: 'recyclerview-v7', version: '25.0.1'
  152 + compile group: 'com.squareup.okhttp', name: 'okhttp', version: '2.7.5'
  153 + compile group: 'com.google.code.gson', name: 'gson', version: '2.4'
  154 + compile group: 'com.google.zxing', name: 'core', version: '3.3.0'
  155 + compile group: 'com.umeng.analytics', name: 'umeng-analytics', version: '5.4.1'
  156 + compile group: 'com.nineoldandroids', name: 'library', version: '2.4.0'
  157 + compile group: 'com.squareup.retrofit2', name: 'retrofit', version: '2.0.2'
  158 + compile group: 'com.squareup.retrofit2', name: 'converter-gson', version: '2.0.2'
  159 + compile 'org.greenrobot:eventbus:3.0.0'
  160 +}
  161 +
  162 +def getPwd(modifyPwd) {
  163 + return modifyPwd.replaceAll(".*:", "").trim()
  164 +}
  165 +
  166 +def getName(modifyPwd) {
  167 + return new File(modifyPwd).getName().replace(".java", "");
  168 +}
  169 +
  170 +task('buildRelease') << {
  171 +
  172 +}
  173 +task releaseToTesting(type: Copy) {
  174 + from 'build/outputs/apk'
  175 +// into 'E:/py'
  176 + if (isWindows())
  177 + into '//192.168.4.214/root/apks'
  178 + else
  179 + into '/Volumes/root/apks'
  180 + include '*.apk'
  181 + exclude { details ->
  182 + details.file.name.contains('debug') ||
  183 + details.file.name.contains('release')
  184 + }
  185 +}
  186 +build.dependsOn clean
  187 +releaseToTesting {}.dependsOn build
  188 +build.shouldRunAfter clean
  189 +releaseToTesting {}.shouldRunAfter build
  190 +
  191 +task tests(type: Copy) {
  192 + from 'build/outputs/apk'
  193 +// into 'E:/py'
  194 + into '/Volumes/root/apks'
  195 +// into '\\\\192.168.4.214\\root'
  196 + include '*.apk'
  197 + exclude { details ->
  198 + details.file.name.contains('debug') ||
  199 + details.file.name.contains('release')
  200 + }
  201 +}
  202 +
  203 +task getType() {
  204 + def pwd = new File('build.gradle').getAbsolutePath()
  205 + def windows = isWindows();
  206 + println pwd + " fuck " + windows
  207 +}
  208 +
  209 +task('gitCommit') << {
  210 + def debug = false;
  211 + def pull = "git pull"
  212 + pull.execute()
  213 +
  214 + def cmdStatus = "git status ."
  215 + println "*****************execute $cmdStatus start*******************"
  216 + def var = cmdStatus.execute()/*.text.trim()*/
  217 + println "*****************execute $cmdStatus start*******************"
  218 +// println var.text
  219 + def outputStream = new StringBuffer();
  220 + var.waitForProcessOutput(outputStream, System.err)
  221 + def a = 0;
  222 + def commitMsg = "";
  223 + def commitDelMsg = "删除了";
  224 + def commitModMsg = "修改了";
  225 + def commitAddMsg = "添加了";
  226 + outputStream.toString().eachLine {
  227 + a++
  228 + if (it.contains("build.gradle")) {
  229 + println "pass build.gradle $it"
  230 + return
  231 + }
  232 + if (it.contains("deleted:")) {
  233 + def pwd = getPwd(it);
  234 + println "deleted pwd is :" + pwd
  235 + commitDelMsg += getName(pwd) + " "
  236 + if (!debug) {
  237 + def rm = "git rm " + pwd
  238 + def rmResult = rm.execute()
  239 + def rmOutputStream = new StringBuffer()
  240 + rmResult.waitForProcessOutput(rmOutputStream, System.err)
  241 + }
  242 + return
  243 + }
  244 + if (it.contains("modified:")) {
  245 + def pwd = getPwd(it);
  246 + println "modified pwd is :" + pwd
  247 + commitModMsg += getName(pwd) + " "
  248 + if (!debug) {
  249 + def add = "git add " + pwd
  250 + def addResult = add.execute()
  251 + def addOutputStream = new StringBuffer()
  252 + addResult.waitForProcessOutput(addOutputStream, System.err)
  253 + }
  254 + return
  255 + }
  256 +
  257 + if (it.contains("src")) {
  258 + def pwd = getPwd(it);
  259 + println "untracked pwd is :" + pwd
  260 + commitAddMsg += getName(pwd) + " "
  261 + if (!debug) {
  262 + def add = "git add " + pwd
  263 + def addResult = add.execute()
  264 + def addOutputStream = new StringBuffer()
  265 + addResult.waitForProcessOutput(addOutputStream, System.err)
  266 + }
  267 + }
  268 + }
  269 + if (commitDelMsg != "删除了") {
  270 + commitMsg += commitDelMsg + " "
  271 + }
  272 + if (commitModMsg != "修改了") {
  273 + commitMsg += commitModMsg + " "
  274 + }
  275 + if (commitAddMsg != "添加了") {
  276 + commitMsg += commitAddMsg + " "
  277 + }
  278 +
  279 + println "######################commitMsg##########################"
  280 + println "$commitMsg"
  281 + println "######################commitMsg##########################"
  282 + println "*****************execute $cmdStatus end*******************"
  283 +
  284 + if (!debug) {
  285 + def commit = "git commit -m " + commitMsg
  286 + def commitResult = commit.execute()
  287 + def commitOutputStream = new StringBuffer();
  288 + commitResult.waitForProcessOutput(commitOutputStream, System.err)
  289 + def push = "git push"
  290 + def putResult = push.execute()
  291 + def pushOutputStream = new StringBuffer()
  292 + putResult.waitForProcessOutput(pushOutputStream, System.err)
  293 + }
  294 +}
... ...
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + package="com.xgimi.gimicinema"
  5 + android:sharedUserId="android.uid.system">
  6 +
  7 + <uses-permission android:name="android.permission.INTERNET"/>
  8 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  9 + <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
  10 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  11 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  12 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
  13 + <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
  14 + <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES"/>
  15 + <uses-permission
  16 + android:name="android.permission.FORCE_STOP_PACKAGES"
  17 + tools:ignore="ProtectedPermissions"/>
  18 + <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  19 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
  20 +
  21 + <!--
  22 + windows not support lable replace by gradle,just replace by string values
  23 + occour error: AndroidMainfest.xml:line:AAPT:Error parsing XML:not well-formed(invalid toke) -v.8.3
  24 + -->
  25 + <application
  26 + android:allowBackup="true"
  27 + android:hardwareAccelerated="true"
  28 + android:icon="${icon}"
  29 + android:label="@string/app_name"
  30 + android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
  31 + <meta-data
  32 + android:name="UMENG_APPKEY"
  33 + android:value="556ff5c367e58e3d5900180b"/>
  34 + <meta-data
  35 + android:name="UMENG_CHANNEL"
  36 + android:value="${channel}"/>
  37 + <!-- <meta-data android:name="com.gimi.common.cinema.utils.CustomCachingGlideModule" android:value="GlideModule" /> -->
  38 +
  39 + <activity
  40 + android:name=".activity.StartActivity"
  41 + android:theme="@style/AppStartTheme">
  42 + <intent-filter>
  43 + <action android:name="android.intent.action.MAIN"/>
  44 +
  45 + <category android:name="android.intent.category.LAUNCHER"/>
  46 + </intent-filter>
  47 + </activity>
  48 + <activity
  49 + android:name=".activity.CinemaConfig"
  50 + android:theme="@style/AppStartTheme">
  51 + </activity>
  52 + <activity android:name=".activity.NewMovieActivity1"/>
  53 + <activity android:name=".activity.SearchActivity"/>
  54 + <activity android:name=".activity.SearchNewActivity"/>
  55 + <activity android:name=".activity.PlayListActivity"/>
  56 + <activity android:name=".activity.SettingActivity"/>
  57 + <activity android:name=".activity.AlarmAlert"/>
  58 + <activity android:name=".activity.MovieDetailActivity"/>
  59 + <activity android:name=".activity.MovieInHDActivity"/>
  60 + <activity
  61 + android:name=".activity.EnterPassWordActivity"
  62 + android:theme="@style/DialogActivity"/>
  63 + <activity android:name=".activity.MainActivity"/>
  64 + <activity android:name=".activity.MovieDetailInHDActivity"/>
  65 + <activity android:name=".activity.MovieListActivity"/>
  66 + <activity android:name=".activity.ChoseSourceActivity"/>
  67 + <activity android:name=".activity.NewMovie4HJActivity"/>
  68 + <activity android:name=".cctvsix.activity.M1905MovieDetailActivity"/>
  69 + <activity android:name=".cctvsix.activity.M1905MovieDetailActivity1"/>
  70 + <activity android:name=".cctvsix.activity.M1905VideoListActivity"/>
  71 + <activity android:name=".activity.AddCActivity"/>
  72 + <activity android:name=".activity.OtherMovieActivity"/>
  73 + <activity android:name=".activity.SimpleAdsPlayActivity"/>
  74 + <activity android:name=".activity.SimpleAdsPlayer2"/>
  75 + <activity android:name=".activity.AdsPreVideoPlayerActivity"/>
  76 + <activity android:name=".activity.OtherMovieActivityTv"/>
  77 + <activity android:name=".activity.OtherMovieActivityHome"/>
  78 + <activity android:name=".activity.ImageShowActivity"/>
  79 + <activity android:name=".activity.CheckActivity"/>
  80 +
  81 + <service android:name=".service.MovieMessageService"/>
  82 + <service android:name=".service.SearchMovieMessageService"/>
  83 + <service
  84 + android:name=".service.AskService"
  85 + android:persistent="true"
  86 + android:priority="1000"> <!-- 免杀,?有没有起作用 -->
  87 + <!-- 提高service优先级 -->
  88 + <intent-filter>
  89 + <action android:name="com.qnbar.ask.service"/>
  90 + </intent-filter>
  91 + </service>
  92 +
  93 + <receiver android:name=".receiver.AlarmReceiver"/>
  94 + <receiver android:name=".receiver.BootReceiver">
  95 + <intent-filter>
  96 + <action android:name="android.intent.action.BOOT_COMPLETED"/>
  97 + </intent-filter>
  98 + </receiver>
  99 + <receiver android:name=".service.MovieCompleteReceiver">
  100 + <intent-filter>
  101 + <action android:name="com.xgimi.gimicinema.get_data.movie_complete"/>
  102 + </intent-filter>
  103 + </receiver>
  104 +
  105 + <activity android:name=".activity.MovieListsActivity"/>
  106 + <activity android:name=".activity.MovieDetailMsgActivity"/>
  107 +
  108 + <service
  109 + android:name=".service.CinemaControlService"
  110 + android:enabled="true"
  111 + android:exported="true">
  112 + <intent-filter>
  113 + <action android:name="com.gimicinema.cinemacontrol"/>
  114 +
  115 + <category android:name="android.intent.category.DEFAULT"/>
  116 + </intent-filter>
  117 + </service>
  118 + <service
  119 + android:name=".service.ProguardService" >
  120 + <intent-filter>
  121 + <action android:name="com.qnbar.proguard.service"/>
  122 + </intent-filter>
  123 + </service>
  124 + </application>
  125 +
  126 +</manifest>
\ No newline at end of file
... ...
  1 +// ICinemaControl.aidl
  2 +package com.xgimi.gimicinema;
  3 +
  4 +// Declare any non-default types here with import statements
  5 +interface ICinemaControl {
  6 + /**
  7 + * Demonstrates some basic types that you can use as parameters
  8 + * and return values in AIDL.
  9 + */
  10 + void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
  11 + double aDouble, String aString);
  12 + //设置当前播放电影总时长.
  13 + void setMovieDuration(long duration);
  14 +
  15 + // 获取当前播放电影总时长.
  16 + long getMovieDuration();
  17 +
  18 + //设置当前播放电影进度.
  19 + void setCurrentMoviePosition(long duration);
  20 +
  21 + //获取当前播放电影进度.
  22 + long getCurrentMoviePosition();
  23 +
  24 + int getCurrentStatus();
  25 +
  26 + void setCurrentStatus(int state);
  27 +
  28 + // 添加新的播放路径到播放列表.
  29 + void addPlayPath(String path);
  30 +
  31 + //设置当前播放电影.if null 播放器没有播放电影
  32 + void setCurrentPlayPath(String path);
  33 +
  34 + //获取当前播放路径,可以从中获取电影名
  35 + String getCurrentPath();
  36 +
  37 + List<String> getPlayList();
  38 +
  39 + void setPlayList(in List<String> movies);
  40 +}
... ...
  1 +// ICinemaSMC.aidl
  2 +package com.xgimi.gimicinema;
  3 +
  4 +// Declare any non-default types here with import statements
  5 +
  6 +interface ICinemaSMC {
  7 + /**
  8 + * Demonstrates some basic types that you can use as parameters
  9 + * and return values in AIDL.
  10 + */
  11 + void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat,
  12 + double aDouble, String aString);
  13 +
  14 + boolean open();
  15 +
  16 + boolean close();
  17 +}
... ...
  1 +package com.gimi.common.cinema.db;
  2 +
  3 +import android.content.Context;
  4 +import android.database.sqlite.SQLiteDatabase;
  5 +import android.database.sqlite.SQLiteOpenHelper;
  6 +
  7 +public class NewDBHelper extends SQLiteOpenHelper {
  8 +
  9 + private static final String DATABASE_NAME = "xgimi_cinema_movie.db";
  10 + private static final int DATABASE_VERSION = 5;
  11 + private static final String CREATE_TABLE = "create table movie_message(id integer primary key autoincrement," +
  12 + "name text," +
  13 + "path text UNIQUE," +
  14 + "poster_path text," +
  15 + "pinyin text," +
  16 + "md5 text," +
  17 + "type text," +
  18 + "douban_id text)";
  19 + public static final String TABLE_NAME = "movie_message";
  20 + public static final String ID = "id";
  21 + public static final String NAME = "name";
  22 + public static final String PATH = "path";
  23 + public static final String POSTER_PATH = "poster_path";
  24 + public static final String PINYIN = "pinyin";
  25 + public static final String TYPE = "type";
  26 + public static final String DOUBAN_ID = "douban_id";
  27 + public static final String MD5 = "md5";
  28 + public static final String CLASS_DESCRIBE = "class_describe";
  29 + public static final String MOVIE_LENGTH = "movie_length";
  30 + public static final String DOUBAN_RATING = "douban_rating";
  31 + public static final String LAST_PLAY_TIME = "last_play_time";
  32 + public static final String SCREEN_TIME = "screen_time";
  33 + public static final String MOVIE_COUNT = "movie_count";
  34 + public static final String MOVIE_DL_TIME = "movie_dl_time";
  35 +
  36 +
  37 + public NewDBHelper(Context context) {
  38 + //CursorFactory设置为null,使用默认值
  39 + super(context, DATABASE_NAME, null, DATABASE_VERSION);
  40 + }
  41 +
  42 + //数据库第一次被创建时onCreate会被调用
  43 + @Override
  44 + public void onCreate(SQLiteDatabase db) {
  45 + db.execSQL(CREATE_TABLE);
  46 + db.execSQL(ADD_COLUMNS);
  47 + db.execSQL(ADD_COLUMNS1);
  48 + db.execSQL(ADD_COLUMNS2);
  49 + db.execSQL(ADD_COLUMNS3);
  50 + db.execSQL(ADD_COLUMNS4);
  51 + db.execSQL(ADD_COLUMNS5);
  52 + db.execSQL(ADD_COLUMNS6);
  53 + }
  54 +
  55 + private static final String ADD_COLUMNS = "ALTER TABLE movie_message ADD class_describe TEXT";
  56 + private static final String ADD_COLUMNS1 = "ALTER TABLE movie_message ADD movie_length TEXT";
  57 + private static final String ADD_COLUMNS2 = "ALTER TABLE movie_message ADD douban_rating TEXT";
  58 + private static final String ADD_COLUMNS3 = "ALTER TABLE movie_message ADD last_play_time TEXT";
  59 + private static final String ADD_COLUMNS4 = "ALTER TABLE movie_message ADD screen_time TEXT";
  60 + private static final String ADD_COLUMNS5 = "ALTER TABLE movie_message ADD movie_count TEXT";
  61 + private static final String ADD_COLUMNS6 = "ALTER TABLE movie_message ADD movie_dl_time TEXT";
  62 +
  63 +
  64 + private static final String DROP_TABLE = "drop table if exists movie_message";
  65 + //如果DATABASE_VERSION值被改为2,系统发现现有数据库版本不同,即会调用onUpgrade
  66 + @Override
  67 + public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  68 + if (newVersion != oldVersion) {
  69 + db.execSQL(DROP_TABLE);
  70 + onCreate(db);
  71 + }
  72 + }
  73 +
  74 + @Override
  75 + public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
  76 + if (newVersion != oldVersion) {
  77 + db.execSQL(DROP_TABLE);
  78 + onCreate(db);
  79 + }
  80 + }
  81 +}
\ No newline at end of file
... ...
  1 +package com.gimi.common.cinema.db;
  2 +
  3 +import android.content.ContentValues;
  4 +import android.content.Context;
  5 +import android.database.Cursor;
  6 +import android.database.sqlite.SQLiteDatabase;
  7 +import android.text.TextUtils;
  8 +import android.util.Log;
  9 +import com.gimi.common.cinema.model.LocalMovieMessage;
  10 +import com.gimi.common.cinema.model.QueryType;
  11 +import com.gimi.common.cinema.model.SourceType;
  12 +import com.xgimi.gimicinema.activity.CinemaConfig;
  13 +
  14 +import java.io.File;
  15 +import java.util.ArrayList;
  16 +import java.util.List;
  17 +
  18 +public class NewDBManager {
  19 + private SQLiteDatabase db;
  20 +
  21 + public NewDBManager(Context context) {
  22 + NewDBHelper helper = new NewDBHelper(context);
  23 + //因为getWritableDatabase内部调用了mContext.openOrCreateDatabase(mName, 0, mFactory);
  24 + //所以要确保context已初始化,可以把实例化DBManager的步骤放在Activity的onCreate里
  25 + db = helper.getWritableDatabase();
  26 + }
  27 +
  28 + /**
  29 + * 利用事务批量添加本地数据
  30 + *
  31 + * @param localMovieMessageList movie list
  32 + * @param clear if clear
  33 + * @return boolean
  34 + */
  35 + public boolean add(List<LocalMovieMessage> localMovieMessageList, boolean clear) {
  36 + boolean result = false;
  37 + db.beginTransaction(); //开始事务
  38 + try {
  39 + //do delete if need
  40 + if (clear) {
  41 + db.delete(NewDBHelper.TABLE_NAME, null, null);
  42 + }
  43 + for (LocalMovieMessage person : localMovieMessageList) {
  44 + ContentValues cv = constructCv(person);
  45 + db.insert(NewDBHelper.TABLE_NAME, null, cv);
  46 + }
  47 + db.setTransactionSuccessful(); //设置事务成功完成
  48 + result = true;
  49 + } catch (Exception e) {
  50 + e.printStackTrace();
  51 + result = false;
  52 + } finally {
  53 + db.endTransaction(); //结束事务
  54 + }
  55 + return result;
  56 + }
  57 +
  58 + /**
  59 + * public static final String ID = "id";
  60 + * public static final String NAME = "name";
  61 + * public static final String PATH = "path";
  62 + * public static final String POSTER_PATH = "poster_path";
  63 + * public static final String PINYIN = "pinyin";
  64 + * public static final String TYPE = "type";
  65 + * public static final String DOUBAN_ID = "douban_id";
  66 + * public static final String MD5 = "md5";
  67 + * public static final String CLASS_DESCRIBE = "class_describe";
  68 + * public static final String MOVIE_LENGTH = "movie_length";
  69 + * public static final String DOUBAN_RATING = "douban_rating";
  70 + *
  71 + * @param localMovieMessage movie msg
  72 + * @return contentValues
  73 + */
  74 + private ContentValues constructCv(LocalMovieMessage localMovieMessage) {
  75 + ContentValues cv = new ContentValues();
  76 + cv.put(NewDBHelper.NAME, localMovieMessage.getMovieName());
  77 + cv.put(NewDBHelper.PATH, localMovieMessage.getPlayPath().replace(CinemaConfig.BASIC_ROOT, ""));
  78 + String posterPath = localMovieMessage.getPosterPath();
  79 + if (!TextUtils.isEmpty(posterPath)) {
  80 + cv.put(NewDBHelper.POSTER_PATH, posterPath.replace(CinemaConfig.BASIC_ROOT, ""));
  81 + }
  82 + cv.put(NewDBHelper.PINYIN, localMovieMessage.getNamePinyin());
  83 + cv.put(NewDBHelper.MD5, localMovieMessage.getMd5());
  84 + if (localMovieMessage.getDoubanRating() != 0) {
  85 + cv.put(NewDBHelper.DOUBAN_RATING, localMovieMessage.getDoubanRating());
  86 + }
  87 + if (localMovieMessage.getCount() != 0) {
  88 + cv.put(NewDBHelper.MOVIE_COUNT, localMovieMessage.getCount());
  89 + }
  90 + if (!TextUtils.isEmpty(localMovieMessage.getDoubanId())) {
  91 + cv.put(NewDBHelper.DOUBAN_ID, localMovieMessage.getDoubanId());
  92 + }
  93 + if (!TextUtils.isEmpty(localMovieMessage.getDlTime())) {
  94 + cv.put(NewDBHelper.MOVIE_DL_TIME, localMovieMessage.getDlTime());
  95 + }
  96 + if (localMovieMessage.getClassDescribe() != null) {
  97 + cv.put(NewDBHelper.CLASS_DESCRIBE, localMovieMessage.getClassDescribe());
  98 + }
  99 + if (localMovieMessage.getMovieLength() != null) {
  100 + cv.put(NewDBHelper.MOVIE_LENGTH, localMovieMessage.getMovieLength());
  101 + }
  102 + if (localMovieMessage.getType() != null) {
  103 + cv.put(NewDBHelper.TYPE, localMovieMessage.getType());
  104 + }
  105 + if (localMovieMessage.getScreenTime() != null) {
  106 + cv.put(NewDBHelper.SCREEN_TIME, localMovieMessage.getScreenTime());
  107 + }
  108 + return cv;
  109 + }
  110 +
  111 + /**
  112 + * 利用事务批量添加本地数据,存在的数据不再更新,不存在的直接插入
  113 + *
  114 + * @param localMovieMessageList lst
  115 + * @return boolean
  116 + */
  117 + public boolean add1905(List<LocalMovieMessage> localMovieMessageList) {
  118 + boolean result = false;
  119 + for (LocalMovieMessage localMovieMessage : localMovieMessageList) {
  120 + result = insertLocalMM1905(localMovieMessage);
  121 + }
  122 + return result;
  123 + }
  124 +
  125 + private boolean insertLocalMM1905(LocalMovieMessage localMovieMessage) {
  126 + int id = queryId1905(localMovieMessage);
  127 + return updateLocalMM1905(localMovieMessage, id);
  128 + }
  129 +
  130 + private int queryId1905(LocalMovieMessage lmm) {
  131 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  132 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, "md5 = ? and path = ?",
  133 + new String[]{"qnyb_abc_test", lmm.getPlayPath()}, null, null, null);
  134 + readCursor2List(persons, c);
  135 + c.close();
  136 + if (persons.size() == 0) {
  137 + return -1;
  138 + } else {
  139 + for (LocalMovieMessage person : persons) {
  140 + if (person.getPlayPath().equals(lmm.getPlayPath())
  141 + && person.getMd5().equals(lmm.getMd5())) {
  142 + return person.getId();
  143 + }
  144 + }
  145 + return -1;
  146 + }
  147 + }
  148 +
  149 + private boolean updateLocalMM1905(LocalMovieMessage localMovieMessage, int id) {
  150 + boolean result;
  151 + if (id == -1) {
  152 + result = add(localMovieMessage, true);
  153 + } else {
  154 + return updateDoubanMsg(localMovieMessage);
  155 + }
  156 + return result;
  157 + }
  158 +
  159 + /**
  160 + * 利用事务批量添加本地数据,存在的数据不再更新,不存在的直接插入
  161 + *
  162 + * @param localMovieMessageList lst
  163 + * @return boolean
  164 + */
  165 + public boolean add(List<LocalMovieMessage> localMovieMessageList) {
  166 + boolean result = false;
  167 + for (LocalMovieMessage localMovieMessage : localMovieMessageList) {
  168 + result = insertLocalMM(localMovieMessage);
  169 + }
  170 + return result;
  171 + }
  172 +
  173 + public void deleteFileNotExists() {
  174 + List<LocalMovieMessage> result = query();
  175 + for (LocalMovieMessage lmm : result)
  176 + if (!new File(lmm.getPlayPath()).exists()
  177 + && !"qnyb_abc_test".equals(lmm.getMd5())) {
  178 + delete(lmm);
  179 + Log.d("lovely", "delete success " + lmm.getMovieName());
  180 + }
  181 + }
  182 +
  183 + /**
  184 + * 单个添加本地数据
  185 + *
  186 + * @param localMovieMessage movie message
  187 + */
  188 + public void add(LocalMovieMessage localMovieMessage) {
  189 + db.beginTransaction(); //开始事务
  190 + try {
  191 + ContentValues contentValues = constructCv(localMovieMessage);
  192 + db.insert(NewDBHelper.TABLE_NAME, null, contentValues);
  193 + db.setTransactionSuccessful(); //设置事务成功完成
  194 + } finally {
  195 + db.endTransaction(); //结束事务
  196 + }
  197 + }
  198 +
  199 + /**
  200 + * 单个添加本地数据
  201 + *
  202 + * @param localMovieMessage local
  203 + */
  204 + public boolean add(LocalMovieMessage localMovieMessage, boolean insert) {
  205 + boolean result = false;
  206 + db.beginTransaction(); //开始事务
  207 + try {
  208 + if (insert) {
  209 + ContentValues contentValues = constructCv(localMovieMessage);
  210 + db.insert(NewDBHelper.TABLE_NAME, null, contentValues);
  211 + } else {
  212 + ContentValues contentValues = constructCv(localMovieMessage);
  213 + db.updateWithOnConflict(NewDBHelper.TABLE_NAME, contentValues, "id=?",
  214 + new String[]{String.valueOf(localMovieMessage.getId())}, SQLiteDatabase.CONFLICT_REPLACE);
  215 +// db.update(NewDBoHelper.TABLE_NAME, contentValues, " id = ", new String[]{String.valueOf(localMovieMessage.getId())});
  216 + }
  217 + db.setTransactionSuccessful(); //设置事务成功完成
  218 + result = true;
  219 + } catch (Exception e) {
  220 + e.printStackTrace();
  221 + } finally {
  222 + db.endTransaction(); //结束事务
  223 + }
  224 + return result;
  225 + }
  226 +
  227 +
  228 + private int queryId(LocalMovieMessage lmm) {//not right
  229 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  230 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, "md5 = ?", new String[]{lmm.getMd5()}, null, null, null);
  231 + readCursor2List(persons, c);
  232 + c.close();
  233 + if (persons.size() == 0) {
  234 + return -1;
  235 + } else {
  236 + for (LocalMovieMessage person : persons) {
  237 + if (person.getPlayPath().equals(lmm.getPlayPath()) && person.getMd5().equals(lmm.getMd5())
  238 + && person.getPlayPath().startsWith("/mnt/samba")) {
  239 + return person.getId();
  240 + }
  241 + }
  242 + return -1;
  243 + }
  244 + }
  245 +
  246 + private LocalMovieMessage queryByPath(String lmm) {
  247 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  248 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, "path = ?", new String[]{lmm}, null, null, null);
  249 + readCursor2List(persons, c);
  250 + c.close();
  251 + if (persons.size() == 0) {
  252 + return null;
  253 + } else {
  254 + for (LocalMovieMessage person : persons) {
  255 + if (person.getPlayPath().equals(lmm)) {
  256 + return person;
  257 + }
  258 + }
  259 + return null;
  260 + }
  261 + }
  262 +
  263 + private void readCursor2List(ArrayList<LocalMovieMessage> persons, Cursor c) {
  264 + while (c.moveToNext()) {
  265 + LocalMovieMessage person = new LocalMovieMessage();
  266 + person.setId(c.getInt(c.getColumnIndex(NewDBHelper.ID)));
  267 + person.setMovieName(c.getString(c.getColumnIndex(NewDBHelper.NAME)));
  268 + person.setPlayPath(c.getString(c.getColumnIndex(NewDBHelper.PATH)));
  269 + person.setPosterPath(c.getString(c.getColumnIndex(NewDBHelper.POSTER_PATH)));
  270 + person.setNamePinyin(c.getString(c.getColumnIndex(NewDBHelper.PINYIN)));
  271 + person.setType(c.getString(c.getColumnIndex(NewDBHelper.TYPE)));
  272 + person.setDoubanId(c.getString(c.getColumnIndex(NewDBHelper.DOUBAN_ID)));
  273 + person.setMd5(c.getString(c.getColumnIndex(NewDBHelper.MD5)));
  274 + person.setClassDescribe(c.getString(c.getColumnIndex(NewDBHelper.CLASS_DESCRIBE)));
  275 + person.setMovieLength(c.getString(c.getColumnIndex(NewDBHelper.MOVIE_LENGTH)));
  276 + int columnIndex = c.getColumnIndex(NewDBHelper.DOUBAN_RATING);
  277 + person.setDoubanRating(c.getDouble(columnIndex));
  278 + int timeIndex = c.getColumnIndex(NewDBHelper.LAST_PLAY_TIME);
  279 + if (timeIndex != -1) {
  280 + person.setLastPlayTime(c.getLong(timeIndex));
  281 + }
  282 + int screenIndex = c.getColumnIndex(NewDBHelper.SCREEN_TIME);
  283 + if (screenIndex != -1) {
  284 + person.setScreenTime(c.getString(screenIndex));
  285 + }
  286 + int dlTimeIdx = c.getColumnIndex(NewDBHelper.MOVIE_DL_TIME);
  287 + if (dlTimeIdx != -1) {
  288 + person.setDlTime(c.getString(dlTimeIdx));
  289 + }
  290 + int countIdx = c.getColumnIndex(NewDBHelper.MOVIE_COUNT);
  291 + if (countIdx != -1) {
  292 + person.setCount(c.getInt(countIdx));
  293 + }
  294 + persons.add(person);
  295 + }
  296 + }
  297 +
  298 + private boolean insertLocalMM(LocalMovieMessage localMovieMessage) {
  299 + int id = queryId(localMovieMessage);
  300 + return updateLocalMM(localMovieMessage, id);
  301 + }
  302 +
  303 + private boolean updateLocalMM(LocalMovieMessage localMovieMessage, int id) {
  304 + boolean result;
  305 + if (id == -1) {
  306 + result = add(localMovieMessage, true);
  307 + } else {
  308 + localMovieMessage.setId(id);
  309 + result = add(localMovieMessage, false);
  310 + }
  311 + return result;
  312 + }
  313 +
  314 + /**
  315 + * query all
  316 + *
  317 + * @return persons
  318 + */
  319 + public List<LocalMovieMessage> query() {
  320 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  321 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, null, null, null, null, null);
  322 + readCursor2List(persons, c);
  323 + c.close();
  324 + return persons;
  325 + }
  326 +
  327 + /**
  328 + * query queryIdNotNullAndPostNull
  329 + *
  330 + * @return persons
  331 + */
  332 + public List<LocalMovieMessage> queryIdNotNullAndPostNull() {
  333 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  334 + getNullItems(persons, NewDBHelper.DOUBAN_ID + " is not null and " + NewDBHelper.POSTER_PATH + " is null");
  335 + return persons;
  336 + }
  337 +
  338 + private void getNullItems(ArrayList<LocalMovieMessage> persons, String condition) {
  339 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, condition, null, null, null, null);
  340 + readCursor2List(persons, c);
  341 + c.close();
  342 + }
  343 +
  344 + /**
  345 + * query poster
  346 + *
  347 + * @return persons
  348 + */
  349 + public ArrayList<LocalMovieMessage> queryPosterDoubanIdNull() {
  350 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  351 + getNullItems(persons, NewDBHelper.POSTER_PATH + " is null and " + NewDBHelper.DOUBAN_ID + " is null");
  352 + return persons;
  353 + }
  354 +
  355 + /**
  356 + * query all movie from 1905 and qn
  357 + *
  358 + * @return persons
  359 + */
  360 + public List<LocalMovieMessage> queryType(String key, QueryType queryType, SourceType sourceType) {
  361 + String sql = "SELECT distinct(path),id,name,poster_path,path,pinyin,md5,douban_id,type,class_describe,movie_length,douban_rating,screen_time" +
  362 + " FROM movie_message where";/* + " path like '%" + key + "%'";*/
  363 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  364 + StringBuffer sb = new StringBuffer(sql);
  365 +
  366 + String queryQn = " path like '%/" + key + "/%'";
  367 + if (sourceType == SourceType.SOURCE_ALL || sourceType == SourceType.SOURCE_JUST_QN) {
  368 + sb.append(queryQn);
  369 + }
  370 +
  371 + String order = " order by pinyin asc";
  372 + switch (queryType) {
  373 + case QUERY_TYPE_SCREEN_TIME:
  374 + order = " order by screen_time desc";
  375 + break;
  376 + case QUERY_TYPE_RATING:
  377 + order = " order by douban_rating desc";
  378 + break;
  379 + case QUERY_TYPE_DOWNLOAD_TIME:
  380 + order = " order by cast(movie_dl_time as int) desc";
  381 + break;
  382 + case QUERY_TYPE_DEMAND:
  383 + order = " order by cast(movie_count as int) desc";
  384 + break;
  385 + }
  386 +// String order = " order by " + orderKey + (isUp ? " desc" : " asc");
  387 + String sqlSub = " and path not like '%/LXJ/%'";
  388 + if (key.equals("XJ/")) {
  389 + if (sourceType == SourceType.SOURCE_ALL || sourceType == SourceType.SOURCE_JUST_QN) {
  390 + sb.append(sqlSub);
  391 + }
  392 + }
  393 +
  394 + //if use 1905
  395 + String query1905 = getAppendCond(key);
  396 + if (sourceType == SourceType.SOURCE_ALL || sourceType == SourceType.SOURCE_JUST_1905) {
  397 + if (sourceType == SourceType.SOURCE_ALL) {
  398 + if (!TextUtils.isEmpty(query1905)) {
  399 + sb.append(" or ");
  400 + }
  401 + }
  402 + sb.append(query1905);
  403 + }
  404 + if (sourceType == SourceType.SOURCE_JUST_1905 && TextUtils.isEmpty(query1905)) {
  405 + return persons;
  406 + }
  407 +// sb.append(query1905);
  408 +
  409 + sb.append(order);
  410 +
  411 + Cursor c = db.rawQuery(sb.toString(), null);
  412 + readCursor2List(persons, c);
  413 + c.close();
  414 + return persons;
  415 + }
  416 +
  417 + private static final int RECOMMEND_MOVIE_COUNT = 200;
  418 + private static final int PXB_MOVIE_COUNT = 200;
  419 +
  420 + /**
  421 + * query all recommend qn
  422 + *
  423 + * @return persons
  424 + */
  425 + public List<LocalMovieMessage> queryAllNewMovies() {
  426 + String sql = "SELECT * FROM movie_message order by cast(movie_dl_time as int) desc limit " + RECOMMEND_MOVIE_COUNT;/* + " path like '%" + key + "%'";*/
  427 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  428 + StringBuffer sb = new StringBuffer(sql);
  429 +
  430 + Cursor c = db.rawQuery(sb.toString(), null);
  431 + readCursor2List(persons, c);
  432 + c.close();
  433 + return persons;
  434 + }
  435 +
  436 + /**
  437 + * query all recommend qn
  438 + *
  439 + * @return persons
  440 + */
  441 + public List<LocalMovieMessage> queryAllDemandMovies() {
  442 + String sql = "SELECT * FROM movie_message order by cast(" + NewDBHelper.MOVIE_COUNT + " as int) desc, cast(movie_dl_time as int) desc limit " + PXB_MOVIE_COUNT;/* + " path like '%" + key + "%'";*/
  443 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  444 + StringBuffer sb = new StringBuffer(sql);
  445 +
  446 + Cursor c = db.rawQuery(sb.toString(), null);
  447 + readCursor2List(persons, c);
  448 + c.close();
  449 + return persons;
  450 + }
  451 +
  452 + private String getAppendCond(String key) {
  453 + String rtn = "";
  454 + if (key.contains("KH")) {
  455 + rtn = " class_describe like '%科幻%' and md5 = 'qnyb_abc_test'";
  456 + return rtn;
  457 + } else if (key.contains("DZ")) {
  458 + rtn = " class_describe like '%动作%' and md5 = 'qnyb_abc_test'";
  459 + return rtn;
  460 + } else if (key.contains("KB")) {
  461 + rtn = " class_describe like '%恐怖%' and md5 = 'qnyb_abc_test'";
  462 + return rtn;
  463 + } else if (key.contains("XJ")) {
  464 + if (!key.contains("LXJ")) {
  465 + rtn = " class_describe like '%喜剧%' and md5 = 'qnyb_abc_test'";
  466 + }
  467 + return rtn;
  468 + } else if (key.contains("AQ")) {
  469 + rtn = " class_describe like '%爱情%' and md5 = 'qnyb_abc_test'";
  470 + return rtn;
  471 + } else if (key.contains("JQ")) {
  472 + rtn = " class_describe like '%剧情%' and md5 = 'qnyb_abc_test'";
  473 + return rtn;
  474 + } else if (key.contains("DM")) {
  475 + rtn = " class_describe like '%儿童%' and md5 = 'qnyb_abc_test' or class_describe like '%动画%' and md5 = 'qnyb_abc_test'";
  476 + return rtn;
  477 + } else if (key.contains("TJ")) {
  478 + rtn = " class_describe like '%经典%' and md5 = 'qnyb_abc_test'";
  479 + return rtn;
  480 + } else if (key.contains("TY")) {
  481 + rtn = " class_describe like '%运动%' and md5 = 'qnyb_abc_test'";
  482 + return rtn;
  483 + }
  484 + return rtn;
  485 + }
  486 +
  487 + public List<LocalMovieMessage> queryTop(int top, QueryType queryType) {
  488 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  489 + String orderBy = NewDBHelper.DOUBAN_RATING + " desc";
  490 + switch (queryType) {
  491 + case QUERY_TYPE_NAME:
  492 + orderBy = NewDBHelper.PINYIN + " asc";
  493 + break;
  494 + case QUERY_TYPE_SCREEN_TIME:
  495 + orderBy = "screen_time desc";
  496 + break;
  497 + }
  498 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null, null, null, null, null, orderBy, String.valueOf(top));
  499 + readCursor2List(persons, c);
  500 + c.close();
  501 + return persons;
  502 + }
  503 +
  504 + /**
  505 + * query all
  506 + *
  507 + * @return persons
  508 + */
  509 + public List<LocalMovieMessage> queryRecommend() {
  510 + return queryTJLimit(4);
  511 + }
  512 +
  513 + private List<LocalMovieMessage> queryTJLimit(int limitNum) {
  514 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  515 + String sql = "SELECT * FROM movie_message where path like '%/TJ/%' and poster_path is not null";
  516 + StringBuffer sb = new StringBuffer(sql);
  517 +// String order = " order by douban_rating desc";
  518 + String order = " order by random()";
  519 + String limit = " limit " + limitNum;
  520 + sb.append(order).append(limit);
  521 +
  522 + Cursor c = db.rawQuery(sb.toString(), null);
  523 + readCursor2List(persons, c);
  524 + c.close();
  525 + return persons;
  526 + }
  527 +
  528 + /**
  529 + * query all
  530 + *
  531 + * @return persons
  532 + */
  533 + public List<LocalMovieMessage> queryRecommendInDetail() {
  534 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  535 +// String sql = "SELECT * FROM movie_message where path like '%/TJ/%' and poster_path is not null";
  536 + String sql = "SELECT * FROM movie_message where path like '%/TJ/%'" + " order by random() limit 7 ";
  537 + StringBuffer sb = new StringBuffer(sql);
  538 +
  539 + Cursor c = db.rawQuery(sb.toString(), null);
  540 + readCursor2List(persons, c);
  541 +// if (persons.size() < 5) {
  542 +// sql = sql + " class_describe like '%经典%' and md5 = 'qnyb_abc_test'";
  543 +// }
  544 + c.close();
  545 + return persons;
  546 + }
  547 +
  548 + /**
  549 + * query all record contain key, return list
  550 + *
  551 + * @return List<Person>
  552 + */
  553 + public List<LocalMovieMessage> queryKey(String key) {
  554 + key = key.toLowerCase();
  555 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  556 + /*StringBuffer keyBuffer = new StringBuffer();
  557 + keyBuffer.append("'");
  558 + for (int i = 0; i < key.length(); i++) {
  559 + keyBuffer.append("%").append(key.charAt(i)).append("%");
  560 + }
  561 + keyBuffer.append("'");*/
  562 +// Cursor c = db.rawQuery("SELECT * FROM movie_message where pinyin LIKE '%" + key + "%' order by length(pinyin) asc limit 0,20", null);
  563 + String sql = "SELECT * FROM movie_message where pinyin LIKE " + "'%" + key + "%'" + " order by length(name) asc limit 20";
  564 + Cursor c = db.rawQuery(sql, null);
  565 + readCursor2List(persons, c);
  566 + c.close();
  567 + return persons;
  568 + }
  569 +
  570 + /**
  571 + * query all record contain key, return list
  572 + *
  573 + * @return List<Person>
  574 + */
  575 + public List<LocalMovieMessage> querySearchRecommend() {
  576 + return queryTJLimit(22);
  577 + }
  578 +
  579 + /**
  580 + * 删除
  581 + *
  582 + * @param lmm movie message
  583 + * @return boolean
  584 + */
  585 + public boolean delete(LocalMovieMessage lmm) {
  586 + db.delete(NewDBHelper.TABLE_NAME, "id = ?", new String[]{String.valueOf(lmm.getId())});
  587 +// String sql = "DELETE FROM movie_message where id = " + lmm.getId();
  588 +// db.execSQL(sql);
  589 + return false;
  590 + }
  591 +
  592 + /**
  593 + * 更新电影分类,豆瓣评分
  594 + *
  595 + * @param lmm movie message
  596 + * @return boolean
  597 + */
  598 + public boolean updateDoubanMsg(LocalMovieMessage lmm) {
  599 + boolean result = false;
  600 + db.beginTransaction();
  601 + try {
  602 + ContentValues cv = constructCv(lmm);
  603 + db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())});
  604 + db.setTransactionSuccessful(); // changes get rolled back if this not called
  605 + result = true;
  606 + } catch (Exception e) {
  607 + e.printStackTrace();
  608 + result = false;
  609 + } finally {
  610 + db.endTransaction(); // commit or rollback
  611 + }
  612 + return result;
  613 + }
  614 +
  615 + /**
  616 + * 更新电影分类,豆瓣评分
  617 + *
  618 + * @param lmm movie message
  619 + * @return boolean
  620 + */
  621 + public boolean updateMovieMsg(LocalMovieMessage lmm) {
  622 + boolean result;
  623 + db.beginTransaction();
  624 + ContentValues cv = constructCv(lmm);
  625 +// db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())});
  626 + db.updateWithOnConflict(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())},SQLiteDatabase.CONFLICT_REPLACE);
  627 + db.setTransactionSuccessful(); // changes get rolled back if this not called
  628 + result = true;
  629 + db.endTransaction(); // commit or rollback
  630 + return result;
  631 + }
  632 +
  633 + /**
  634 + * updateMovieCount,现想主要用于已有本地数据,更新网络数据
  635 + *
  636 + * @param lmm movie message
  637 + * @return boolean
  638 + */
  639 + public boolean updateMovieCount(LocalMovieMessage lmm) {
  640 + boolean result = false;
  641 + db.beginTransaction();
  642 + try {
  643 + ContentValues cv = new ContentValues();
  644 + cv.put(NewDBHelper.MOVIE_COUNT, lmm.getCount());
  645 + db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())});
  646 + db.setTransactionSuccessful(); // changes get rolled back if this not called
  647 + result = true;
  648 + } catch (Exception e) {
  649 + e.printStackTrace();
  650 + result = false;
  651 + } finally {
  652 + db.endTransaction(); // commit or rollback
  653 + }
  654 + return result;
  655 + }
  656 +
  657 + /**
  658 + * updateMovieCount,现想主要用于已有本地数据,更新网络数据
  659 + *
  660 + * @param path movie path
  661 + * @param count movie click count
  662 + * @return boolean
  663 + */
  664 + public boolean updateMovieCount(String path, int count) {
  665 + LocalMovieMessage localMovieMessage = queryByPath(path);
  666 + if (localMovieMessage != null) {
  667 + localMovieMessage.setCount(count);
  668 + return updateMovieCount(localMovieMessage);
  669 + }
  670 + return false;
  671 + }
  672 +
  673 +
  674 + public boolean updatePlayTime(LocalMovieMessage lmm) {
  675 + boolean result = false;
  676 + db.beginTransaction();
  677 + try {
  678 + ContentValues cv = new ContentValues();
  679 + cv.put(NewDBHelper.LAST_PLAY_TIME, System.currentTimeMillis());
  680 + db.update(NewDBHelper.TABLE_NAME, cv, "id = ? ", new String[]{String.valueOf(lmm.getId())});
  681 + db.setTransactionSuccessful(); // changes get rolled back if this not called
  682 + result = true;
  683 + } catch (Exception e) {
  684 + e.printStackTrace();
  685 + result = false;
  686 + } finally {
  687 + db.endTransaction(); // commit or rollback
  688 + }
  689 + return result;
  690 + }
  691 +
  692 + public List<LocalMovieMessage> queryLastPlay(int top) {
  693 + ArrayList<LocalMovieMessage> persons = new ArrayList<LocalMovieMessage>();
  694 + Cursor c = db.query(NewDBHelper.TABLE_NAME, null,
  695 + NewDBHelper.LAST_PLAY_TIME + " != ?", new String[]{String.valueOf(0)},
  696 + null, null, NewDBHelper.LAST_PLAY_TIME + " desc", String.valueOf(top));
  697 + readCursor2List(persons, c);
  698 + c.close();
  699 + return persons;
  700 + }
  701 +
  702 +
  703 + /**
  704 + * close database
  705 + */
  706 + public void closeDB() {
  707 + db.close();
  708 + }
  709 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/8/4
  5 + */
  6 +public class AdsProof {
  7 +
  8 + /**
  9 + * code : 0
  10 + * message : 成功
  11 + */
  12 +
  13 + private int code;
  14 + private String msg;
  15 +
  16 + public int getCode() {
  17 + return code;
  18 + }
  19 +
  20 + public void setCode(int code) {
  21 + this.code = code;
  22 + }
  23 +
  24 + public String getMsg() {
  25 + return msg;
  26 + }
  27 +
  28 + public void setMsg(String msg) {
  29 + this.msg = msg;
  30 + }
  31 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/12/17
  5 + */
  6 +
  7 +public class AgentInfo {
  8 +
  9 + /**
  10 + * code : 0
  11 + * msg : 成功
  12 + * data : {"agent":{"agentId":"81","agentName":"广东省廉江市花田影咖","agentPic":"","agentAddr":"广东省湛江市廉江市石城大道东66号","agentTel":"13724745600","agentType":"2","addTime":"1454763474","distTime":"1486656000","status":"1","agentSequence":"1","sysVersion":"1"}}
  13 + */
  14 +
  15 + private int code;
  16 + private String msg;
  17 + private DataBean data;
  18 +
  19 + public int getCode() {
  20 + return code;
  21 + }
  22 +
  23 + public void setCode(int code) {
  24 + this.code = code;
  25 + }
  26 +
  27 + public String getMsg() {
  28 + return msg;
  29 + }
  30 +
  31 + public void setMsg(String msg) {
  32 + this.msg = msg;
  33 + }
  34 +
  35 + public DataBean getData() {
  36 + return data;
  37 + }
  38 +
  39 + public void setData(DataBean data) {
  40 + this.data = data;
  41 + }
  42 +
  43 + public static class DataBean {
  44 + /**
  45 + * agent : {"agentId":"81","agentName":"广东省廉江市花田影咖","agentPic":"","agentAddr":"广东省湛江市廉江市石城大道东66号","agentTel":"13724745600","agentType":"2","addTime":"1454763474","distTime":"1486656000","status":"1","agentSequence":"1","sysVersion":"1"}
  46 + */
  47 +
  48 + private AgentBean agent;
  49 +
  50 + public AgentBean getAgent() {
  51 + return agent;
  52 + }
  53 +
  54 + public void setAgent(AgentBean agent) {
  55 + this.agent = agent;
  56 + }
  57 +
  58 + public static class AgentBean {
  59 + /**
  60 + * agentId : 81
  61 + * agentName : 广东省廉江市花田影咖
  62 + * agentPic :
  63 + * agentAddr : 广东省湛江市廉江市石城大道东66号
  64 + * agentTel : 13724745600
  65 + * agentType : 2
  66 + * addTime : 1454763474
  67 + * distTime : 1486656000
  68 + * status : 1
  69 + * agentSequence : 1
  70 + * sysVersion : 1
  71 + */
  72 +
  73 + private String agentId;
  74 + private String agentName;
  75 + private String agentPic;
  76 + private String agentAddr;
  77 + private String agentTel;
  78 + private String agentType;
  79 + private String addTime;
  80 + private String distTime;
  81 + private String status;
  82 + private String agentSequence;
  83 + private String sysVersion;
  84 +
  85 + public String getAgentId() {
  86 + return agentId;
  87 + }
  88 +
  89 + public void setAgentId(String agentId) {
  90 + this.agentId = agentId;
  91 + }
  92 +
  93 + public String getAgentName() {
  94 + return agentName;
  95 + }
  96 +
  97 + public void setAgentName(String agentName) {
  98 + this.agentName = agentName;
  99 + }
  100 +
  101 + public String getAgentPic() {
  102 + return agentPic;
  103 + }
  104 +
  105 + public void setAgentPic(String agentPic) {
  106 + this.agentPic = agentPic;
  107 + }
  108 +
  109 + public String getAgentAddr() {
  110 + return agentAddr;
  111 + }
  112 +
  113 + public void setAgentAddr(String agentAddr) {
  114 + this.agentAddr = agentAddr;
  115 + }
  116 +
  117 + public String getAgentTel() {
  118 + return agentTel;
  119 + }
  120 +
  121 + public void setAgentTel(String agentTel) {
  122 + this.agentTel = agentTel;
  123 + }
  124 +
  125 + public String getAgentType() {
  126 + return agentType;
  127 + }
  128 +
  129 + public void setAgentType(String agentType) {
  130 + this.agentType = agentType;
  131 + }
  132 +
  133 + public String getAddTime() {
  134 + return addTime;
  135 + }
  136 +
  137 + public void setAddTime(String addTime) {
  138 + this.addTime = addTime;
  139 + }
  140 +
  141 + public String getDistTime() {
  142 + return distTime;
  143 + }
  144 +
  145 + public void setDistTime(String distTime) {
  146 + this.distTime = distTime;
  147 + }
  148 +
  149 + public String getStatus() {
  150 + return status;
  151 + }
  152 +
  153 + public void setStatus(String status) {
  154 + this.status = status;
  155 + }
  156 +
  157 + public String getAgentSequence() {
  158 + return agentSequence;
  159 + }
  160 +
  161 + public void setAgentSequence(String agentSequence) {
  162 + this.agentSequence = agentSequence;
  163 + }
  164 +
  165 + public String getSysVersion() {
  166 + return sysVersion;
  167 + }
  168 +
  169 + public void setSysVersion(String sysVersion) {
  170 + this.sysVersion = sysVersion;
  171 + }
  172 + }
  173 + }
  174 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/8/5
  5 + */
  6 +public class ApkMessage {
  7 + /**
  8 + * code : 0
  9 + * msg : 成功
  10 + * data : {"verCode":"41","verName":"v4.1","description":"1,数据库共用.#2,搜索功能优化.#3,扫描优化.#3,其他片源兼容测试","appUrl":"http://apkhome.qiniudn.com/088/GimiCinema-qinlin-4.0-40-1.apk"}
  11 + */
  12 +
  13 + private int code;
  14 + private String msg;
  15 + /**
  16 + * verCode : 41
  17 + * verName : v4.1
  18 + * description : 1,数据库共用.#2,搜索功能优化.#3,扫描优化.#3,其他片源兼容测试
  19 + * appUrl : http://apkhome.qiniudn.com/088/GimiCinema-qinlin-4.0-40-1.apk
  20 + */
  21 +
  22 + private DataEntity data;
  23 +
  24 + public int getCode() {
  25 + return code;
  26 + }
  27 +
  28 + public void setCode(int code) {
  29 + this.code = code;
  30 + }
  31 +
  32 + public String getMsg() {
  33 + return msg;
  34 + }
  35 +
  36 + public void setMsg(String msg) {
  37 + this.msg = msg;
  38 + }
  39 +
  40 + public DataEntity getData() {
  41 + return data;
  42 + }
  43 +
  44 + public void setData(DataEntity data) {
  45 + this.data = data;
  46 + }
  47 +
  48 + public static class DataEntity {
  49 + private int verCode;
  50 + private String verName;
  51 + private String description;
  52 + private String appUrl;
  53 +
  54 + public int getVerCode() {
  55 + return verCode;
  56 + }
  57 +
  58 + public void setVerCode(int verCode) {
  59 + this.verCode = verCode;
  60 + }
  61 +
  62 + public String getVerName() {
  63 + return verName;
  64 + }
  65 +
  66 + public void setVerName(String verName) {
  67 + this.verName = verName;
  68 + }
  69 +
  70 + public String getDescription() {
  71 + return description;
  72 + }
  73 +
  74 + public void setDescription(String description) {
  75 + this.description = description;
  76 + }
  77 +
  78 + public String getAppUrl() {
  79 + return appUrl;
  80 + }
  81 +
  82 + public void setAppUrl(String appUrl) {
  83 + this.appUrl = appUrl;
  84 + }
  85 + }
  86 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +public class AsyncCallback<T> {
  4 + // private static final String TAG = AsynCallback.class.getSimpleName();
  5 +
  6 + public void onStart() {
  7 + }
  8 +
  9 + public void onDone() {
  10 + }
  11 +
  12 + public void onSuccess(T data) {
  13 + }
  14 +
  15 + public void onMessage(String data) {
  16 + }
  17 +
  18 + public void onFailure(final WrongMsg caught) {
  19 + }
  20 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import android.os.Parcel;
  4 +import android.os.Parcelable;
  5 +
  6 +/**
  7 + * Data provide foundation class(photo Music Video Other search).
  8 + */
  9 +public class BaseData implements Parcelable {
  10 + private String name;
  11 + private String path;
  12 + private long duration;
  13 + private int doubanId;
  14 + private String doubanUrl;
  15 + private String posterUrl;
  16 + private long lastPlayPosition;
  17 + private long lastPlayTime;
  18 +
  19 + public BaseData() {
  20 + }
  21 +
  22 + public int getDoubanId() {
  23 + return doubanId;
  24 + }
  25 +
  26 + public void setDoubanId(int doubanId) {
  27 + this.doubanId = doubanId;
  28 + }
  29 +
  30 + public String getDoubanUrl() {
  31 + return doubanUrl;
  32 + }
  33 +
  34 + public void setDoubanUrl(String doubanUrl) {
  35 + this.doubanUrl = doubanUrl;
  36 + }
  37 +
  38 + public String getPosterUrl() {
  39 + return posterUrl;
  40 + }
  41 +
  42 + public void setPosterUrl(String posterUrl) {
  43 + this.posterUrl = posterUrl;
  44 + }
  45 +
  46 + public long getLastPlayPosition() {
  47 + return lastPlayPosition;
  48 + }
  49 +
  50 + public void setLastPlayPosition(long lastPlayPosition) {
  51 + this.lastPlayPosition = lastPlayPosition;
  52 + }
  53 +
  54 + public long getLastPlayTime() {
  55 + return lastPlayTime;
  56 + }
  57 +
  58 + public void setLastPlayTime(long lastPlayTime) {
  59 + this.lastPlayTime = lastPlayTime;
  60 + }
  61 +
  62 + public void setDuration(long duration) {
  63 + this.duration = duration;
  64 + }
  65 +
  66 + public long getDuration() {
  67 + return duration;
  68 + }
  69 +
  70 + /**
  71 + * @return the name
  72 + */
  73 + public String getName() {
  74 + return name;
  75 + }
  76 +
  77 + /**
  78 + * @param name the name to set
  79 + */
  80 + public void setName(String name) {
  81 + this.name = name;
  82 + }
  83 +
  84 + /**
  85 + * @return the path
  86 + */
  87 + public String getPath() {
  88 + return path;
  89 + }
  90 +
  91 + /**
  92 + * @param path the path to set
  93 + */
  94 + public void setPath(String path) {
  95 + this.path = path;
  96 + }
  97 +
  98 + @Override
  99 + public String toString() {
  100 + return "BaseData{" +
  101 + "name='" + name + '\'' +
  102 + ", path='" + path + '\'' +
  103 + ", duration=" + duration +
  104 + ", doubanId=" + doubanId +
  105 + ", doubanUrl='" + doubanUrl + '\'' +
  106 + ", posterUrl='" + posterUrl + '\'' +
  107 + ", lastPlayPosition=" + lastPlayPosition +
  108 + ", lastPlayTime=" + lastPlayTime +
  109 + '}';
  110 + }
  111 +
  112 +
  113 + @Override
  114 + public int describeContents() {
  115 + return 0;
  116 + }
  117 +
  118 + @Override
  119 + public void writeToParcel(Parcel dest, int flags) {
  120 + dest.writeString(this.name);
  121 + dest.writeString(this.path);
  122 + dest.writeLong(this.duration);
  123 + dest.writeInt(this.doubanId);
  124 + dest.writeString(this.doubanUrl);
  125 + dest.writeString(this.posterUrl);
  126 + dest.writeLong(this.lastPlayPosition);
  127 + dest.writeLong(this.lastPlayTime);
  128 + }
  129 +
  130 + protected BaseData(Parcel in) {
  131 + this.name = in.readString();
  132 + this.path = in.readString();
  133 + this.duration = in.readLong();
  134 + this.doubanId = in.readInt();
  135 + this.doubanUrl = in.readString();
  136 + this.posterUrl = in.readString();
  137 + this.lastPlayPosition = in.readLong();
  138 + this.lastPlayTime = in.readLong();
  139 + }
  140 +
  141 + public static final Creator<BaseData> CREATOR = new Creator<BaseData>() {
  142 + public BaseData createFromParcel(Parcel source) {
  143 + return new BaseData(source);
  144 + }
  145 +
  146 + public BaseData[] newArray(int size) {
  147 + return new BaseData[size];
  148 + }
  149 + };
  150 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by 李攀 on 2015/12/21.
  5 + */
  6 +public class CinemaConfig {
  7 + private int dbVersion;
  8 + private int classVersion;
  9 + private String[] classArray;
  10 +
  11 + public CinemaConfig() {
  12 + }
  13 +
  14 + public int getDbVersion() {
  15 + return dbVersion;
  16 + }
  17 +
  18 + public void setDbVersion(int dbVersion) {
  19 + this.dbVersion = dbVersion;
  20 + }
  21 +
  22 + public int getClassVersion() {
  23 + return classVersion;
  24 + }
  25 +
  26 + public void setClassVersion(int classVersion) {
  27 + this.classVersion = classVersion;
  28 + }
  29 +
  30 +
  31 + public String[] getClassArray() {
  32 + return classArray;
  33 + }
  34 +
  35 + public void setClassArray(String[] classArray) {
  36 + this.classArray = classArray;
  37 + }
  38 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by 李攀 on 2015/7/7.
  5 + */
  6 +public class ClassificationItem {
  7 + private int color;
  8 + private String name;
  9 + private int icon;
  10 +
  11 + public int getColor() {
  12 + return color;
  13 + }
  14 +
  15 + public void setColor(int color) {
  16 + this.color = color;
  17 + }
  18 +
  19 + public String getName() {
  20 + return name;
  21 + }
  22 +
  23 + public void setName(String name) {
  24 + this.name = name;
  25 + }
  26 +
  27 + public int getIcon() {
  28 + return icon;
  29 + }
  30 +
  31 + public void setIcon(int icon) {
  32 + this.icon = icon;
  33 + }
  34 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/3/1.
  5 + */
  6 +public class CodeData {
  7 +
  8 + /**
  9 + * data :
  10 + * code : 602
  11 + * message : 此机器未被分配!
  12 + */
  13 +
  14 + private int code;
  15 + private String message;
  16 +
  17 + public void setCode(int code) {
  18 + this.code = code;
  19 + }
  20 +
  21 + public void setMessage(String message) {
  22 + this.message = message;
  23 + }
  24 +
  25 + public int getCode() {
  26 + return code;
  27 + }
  28 +
  29 + public String getMessage() {
  30 + return message;
  31 + }
  32 +
  33 + @Override
  34 + public String toString() {
  35 + return "CodeData{" +
  36 + "code=" + code +
  37 + ", message='" + message + '\'' +
  38 + '}';
  39 + }
  40 +}
\ No newline at end of file
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.xgimi.gimicinema.BuildConfig;
  4 +
  5 +/**
  6 + * Created by pc on 2014/12/11
  7 + */
  8 +public class Constant {
  9 + public static final String XML_NAME = "gimi-cinema-pref";
  10 +
  11 + public static final String ACTION_GET_MESSAGE_MEDIA_PLAYER_MOVIE_COMPLETE = "com.xgimi.gimicinema.get_data.movie_complete";
  12 + public static final String ACTION_GET_MESSAGE_CLOSE_LED = "com.xgimi.gimicinema_close_led";
  13 + public static final String GIMI_AUTHENTICATION = "gimi-authentication";
  14 + public static boolean run = true;
  15 + public static boolean messageRun = true;
  16 + public static boolean startAds = false;//现定义每部电影放完后播放两次广告,若系统结算则及时关闭光机,反之播放两次视频后再关闭光机
  17 + public static boolean isAdsOn = false;
  18 +
  19 + public static boolean gimiAuth = true;
  20 +
  21 +
  22 + public static String MOVIE_MESSAGE_NAME_NEW = "/mm.qnt";
  23 + public static String MOVIE_MESSAGE_NAME_OLD = "/mm.txt";
  24 +
  25 + public static String MOVIE_POSTER_GIF = "/video.gif";
  26 + public static String MOVIE_POSTER_NEW = "/poster.qnj";
  27 + public static String MOVIE_POSTER_OLD = "/poster.jpg";
  28 + public static String MOVIE_COUNT = "/.count.qdat";
  29 +
  30 + public static final int DB_INIT_SUCCESS = 0x0;
  31 + public static final int DB_INIT_FAILURE = 0x1;
  32 + public static final int DB_INIT_ZERO = 0x2;
  33 + public static final int DB_INIT_DONE = 0x3;
  34 + public static final int DB_INIT_START = 0x5;
  35 + public static final int DB_INIT_MSG = 0xE;
  36 + public static final int DB_DELETE_NOT_EXIST_START = 0x1A;
  37 + public static final int DB_DELETE_NOT_EXIST_SUCCESS = 0x1B;
  38 + public static final int DB_DELETE_NOT_EXIST_FAILURE = 0x1C;
  39 + public static final int DB_DELETE_NOT_EXIST_END = 0x1D;
  40 +
  41 + public static final int DB_UPDATE_DOUBAN_MSG_START = 0x20;
  42 + public static final int DB_UPDATE_DOUBAN_MSG_SUCCESS = 0x21;
  43 + public static final int DB_UPDATE_DOUBAN_MSG_FAILURE = 0x22;
  44 + public static final int DB_UPDATE_DOUBAN_MSG_END = 0x23;
  45 +
  46 + public static final String DEFAULT_IP = BuildConfig.DEFAULT_IP;
  47 + public static final String DEFAULT_USER = "admin";
  48 + public static final String DEFAULT_PWD = "Asd123456";
  49 + public static final String DEFAULT_FOLDER = "root";
  50 + public static final String DEFAULT_PATH = "";
  51 + public static boolean userOpen = false;
  52 +}
... ...
  1 +/*
  2 + * Copyright 2016 wugian
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +/**
  20 + * Created by wugian on 2016/12/28
  21 + */
  22 +
  23 +public class ControlMessage {
  24 + public int action;//0:默认播放单个电影,1:播放列表电影,2,同步播放电影相关状态(电影路径,
  25 + // 播放列表,电影进度,电影长度,电影播放状态 )
  26 + public UdpModel udpModel;
  27 +
  28 + public int getAction() {
  29 + return action;
  30 + }
  31 +
  32 + public void setAction(int action) {
  33 + this.action = action;
  34 + }
  35 +
  36 + public UdpModel getUdpModel() {
  37 + return udpModel;
  38 + }
  39 +
  40 + public void setUdpModel(UdpModel udpModel) {
  41 + this.udpModel = udpModel;
  42 + }
  43 +
  44 + @Override
  45 + public String toString() {
  46 + return "ControlMessage{" +
  47 + "action=" + action +
  48 + ", status=" + udpModel +
  49 + '}';
  50 + }
  51 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * Created by pc on 2014/12/9
  7 + */
  8 +//@Table(name = "type_table")
  9 +public class FolderItem implements Serializable {
  10 +// @Property(column = "_id")
  11 + private int id;
  12 +// @Property(column = "folder_name")
  13 + private String folderName;
  14 +// @Property(column = "poster_path")
  15 + private String posterPath;
  16 +// @Property(column = "folder_path")
  17 + private String folderPath;
  18 +
  19 +
  20 + public int getId() {
  21 + return id;
  22 + }
  23 +
  24 + public void setId(int id) {
  25 + this.id = id;
  26 + }
  27 +
  28 + public String getFolderName() {
  29 + return folderName;
  30 + }
  31 +
  32 + public void setFolderName(String folderName) {
  33 + this.folderName = folderName;
  34 + }
  35 +
  36 + public String getPosterPath() {
  37 + return posterPath;
  38 + }
  39 +
  40 + public void setPosterPath(String posterPath) {
  41 + this.posterPath = posterPath;
  42 + }
  43 +
  44 + public String getFolderPath() {
  45 + return folderPath;
  46 + }
  47 +
  48 + public void setFolderPath(String folderPath) {
  49 + this.folderPath = folderPath;
  50 + }
  51 +
  52 + @Override
  53 + public String toString() {
  54 + return "FolderItem{" +
  55 + "id=" + id +
  56 + ", folderName='" + folderName + '\'' +
  57 + ", posterPath='" + posterPath + '\'' +
  58 + ", folderPath='" + folderPath + '\'' +
  59 + '}';
  60 + }
  61 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by pc on 2015/1/6
  5 + */
  6 +public class GimiData {
  7 + // "status":"on","delay":300
  8 + private String status;
  9 + private int delay;
  10 +
  11 + public String getStatus() {
  12 + return status;
  13 + }
  14 +
  15 + public void setStatus(String status) {
  16 + this.status = status;
  17 + }
  18 +
  19 + public int getDelay() {
  20 + return delay;
  21 + }
  22 +
  23 + public void setDelay(int delay) {
  24 + this.delay = delay;
  25 + }
  26 +
  27 + @Override
  28 + public String toString() {
  29 + return "GimiData{" +
  30 + "status='" + status + '\'' +
  31 + ", delay=" + delay +
  32 + '}';
  33 + }
  34 +}
  35 +
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.google.gson.annotations.Expose;
  4 +
  5 +/**
  6 + * Created by pc on 2015/1/6.
  7 + * 服务器的消息用来判定系统的状态开关
  8 + */
  9 +public class GimiMessage {
  10 + // {"data":{"status":"on","delay":300},"code":200,"message":"ok"}
  11 + @Expose
  12 + private int code;
  13 + @Expose
  14 + private String message;
  15 + @Expose
  16 + private GimiData data;
  17 +
  18 + public int getCode() {
  19 + return code;
  20 + }
  21 +
  22 + public void setCode(int code) {
  23 + this.code = code;
  24 + }
  25 +
  26 + public String getMessage() {
  27 + return message;
  28 + }
  29 +
  30 + public void setMessage(String message) {
  31 + this.message = message;
  32 + }
  33 +
  34 + public GimiData getData() {
  35 + return data;
  36 + }
  37 +
  38 + public void setData(GimiData data) {
  39 + this.data = data;
  40 + }
  41 +
  42 + @Override
  43 + public String toString() {
  44 + return "GimiMessage{" +
  45 + "code=" + code +
  46 + ", message='" + message + '\'' +
  47 + ", data=" + (data == null ? "data is null" : data.toString()) +
  48 + '}';
  49 + }
  50 +}
  51 +
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.google.gson.annotations.Expose;
  4 +
  5 +/**
  6 + * Created by pc on 2015/1/6.
  7 + * 系统所发的信息,用以展示给用户
  8 + */
  9 +public class GimiSysData {
  10 +// "data":[
  11 +//
  12 +// {
  13 +// "Messages":{
  14 +// "msg_content":"asdfagsdfgasdf",
  15 +// "msg_type":"0",
  16 +// "addtime":"1420532750"
  17 +// }
  18 +// }
  19 +//
  20 +// ],
  21 + @Expose
  22 + Message Messages;
  23 +
  24 + public Message getMessages() {
  25 + return Messages;
  26 + }
  27 +
  28 + public void setMessages(Message messages) {
  29 + Messages = messages;
  30 + }
  31 +
  32 + @Override
  33 + public String toString() {
  34 + return "GimiSysData{" +
  35 + "Messages=" + Messages.toString() +
  36 + '}';
  37 + }
  38 +
  39 + public class Message {
  40 + @Expose
  41 + private String msg_content;
  42 + @Expose
  43 + private String msg_type;
  44 + @Expose
  45 + private String addtime;
  46 +
  47 +
  48 + public String getMsg_content() {
  49 + return msg_content;
  50 + }
  51 +
  52 + public String getMsg_type() {
  53 + return msg_type;
  54 + }
  55 +
  56 + public String getAddtime() {
  57 + return addtime;
  58 + }
  59 +
  60 + @Override
  61 + public String toString() {
  62 + return "Message{" +
  63 + "addtime='" + addtime + '\'' +
  64 + ", msg_type='" + msg_type + '\'' +
  65 + ", msg_content='" + msg_content + '\'' +
  66 + '}';
  67 + }
  68 + }
  69 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.google.gson.annotations.Expose;
  4 +
  5 +/**
  6 + * Created by pc on 2015/1/6
  7 + */
  8 +public class GimiSysMsg {
  9 +// "data": [
  10 +// {
  11 +// "Messages": {
  12 +// "msg_content": "asdfagsdfgasdf",
  13 +// "msg_type": "0",
  14 +// "addtime": "1420532750"
  15 +// }
  16 +// }
  17 +// ],
  18 +// "code": 200,
  19 +// "message": "ok"
  20 +
  21 + @Expose
  22 + String message;
  23 + @Expose
  24 + int code;
  25 + @Expose
  26 + GimiSysData[] data;
  27 +
  28 + public String getMessage() {
  29 + return message;
  30 + }
  31 +
  32 + public void setMessage(String message) {
  33 + this.message = message;
  34 + }
  35 +
  36 + public int getCode() {
  37 + return code;
  38 + }
  39 +
  40 + public void setCode(int code) {
  41 + this.code = code;
  42 + }
  43 +
  44 + public GimiSysData[] getData() {
  45 + return data;
  46 + }
  47 +
  48 + public void setData(GimiSysData[] data) {
  49 + this.data = data;
  50 + }
  51 +
  52 + @Override
  53 + public String toString() {
  54 + return "GimiSysMsg{" +
  55 + "message='" + message + '\'' +
  56 + ", code=" + code +
  57 + ", data=" + (data != null ? data.toString() : "data is null") +
  58 + '}';
  59 + }
  60 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import android.text.TextUtils;
  4 +import com.xgimi.gimicinema.activity.CinemaConfig;
  5 +
  6 +import java.io.Serializable;
  7 +import java.text.DateFormat;
  8 +import java.text.SimpleDateFormat;
  9 +import java.util.Calendar;
  10 +
  11 +/**
  12 + * Created by 李攀 on 2015/4/29
  13 + */
  14 +public class LocalMovieMessage implements Serializable {
  15 + private int id;
  16 + private String movieName;
  17 + private String posterPath;
  18 + private String playPath;
  19 + private String namePinyin;
  20 + private String md5;
  21 + private String type;
  22 + private String doubanId;
  23 + private String classDescribe;
  24 + private String movieLength;
  25 + private double doubanRating;
  26 + private String lastPlayTime;
  27 + private String screenTime;
  28 + private int count;
  29 + private String dlTime;
  30 +
  31 + public int getId() {
  32 + return id;
  33 + }
  34 +
  35 + public void setId(int id) {
  36 + this.id = id;
  37 + }
  38 +
  39 + public String getMovieName() {
  40 + return movieName;
  41 + }
  42 +
  43 + public void setMovieName(String movieName) {
  44 + this.movieName = movieName;
  45 + }
  46 +
  47 + public String getPosterPath() {
  48 + if (TextUtils.isEmpty(posterPath) || posterPath.startsWith("/mnt/samba/")|| posterPath.startsWith("/Uploads/pic/")
  49 + || posterPath.startsWith("/mnt/usb/")) {
  50 + return posterPath;
  51 + }
  52 + return CinemaConfig.BASIC_ROOT + posterPath;
  53 + }
  54 +
  55 + public void setPosterPath(String posterPath) {
  56 + if (TextUtils.isEmpty(posterPath)) {
  57 + this.posterPath = null;
  58 + } else {
  59 + this.posterPath = posterPath.replace(CinemaConfig.BASIC_ROOT, "");
  60 + }
  61 + }
  62 +
  63 + public String getPlayPath() {
  64 + if (TextUtils.isEmpty(playPath) || playPath.startsWith("/mnt/samba/")|| playPath.startsWith("/mnt/usb/")) {
  65 + return playPath;
  66 + }
  67 + return CinemaConfig.BASIC_ROOT + playPath;
  68 + }
  69 +
  70 + public void setPlayPath(String playPath) {
  71 + if (TextUtils.isEmpty(playPath)) {
  72 + this.playPath = null;
  73 + } else {
  74 + this.playPath = playPath.replace(CinemaConfig.BASIC_ROOT, "");
  75 + }
  76 + }
  77 +
  78 + public String getNamePinyin() {
  79 + return namePinyin;
  80 + }
  81 +
  82 + public void setNamePinyin(String namePinyin) {
  83 + this.namePinyin = namePinyin;
  84 + }
  85 +
  86 + public String getMd5() {
  87 + return md5;
  88 + }
  89 +
  90 + public void setMd5(String md5) {
  91 + this.md5 = md5;
  92 + }
  93 +
  94 + public String getType() {
  95 + return type;
  96 + }
  97 +
  98 + public void setType(String type) {
  99 + this.type = type;
  100 + }
  101 +
  102 + public String getDoubanId() {
  103 + return doubanId;
  104 + }
  105 +
  106 + public void setDoubanId(String doubanId) {
  107 + this.doubanId = doubanId;
  108 + }
  109 +
  110 + public String getClassDescribe() {
  111 + return classDescribe;
  112 + }
  113 +
  114 + public void setClassDescribe(String classDescribe) {
  115 + this.classDescribe = classDescribe;
  116 + }
  117 +
  118 + public String getMovieLength() {
  119 + return movieLength;
  120 + }
  121 +
  122 + public void setMovieLength(String movieLength) {
  123 + this.movieLength = movieLength;
  124 + }
  125 +
  126 + public double getDoubanRating() {
  127 + return doubanRating;
  128 + }
  129 +
  130 + public void setDoubanRating(double doubanRating) {
  131 + this.doubanRating = doubanRating;
  132 + }
  133 +
  134 + public String getLastPlayTime() {
  135 + return lastPlayTime;
  136 + }
  137 +
  138 + public void setLastPlayTime(long lastPlayTime1) {
  139 + DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
  140 + Calendar calendar = Calendar.getInstance();
  141 + calendar.setTimeInMillis(lastPlayTime1);
  142 + String format = formatter.format(calendar.getTime());
  143 + this.lastPlayTime = format;
  144 + }
  145 +
  146 + public void setLastPlayTime(String lastPlayTime) {
  147 + this.lastPlayTime = lastPlayTime;
  148 + }
  149 +
  150 + public String getScreenTime() {
  151 + return screenTime;
  152 + }
  153 +
  154 + public void setScreenTime(String screenTime) {
  155 + this.screenTime = screenTime;
  156 + }
  157 +
  158 +
  159 + public int getCount() {
  160 + return count;
  161 + }
  162 +
  163 + public void setCount(int count) {
  164 + this.count = count;
  165 + }
  166 +
  167 + public String getDlTime() {
  168 + return dlTime;
  169 + }
  170 +
  171 + public void setDlTime(String dlTime) {
  172 + this.dlTime = dlTime;
  173 + }
  174 +
  175 + @Override
  176 + public String toString() {
  177 + return "LocalMovieMessage{" +
  178 + "id=" + id +
  179 + ", movieName='" + movieName + '\'' +
  180 + ", posterPath='" + posterPath + '\'' +
  181 + ", playPath='" + playPath + '\'' +
  182 + ", namePinyin='" + namePinyin + '\'' +
  183 + ", md5='" + md5 + '\'' +
  184 + ", type='" + type + '\'' +
  185 + ", doubanId='" + doubanId + '\'' +
  186 + ", classDescribe='" + classDescribe + '\'' +
  187 + ", movieLength='" + movieLength + '\'' +
  188 + ", doubanRating='" + doubanRating + '\'' +
  189 + ", lastPlayTime=" + lastPlayTime +
  190 + ", screenTime=" + screenTime +
  191 + '}';
  192 + }
  193 +}
... ...
  1 +/*
  2 + * Copyright (c) 2016. wugian
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +import com.google.gson.annotations.Expose;
  20 +
  21 +/**
  22 + * Created by pc on 2015/1/6.
  23 + * 系统所发的信息,用以展示给用户
  24 + */
  25 +public class MessageData {
  26 +// "data":[
  27 +//
  28 +// {
  29 +// "Messages":{
  30 +// "msg_content":"asdfagsdfgasdf",
  31 +// "msg_type":"0",
  32 +// "addtime":"1420532750"
  33 +// }
  34 +// }
  35 +//
  36 +// ],
  37 + @Expose
  38 + Message Messages;
  39 +
  40 + public Message getMessages() {
  41 + return Messages;
  42 + }
  43 +
  44 + public void setMessages(Message messages) {
  45 + Messages = messages;
  46 + }
  47 +
  48 + @Override
  49 + public String toString() {
  50 + return "MessageData{" +
  51 + "Messages=" + Messages.toString() +
  52 + '}';
  53 + }
  54 +
  55 + public class Message {
  56 + @Expose
  57 + private String msg_content;
  58 + @Expose
  59 + private String msg_type;
  60 + @Expose
  61 + private String addtime;
  62 +
  63 +
  64 + public String getMsg_content() {
  65 + return msg_content;
  66 + }
  67 +
  68 + public String getMsg_type() {
  69 + return msg_type;
  70 + }
  71 +
  72 + public String getAddtime() {
  73 + return addtime;
  74 + }
  75 +
  76 + @Override
  77 + public String toString() {
  78 + return "Message{" +
  79 + "addtime='" + addtime + '\'' +
  80 + ", msg_type='" + msg_type + '\'' +
  81 + ", msg_content='" + msg_content + '\'' +
  82 + '}';
  83 + }
  84 + }
  85 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +public class MessageEvent {
  4 + private int eventId;
  5 + private String message;
  6 +
  7 + public int getEventId() {
  8 + return eventId;
  9 + }
  10 +
  11 + public void setEventId(int eventId) {
  12 + this.eventId = eventId;
  13 + }
  14 +
  15 + public String getMessage() {
  16 + return message;
  17 + }
  18 +
  19 + public void setMessage(String message) {
  20 + this.message = message;
  21 + }
  22 +}
\ No newline at end of file
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by pc on 2014/12/24.演员,导演属性
  5 + */
  6 +public class MovieCast {
  7 +
  8 +
  9 + private MovieImages avatars;
  10 + private String alt;
  11 + private String id;
  12 + private String name;
  13 +
  14 + public MovieImages getAvatars() {
  15 + return avatars;
  16 + }
  17 +
  18 + public void setAvatars(MovieImages avatars) {
  19 + this.avatars = avatars;
  20 + }
  21 +
  22 + public String getAlt() {
  23 + return alt;
  24 + }
  25 +
  26 + public void setAlt(String alt) {
  27 + this.alt = alt;
  28 + }
  29 +
  30 + public String getId() {
  31 + return id;
  32 + }
  33 +
  34 + public void setId(String id) {
  35 + this.id = id;
  36 + }
  37 +
  38 + public String getName() {
  39 + return name;
  40 + }
  41 +
  42 + public void setName(String name) {
  43 + this.name = name;
  44 + }
  45 +
  46 + @Override
  47 + public String toString() {
  48 + return "MovieCast{" +
  49 + "avatars=" + avatars +
  50 + ", alt='" + alt + '\'' +
  51 + ", id='" + id + '\'' +
  52 + ", name='" + name + '\'' +
  53 + '}';
  54 + }
  55 +}
  56 +
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by pc on 2014/12/24
  5 + */
  6 +public class MovieImages {
  7 + private String small;
  8 + private String large;
  9 + private String medium;
  10 +
  11 + public String getSmall() {
  12 + return small;
  13 + }
  14 +
  15 + public void setSmall(String small) {
  16 + this.small = small;
  17 + }
  18 +
  19 + public String getLarge() {
  20 + return large;
  21 + }
  22 +
  23 + public void setLarge(String large) {
  24 + this.large = large;
  25 + }
  26 +
  27 + public String getMedium() {
  28 + return medium;
  29 + }
  30 +
  31 + public void setMedium(String medium) {
  32 + this.medium = medium;
  33 + }
  34 +
  35 + @Override
  36 + public String toString() {
  37 + return "MovieImages{" +
  38 + "small='" + small + '\'' +
  39 + ", large='" + large + '\'' +
  40 + ", medium='" + medium + '\'' +
  41 + '}';
  42 + }
  43 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.google.gson.annotations.Expose;
  4 +
  5 +import java.util.Arrays;
  6 +
  7 +/**
  8 + * Created by pc on 2014/12/24.
  9 + */
  10 +public class MovieMessage {
  11 + @Expose
  12 + private Rating rating;
  13 + @Expose
  14 + private int reviews_count;
  15 + @Expose
  16 + private int wish_count;
  17 + @Expose
  18 + private int collect_count;
  19 + @Expose
  20 + private String douban_site;
  21 + @Expose
  22 + private String year;
  23 + @Expose
  24 + private MovieImages images;
  25 + @Expose
  26 + private String alt;
  27 + @Expose
  28 + private String id;
  29 + @Expose
  30 + private String mobile_url;
  31 + @Expose
  32 + private String title;
  33 + @Expose
  34 + private String do_count;// not confirm type
  35 + @Expose
  36 + private String seasons_count;// not confirm type
  37 + @Expose
  38 + private String schedule_url;// not confirm type
  39 + @Expose
  40 + private String episodes_count;// not confirm type
  41 + @Expose
  42 + private String[] genres;//分类,关键词
  43 + @Expose
  44 + private String[] countries;
  45 + @Expose
  46 + private MovieCast[] casts;//演员列表
  47 + @Expose
  48 + private String current_season;//
  49 + @Expose
  50 + private String original_title;//原名
  51 + @Expose
  52 + private String summary;//电影简介:互相猜忌,却无意间发现了彼此间的联系。但是,大家怀疑的嫌疑人却纷纷死去,谜团笼罩在旅馆狭小的空间里,这样的凶杀案件却有着人们猜不到的真相……©豆瓣",
  53 + @Expose
  54 + private String subtype;// 电影 音乐 图书 (英文)……
  55 + @Expose
  56 + private MovieCast[] directors;
  57 + @Expose
  58 + private int comments_count;
  59 + @Expose
  60 + private int ratings_count;
  61 + @Expose
  62 + private String []aka;//应该是别名
  63 +
  64 + public Rating getRating() {
  65 + return rating;
  66 + }
  67 +
  68 + public void setRating(Rating rating) {
  69 + this.rating = rating;
  70 + }
  71 +
  72 + public int getReviews_count() {
  73 + return reviews_count;
  74 + }
  75 +
  76 + public void setReviews_count(int reviews_count) {
  77 + this.reviews_count = reviews_count;
  78 + }
  79 +
  80 + public int getWish_count() {
  81 + return wish_count;
  82 + }
  83 +
  84 + public void setWish_count(int wish_count) {
  85 + this.wish_count = wish_count;
  86 + }
  87 +
  88 + public int getCollect_count() {
  89 + return collect_count;
  90 + }
  91 +
  92 + public void setCollect_count(int collect_count) {
  93 + this.collect_count = collect_count;
  94 + }
  95 +
  96 + public String getDouban_site() {
  97 + return douban_site;
  98 + }
  99 +
  100 + public void setDouban_site(String douban_site) {
  101 + this.douban_site = douban_site;
  102 + }
  103 +
  104 + public String getYear() {
  105 + return year;
  106 + }
  107 +
  108 + public void setYear(String year) {
  109 + this.year = year;
  110 + }
  111 +
  112 + public MovieImages getImages() {
  113 + return images;
  114 + }
  115 +
  116 + public void setImages(MovieImages images) {
  117 + this.images = images;
  118 + }
  119 +
  120 + public String getAlt() {
  121 + return alt;
  122 + }
  123 +
  124 + public void setAlt(String alt) {
  125 + this.alt = alt;
  126 + }
  127 +
  128 + public String getId() {
  129 + return id;
  130 + }
  131 +
  132 + public void setId(String id) {
  133 + this.id = id;
  134 + }
  135 +
  136 + public String getMobile_url() {
  137 + return mobile_url;
  138 + }
  139 +
  140 + public void setMobile_url(String mobile_url) {
  141 + this.mobile_url = mobile_url;
  142 + }
  143 +
  144 + public String getTitle() {
  145 + return title;
  146 + }
  147 +
  148 + public void setTitle(String title) {
  149 + this.title = title;
  150 + }
  151 +
  152 + public String getDo_count() {
  153 + return do_count;
  154 + }
  155 +
  156 + public void setDo_count(String do_count) {
  157 + this.do_count = do_count;
  158 + }
  159 +
  160 + public String getSeasons_count() {
  161 + return seasons_count;
  162 + }
  163 +
  164 + public void setSeasons_count(String seasons_count) {
  165 + this.seasons_count = seasons_count;
  166 + }
  167 +
  168 + public String getSchedule_url() {
  169 + return schedule_url;
  170 + }
  171 +
  172 + public void setSchedule_url(String schedule_url) {
  173 + this.schedule_url = schedule_url;
  174 + }
  175 +
  176 + public String getEpisodes_count() {
  177 + return episodes_count;
  178 + }
  179 +
  180 + public void setEpisodes_count(String episodes_count) {
  181 + this.episodes_count = episodes_count;
  182 + }
  183 +
  184 + public String[] getGenres() {
  185 + return genres;
  186 + }
  187 +
  188 + public void setGenres(String[] genres) {
  189 + this.genres = genres;
  190 + }
  191 +
  192 + public String[] getCountries() {
  193 + return countries;
  194 + }
  195 +
  196 + public void setCountries(String[] countries) {
  197 + this.countries = countries;
  198 + }
  199 +
  200 + public MovieCast[] getCasts() {
  201 + return casts;
  202 + }
  203 +
  204 + public void setCasts(MovieCast[] casts) {
  205 + this.casts = casts;
  206 + }
  207 +
  208 + public String getCurrent_season() {
  209 + return current_season;
  210 + }
  211 +
  212 + public void setCurrent_season(String current_season) {
  213 + this.current_season = current_season;
  214 + }
  215 +
  216 + public String getOriginal_title() {
  217 + return original_title;
  218 + }
  219 +
  220 + public void setOriginal_title(String original_title) {
  221 + this.original_title = original_title;
  222 + }
  223 +
  224 + public String getSummary() {
  225 + return summary;
  226 + }
  227 +
  228 + public void setSummary(String summary) {
  229 + this.summary = summary;
  230 + }
  231 +
  232 + public String getSubtype() {
  233 + return subtype;
  234 + }
  235 +
  236 + public void setSubtype(String subtype) {
  237 + this.subtype = subtype;
  238 + }
  239 +
  240 + public MovieCast[] getDirectors() {
  241 + return directors;
  242 + }
  243 +
  244 + public void setDirectors(MovieCast[] directors) {
  245 + this.directors = directors;
  246 + }
  247 +
  248 + public int getComments_count() {
  249 + return comments_count;
  250 + }
  251 +
  252 + public void setComments_count(int comments_count) {
  253 + this.comments_count = comments_count;
  254 + }
  255 +
  256 + public int getRatings_count() {
  257 + return ratings_count;
  258 + }
  259 +
  260 + public void setRatings_count(int ratings_count) {
  261 + this.ratings_count = ratings_count;
  262 + }
  263 +
  264 + public String[] getAka() {
  265 + return aka;
  266 + }
  267 +
  268 + public void setAka(String[] aka) {
  269 + this.aka = aka;
  270 + }
  271 +
  272 + @Override
  273 + public String toString() {
  274 + return "MM{" +
  275 + "rating=" + rating +
  276 + ", reviews_count=" + reviews_count +
  277 + ", wish_count=" + wish_count +
  278 + ", collect_count=" + collect_count +
  279 + ", douban_site='" + douban_site + '\'' +
  280 + ", year='" + year + '\'' +
  281 + ", images=" + images +
  282 + ", alt='" + alt + '\'' +
  283 + ", id='" + id + '\'' +
  284 + ", mobile_url='" + mobile_url + '\'' +
  285 + ", title='" + title + '\'' +
  286 + ", do_count='" + do_count + '\'' +
  287 + ", seasons_count='" + seasons_count + '\'' +
  288 + ", schedule_url='" + schedule_url + '\'' +
  289 + ", episodes_count='" + episodes_count + '\'' +
  290 + ", genres=" + Arrays.toString(genres) +
  291 + ", countries=" + Arrays.toString(countries) +
  292 + ", casts=" + Arrays.toString(casts) +
  293 + ", current_season='" + current_season + '\'' +
  294 + ", original_title='" + original_title + '\'' +
  295 + ", summary='" + summary + '\'' +
  296 + ", subtype='" + subtype + '\'' +
  297 + ", directors=" + Arrays.toString(directors) +
  298 + ", comments_count=" + comments_count +
  299 + ", ratings_count=" + ratings_count +
  300 + ", aka=" + Arrays.toString(aka) +
  301 + '}';
  302 + }
  303 +}
... ...
  1 +/*
  2 + * Copyright 2016 wugian
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +import java.util.List;
  20 +
  21 +public class PlayStatus {
  22 +
  23 + public PlayStatus(){}
  24 + public int state;
  25 + public long currentPosition;
  26 + public long movieLength;
  27 + public String path;
  28 + public List<String> movieUrls;
  29 +
  30 + public int getState() {
  31 + return state;
  32 + }
  33 +
  34 + public void setState(int state) {
  35 + this.state = state;
  36 + }
  37 +
  38 + public long getCurrentPosition() {
  39 + return currentPosition;
  40 + }
  41 +
  42 + public void setCurrentPosition(long currentPosition) {
  43 + this.currentPosition = currentPosition;
  44 + }
  45 +
  46 + public long getMovieLength() {
  47 + return movieLength;
  48 + }
  49 +
  50 + public void setMovieLength(long movieLength) {
  51 + this.movieLength = movieLength;
  52 + }
  53 +
  54 + public String getPath() {
  55 + return path;
  56 + }
  57 +
  58 + public void setPath(String path) {
  59 + this.path = path;
  60 + }
  61 +
  62 + public List<String> getMovieUrls() {
  63 + return movieUrls;
  64 + }
  65 +
  66 + public void setMovieUrls(List<String> movieUrls) {
  67 + this.movieUrls = movieUrls;
  68 + }
  69 +
  70 + @Override
  71 + public String toString() {
  72 + return "PlayStatus{" +
  73 + "state=" + state +
  74 + ", currentPosition=" + currentPosition +
  75 + ", movieLength=" + movieLength +
  76 + ", path='" + path + '\'' +
  77 + ", movieUrls=" + movieUrls +
  78 + '}';
  79 + }
  80 + }
... ...
  1 +/*
  2 + * Copyright 2016 wugian
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +/**
  20 + * Created by wugian on 2016/12/28
  21 + */
  22 +
  23 +public class PlayStatusMessage {
  24 + public int action;
  25 + public PlayStatus status;
  26 +
  27 + public int getAction() {
  28 + return action;
  29 + }
  30 +
  31 + public void setAction(int action) {
  32 + this.action = action;
  33 + }
  34 +
  35 + public PlayStatus getStatus() {
  36 + return status;
  37 + }
  38 +
  39 + public void setStatus(PlayStatus status) {
  40 + this.status = status;
  41 + }
  42 +
  43 + @Override
  44 + public String toString() {
  45 + return "PlayStatusMessage{" +
  46 + "action=" + action +
  47 + ", status=" + status +
  48 + '}';
  49 + }
  50 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/8/4
  5 + */
  6 +public class PosterMessage {
  7 +
  8 + /**
  9 + * code : 0
  10 + * msg : 成功
  11 + * data : {"versionId":"b52b6c33","posterUrl":"http://qnbar-test.oss-cn-hangzhou.aliyuncs.com/fbms/upload/img/57a2f46039dd1.jpg"}
  12 + */
  13 +
  14 + private int code;
  15 + private String msg;
  16 + /**
  17 + * versionId : b52b6c33
  18 + * posterUrl : http://qnbar-test.oss-cn-hangzhou.aliyuncs.com/fbms/upload/img/57a2f46039dd1.jpg
  19 + */
  20 +
  21 + private DataEntity data;
  22 +
  23 + public int getCode() {
  24 + return code;
  25 + }
  26 +
  27 + public void setCode(int code) {
  28 + this.code = code;
  29 + }
  30 +
  31 + public String getMsg() {
  32 + return msg;
  33 + }
  34 +
  35 + public void setMsg(String msg) {
  36 + this.msg = msg;
  37 + }
  38 +
  39 + public DataEntity getData() {
  40 + return data;
  41 + }
  42 +
  43 + public void setData(DataEntity data) {
  44 + this.data = data;
  45 + }
  46 +
  47 + public class DataEntity {
  48 + private String versionId;
  49 + private String posterUrl;
  50 +
  51 + public String getVersionId() {
  52 + return versionId;
  53 + }
  54 +
  55 + public void setVersionId(String versionId) {
  56 + this.versionId = versionId;
  57 + }
  58 +
  59 + public String getPosterUrl() {
  60 + return posterUrl;
  61 + }
  62 +
  63 + public void setPosterUrl(String posterUrl) {
  64 + this.posterUrl = posterUrl;
  65 + }
  66 + }
  67 +}
... ...
  1 +/*
  2 + * Copyright (c) 2016. wugian
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +
  20 +/**
  21 + * Created by wugian on 2016/11/15
  22 + */
  23 +public class QnResult<ObjectType> {
  24 + private int code;
  25 + private String message;
  26 + private int error;
  27 + private ObjectType t;//t is List<MessageData> StatusData
  28 +
  29 + public int getCode() {
  30 + return code;
  31 + }
  32 +
  33 + public void setCode(int code) {
  34 + this.code = code;
  35 + }
  36 +
  37 + public String getMessage() {
  38 + return message;
  39 + }
  40 +
  41 + public void setMessage(String message) {
  42 + this.message = message;
  43 + }
  44 +
  45 + public int getError() {
  46 + return error;
  47 + }
  48 +
  49 + public void setError(int error) {
  50 + this.error = error;
  51 + }
  52 +
  53 + public ObjectType getT() {
  54 + return t;
  55 + }
  56 +
  57 + public void setT(ObjectType t) {
  58 + this.t = t;
  59 + }
  60 +
  61 + @Override
  62 + public String toString() {
  63 + return "QnResult{" +
  64 + "code=" + code +
  65 + ", message='" + message + '\'' +
  66 + ", error=" + error +
  67 + ", t=" + (t == null ? "type is null" : t.toString()) +
  68 + '}';
  69 + }
  70 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import java.util.List;
  4 +
  5 +/**
  6 + * Created by wugian on 2015/12/29
  7 + */
  8 +public class QueryBean {
  9 +
  10 + /**
  11 + * count : 3
  12 + * start : 0
  13 + * total : 2
  14 + * subjects : [{"rating":{"max":10,"average":9.6,"stars":"50","min":0},"genres":["犯罪","剧情"],"collect_count":888203,"casts":[{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/1679.jpg","large":"https://img1.doubanio.com/img/celebrity/large/1679.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/1679.jpg"},"alt":"http://movie.douban.com/celebrity/1054521/","id":"1054521","name":"蒂姆·罗宾斯"},{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/34642.jpg","large":"https://img1.doubanio.com/img/celebrity/large/34642.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/34642.jpg"},"alt":"http://movie.douban.com/celebrity/1054534/","id":"1054534","name":"摩根·弗里曼"},{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/5837.jpg","large":"https://img1.doubanio.com/img/celebrity/large/5837.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/5837.jpg"},"alt":"http://movie.douban.com/celebrity/1041179/","id":"1041179","name":"鲍勃·冈顿"}],"title":"肖申克的救赎","original_title":"The Shawshank Redemption","subtype":"movie","directors":[{"avatars":{"small":"https://img3.doubanio.com/img/celebrity/small/230.jpg","large":"https://img3.doubanio.com/img/celebrity/large/230.jpg","medium":"https://img3.doubanio.com/img/celebrity/medium/230.jpg"},"alt":"http://movie.douban.com/celebrity/1047973/","id":"1047973","name":"弗兰克·德拉邦特"}],"year":"1994","images":{"small":"https://img1.doubanio.com/view/movie_poster_cover/ipst/public/p480747492.jpg","large":"https://img1.doubanio.com/view/movie_poster_cover/lpst/public/p480747492.jpg","medium":"https://img1.doubanio.com/view/movie_poster_cover/spst/public/p480747492.jpg"},"alt":"http://movie.douban.com/subject/1292052/","id":"1292052"},{"rating":{"max":10,"average":0,"stars":"00","min":0},"genres":["科幻","短片"],"collect_count":15,"casts":[],"title":"搏击之王第五集","original_title":"Redemption","subtype":"movie","directors":[{"avatars":null,"alt":null,"id":null,"name":"Balthasar von Weymarn"}],"year":"1995","images":{"small":"https://img1.doubanio.com/spic/s6810648.jpg","large":"https://img1.doubanio.com/lpic/s6810648.jpg","medium":"https://img1.doubanio.com/mpic/s6810648.jpg"},"alt":"http://movie.douban.com/subject/1306171/","id":"1306171"}]
  15 + * title : 搜索 "肖申克的救赎" 的结果
  16 + */
  17 +
  18 + private int count;
  19 + private int start;
  20 + private int total;
  21 + private String title;
  22 + /**
  23 + * rating : {"max":10,"average":9.6,"stars":"50","min":0}
  24 + * genres : ["犯罪","剧情"]
  25 + * collect_count : 888203
  26 + * casts : [{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/1679.jpg","large":"https://img1.doubanio.com/img/celebrity/large/1679.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/1679.jpg"},"alt":"http://movie.douban.com/celebrity/1054521/","id":"1054521","name":"蒂姆·罗宾斯"},{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/34642.jpg","large":"https://img1.doubanio.com/img/celebrity/large/34642.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/34642.jpg"},"alt":"http://movie.douban.com/celebrity/1054534/","id":"1054534","name":"摩根·弗里曼"},{"avatars":{"small":"https://img1.doubanio.com/img/celebrity/small/5837.jpg","large":"https://img1.doubanio.com/img/celebrity/large/5837.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/5837.jpg"},"alt":"http://movie.douban.com/celebrity/1041179/","id":"1041179","name":"鲍勃·冈顿"}]
  27 + * title : 肖申克的救赎
  28 + * original_title : The Shawshank Redemption
  29 + * subtype : movie
  30 + * directors : [{"avatars":{"small":"https://img3.doubanio.com/img/celebrity/small/230.jpg","large":"https://img3.doubanio.com/img/celebrity/large/230.jpg","medium":"https://img3.doubanio.com/img/celebrity/medium/230.jpg"},"alt":"http://movie.douban.com/celebrity/1047973/","id":"1047973","name":"弗兰克·德拉邦特"}]
  31 + * year : 1994
  32 + * images : {"small":"https://img1.doubanio.com/view/movie_poster_cover/ipst/public/p480747492.jpg","large":"https://img1.doubanio.com/view/movie_poster_cover/lpst/public/p480747492.jpg","medium":"https://img1.doubanio.com/view/movie_poster_cover/spst/public/p480747492.jpg"}
  33 + * alt : http://movie.douban.com/subject/1292052/
  34 + * id : 1292052
  35 + */
  36 +
  37 + private List<SubjectsEntity> subjects;
  38 +
  39 + public void setCount(int count) {
  40 + this.count = count;
  41 + }
  42 +
  43 + public void setStart(int start) {
  44 + this.start = start;
  45 + }
  46 +
  47 + public void setTotal(int total) {
  48 + this.total = total;
  49 + }
  50 +
  51 + public void setTitle(String title) {
  52 + this.title = title;
  53 + }
  54 +
  55 + public void setSubjects(List<SubjectsEntity> subjects) {
  56 + this.subjects = subjects;
  57 + }
  58 +
  59 + public int getCount() {
  60 + return count;
  61 + }
  62 +
  63 + public int getStart() {
  64 + return start;
  65 + }
  66 +
  67 + public int getTotal() {
  68 + return total;
  69 + }
  70 +
  71 + public String getTitle() {
  72 + return title;
  73 + }
  74 +
  75 + public List<SubjectsEntity> getSubjects() {
  76 + return subjects;
  77 + }
  78 +
  79 + public static class SubjectsEntity {
  80 + /**
  81 + * max : 10
  82 + * average : 9.6
  83 + * stars : 50
  84 + * min : 0
  85 + */
  86 +
  87 + private RatingEntity rating;
  88 + private int collect_count;
  89 + private String title;
  90 + private String original_title;
  91 + private String subtype;
  92 + private String year;
  93 + /**
  94 + * small : https://img1.doubanio.com/view/movie_poster_cover/ipst/public/p480747492.jpg
  95 + * large : https://img1.doubanio.com/view/movie_poster_cover/lpst/public/p480747492.jpg
  96 + * medium : https://img1.doubanio.com/view/movie_poster_cover/spst/public/p480747492.jpg
  97 + */
  98 +
  99 + private ImagesEntity images;
  100 + private String alt;
  101 + private String id;
  102 + private List<String> genres;
  103 + /**
  104 + * avatars : {"small":"https://img1.doubanio.com/img/celebrity/small/1679.jpg","large":"https://img1.doubanio.com/img/celebrity/large/1679.jpg","medium":"https://img1.doubanio.com/img/celebrity/medium/1679.jpg"}
  105 + * alt : http://movie.douban.com/celebrity/1054521/
  106 + * id : 1054521
  107 + * name : 蒂姆·罗宾斯
  108 + */
  109 +
  110 + private List<CastsEntity> casts;
  111 + /**
  112 + * avatars : {"small":"https://img3.doubanio.com/img/celebrity/small/230.jpg","large":"https://img3.doubanio.com/img/celebrity/large/230.jpg","medium":"https://img3.doubanio.com/img/celebrity/medium/230.jpg"}
  113 + * alt : http://movie.douban.com/celebrity/1047973/
  114 + * id : 1047973
  115 + * name : 弗兰克·德拉邦特
  116 + */
  117 +
  118 + private List<DirectorsEntity> directors;
  119 +
  120 + public void setRating(RatingEntity rating) {
  121 + this.rating = rating;
  122 + }
  123 +
  124 + public void setCollect_count(int collect_count) {
  125 + this.collect_count = collect_count;
  126 + }
  127 +
  128 + public void setTitle(String title) {
  129 + this.title = title;
  130 + }
  131 +
  132 + public void setOriginal_title(String original_title) {
  133 + this.original_title = original_title;
  134 + }
  135 +
  136 + public void setSubtype(String subtype) {
  137 + this.subtype = subtype;
  138 + }
  139 +
  140 + public void setYear(String year) {
  141 + this.year = year;
  142 + }
  143 +
  144 + public void setImages(ImagesEntity images) {
  145 + this.images = images;
  146 + }
  147 +
  148 + public void setAlt(String alt) {
  149 + this.alt = alt;
  150 + }
  151 +
  152 + public void setId(String id) {
  153 + this.id = id;
  154 + }
  155 +
  156 + public void setGenres(List<String> genres) {
  157 + this.genres = genres;
  158 + }
  159 +
  160 + public void setCasts(List<CastsEntity> casts) {
  161 + this.casts = casts;
  162 + }
  163 +
  164 + public void setDirectors(List<DirectorsEntity> directors) {
  165 + this.directors = directors;
  166 + }
  167 +
  168 + public RatingEntity getRating() {
  169 + return rating;
  170 + }
  171 +
  172 + public int getCollect_count() {
  173 + return collect_count;
  174 + }
  175 +
  176 + public String getTitle() {
  177 + return title;
  178 + }
  179 +
  180 + public String getOriginal_title() {
  181 + return original_title;
  182 + }
  183 +
  184 + public String getSubtype() {
  185 + return subtype;
  186 + }
  187 +
  188 + public String getYear() {
  189 + return year;
  190 + }
  191 +
  192 + public ImagesEntity getImages() {
  193 + return images;
  194 + }
  195 +
  196 + public String getAlt() {
  197 + return alt;
  198 + }
  199 +
  200 + public String getId() {
  201 + return id;
  202 + }
  203 +
  204 + public List<String> getGenres() {
  205 + return genres;
  206 + }
  207 +
  208 + public List<CastsEntity> getCasts() {
  209 + return casts;
  210 + }
  211 +
  212 + public List<DirectorsEntity> getDirectors() {
  213 + return directors;
  214 + }
  215 +
  216 + public static class RatingEntity {
  217 + private int max;
  218 + private double average;
  219 + private String stars;
  220 + private int min;
  221 +
  222 + public void setMax(int max) {
  223 + this.max = max;
  224 + }
  225 +
  226 + public void setAverage(double average) {
  227 + this.average = average;
  228 + }
  229 +
  230 + public void setStars(String stars) {
  231 + this.stars = stars;
  232 + }
  233 +
  234 + public void setMin(int min) {
  235 + this.min = min;
  236 + }
  237 +
  238 + public int getMax() {
  239 + return max;
  240 + }
  241 +
  242 + public double getAverage() {
  243 + return average;
  244 + }
  245 +
  246 + public String getStars() {
  247 + return stars;
  248 + }
  249 +
  250 + public int getMin() {
  251 + return min;
  252 + }
  253 + }
  254 +
  255 + public static class ImagesEntity {
  256 + private String small;
  257 + private String large;
  258 + private String medium;
  259 +
  260 + public void setSmall(String small) {
  261 + this.small = small;
  262 + }
  263 +
  264 + public void setLarge(String large) {
  265 + this.large = large;
  266 + }
  267 +
  268 + public void setMedium(String medium) {
  269 + this.medium = medium;
  270 + }
  271 +
  272 + public String getSmall() {
  273 + return small;
  274 + }
  275 +
  276 + public String getLarge() {
  277 + return large;
  278 + }
  279 +
  280 + public String getMedium() {
  281 + return medium;
  282 + }
  283 + }
  284 +
  285 + public static class CastsEntity {
  286 + /**
  287 + * small : https://img1.doubanio.com/img/celebrity/small/1679.jpg
  288 + * large : https://img1.doubanio.com/img/celebrity/large/1679.jpg
  289 + * medium : https://img1.doubanio.com/img/celebrity/medium/1679.jpg
  290 + */
  291 +
  292 + private AvatarsEntity avatars;
  293 + private String alt;
  294 + private String id;
  295 + private String name;
  296 +
  297 + public void setAvatars(AvatarsEntity avatars) {
  298 + this.avatars = avatars;
  299 + }
  300 +
  301 + public void setAlt(String alt) {
  302 + this.alt = alt;
  303 + }
  304 +
  305 + public void setId(String id) {
  306 + this.id = id;
  307 + }
  308 +
  309 + public void setName(String name) {
  310 + this.name = name;
  311 + }
  312 +
  313 + public AvatarsEntity getAvatars() {
  314 + return avatars;
  315 + }
  316 +
  317 + public String getAlt() {
  318 + return alt;
  319 + }
  320 +
  321 + public String getId() {
  322 + return id;
  323 + }
  324 +
  325 + public String getName() {
  326 + return name;
  327 + }
  328 +
  329 + public static class AvatarsEntity {
  330 + private String small;
  331 + private String large;
  332 + private String medium;
  333 +
  334 + public void setSmall(String small) {
  335 + this.small = small;
  336 + }
  337 +
  338 + public void setLarge(String large) {
  339 + this.large = large;
  340 + }
  341 +
  342 + public void setMedium(String medium) {
  343 + this.medium = medium;
  344 + }
  345 +
  346 + public String getSmall() {
  347 + return small;
  348 + }
  349 +
  350 + public String getLarge() {
  351 + return large;
  352 + }
  353 +
  354 + public String getMedium() {
  355 + return medium;
  356 + }
  357 + }
  358 + }
  359 +
  360 + public static class DirectorsEntity {
  361 + /**
  362 + * small : https://img3.doubanio.com/img/celebrity/small/230.jpg
  363 + * large : https://img3.doubanio.com/img/celebrity/large/230.jpg
  364 + * medium : https://img3.doubanio.com/img/celebrity/medium/230.jpg
  365 + */
  366 +
  367 + private AvatarsEntity avatars;
  368 + private String alt;
  369 + private String id;
  370 + private String name;
  371 +
  372 + public void setAvatars(AvatarsEntity avatars) {
  373 + this.avatars = avatars;
  374 + }
  375 +
  376 + public void setAlt(String alt) {
  377 + this.alt = alt;
  378 + }
  379 +
  380 + public void setId(String id) {
  381 + this.id = id;
  382 + }
  383 +
  384 + public void setName(String name) {
  385 + this.name = name;
  386 + }
  387 +
  388 + public AvatarsEntity getAvatars() {
  389 + return avatars;
  390 + }
  391 +
  392 + public String getAlt() {
  393 + return alt;
  394 + }
  395 +
  396 + public String getId() {
  397 + return id;
  398 + }
  399 +
  400 + public String getName() {
  401 + return name;
  402 + }
  403 +
  404 + public static class AvatarsEntity {
  405 + private String small;
  406 + private String large;
  407 + private String medium;
  408 +
  409 + public void setSmall(String small) {
  410 + this.small = small;
  411 + }
  412 +
  413 + public void setLarge(String large) {
  414 + this.large = large;
  415 + }
  416 +
  417 + public void setMedium(String medium) {
  418 + this.medium = medium;
  419 + }
  420 +
  421 + public String getSmall() {
  422 + return small;
  423 + }
  424 +
  425 + public String getLarge() {
  426 + return large;
  427 + }
  428 +
  429 + public String getMedium() {
  430 + return medium;
  431 + }
  432 + }
  433 + }
  434 + }
  435 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.gimi.common.cinema.utils.OkHttpClientManager;
  4 +import com.google.gson.Gson;
  5 +import com.google.gson.JsonSyntaxException;
  6 +import com.google.gson.reflect.TypeToken;
  7 +import com.xgimi.gimicinema.model.ThreadUtils;
  8 +
  9 +import java.io.IOException;
  10 +
  11 +/**
  12 + * Created by wugian on 2015/12/29
  13 + */
  14 +public class QueryDoubanUtils {
  15 + private static final String SEARCH_BY_NAME_URL =
  16 + "https://api.douban.com/v2/movie/search?count=3&q=";
  17 +
  18 + public static void getQueryBeanByName(
  19 + final String name, final AsyncCallback<QueryBean> callback) {
  20 + ThreadUtils.subThread(new ThreadUtils.DoSomeThing() {
  21 + @Override
  22 + public void doSomeThing() {
  23 + callback.onStart();
  24 + WrongMsg wrongMsg = new WrongMsg();
  25 + QueryBean result = null;
  26 + Gson gson = new Gson();
  27 + String s = "";
  28 + try {
  29 + s = OkHttpClientManager.getAsString(SEARCH_BY_NAME_URL + name);
  30 + wrongMsg = gson.fromJson(s, new TypeToken<WrongMsg>() {
  31 + }.getType());
  32 + if (wrongMsg.getCode() != 0) {
  33 + callback.onFailure(wrongMsg);
  34 + } else {
  35 + result = gson.fromJson(s, new TypeToken<QueryBean>() {
  36 + }.getType());
  37 +
  38 + callback.onSuccess(result);
  39 + }
  40 + } catch (JsonSyntaxException | IOException e) {
  41 + e.printStackTrace();
  42 + }
  43 + callback.onDone();
  44 + }
  45 + });
  46 + }
  47 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by 李攀 on 2015/11/5.
  5 + * 名字,评分,上映时间,添加时间,点播量
  6 + */
  7 +public enum QueryType {
  8 + QUERY_TYPE_NAME,QUERY_TYPE_RATING, QUERY_TYPE_SCREEN_TIME, QUERY_TYPE_DOWNLOAD_TIME, QUERY_TYPE_DEMAND
  9 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by pc on 2014/12/24
  5 + */
  6 +public class Rating {
  7 + private int max;
  8 + private double average;
  9 + private String stars;
  10 + private int min;
  11 +
  12 +
  13 + public int getMax() {
  14 + return max;
  15 + }
  16 +
  17 + public void setMax(int max) {
  18 + this.max = max;
  19 + }
  20 +
  21 + public double getAverage() {
  22 + return average;
  23 + }
  24 +
  25 + public void setAverage(double average) {
  26 + this.average = average;
  27 + }
  28 +
  29 + public String getStars() {
  30 + return stars;
  31 + }
  32 +
  33 + public void setStars(String stars) {
  34 + this.stars = stars;
  35 + }
  36 +
  37 + public int getMin() {
  38 + return min;
  39 + }
  40 +
  41 + public void setMin(int min) {
  42 + this.min = min;
  43 + }
  44 +
  45 +
  46 + @Override
  47 + public String toString() {
  48 + return "Rating{" +
  49 + "max=" + max +
  50 + ", average=" + average +
  51 + ", stars='" + stars + '\'' +
  52 + ", min=" + min +
  53 + '}';
  54 + }
  55 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by wugian on 2016/5/23
  5 + */
  6 +public enum SourceType {
  7 + SOURCE_ALL, SOURCE_JUST_QN, SOURCE_JUST_1905
  8 +}
... ...
  1 +/*
  2 + * Copyright (c) 2016. wugian
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +
  17 +package com.gimi.common.cinema.model;
  18 +
  19 +/**
  20 + * Created by pc on 2015/1/6
  21 + */
  22 +public class StatusData {
  23 + // "status":"on","delay":300
  24 + private String status;
  25 + private int delay;
  26 +
  27 + public String getStatus() {
  28 + return status;
  29 + }
  30 +
  31 + public void setStatus(String status) {
  32 + this.status = status;
  33 + }
  34 +
  35 + public int getDelay() {
  36 + return delay;
  37 + }
  38 +
  39 + public void setDelay(int delay) {
  40 + this.delay = delay;
  41 + }
  42 +
  43 + @Override
  44 + public String toString() {
  45 + return "GimiData{" +
  46 + "status='" + status + '\'' +
  47 + ", delay=" + delay +
  48 + '}';
  49 + }
  50 +}
  51 +
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import java.util.Arrays;
  4 +
  5 +/**
  6 + * Created by 李攀 on 2015/9/16
  7 + * {
  8 + "multi": "false",
  9 + "position": 2,
  10 + "movie_urls": [
  11 + "192.168.4.214/root/TS/我不是潘金莲/【我不是潘金莲】【导演:冯小刚】【2016年】【国语】-魅族DVD高清.mp4",
  12 + "192.168.4.214/root/XS/GaIn/GaIn.ts",
  13 + "192.168.4.214/root/XS/真的喜欢你/真的喜欢你.ts",
  14 + "192.168.4.214/root/XS/岁的纯情/岁的纯情.ts"
  15 + ]
  16 + }
  17 + */
  18 +public class UdpModel {
  19 + private String movie_url;
  20 + private boolean multi;
  21 + private int position;
  22 + private String[] movie_urls;
  23 +
  24 + public String getMovie_url() {
  25 + return movie_url;
  26 + }
  27 +
  28 + public void setMovie_url(String movie_url) {
  29 + this.movie_url = movie_url;
  30 + }
  31 +
  32 + public boolean isMulti() {
  33 + return multi;
  34 + }
  35 +
  36 + public void setMulti(boolean multi) {
  37 + this.multi = multi;
  38 + }
  39 +
  40 + public int getPosition() {
  41 + return position;
  42 + }
  43 +
  44 + public void setPosition(int position) {
  45 + this.position = position;
  46 + }
  47 +
  48 + public String[] getMovie_urls() {
  49 + return movie_urls;
  50 + }
  51 +
  52 + public void setMovie_urls(String[] movie_urls) {
  53 + this.movie_urls = movie_urls;
  54 + }
  55 +
  56 + @Override
  57 + public String toString() {
  58 + return "UdpModel{" +
  59 + "movie_url='" + movie_url + '\'' +
  60 + ", single=" + multi +
  61 + ", position=" + position +
  62 + ", movie_urls=" + Arrays.toString(movie_urls) +
  63 + '}';
  64 + }
  65 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by pc on 2014/12/23
  5 + */
  6 +public class Urls {
  7 + public static final String BASIC_URL ="https://api.douban.com/v2";
  8 + public static final String MOVIE_MESSAGE="/movie/subject/";
  9 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +/**
  4 + * Created by 李攀 on 2015/11/11.
  5 + */
  6 +public class UserInfo {
  7 + private String userName;
  8 + private String pwd;
  9 + private String serverIp;
  10 + private String ipAddr;
  11 + private String shareFolder;
  12 +
  13 + public String getUserName() {
  14 + return userName;
  15 + }
  16 +
  17 + public void setUserName(String userName) {
  18 + this.userName = userName;
  19 + }
  20 +
  21 + public String getPwd() {
  22 + return pwd;
  23 + }
  24 +
  25 + public void setPwd(String pwd) {
  26 + this.pwd = pwd;
  27 + }
  28 +
  29 + public String getServerIp() {
  30 + return serverIp;
  31 + }
  32 +
  33 + public void setServerIp(String serverIp) {
  34 + this.serverIp = serverIp;
  35 + }
  36 +
  37 + public String getIpAddr() {
  38 + return ipAddr;
  39 + }
  40 +
  41 + public void setIpAddr(String ipAddr) {
  42 + this.ipAddr = ipAddr;
  43 + }
  44 +
  45 + public String getShareFolder() {
  46 + return shareFolder;
  47 + }
  48 +
  49 + public void setShareFolder(String shareFolder) {
  50 + this.shareFolder = shareFolder;
  51 + }
  52 +}
... ...
  1 +package com.gimi.common.cinema.model;
  2 +
  3 +import com.google.gson.annotations.Expose;
  4 +
  5 +public class WrongMsg extends Throwable {
  6 + /**
  7 + *
  8 + */
  9 + private static final long serialVersionUID = 7457964260418110305L;
  10 + // "msg":"uri_not_found",
  11 + // "code":1001,
  12 + // "request":"GET \/v2\/photo\/132"
  13 + @Expose
  14 + private String msg;// wrong msg describe
  15 + @Expose
  16 + private String request;// request url and method
  17 + @Expose
  18 + private int code;// wrong code
  19 +
  20 + public String getMsg() {
  21 + return msg;
  22 + }
  23 +
  24 + public void setMsg(String msg) {
  25 + this.msg = msg;
  26 + }
  27 +
  28 + public String getRequest() {
  29 + return request;
  30 + }
  31 +
  32 + public void setRequest(String request) {
  33 + this.request = request;
  34 + }
  35 +
  36 + public int getCode() {
  37 + return code;
  38 + }
  39 +
  40 + public void setCode(int code) {
  41 + this.code = code;
  42 + }
  43 +
  44 +}
... ...
  1 +/*
  2 + * Copyright (c) 2016. wugian
  3 + * Licensed under the Apache License, Version 2.0 (the "License");
  4 + * you may not use this file except in compliance with the License.
  5 + * You may obtain a copy of the License at
  6 + *
  7 + * http://www.apache.org/licenses/LICENSE-2.0
  8 + *
  9 + * Unless required by applicable law or agreed to in writing, software
  10 + * distributed under the License is distributed on an "AS IS" BASIS,
  11 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 + * See the License for the specific language governing permissions and
  13 + * limitations under the License.
  14 + *
  15 + */
  16 +package com.gimi.common.cinema.utils;
  17 +
  18 +import android.content.Context;
  19 +import android.graphics.Bitmap;
  20 +import android.graphics.BitmapFactory;
  21 +import android.graphics.Canvas;
  22 +import android.graphics.PixelFormat;
  23 +import android.graphics.drawable.BitmapDrawable;
  24 +import android.graphics.drawable.Drawable;
  25 +import org.json.JSONArray;
  26 +import org.json.JSONObject;
  27 +
  28 +import java.io.BufferedReader;
  29 +import java.io.BufferedWriter;
  30 +import java.io.ByteArrayInputStream;
  31 +import java.io.ByteArrayOutputStream;
  32 +import java.io.File;
  33 +import java.io.FileOutputStream;
  34 +import java.io.FileReader;
  35 +import java.io.FileWriter;
  36 +import java.io.IOException;
  37 +import java.io.ObjectInputStream;
  38 +import java.io.ObjectOutputStream;
  39 +import java.io.RandomAccessFile;
  40 +import java.io.Serializable;
  41 +import java.util.Collections;
  42 +import java.util.HashMap;
  43 +import java.util.Map;
  44 +import java.util.Map.Entry;
  45 +import java.util.Set;
  46 +import java.util.concurrent.atomic.AtomicInteger;
  47 +import java.util.concurrent.atomic.AtomicLong;
  48 +
  49 +/**
  50 + * @author Michael Yang(www.yangfuhai.com) update at 2013.08.07
  51 + */
  52 +public class ACache {
  53 + public static final int TIME_HOUR = 60 * 60;
  54 + public static final int TIME_DAY = TIME_HOUR * 24;
  55 + private static final int MAX_SIZE = 1000 * 1000 * 50; // 50 mb
  56 + private static final int MAX_COUNT = Integer.MAX_VALUE; // 不限制存放数据的数量
  57 + private static Map<String, ACache> mInstanceMap = new HashMap<String, ACache>();
  58 + private ACacheManager mCache;
  59 +
  60 + public static ACache get(Context ctx) {
  61 + return get(ctx, "ACache");
  62 + }
  63 +
  64 + public static ACache get(Context ctx, String cacheName) {
  65 + File f = new File(ctx.getCacheDir(), cacheName);
  66 + return get(f, MAX_SIZE, MAX_COUNT);
  67 + }
  68 +
  69 + public static ACache get(File cacheDir) {
  70 + return get(cacheDir, MAX_SIZE, MAX_COUNT);
  71 + }
  72 +
  73 + public static ACache get(Context ctx, long max_zise, int max_count) {
  74 + File f = new File(ctx.getCacheDir(), "ACache");
  75 + return get(f, max_zise, max_count);
  76 + }
  77 +
  78 + public static ACache get(File cacheDir, long max_zise, int max_count) {
  79 + ACache manager = mInstanceMap.get(cacheDir.getAbsoluteFile() + myPid());
  80 + if (manager == null) {
  81 + manager = new ACache(cacheDir, max_zise, max_count);
  82 + mInstanceMap.put(cacheDir.getAbsolutePath() + myPid(), manager);
  83 + }
  84 + return manager;
  85 + }
  86 +
  87 + private static String myPid() {
  88 + return "_" + android.os.Process.myPid();
  89 + }
  90 +
  91 + private ACache(File cacheDir, long max_size, int max_count) {
  92 + if (!cacheDir.exists() && !cacheDir.mkdirs()) {
  93 + throw new RuntimeException("can't make dirs in "
  94 + + cacheDir.getAbsolutePath());
  95 + }
  96 + mCache = new ACacheManager(cacheDir, max_size, max_count);
  97 + }
  98 +
  99 + // =======================================
  100 + // ============ String数据 读写 ==============
  101 + // =======================================
  102 + /**
  103 + * 保存 String数据 到 缓存中
  104 + *
  105 + * @param key
  106 + * 保存的key
  107 + * @param value
  108 + * 保存的String数据
  109 + */
  110 + public void put(String key, String value) {
  111 + File file = mCache.newFile(key);
  112 + BufferedWriter out = null;
  113 + try {
  114 + out = new BufferedWriter(new FileWriter(file), 1024);
  115 + out.write(value);
  116 + } catch (IOException e) {
  117 + e.printStackTrace();
  118 + } finally {
  119 + if (out != null) {
  120 + try {
  121 + out.flush();
  122 + out.close();
  123 + } catch (IOException e) {
  124 + e.printStackTrace();
  125 + }
  126 + }
  127 + mCache.put(file);
  128 + }
  129 + }
  130 +
  131 + /**
  132 + * 保存 String数据 到 缓存中
  133 + *
  134 + * @param key
  135 + * 保存的key
  136 + * @param value
  137 + * 保存的String数据
  138 + * @param saveTime
  139 + * 保存的时间,单位:秒
  140 + */
  141 + public void put(String key, String value, int saveTime) {
  142 + put(key, Utils.newStringWithDateInfo(saveTime, value));
  143 + }
  144 +
  145 + /**
  146 + * 读取 String数据
  147 + *
  148 + * @param key
  149 + * @return String 数据
  150 + */
  151 + public String getAsString(String key) {
  152 + File file = mCache.get(key);
  153 + if (!file.exists())
  154 + return null;
  155 + boolean removeFile = false;
  156 + BufferedReader in = null;
  157 + try {
  158 + in = new BufferedReader(new FileReader(file));
  159 + String readString = "";
  160 + String currentLine;
  161 + while ((currentLine = in.readLine()) != null) {
  162 + readString += currentLine;
  163 + }
  164 + if (!Utils.isDue(readString)) {
  165 + return Utils.clearDateInfo(readString);
  166 + } else {
  167 + removeFile = true;
  168 + return null;
  169 + }
  170 + } catch (IOException e) {
  171 + e.printStackTrace();
  172 + return null;
  173 + } finally {
  174 + if (in != null) {
  175 + try {
  176 + in.close();
  177 + } catch (IOException e) {
  178 + e.printStackTrace();
  179 + }
  180 + }
  181 + if (removeFile)
  182 + remove(key);
  183 + }
  184 + }
  185 +
  186 + // =======================================
  187 + // ============= JSONObject 数据 读写 ==============
  188 + // =======================================
  189 + /**
  190 + * 保存 JSONObject数据 到 缓存中
  191 + *
  192 + * @param key
  193 + * 保存的key
  194 + * @param value
  195 + * 保存的JSON数据
  196 + */
  197 + public void put(String key, JSONObject value) {
  198 + put(key, value.toString());
  199 + }
  200 +
  201 + /**
  202 + * 保存 JSONObject数据 到 缓存中
  203 + *
  204 + * @param key
  205 + * 保存的key
  206 + * @param value
  207 + * 保存的JSONObject数据
  208 + * @param saveTime
  209 + * 保存的时间,单位:秒
  210 + */
  211 + public void put(String key, JSONObject value, int saveTime) {
  212 + put(key, value.toString(), saveTime);
  213 + }
  214 +
  215 + /**
  216 + * 读取JSONObject数据
  217 + *
  218 + * @param key
  219 + * @return JSONObject数据
  220 + */
  221 + public JSONObject getAsJSONObject(String key) {
  222 + String JSONString = getAsString(key);
  223 + try {
  224 + JSONObject obj = new JSONObject(JSONString);
  225 + return obj;
  226 + } catch (Exception e) {
  227 + e.printStackTrace();
  228 + return null;
  229 + }
  230 + }
  231 +
  232 + // =======================================
  233 + // ============ JSONArray 数据 读写 =============
  234 + // =======================================
  235 + /**
  236 + * 保存 JSONArray数据 到 缓存中
  237 + *
  238 + * @param key
  239 + * 保存的key
  240 + * @param value
  241 + * 保存的JSONArray数据
  242 + */
  243 + public void put(String key, JSONArray value) {
  244 + put(key, value.toString());
  245 + }
  246 +
  247 + /**
  248 + * 保存 JSONArray数据 到 缓存中
  249 + *
  250 + * @param key
  251 + * 保存的key
  252 + * @param value
  253 + * 保存的JSONArray数据
  254 + * @param saveTime
  255 + * 保存的时间,单位:秒
  256 + */
  257 + public void put(String key, JSONArray value, int saveTime) {
  258 + put(key, value.toString(), saveTime);
  259 + }
  260 +
  261 + /**
  262 + * 读取JSONArray数据
  263 + *
  264 + * @param key
  265 + * @return JSONArray数据
  266 + */
  267 + public JSONArray getAsJSONArray(String key) {
  268 + String JSONString = getAsString(key);
  269 + try {
  270 + JSONArray obj = new JSONArray(JSONString);
  271 + return obj;
  272 + } catch (Exception e) {
  273 + e.printStackTrace();
  274 + return null;
  275 + }
  276 + }
  277 +
  278 + // =======================================
  279 + // ============== byte 数据 读写 =============
  280 + // =======================================
  281 + /**
  282 + * 保存 byte数据 到 缓存中
  283 + *
  284 + * @param key
  285 + * 保存的key
  286 + * @param value
  287 + * 保存的数据
  288 + */
  289 + public void put(String key, byte[] value) {
  290 + File file = mCache.newFile(key);
  291 + FileOutputStream out = null;
  292 + try {
  293 + out = new FileOutputStream(file);
  294 + out.write(value);
  295 + } catch (Exception e) {
  296 + e.printStackTrace();
  297 + } finally {
  298 + if (out != null) {
  299 + try {
  300 + out.flush();
  301 + out.close();
  302 + } catch (IOException e) {
  303 + e.printStackTrace();
  304 + }
  305 + }
  306 + mCache.put(file);
  307 + }
  308 + }
  309 +
  310 + /**
  311 + * 保存 byte数据 到 缓存中
  312 + *
  313 + * @param key
  314 + * 保存的key
  315 + * @param value
  316 + * 保存的数据
  317 + * @param saveTime
  318 + * 保存的时间,单位:秒
  319 + */
  320 + public void put(String key, byte[] value, int saveTime) {
  321 + put(key, Utils.newByteArrayWithDateInfo(saveTime, value));
  322 + }
  323 +
  324 + /**
  325 + * 获取 byte 数据
  326 + *
  327 + * @param key
  328 + * @return byte 数据
  329 + */
  330 + public byte[] getAsBinary(String key) {
  331 + RandomAccessFile RAFile = null;
  332 + boolean removeFile = false;
  333 + try {
  334 + File file = mCache.get(key);
  335 + if (!file.exists())
  336 + return null;
  337 + RAFile = new RandomAccessFile(file, "r");
  338 + byte[] byteArray = new byte[(int) RAFile.length()];
  339 + RAFile.read(byteArray);
  340 + if (!Utils.isDue(byteArray)) {
  341 + return Utils.clearDateInfo(byteArray);
  342 + } else {
  343 + removeFile = true;
  344 + return null;
  345 + }
  346 + } catch (Exception e) {
  347 + e.printStackTrace();
  348 + return null;
  349 + } finally {
  350 + if (RAFile != null) {
  351 + try {
  352 + RAFile.close();
  353 + } catch (IOException e) {
  354 + e.printStackTrace();
  355 + }
  356 + }
  357 + if (removeFile)
  358 + remove(key);
  359 + }
  360 + }
  361 +
  362 + // =======================================
  363 + // ============= 序列化 数据 读写 ===============
  364 + // =======================================
  365 + /**
  366 + * 保存 Serializable数据 到 缓存中
  367 + *
  368 + * @param key
  369 + * 保存的key
  370 + * @param value
  371 + * 保存的value
  372 + */
  373 + public void put(String key, Serializable value) {
  374 + put(key, value, -1);
  375 + }
  376 +
  377 + /**
  378 + * 保存 Serializable数据到 缓存中
  379 + *
  380 + * @param key
  381 + * 保存的key
  382 + * @param value
  383 + * 保存的value
  384 + * @param saveTime
  385 + * 保存的时间,单位:秒
  386 + */
  387 + public void put(String key, Serializable value, int saveTime) {
  388 + ByteArrayOutputStream baos = null;
  389 + ObjectOutputStream oos = null;
  390 + try {
  391 + baos = new ByteArrayOutputStream();
  392 + oos = new ObjectOutputStream(baos);
  393 + oos.writeObject(value);
  394 + byte[] data = baos.toByteArray();
  395 + if (saveTime != -1) {
  396 + put(key, data, saveTime);
  397 + } else {
  398 + put(key, data);
  399 + }
  400 + } catch (Exception e) {
  401 + e.printStackTrace();
  402 + } finally {
  403 + try {
  404 + oos.close();
  405 + } catch (IOException e) {
  406 + }
  407 + }
  408 + }
  409 +
  410 + /**
  411 + * 读取 Serializable数据
  412 + *
  413 + * @param key
  414 + * @return Serializable 数据
  415 + */
  416 + public Object getAsObject(String key) {
  417 + byte[] data = getAsBinary(key);
  418 + if (data != null) {
  419 + ByteArrayInputStream bais = null;
  420 + ObjectInputStream ois = null;
  421 + try {
  422 + bais = new ByteArrayInputStream(data);
  423 + ois = new ObjectInputStream(bais);
  424 + Object reObject = ois.readObject();
  425 + return reObject;
  426 + } catch (Exception e) {
  427 + e.printStackTrace();
  428 + return null;
  429 + } finally {
  430 + try {
  431 + if (bais != null)
  432 + bais.close();
  433 + } catch (IOException e) {
  434 + e.printStackTrace();
  435 + }
  436 + try {
  437 + if (ois != null)
  438 + ois.close();
  439 + } catch (IOException e) {
  440 + e.printStackTrace();
  441 + }
  442 + }
  443 + }
  444 + return null;
  445 +
  446 + }
  447 +
  448 + // =======================================
  449 + // ============== bitmap 数据 读写 =============
  450 + // =======================================
  451 + /**
  452 + * 保存 bitmap 到 缓存中
  453 + *
  454 + * @param key
  455 + * 保存的key
  456 + * @param value
  457 + * 保存的bitmap数据
  458 + */
  459 + public void put(String key, Bitmap value) {
  460 + put(key, Utils.Bitmap2Bytes(value));
  461 + }
  462 +
  463 + /**
  464 + * 保存 bitmap 到 缓存中
  465 + *
  466 + * @param key
  467 + * 保存的key
  468 + * @param value
  469 + * 保存的 bitmap 数据
  470 + * @param saveTime
  471 + * 保存的时间,单位:秒
  472 + */
  473 + public void put(String key, Bitmap value, int saveTime) {
  474 + put(key, Utils.Bitmap2Bytes(value), saveTime);
  475 + }
  476 +
  477 + /**
  478 + * 读取 bitmap 数据
  479 + *
  480 + * @param key
  481 + * @return bitmap 数据
  482 + */
  483 + public Bitmap getAsBitmap(String key) {
  484 + if (getAsBinary(key) == null) {
  485 + return null;
  486 + }
  487 + return Utils.Bytes2Bimap(getAsBinary(key));
  488 + }
  489 +
  490 + // =======================================
  491 + // ============= drawable 数据 读写 =============
  492 + // =======================================
  493 + /**
  494 + * 保存 drawable 到 缓存中
  495 + *
  496 + * @param key
  497 + * 保存的key
  498 + * @param value
  499 + * 保存的drawable数据
  500 + */
  501 + public void put(String key, Drawable value) {
  502 + put(key, Utils.drawable2Bitmap(value));
  503 + }
  504 +
  505 + /**
  506 + * 保存 drawable 到 缓存中
  507 + *
  508 + * @param key
  509 + * 保存的key
  510 + * @param value
  511 + * 保存的 drawable 数据
  512 + * @param saveTime
  513 + * 保存的时间,单位:秒
  514 + */
  515 + public void put(String key, Drawable value, int saveTime) {
  516 + put(key, Utils.drawable2Bitmap(value), saveTime);
  517 + }
  518 +
  519 + /**
  520 + * 读取 Drawable 数据
  521 + *
  522 + * @param key
  523 + * @return Drawable 数据
  524 + */
  525 + public Drawable getAsDrawable(String key) {
  526 + if (getAsBinary(key) == null) {
  527 + return null;
  528 + }
  529 + return Utils.bitmap2Drawable(Utils.Bytes2Bimap(getAsBinary(key)));
  530 + }
  531 +
  532 + /**
  533 + * 获取缓存文件
  534 + *
  535 + * @param key
  536 + * @return value 缓存的文件
  537 + */
  538 + public File file(String key) {
  539 + File f = mCache.newFile(key);
  540 + if (f.exists())
  541 + return f;
  542 + return null;
  543 + }
  544 +
  545 + /**
  546 + * 移除某个key
  547 + *
  548 + * @param key
  549 + * @return 是否移除成功
  550 + */
  551 + public boolean remove(String key) {
  552 + return mCache.remove(key);
  553 + }
  554 +
  555 + /**
  556 + * 清除所有数据
  557 + */
  558 + public void clear() {
  559 + mCache.clear();
  560 + }
  561 +
  562 + /**
  563 + * @title 缓存管理器
  564 + * @author 杨福海(michael) www.yangfuhai.com
  565 + * @version 1.0
  566 + */
  567 + public class ACacheManager {
  568 + private final AtomicLong cacheSize;
  569 + private final AtomicInteger cacheCount;
  570 + private final long sizeLimit;
  571 + private final int countLimit;
  572 + private final Map<File, Long> lastUsageDates = Collections
  573 + .synchronizedMap(new HashMap<File, Long>());
  574 + protected File cacheDir;
  575 +
  576 + private ACacheManager(File cacheDir, long sizeLimit, int countLimit) {
  577 + this.cacheDir = cacheDir;
  578 + this.sizeLimit = sizeLimit;
  579 + this.countLimit = countLimit;
  580 + cacheSize = new AtomicLong();
  581 + cacheCount = new AtomicInteger();
  582 + calculateCacheSizeAndCacheCount();
  583 + }
  584 +
  585 + /**
  586 + * 计算 cacheSize和cacheCount
  587 + */
  588 + private void calculateCacheSizeAndCacheCount() {
  589 + new Thread(new Runnable() {
  590 + @Override
  591 + public void run() {
  592 + int size = 0;
  593 + int count = 0;
  594 + File[] cachedFiles = cacheDir.listFiles();
  595 + if (cachedFiles != null) {
  596 + for (File cachedFile : cachedFiles) {
  597 + size += calculateSize(cachedFile);
  598 + count += 1;
  599 + lastUsageDates.put(cachedFile,
  600 + cachedFile.lastModified());
  601 + }
  602 + cacheSize.set(size);
  603 + cacheCount.set(count);
  604 + }
  605 + }
  606 + }).start();
  607 + }
  608 +
  609 + private void put(File file) {
  610 + int curCacheCount = cacheCount.get();
  611 + while (curCacheCount + 1 > countLimit) {
  612 + long freedSize = removeNext();
  613 + cacheSize.addAndGet(-freedSize);
  614 +
  615 + curCacheCount = cacheCount.addAndGet(-1);
  616 + }
  617 + cacheCount.addAndGet(1);
  618 +
  619 + long valueSize = calculateSize(file);
  620 + long curCacheSize = cacheSize.get();
  621 + while (curCacheSize + valueSize > sizeLimit) {
  622 + long freedSize = removeNext();
  623 + curCacheSize = cacheSize.addAndGet(-freedSize);
  624 + }
  625 + cacheSize.addAndGet(valueSize);
  626 +
  627 + Long currentTime = System.currentTimeMillis();
  628 + file.setLastModified(currentTime);
  629 + lastUsageDates.put(file, currentTime);
  630 + }
  631 +
  632 + private File get(String key) {
  633 + File file = newFile(key);
  634 + Long currentTime = System.currentTimeMillis();
  635 + file.setLastModified(currentTime);
  636 + lastUsageDates.put(file, currentTime);
  637 +
  638 + return file;
  639 + }
  640 +
  641 + private File newFile(String key) {
  642 + return new File(cacheDir, key.hashCode() + "");
  643 + }
  644 +
  645 + private boolean remove(String key) {
  646 + File image = get(key);
  647 + return image.delete();
  648 + }
  649 +
  650 + private void clear() {
  651 + lastUsageDates.clear();
  652 + cacheSize.set(0);
  653 + File[] files = cacheDir.listFiles();
  654 + if (files != null) {
  655 + for (File f : files) {
  656 + f.delete();
  657 + }
  658 + }
  659 + }
  660 +
  661 + /**
  662 + * 移除旧的文件
  663 + *
  664 + * @return
  665 + */
  666 + private long removeNext() {
  667 + if (lastUsageDates.isEmpty()) {
  668 + return 0;
  669 + }
  670 +
  671 + Long oldestUsage = null;
  672 + File mostLongUsedFile = null;
  673 + Set<Entry<File, Long>> entries = lastUsageDates.entrySet();
  674 + synchronized (lastUsageDates) {
  675 + for (Entry<File, Long> entry : entries) {
  676 + if (mostLongUsedFile == null) {
  677 + mostLongUsedFile = entry.getKey();
  678 + oldestUsage = entry.getValue();
  679 + } else {
  680 + Long lastValueUsage = entry.getValue();
  681 + if (lastValueUsage < oldestUsage) {
  682 + oldestUsage = lastValueUsage;
  683 + mostLongUsedFile = entry.getKey();
  684 + }
  685 + }
  686 + }
  687 + }
  688 +
  689 + long fileSize = calculateSize(mostLongUsedFile);
  690 + if (mostLongUsedFile.delete()) {
  691 + lastUsageDates.remove(mostLongUsedFile);
  692 + }
  693 + return fileSize;
  694 + }
  695 +
  696 + private long calculateSize(File file) {
  697 + return file.length();
  698 + }
  699 + }
  700 +
  701 + /**
  702 + * @title 时间计算工具类
  703 + * @author 杨福海(michael) www.yangfuhai.com
  704 + * @version 1.0
  705 + */
  706 + private static class Utils {
  707 +
  708 + /**
  709 + * 判断缓存的String数据是否到期
  710 + *
  711 + * @param str
  712 + * @return true:到期了 false:还没有到期
  713 + */
  714 + private static boolean isDue(String str) {
  715 + return isDue(str.getBytes());
  716 + }
  717 +
  718 + /**
  719 + * 判断缓存的byte数据是否到期
  720 + *
  721 + * @param data
  722 + * @return true:到期了 false:还没有到期
  723 + */
  724 + private static boolean isDue(byte[] data) {
  725 + String[] strs = getDateInfoFromDate(data);
  726 + if (strs != null && strs.length == 2) {
  727 + String saveTimeStr = strs[0];
  728 + while (saveTimeStr.startsWith("0")) {
  729 + saveTimeStr = saveTimeStr
  730 + .substring(1, saveTimeStr.length());
  731 + }
  732 + long saveTime = Long.valueOf(saveTimeStr);
  733 + long deleteAfter = Long.valueOf(strs[1]);
  734 + if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) {
  735 + return true;
  736 + }
  737 + }
  738 + return false;
  739 + }
  740 +
  741 + private static String newStringWithDateInfo(int second, String strInfo) {
  742 + return createDateInfo(second) + strInfo;
  743 + }
  744 +
  745 + private static byte[] newByteArrayWithDateInfo(int second, byte[] data2) {
  746 + byte[] data1 = createDateInfo(second).getBytes();
  747 + byte[] retdata = new byte[data1.length + data2.length];
  748 + System.arraycopy(data1, 0, retdata, 0, data1.length);
  749 + System.arraycopy(data2, 0, retdata, data1.length, data2.length);
  750 + return retdata;
  751 + }
  752 +
  753 + private static String clearDateInfo(String strInfo) {
  754 + if (strInfo != null && hasDateInfo(strInfo.getBytes())) {
  755 + strInfo = strInfo.substring(strInfo.indexOf(mSeparator) + 1,
  756 + strInfo.length());
  757 + }
  758 + return strInfo;
  759 + }
  760 +
  761 + private static byte[] clearDateInfo(byte[] data) {
  762 + if (hasDateInfo(data)) {
  763 + return copyOfRange(data, indexOf(data, mSeparator) + 1,
  764 + data.length);
  765 + }
  766 + return data;
  767 + }
  768 +
  769 + private static boolean hasDateInfo(byte[] data) {
  770 + return data != null && data.length > 15 && data[13] == '-'
  771 + && indexOf(data, mSeparator) > 14;
  772 + }
  773 +
  774 + private static String[] getDateInfoFromDate(byte[] data) {
  775 + if (hasDateInfo(data)) {
  776 + String saveDate = new String(copyOfRange(data, 0, 13));
  777 + String deleteAfter = new String(copyOfRange(data, 14,
  778 + indexOf(data, mSeparator)));
  779 + return new String[] { saveDate, deleteAfter };
  780 + }
  781 + return null;
  782 + }
  783 +
  784 + private static int indexOf(byte[] data, char c) {
  785 + for (int i = 0; i < data.length; i++) {
  786 + if (data[i] == c) {
  787 + return i;
  788 + }
  789 + }
  790 + return -1;
  791 + }
  792 +
  793 + private static byte[] copyOfRange(byte[] original, int from, int to) {
  794 + int newLength = to - from;
  795 + if (newLength < 0)
  796 + throw new IllegalArgumentException(from + " > " + to);
  797 + byte[] copy = new byte[newLength];
  798 + System.arraycopy(original, from, copy, 0,
  799 + Math.min(original.length - from, newLength));
  800 + return copy;
  801 + }
  802 +
  803 + private static final char mSeparator = ' ';
  804 +
  805 + private static String createDateInfo(int second) {
  806 + String currentTime = System.currentTimeMillis() + "";
  807 + while (currentTime.length() < 13) {
  808 + currentTime = "0" + currentTime;
  809 + }
  810 + return currentTime + "-" + second + mSeparator;
  811 + }
  812 +
  813 + /*
  814 + * Bitmap → byte[]
  815 + */
  816 + private static byte[] Bitmap2Bytes(Bitmap bm) {
  817 + if (bm == null) {
  818 + return null;
  819 + }
  820 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
  821 + bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
  822 + return baos.toByteArray();
  823 + }
  824 +
  825 + /*
  826 + * byte[] → Bitmap
  827 + */
  828 + private static Bitmap Bytes2Bimap(byte[] b) {
  829 + if (b.length == 0) {
  830 + return null;
  831 + }
  832 + return BitmapFactory.decodeByteArray(b, 0, b.length);
  833 + }
  834 +
  835 + /*
  836 + * Drawable → Bitmap
  837 + */
  838 + private static Bitmap drawable2Bitmap(Drawable drawable) {
  839 + if (drawable == null) {
  840 + return null;
  841 + }
  842 + // 取 drawable 的长宽
  843 + int w = drawable.getIntrinsicWidth();
  844 + int h = drawable.getIntrinsicHeight();
  845 + // 取 drawable 的颜色格式
  846 + Bitmap.Config config = drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
  847 + : Bitmap.Config.RGB_565;
  848 + // 建立对应 bitmap
  849 + Bitmap bitmap = Bitmap.createBitmap(w, h, config);
  850 + // 建立对应 bitmap 的画布
  851 + Canvas canvas = new Canvas(bitmap);
  852 + drawable.setBounds(0, 0, w, h);
  853 + // 把 drawable 内容画到画布中
  854 + drawable.draw(canvas);
  855 + return bitmap;
  856 + }
  857 +
  858 + /*
  859 + * Bitmap → Drawable
  860 + */
  861 + @SuppressWarnings("deprecation")
  862 + private static Drawable bitmap2Drawable(Bitmap bm) {
  863 + if (bm == null) {
  864 + return null;
  865 + }
  866 + return new BitmapDrawable(bm);
  867 + }
  868 + }
  869 +
  870 +}
\ No newline at end of file
... ...
Please register or login to post a comment