diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 26355427d0c02cb281a52bf083e1e847bcdf45bc..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1,126 +0,0 @@ -tng-customsuite.xml -**pom.xml.releaseBackup -release.properties -gen -*/seed.txt -notes -logs -gen-external-apklibs -.idea -*.iml -.DS_Store -*.swp -out -.gradle -/local.properties -/build - -###OSX### - -.DS_Store -.AppleDouble -.LSOverride - -# Icon must ends with two \r. -Icon - - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - - -###Linux### - -*~ - -# KDE directory preferences -.directory - - -###Android### - -# Built application files -*.apk -*.ap_ - -# Files for ART and Dalvik VM -*.dex - -# Java class files -*.class - -# Generated files -bin/ -gen/ - -# Gradle files -.gradle/ -.gradletasknamecache -build/ - -# Local configuration file (sdk path, etc) -local.properties - -# Proguard folder generated by Eclipse -proguard/ - -# Lint -lint-report.html -lint-report_files/ -lint_result.txt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.war -*.ear - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - - -###IntelliJ### - -*.iml -*.ipr -*.iws -.idea/ - - -###Eclipse### - -*.pydevproject -.metadata -tmp/ -*.tmp -*.bak -*.swp -*~.nib -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - -# sbteclipse plugin -.target - -# TeXlipse plugin -.texlipseXml version="1.0" encoding="UTF-8"?> -gradle.properties -sign.properties -app/oschina.keystore diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..f8fbd386455ba1cf2f549346b7aa576a233a216d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 巴拉迪维 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 997af8c75b136362fddbcaf659619b5b3833fdd2..ad045e5d884514c778b6314f44985e3e24721138 100644 --- a/README.md +++ b/README.md @@ -1,47 +1,104 @@ -# OSChina Android [客户端](http://www.oschina.net/app/) - -##写在前面的话 -从2.3版本开始,项目已经完成了gradle化,完全迁移到了android studio,如果想使用eclipse进行该项目的学习,可以clone [tag v2.2.1](http://git.oschina.net/oschina/android-app/tree/v2.2.1/),不过需要注意的是,eclipse需要按照开发环境中提到的:进行butterknife注解设置 - -##开发环境 -由于使用了较多的Eclipse项目Library,项目目前使用的是Eclipse。需要提示的是,由于butterknife注解特性,Eclipse需要开启注解功能,详细方法参考[这里](http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0102/2247.html)。对于使用Android Studio的开发者,可能你们需要等待一段时间,项目目前正在Gradle化。当然,我们也欢迎由你来转换项目并通过PullRequest提交给我们,充分发挥社区化协作的优势。 - -##项目简述 -1. 底部导航 - * 主界面的底部TAB导航采用[FragmentTabHost](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/ui/MainTab.java)点击底部按钮时切换Fragment。中间的快捷操作按钮使用的是[自定义dialog](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/ui/QuickOptionDialog.java),通过点击时加入动画效果实现。 -2. 一级界面 - * 包括资讯、动弹两个模块,采用[ViewPagerFragment](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/viewpagerfragment/NewsViewPagerFragment.java)根据滑动到不同页面显示不同信息。 -3. 详情界面 - * 详情界面包括[博客详情](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/fragment/BlogDetailFragment.java),[动弹详情](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/fragment/TweetDetailFragment.java),[新闻详情](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/fragment/NewsDetailFragment.java),[帖子详情](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/fragment/PostDetailFragment.java), [活动详情](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/fragment/EventDetailFragment.java)等……是通过在Fragment中的WebView直接loadData()加载一段html数据并显示。 - * 而详情Fragment的显示则是通过一个外部DetailActivity,来根据传入的参数不同来加载不同的Fragment。 -4. 链接跳转 - * 整个应用打开链接的规则都定义在UIHelper.openBrowser()方法中,本方法会根据不同的url去解析,如果是www.oschina.net的链接,则会调用相应的界面去展示;如果是git.oschina.net我们目前会使用手机自带的浏览器打开(之后会改为使用[OscGit客户端](http://git.oschina.net/oschina/git-osc-android-project)打开);如果不是oschina的站内链接,则使用内置浏览器打开。 -5. 侧滑菜单 - * [侧滑菜单](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/ui/NavigationDrawerFragment.java)采用系统的DrawerLayout实现。关于很多朋友好奇的左上角箭头,是采用的开源控件[DrawerArrowDrawable](http://git.oschina.net/oschina/osc-android-app/blob/master/osc-android-app/src/net/oschina/app/widget/DrawerArrowDrawable.java)(准确的说不应该是控件而是一个Drawable) - -##依赖包介绍 -1. jar包依赖 - * 网络请求库 **android-async-http** :http://loopj.com/android-async-http/ - * 注解绑定控件 **butterknife** http://jakewharton.github.io/butterknife/ - * 网络图片加载库 **KJFrameForAndroid** http://git.oschina.net/kymjs/KJFrameForAndroid - * XML解析库 **xstream** http://xstream.codehaus.org/ -2. 源码依赖 - * **PhotoView-library** :用于图片预览界面展示 - * **UmengShareLib** :用于分享到第三方平台 - -##开源协议 - Copyright (C) 2014, The OSChina Open Source Project - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \ No newline at end of file +# OSChina Android + +开源中国官方App客户端开源代码。 + + +## 注意 + +- master中不再放置源码,请切换到对应tag或branch查看 +- 源码仅作学习,接口将进行限制,如需请求API接口应使用 [openapi](http://www.oschina.net/openapi) + + +## 历史分支 + +| 序号 | 标签名 | 发布版本 |说明 | 链接 | +| ----| ---------------------------------------- | ------------------- | ---------------- |---------------- | +| 1 | [v4.1.7](https://gitee.com/oschina/android-app/tree/v4.1.7/) | v4.1.7 |当前最新版 | -- | +| 2 | [v2.9.0](https://gitee.com/oschina/android-app/tree/v2.9.0/) | v2.9.0(1710272043) | -- | [更新说明](https://www.oschina.net/news/90044/oschina-android-app-v290-release) | +| 3 | [v2.8.9](https://gitee.com/oschina/android-app/tree/v2.8.9/) | v2.8.9(1709291445) | -- | [更新说明](https://www.oschina.net/news/89179/oschina-android-app-v289-release) | +| 4 | [v2.8.8](https://gitee.com/oschina/android-app/tree/v2.8.8/) | v2.8.8(1708301525) | -- | [更新说明](https://www.oschina.net/news/88218/oschina-android-app-v288-release) | +| 5 | [v2.8.7](https://gitee.com/oschina/android-app/tree/v2.8.7/) | v2.8.7(1708081543) | -- | [更新说明](https://www.oschina.net/news/87552/oschina-android-app-v287-release) | +| 6 | [v2.8.6](https://gitee.com/oschina/android-app/tree/v2.8.6/) | v2.8.6(1706051018) | -- | [更新说明](https://www.oschina.net/news/85504/oschina-android-app-v286-release) | +| 7 | [v2.8.5](https://gitee.com/oschina/android-app/tree/v2.8.5/) | v2.8.5(1705031527) | -- | [更新说明](https://www.oschina.net/news/84420/oschina-android-app-v285-release) | +| 8 | [v2.8.4](https://gitee.com/oschina/android-app/tree/v2.8.4/) | v2.8.4(1704261126) | -- | [更新说明](https://www.oschina.net/news/84213/oschina-android-app-v284-release) | +| 9 | [v2.8.3](https://gitee.com/oschina/android-app/tree/v2.8.3/) | v2.8.3(1703281011) | -- | [更新说明](https://www.oschina.net/news/83315/oschina-android-app-v283-release) | +| 10 | [v2.8.2](https://gitee.com/oschina/android-app/tree/v2.8.2/) | v2.8.2 (1703171047) | -- | [更新说明](https://www.oschina.net/news/82984/oschina-android-app-v282-release) | +| 11 | [v2.8.1](https://gitee.com/oschina/android-app/tree/v2.8.1/) | v2.8.1 (1702221002) | --| [更新说明](https://www.oschina.net/news/82172/oschina-android-app-v281-release) | +| 12 | [v2.8.0](https://gitee.com/oschina/android-app/tree/v2.8.0/) | v2.8.0 (1701231104) | -- | [更新说明](https://www.oschina.net/news/81253/oschina-android-app-v280-release) | +| 13 | [v2.7.1](https://gitee.com/oschina/android-app/tree/v2.7.1/) | v2.7.1 (1612211352) | -- | [更新说明](https://www.oschina.net/news/80229/oschina-android-app-v271-release) | +| 14 | [v2.6.9](https://gitee.com/oschina/android-app/tree/v2.6.9/) | v2.6.9 (1611220955) | -- |[更新说明](https://www.oschina.net/news/79281/oschina-android-client-v269-release) | +| 15 | [v2.6.6](https://gitee.com/oschina/android-app/tree/v2.6.6/) | v2.6.6 (1609281026) | -- |[更新说明](https://www.oschina.net/news/77610/oschina-android-client-v266-release) | +| 16 | [v2.6.5](https://gitee.com/oschina/android-app/tree/v2.6.5/) | v2.6.5 (1609211120) | -- |[更新说明](https://www.oschina.net/news/77332/oschina-android-client-v265-release)| +| 17 | [v2.6.4](https://gitee.com/oschina/android-app/tree/v2.6.4/) | v2.6.4 (1608081154) | -- |[更新说明](https://www.oschina.net/news/75938/oschina-client-v264-release)| +| 18 | [v2.6.3](https://gitee.com/oschina/android-app/tree/v2.6.3/) | v2.6.3 (1607081128) | -- |[更新说明](https://www.oschina.net/news/75027/oschina-client-v263-release)| +| 19 | [v2.6.2](https://gitee.com/oschina/android-app/tree/v2.6.2/) | v2.6.2 (1606121625) | -- | | +| 20 | [v2.4](https://gitee.com/oschina/android-app/tree/v2.4/) | -- | -- | -- | +| 21 | [v2.3](https://gitee.com/oschina/android-app/tree/v2.3/) | -- | 迁移到AndroidStudio | -- | +| 22 | [v2.2.1](https://gitee.com/oschina/android-app/tree/v2.2.1/) | -- | Eclipse可用 | -- | + + + +## 最新版开发环境 + +1. Android Studio >= 2.2 +2. Gradel Version: 2.14.1 +3. Gradle Plugin Version: 2.2.3 +4. SDK Tool >= 24.0.3 + + + +## 项目简述 + +- 新版相关代码集中在**“net.oschina.app.improve”**包中,其他包中代码将逐步清理。 +- 项目分包方式采取功能模块进行分包,查看代码请按功能查询 +- 由于接口逐步进行规范化限制,自己编译后将会出现大部分接口请求无数据的情况(这不是BUG) +- 新项目已抛弃**ListView**转而使用**Recyclerview** + +#### 相关依赖 + +- **com.android.support**:Google官方适配包,用于提供卡片、列表、主题等基础模块 +- **android-async-http**:当前正在使用的网络框架(后续会进行迁移) +- **butterknife**:注解库,用于简化findView和onClick操作 +- **com.google.zxing**:用于二维码扫描 +- **pub.devrel:easypermissions**:简化权限请求的库 +- **com.github.bumptech.glide**:所有的图片请求管理库 +- **de.hdodenhof:circleimageview**:用于圆角图片的实现 +- **com.google.code.gson**:Json-Model解析库,新API已弃用XML数据格式 +- **net.qiujuer.genius**:用于图片模糊,Material Design 控件5.0以下适配 +- **net.oschina.common**:OSChina官方工具包,用于提供基础功能支持 + + + +## 支持开源 + +通过以下方式对我们的项目进行支持: + +1. 对于Bug请通过:描述**(怎么操作?什么情况?手机型号?操作系统?)**->[Issue](https://gitee.com/oschina/android-app/issues/new?issue%5Bassignee_id%5D=&issue%5Bmilestone_id%5D=) +2. 如果有时间,你可以自己解决问题并向我们提出 [Pull Request](https://gitee.com/oschina/android-app/pulls) +3. 当然,我们提倡通过顶部**捐赠**方式赞助开发小组童鞋们喝杯咖啡 + + + +## 开源协议 + + The MIT License (MIT) + + Copyright (c) 2018 OSChina.net + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d1c402326528b4ba3c12ee9d92d0e212e9..0000000000000000000000000000000000000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index e540323d6a2a30d1cd9d771716ca9684737cdb62..0000000000000000000000000000000000000000 --- a/app/build.gradle +++ /dev/null @@ -1,34 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'newlens' - -android { - compileSdkVersion 23 - buildToolsVersion '21.1.2' - - defaultConfig { - applicationId "net.oschina.app" - minSdkVersion 15 - targetSdkVersion 23 - versionCode 48 - versionName "2.4.1" - } - - // 移除lint检查的error - lintOptions { - abortOnError false - } -} - -dependencies { - compile fileTree(include: ['*.jar'], dir: 'libs') - compile project(':social_sdk_library_project') - compile 'com.android.support:appcompat-v7:23.1.0' - compile 'com.github.chrisbanes.photoview:library:1.2.3' - compile 'com.loopj.android:android-async-http:1.4.9' - compile 'com.jakewharton:butterknife:6.1.0' - compile 'org.kymjs.kjframe:kjframe:2.6' - compile 'com.networkbench.newlens.agent.android:nbs.newlens.agent:2.2.7' - compile 'com.google.zxing:core:3.2.0' - compile 'com.joanzapata.android:android-iconify:1.0.9' - compile 'com.makeramen:roundedimageview:2.1.1' -} diff --git a/app/libs/baidumapapi_v3_2_0.jar b/app/libs/baidumapapi_v3_2_0.jar deleted file mode 100644 index c60212c7633ee1dac18b0cc3292cee99b9bbb290..0000000000000000000000000000000000000000 Binary files a/app/libs/baidumapapi_v3_2_0.jar and /dev/null differ diff --git a/app/libs/library-2.4.0.jar b/app/libs/library-2.4.0.jar deleted file mode 100644 index d6964d7612e29adadb7d6d3c0227f850cc22204b..0000000000000000000000000000000000000000 Binary files a/app/libs/library-2.4.0.jar and /dev/null differ diff --git a/app/libs/locSDK_3.1.jar b/app/libs/locSDK_3.1.jar deleted file mode 100644 index f503848aadcf698ed8c9fe8a04d8bc4dd5de0804..0000000000000000000000000000000000000000 Binary files a/app/libs/locSDK_3.1.jar and /dev/null differ diff --git a/app/libs/pinyin4j-2.5.0.jar b/app/libs/pinyin4j-2.5.0.jar deleted file mode 100755 index e27c5012fdd9f9c843594651ec83cad98b9c02de..0000000000000000000000000000000000000000 Binary files a/app/libs/pinyin4j-2.5.0.jar and /dev/null differ diff --git a/app/libs/xstream-1.4.7.jar b/app/libs/xstream-1.4.7.jar deleted file mode 100644 index ea4b6a2816698260acf78555d655cfaa01555413..0000000000000000000000000000000000000000 Binary files a/app/libs/xstream-1.4.7.jar and /dev/null differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 41abe698d28002306c29e2b019aa0c1f06d893e4..0000000000000000000000000000000000000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/yanghonghe/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/app/src/androidTest/java/net/oschina/app/ApplicationTest.java b/app/src/androidTest/java/net/oschina/app/ApplicationTest.java deleted file mode 100644 index 5b378ac2dc1f57ad81a454efa7534b4304825e4c..0000000000000000000000000000000000000000 --- a/app/src/androidTest/java/net/oschina/app/ApplicationTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.oschina.app; - -import android.app.Application; -import android.test.ApplicationTestCase; - -/** - * Testing Fundamentals - */ -public class ApplicationTest extends ApplicationTestCase { - public ApplicationTest() { - super(Application.class); - } -} \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml deleted file mode 100644 index 2240c7c8d535029f094d51907926d7825e5a57c0..0000000000000000000000000000000000000000 --- a/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/aidl/net/oschina/app/service/INoticeService.aidl b/app/src/main/aidl/net/oschina/app/service/INoticeService.aidl deleted file mode 100644 index fcd7d7b32e3f0f2b404384036f62b9e36eb2795d..0000000000000000000000000000000000000000 --- a/app/src/main/aidl/net/oschina/app/service/INoticeService.aidl +++ /dev/null @@ -1,8 +0,0 @@ -package net.oschina.app.service; - -interface INoticeService -{ - void scheduleNotice(); - void requestNotice(); - void clearNotice(int uid,int type); -} \ No newline at end of file diff --git a/app/src/main/assets/brush.js b/app/src/main/assets/brush.js deleted file mode 100644 index c1bb004da70742c24f1e88fa8cfa82d04723f318..0000000000000000000000000000000000000000 --- a/app/src/main/assets/brush.js +++ /dev/null @@ -1,12 +0,0 @@ -if(!window.SyntaxHighlighter){var SyntaxHighlighter=function(){var a={defaults:{"class-name":"","first-line":1,"pad-line-numbers":true,"highlight":null,"smart-tabs":true,"tab-size":4,"gutter":true,"toolbar":true,"collapse":false,"auto-links":true,"light":false,"wrap-lines":true,"html-script":false},config:{useScriptTags:true,clipboardSwf:null,toolbarItemWidth:16,toolbarItemHeight:16,bloggerMode:false,stripBrs:false,tagName:"pre",strings:{expandSource:"show source",viewSource:"view source",copyToClipboard:"copy to clipboard",copyToClipboardConfirmation:"The code is in your clipboard now",print:"print",help:"?",alert:"SyntaxHighlighter\n\n",noBrush:"Can't find brush for: ",brushNotHtmlScript:"Brush wasn't configured for html-script option: ",aboutDialog:'About SyntaxHighlighter
SyntaxHighlighter
version 2.1.382 (June 24 2010)
http://alexgorbatchev.com
If you like this script, please donate to keep development active!
JavaScript code syntax highlighter.
Copyright 2004-2009 Alex Gorbatchev.
'},debug:false},vars:{discoveredBrushes:null,spaceWidth:null,printFrame:null,highlighters:{}},brushes:{},regexLib:{multiLineCComments:/\/\*[\s\S]*?\*\//gm,singleLineCComments:/\/\/.*$/gm,singleLinePerlComments:/#.*$/gm,doubleQuotedString:/"([^\\"\n]|\\.)*"/g,singleQuotedString:/'([^\\'\n]|\\.)*'/g,multiLineDoubleQuotedString:/"([^\\"]|\\.)*"/g,multiLineSingleQuotedString:/'([^\\']|\\.)*'/g,xmlComments:/(<|<)!--[\s\S]*?--(>|>)/gm,url:/<\w+:\/\/[\w-.\/?%&=@:;]*>|\w+:\/\/[\w-.\/?%&=@:;]*/g,phpScriptTags:{left:/(<|<)\?=?/g,right:/\?(>|>)/g},aspScriptTags:{left:/(<|<)%=?/g,right:/%(>|>)/g},scriptScriptTags:{left:/(<|<)\s*script.*?(>|>)/gi,right:/(<|<)\/\s*script\s*(>|>)/gi}},toolbar:{create:function(d){var h=document.createElement("DIV"),b=a.toolbar.items;h.className="toolbar";for(var c in b){var f=b[c],g=new f(d),e=g.create();d.toolbarCommands[c]=g;if(e==null){continue}if(typeof(e)=="string"){e=a.toolbar.createButton(e,d.id,c)}e.className+="item "+c;h.appendChild(e)}return h},createButton:function(f,c,g){var d=document.createElement("a"),i=d.style,e=a.config,h=e.toolbarItemWidth,b=e.toolbarItemHeight;d.href="#"+g;d.title=f;d.highlighterId=c;d.commandName=g;d.innerHTML=f;if(isNaN(h)==false){i.width=h+"px"}if(isNaN(b)==false){i.height=b+"px"}d.onclick=function(j){try{a.toolbar.executeCommand(this,j||window.event,this.highlighterId,this.commandName)}catch(j){a.utils.alert(j.message)}return false};return d},executeCommand:function(f,g,b,e,d){var c=a.vars.highlighters[b],h;if(c==null||(h=c.toolbarCommands[e])==null){return null}return h.execute(f,g,d)},items:{expandSource:function(b){this.create=function(){if(b.getParam("collapse")!=true){return}return a.config.strings.expandSource};this.execute=function(d,e,c){var f=b.div;d.parentNode.removeChild(d);f.className=f.className.replace("collapsed","")}},viewSource:function(b){this.create=function(){return a.config.strings.viewSource};this.execute=function(d,g,c){var f=a.utils.fixInputString(b.originalCode).replace(/"+f+"");e.document.close()}},copyToClipboard:function(d){var e,c,b=d.id;this.create=function(){var g=a.config;if(g.clipboardSwf==null){return null}function l(o){var m="";for(var n in o){m+=""}return m}function f(o){var m="";for(var n in o){m+=" "+n+"='"+o[n]+"'"}return m}var k={width:g.toolbarItemWidth,height:g.toolbarItemHeight,id:b+"_clipboard",type:"application/x-shockwave-flash",title:a.config.strings.copyToClipboard},j={allowScriptAccess:"always",wmode:"transparent",flashVars:"highlighterId="+b,menu:"false"},i=g.clipboardSwf,h;if(/msie/i.test(navigator.userAgent)){h=""+l(j)+l({movie:i})+""}else{h=""}e=document.createElement("div");e.innerHTML=h;return e};this.execute=function(g,i,f){var j=f.command;switch(j){case"get":var h=a.utils.unindent(a.utils.fixInputString(d.originalCode).replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")); - if(window.clipboardData){window.clipboardData.setData("text",h)}else{return a.utils.unindent(h)}case"ok":a.utils.alert(a.config.strings.copyToClipboardConfirmation);break;case"error":a.utils.alert(f.message);break}}},printSource:function(b){this.create=function(){return a.config.strings.print};this.execute=function(e,g,d){var f=document.createElement("IFRAME"),h=null;if(a.vars.printFrame!=null){document.body.removeChild(a.vars.printFrame)}a.vars.printFrame=f;f.style.cssText="position:absolute;width:0px;height:0px;left:-500px;top:-500px;";document.body.appendChild(f);h=f.contentWindow.document;c(h,window.document);h.write('
'+b.div.innerHTML+"
");h.close();f.contentWindow.focus();f.contentWindow.print();function c(j,m){var k=m.getElementsByTagName("link");for(var l=0;l')}}}}},about:function(b){this.create=function(){return a.config.strings.help};this.execute=function(c,e){var d=a.utils.popup("","_blank",500,250,"scrollbars=0"),f=d.document;f.write(a.config.strings.aboutDialog);f.close();d.focus()}}}},utils:{indexOf:function(e,b,d){d=Math.max(d||0,0);for(var c=d;c(.*?))\\]$"),f=new XRegExp("(?[\\w-]+)"+"\\s*:\\s*"+"(?"+"[\\w-%#]+|"+"\\[.*?\\]|"+'".*?"|'+"'.*?'"+")\\s*;?","g");while((d=f.exec(h))!=null){var g=d.value.replace(/^['"]|['"]$/g,"");if(g!=null&&e.test(g)){var b=e.exec(g);g=b.values.length>0?b.values.split(/\s*,\s*/):[]}c[d.name]=g}return c},decorate:function(c,b){if(c==null||c.length==0||c=="\n"){return c}c=c.replace(/'+d+""})}return c},padNumber:function(d,c){var b=d.toString();while(b.length",e="";c.innerHTML=i+'syntaxhighlighter">'+i+'lines">'+i+'line">'+i+"content"+'"> '+e+e+g+g+g+g;f.appendChild(c);h=document.getElementById(d);if(/opera/i.test(navigator.userAgent)){var b=window.getComputedStyle(h,null);j=parseInt(b.getPropertyValue("width"))}else{j=h.offsetWidth}f.removeChild(c);return j},processTabs:function(d,e){var c="";for(var b=0;b|<br\s*\/?>/gi;if(a.config.bloggerMode==true){c=c.replace(b,"\n")}if(a.config.stripBrs==true){c=c.replace(b,"")}return c},trim:function(b){return b.replace(/^\s+|\s+$/g,"")},unindent:function(j){var c=a.utils.fixInputString(j).split("\n"),h=new Array(),f=/^\s*/,e=1000;for(var d=0;d0;d++){var b=c[d];if(a.utils.trim(b).length==0){continue}var g=f.exec(b);if(g==null){return j}e=Math.min(g[0].length,e)}if(e>0){for(var d=0;db.index){return 1}else{if(c.lengthb.length){return 1 -}}}}return 0},getMatches:function(f,g){function h(i,j){return[new a.Match(i[0],i.index,j.css)]}var d=0,c=null,b=[],e=g.func?g.func:h;while((c=g.regex.exec(f))!=null){b=b.concat(e(c,g))}return b},processUrls:function(d){var b="<",c=">";return d.replace(a.regexLib.url,function(e){var g="",f="";if(e.indexOf(b)==0){f=b;e=e.substring(b.length)}if(e.indexOf(c)==e.length-c.length){e=e.substring(0,e.length-c.length);g=c}return f+''+e+""+g})},getSyntaxHighlighterScriptTags:function(){var c=document.getElementsByTagName("script"),b=[];for(var d=0;dd){break}else{if(g.index==b.index&&g.length>b.length){this.matches[e]=null}else{if(g.index>=b.index&&g.index'+""+""+(f?'":"")+'"+""+"
'+d+"'+(j!=null?''+j.replace(" "," ")+"":"")+o+"
"+""}return b},processMatches:function(b,h){var j=0,l="",c=a.utils.decorate,k=this.getParam("brush-name","");function e(m){var i=m?(m.brushName||k):k;return i?i+" ":""}for(var f=0;f"+b.left.source+")"+"(?.*?)"+"(?"+b.right.source+")","sgi")}}};return a}()}if(!window.XRegExp){(function(){var e={exec:RegExp.prototype.exec,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},d={part:/(?:[^\\([#\s.]+|\\(?!k<[\w$]+>|[pP]{[^}]+})[\S\s]?|\((?=\?(?!#|<[\w$]+>)))+|(\()(?:\?(?:(#)[^)]*\)|<([$\w]+)>))?|\\(?:k<([\w$]+)>|[pP]{([^}]+)})|(\[\^?)|([\S\s])/g,replaceVar:/(?:[^$]+|\$(?![1-9$&`']|{[$\w]+}))+|\$(?:([1-9]\d*|[$&`'])|{([$\w]+)})/g,extended:/^(?:\s+|#.*)+/,quantifier:/^(?:[?*+]|{\d+(?:,\d*)?})/,classLeft:/&&\[\^?/g,classRight:/]/g},b=function(j,g,h){for(var f=h||0;f-1,k=i.indexOf("x")>-1,p=false,r=[],h=[],g=d.part,l,j,n,m,q;g.lastIndex=0;while(l=e.exec.call(g,o)){if(l[2]){if(!d.quantifier.test(o.slice(g.lastIndex))){h.push("(?:)")}}else{if(l[1]){r.push(l[3]||null);if(l[3]){p=true}h.push("(")}else{if(l[4]){m=b(r,l[4]);h.push(m>-1?"\\"+(m+1)+(isNaN(o.charAt(g.lastIndex))?"":"(?:)"):l[0])}else{if(l[5]){h.push(a.unicode?a.unicode.get(l[5],l[0].charAt(1)==="P"):l[0])}else{if(l[6]){if(o.charAt(g.lastIndex)==="]"){h.push(l[6]==="["?"(?!)":"[\\S\\s]");g.lastIndex++}else{j=XRegExp.matchRecursive("&&"+o.slice(l.index),d.classLeft,d.classRight,"",{escapeChar:"\\"})[0];h.push(l[6]+j+"]");g.lastIndex+=j.length+1}}else{if(l[7]){if(f&&l[7]==="."){h.push("[\\S\\s]")}else{if(k&&d.extended.test(l[7])){n=e.exec.call(d.extended,o.slice(g.lastIndex-1))[0].length;if(!d.quantifier.test(o.slice(g.lastIndex-1+n))){h.push("(?:)")}g.lastIndex+=n-1}else{h.push(l[7])}}}else{h.push(l[0])}}}}}}}q=RegExp(h.join(""),e.replace.call(i,/[sx]+/g,""));q._x={source:o,captureNames:p?r:null};return q};XRegExp.addPlugin=function(f,g){a[f]=g};RegExp.prototype.exec=function(k){var h=e.exec.call(this,k),g,j,f;if(h){if(c&&h.length>1){f=new RegExp("^"+this.source+"$(?!\\s)",this.getNativeFlags());e.replace.call(h[0],f,function(){for(j=1;j(h.index+h[0].length)){this.lastIndex--}}return h}})()}RegExp.prototype.getNativeFlags=function(){return(this.global?"g":"")+(this.ignoreCase?"i":"")+(this.multiline?"m":"")+(this.extended?"x":"")+(this.sticky?"y":"")};RegExp.prototype.addFlags=function(a){var b=new XRegExp(this.source,(a||"")+this.getNativeFlags());if(this._x){b._x={source:this._x.source,captureNames:this._x.captureNames?this._x.captureNames.slice(0):null}}return b};RegExp.prototype.call=function(a,b){return this.exec(b)};RegExp.prototype.apply=function(b,a){return this.exec(a[0])};XRegExp.cache=function(c,a){var b="/"+c+"/"+(a||"");return XRegExp.cache[b]||(XRegExp.cache[b]=new XRegExp(c,a))};XRegExp.escape=function(a){return a.replace(/[-[\]{}()*+?.\\^$|,#\s]/g,"\\$&")};XRegExp.matchRecursive=function(p,d,s,f,b){var b=b||{},v=b.escapeChar,k=b.valueNames,f=f||"",q=f.indexOf("g")>-1,c=f.indexOf("i")>-1,h=f.indexOf("m")>-1,u=f.indexOf("y")>-1,f=f.replace(/y/g,""),d=d instanceof RegExp?(d.global?d:d.addFlags("g")):new XRegExp(d,"g"+f),s=s instanceof RegExp?(s.global?s:s.addFlags("g")):new XRegExp(s,"g"+f),i=[],a=0,j=0,n=0,l=0,m,e,o,r,g,t;if(v){if(v.length>1){throw SyntaxError("can't supply more than one escape character") -}if(h){throw TypeError("can't supply escape character when using the multiline flag")}g=XRegExp.escape(v);t=new RegExp("^(?:"+g+"[\\S\\s]|(?:(?!"+d.source+"|"+s.source+")[^"+g+"])+)+",c?"i":"")}while(true){d.lastIndex=s.lastIndex=n+(v?(t.exec(p.slice(n))||[""])[0].length:0);o=d.exec(p);r=s.exec(p);if(o&&r){if(o.index<=r.index){r=null}else{o=null}}if(o||r){j=(o||r).index;n=(o?d:s).lastIndex}else{if(!a){break}}if(u&&!a&&j>l){break}if(o){if(!a++){m=j;e=n}}else{if(r&&a){if(!--a){if(k){if(k[0]&&m>l){i.push([k[0],p.slice(l,m),l,m])}if(k[1]){i.push([k[1],p.slice(m,e),m,e])}if(k[2]){i.push([k[2],p.slice(e,j),e,j])}if(k[3]){i.push([k[3],p.slice(j,n),j,n])}}else{i.push(p.slice(e,j))}l=n;if(!q){break}}}else{d.lastIndex=s.lastIndex=0;throw Error("subject data contains unbalanced delimiters")}}if(j===n){n++}}if(q&&!u&&k&&k[0]&&p.length>l){i.push([k[0],p.slice(l),l,p.length])}d.lastIndex=s.lastIndex=0;return i};SyntaxHighlighter.brushes.AS3=function(){var b="class interface function package";var a="-Infinity ...rest Array as AS3 Boolean break case catch const continue Date decodeURI "+"decodeURIComponent default delete do dynamic each else encodeURI encodeURIComponent escape "+"extends false final finally flash_proxy for get if implements import in include Infinity "+"instanceof int internal is isFinite isNaN isXMLName label namespace NaN native new null "+"Null Number Object object_proxy override parseFloat parseInt private protected public "+"return set static String super switch this throw true try typeof uint undefined unescape "+"use void while with";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi,css:"value"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"color3"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"},{regex:new RegExp("var","gm"),css:"variable"},{regex:new RegExp("trace","gm"),css:"color1"}];this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags)};SyntaxHighlighter.brushes.AS3.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.AS3.aliases=["actionscript3","as3"];SyntaxHighlighter.brushes.Bash=function(){var b="if fi then elif else for do done until while break continue case function return in eq ne gt lt ge le";var a="alias apropos awk basename bash bc bg builtin bzip2 cal cat cd cfdisk chgrp chmod chown chroot"+"cksum clear cmp comm command cp cron crontab csplit cut date dc dd ddrescue declare df "+"diff diff3 dig dir dircolors dirname dirs du echo egrep eject enable env ethtool eval "+"exec exit expand export expr false fdformat fdisk fg fgrep file find fmt fold format "+"free fsck ftp gawk getopts grep groups gzip hash head history hostname id ifconfig "+"import install join kill less let ln local locate logname logout look lpc lpr lprint "+"lprintd lprintq lprm ls lsof make man mkdir mkfifo mkisofs mknod more mount mtools "+"mv netstat nice nl nohup nslookup open op passwd paste pathchk ping popd pr printcap "+"printenv printf ps pushd pwd quota quotacheck quotactl ram rcp read readonly renice "+"remsync rm rmdir rsync screen scp sdiff sed select seq set sftp shift shopt shutdown "+"sleep sort source split ssh strace su sudo sum symlink sync tail tar tee test time "+"times touch top traceroute trap tr true tsort tty type ulimit umask umount unalias "+"uname unexpand uniq units unset unshar useradd usermod users uuencode uudecode v vdir "+"vi watch wc whereis which who whoami Wget xargs yes";this.findMatches=function(d,c){c=c.replace(/>/g,">").replace(/</g,"<");this.code=c;return SyntaxHighlighter.Highlighter.prototype.findMatches.apply(this,[d,c])};this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLinePerlComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"keyword"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"functions"}]};SyntaxHighlighter.brushes.Bash.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Bash.aliases=["bash","shell"];SyntaxHighlighter.brushes.ColdFusion=function(){var b="Abs ACos AddSOAPRequestHeader AddSOAPResponseHeader AjaxLink AjaxOnLoad ArrayAppend ArrayAvg ArrayClear ArrayDeleteAt "+"ArrayInsertAt ArrayIsDefined ArrayIsEmpty ArrayLen ArrayMax ArrayMin ArraySet ArraySort ArraySum ArraySwap ArrayToList "+"Asc ASin Atn BinaryDecode BinaryEncode BitAnd BitMaskClear BitMaskRead BitMaskSet BitNot BitOr BitSHLN BitSHRN BitXor "+"Ceiling CharsetDecode CharsetEncode Chr CJustify Compare CompareNoCase Cos CreateDate CreateDateTime CreateObject "+"CreateODBCDate CreateODBCDateTime CreateODBCTime CreateTime CreateTimeSpan CreateUUID DateAdd DateCompare DateConvert "+"DateDiff DateFormat DatePart Day DayOfWeek DayOfWeekAsString DayOfYear DaysInMonth DaysInYear DE DecimalFormat DecrementValue "+"Decrypt DecryptBinary DeleteClientVariable DeserializeJSON DirectoryExists DollarFormat DotNetToCFType Duplicate Encrypt "+"EncryptBinary Evaluate Exp ExpandPath FileClose FileCopy FileDelete FileExists FileIsEOF FileMove FileOpen FileRead "+"FileReadBinary FileReadLine FileSetAccessMode FileSetAttribute FileSetLastModified FileWrite Find FindNoCase FindOneOf "+"FirstDayOfMonth Fix FormatBaseN GenerateSecretKey GetAuthUser GetBaseTagData GetBaseTagList GetBaseTemplatePath "+"GetClientVariablesList GetComponentMetaData GetContextRoot GetCurrentTemplatePath GetDirectoryFromPath GetEncoding "+"GetException GetFileFromPath GetFileInfo GetFunctionList GetGatewayHelper GetHttpRequestData GetHttpTimeString "+"GetK2ServerDocCount GetK2ServerDocCountLimit GetLocale GetLocaleDisplayName GetLocalHostIP GetMetaData GetMetricData "+"GetPageContext GetPrinterInfo GetProfileSections GetProfileString GetReadableImageFormats GetSOAPRequest GetSOAPRequestHeader "+"GetSOAPResponse GetSOAPResponseHeader GetTempDirectory GetTempFile GetTemplatePath GetTickCount GetTimeZoneInfo GetToken "+"GetUserRoles GetWriteableImageFormats Hash Hour HTMLCodeFormat HTMLEditFormat IIf ImageAddBorder ImageBlur ImageClearRect "+"ImageCopy ImageCrop ImageDrawArc ImageDrawBeveledRect ImageDrawCubicCurve ImageDrawLine ImageDrawLines ImageDrawOval "+"ImageDrawPoint ImageDrawQuadraticCurve ImageDrawRect ImageDrawRoundRect ImageDrawText ImageFlip ImageGetBlob ImageGetBufferedImage "+"ImageGetEXIFTag ImageGetHeight ImageGetIPTCTag ImageGetWidth ImageGrayscale ImageInfo ImageNegative ImageNew ImageOverlay ImagePaste "+"ImageRead ImageReadBase64 ImageResize ImageRotate ImageRotateDrawingAxis ImageScaleToFit ImageSetAntialiasing ImageSetBackgroundColor "+"ImageSetDrawingColor ImageSetDrawingStroke ImageSetDrawingTransparency ImageSharpen ImageShear ImageShearDrawingAxis ImageTranslate "+"ImageTranslateDrawingAxis ImageWrite ImageWriteBase64 ImageXORDrawingMode IncrementValue InputBaseN Insert Int IsArray IsBinary "+"IsBoolean IsCustomFunction IsDate IsDDX IsDebugMode IsDefined IsImage IsImageFile IsInstanceOf IsJSON IsLeapYear IsLocalHost "+"IsNumeric IsNumericDate IsObject IsPDFFile IsPDFObject IsQuery IsSimpleValue IsSOAPRequest IsStruct IsUserInAnyRole IsUserInRole "+"IsUserLoggedIn IsValid IsWDDX IsXML IsXmlAttribute IsXmlDoc IsXmlElem IsXmlNode IsXmlRoot JavaCast JSStringFormat LCase Left Len "+"ListAppend ListChangeDelims ListContains ListContainsNoCase ListDeleteAt ListFind ListFindNoCase ListFirst ListGetAt ListInsertAt "+"ListLast ListLen ListPrepend ListQualify ListRest ListSetAt ListSort ListToArray ListValueCount ListValueCountNoCase LJustify Log "+"Log10 LSCurrencyFormat LSDateFormat LSEuroCurrencyFormat LSIsCurrency LSIsDate LSIsNumeric LSNumberFormat LSParseCurrency LSParseDateTime "+"LSParseEuroCurrency LSParseNumber LSTimeFormat LTrim Max Mid Min Minute Month MonthAsString Now NumberFormat ParagraphFormat ParseDateTime "+"Pi PrecisionEvaluate PreserveSingleQuotes Quarter QueryAddColumn QueryAddRow QueryConvertForGrid QueryNew QuerySetCell QuotedValueList Rand "+"Randomize RandRange REFind REFindNoCase ReleaseComObject REMatch REMatchNoCase RemoveChars RepeatString Replace ReplaceList ReplaceNoCase "+"REReplace REReplaceNoCase Reverse Right RJustify Round RTrim Second SendGatewayMessage SerializeJSON SetEncoding SetLocale SetProfileString "+"SetVariable Sgn Sin Sleep SpanExcluding SpanIncluding Sqr StripCR StructAppend StructClear StructCopy StructCount StructDelete StructFind "+"StructFindKey StructFindValue StructGet StructInsert StructIsEmpty StructKeyArray StructKeyExists StructKeyList StructKeyList StructNew "+"StructSort StructUpdate Tan TimeFormat ToBase64 ToBinary ToScript ToString Trim UCase URLDecode URLEncodedFormat URLSessionFormat Val "+"ValueList VerifyClient Week Wrap Wrap WriteOutput XmlChildPos XmlElemNew XmlFormat XmlGetNodeType XmlNew XmlParse XmlSearch XmlTransform "+"XmlValidate Year YesNoFormat"; - var c="cfabort cfajaximport cfajaxproxy cfapplet cfapplication cfargument cfassociate cfbreak cfcache cfcalendar "+"cfcase cfcatch cfchart cfchartdata cfchartseries cfcol cfcollection cfcomponent cfcontent cfcookie cfdbinfo "+"cfdefaultcase cfdirectory cfdiv cfdocument cfdocumentitem cfdocumentsection cfdump cfelse cfelseif cferror "+"cfexchangecalendar cfexchangeconnection cfexchangecontact cfexchangefilter cfexchangemail cfexchangetask "+"cfexecute cfexit cffeed cffile cfflush cfform cfformgroup cfformitem cfftp cffunction cfgrid cfgridcolumn "+"cfgridrow cfgridupdate cfheader cfhtmlhead cfhttp cfhttpparam cfif cfimage cfimport cfinclude cfindex "+"cfinput cfinsert cfinterface cfinvoke cfinvokeargument cflayout cflayoutarea cfldap cflocation cflock cflog "+"cflogin cfloginuser cflogout cfloop cfmail cfmailparam cfmailpart cfmenu cfmenuitem cfmodule cfNTauthenticate "+"cfobject cfobjectcache cfoutput cfparam cfpdf cfpdfform cfpdfformparam cfpdfparam cfpdfsubform cfpod cfpop "+"cfpresentation cfpresentationslide cfpresenter cfprint cfprocessingdirective cfprocparam cfprocresult "+"cfproperty cfquery cfqueryparam cfregistry cfreport cfreportparam cfrethrow cfreturn cfsavecontent cfschedule "+"cfscript cfsearch cfselect cfset cfsetting cfsilent cfslider cfsprydataset cfstoredproc cfswitch cftable "+"cftextarea cfthread cfthrow cftimer cftooltip cftrace cftransaction cftree cftreeitem cftry cfupdate cfwddx "+"cfwindow cfxml cfzip cfzipparam";var a="all and any between cross in join like not null or outer some";this.regexList=[{regex:new RegExp("--(.*)$","gm"),css:"comments"},{regex:SyntaxHighlighter.regexLib.xmlComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords(b),"gmi"),css:"functions"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"color1"},{regex:new RegExp(this.getKeywords(c),"gmi"),css:"keyword"}]};SyntaxHighlighter.brushes.ColdFusion.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.ColdFusion.aliases=["coldfusion","cf"];SyntaxHighlighter.brushes.Cpp=function(){var c="ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR "+"DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH "+"HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP "+"HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY "+"HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT "+"HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE "+"LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF "+"LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR "+"LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR "+"PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT "+"PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 "+"POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR "+"PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 "+"PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT "+"SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG "+"ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM "+"char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t "+"clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS "+"FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t "+"__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t "+"jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler "+"sig_atomic_t size_t _stat __stat64 _stati64 terminate_function "+"time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf "+"va_list wchar_t wctrans_t wctype_t wint_t signed";var a="break case catch class const __finally __exception __try "+"const_cast continue private public protected __declspec "+"default delete deprecated dllexport dllimport do dynamic_cast "+"else enum explicit extern if for friend goto inline "+"mutable naked namespace new noinline noreturn nothrow "+"register reinterpret_cast return selectany "+"sizeof static static_cast struct switch template this "+"thread throw true false try typedef typeid typename union "+"using uuid virtual void volatile whcar_t while";var b="assert isalnum isalpha iscntrl isdigit isgraph islower isprint"+"ispunct isspace isupper isxdigit tolower toupper errno localeconv "+"setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod "+"frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf "+"longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start "+"clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen "+"fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell "+"fwrite getc getchar gets perror printf putc putchar puts remove "+"rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam "+"ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol "+"bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs "+"mbtowc qsort rand realloc srand strtod strtol strtoul system "+"wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr "+"strcmp strcoll strcpy strcspn strerror strlen strncat strncmp "+"strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime "+"clock ctime difftime gmtime localtime mktime strftime time"; - this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/^ *#.*/gm,css:"preprocessor"},{regex:new RegExp(this.getKeywords(c),"gm"),css:"color1 bold"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"functions bold"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword bold"}]};SyntaxHighlighter.brushes.Cpp.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Cpp.aliases=["cpp","c"];SyntaxHighlighter.brushes.CSharp=function(){var b="abstract as base bool break byte case catch char checked class const "+"continue decimal default delegate do double else enum event explicit "+"extern false finally fixed float for foreach get goto if implicit in int "+"interface internal is lock long namespace new null object operator out "+"override params private protected public readonly ref return sbyte sealed set "+"short sizeof stackalloc static string struct switch this throw true try "+"typeof uint ulong unchecked unsafe ushort using virtual void while";function a(c,e){var d=(c[0].indexOf("///")==0)?"color1":"comments";return[new SyntaxHighlighter.Match(c[0],c.index,d)]}this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,func:a},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:/@"(?:[^"]|"")*"/g,css:"string"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/^\s*#.*/gm,css:"preprocessor"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"keyword"},{regex:/\bpartial(?=\s+(?:class|interface|struct)\b)/g,css:"keyword"},{regex:/\byield(?=\s+(?:return|break)\b)/g,css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.CSharp.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.CSharp.aliases=["c#","c-sharp","csharp"];SyntaxHighlighter.brushes.CSS=function(){function a(f){return"\\b([a-z_]|)"+f.replace(/ /g,"(?=:)\\b|\\b([a-z_\\*]|\\*|)")+"(?=:)\\b"}function c(f){return"\\b"+f.replace(/ /g,"(?!-)(?!:)\\b|\\b()")+":\\b"}var d="ascent azimuth background-attachment background-color background-image background-position "+"background-repeat background baseline bbox border-collapse border-color border-spacing border-style border-top "+"border-right border-bottom border-left border-top-color border-right-color border-bottom-color border-left-color "+"border-top-style border-right-style border-bottom-style border-left-style border-top-width border-right-width "+"border-bottom-width border-left-width border-width border bottom cap-height caption-side centerline clear clip color "+"content counter-increment counter-reset cue-after cue-before cue cursor definition-src descent direction display "+"elevation empty-cells float font-size-adjust font-family font-size font-stretch font-style font-variant font-weight font "+"height left letter-spacing line-height list-style-image list-style-position list-style-type list-style margin-top "+"margin-right margin-bottom margin-left margin marker-offset marks mathline max-height max-width min-height min-width orphans "+"outline-color outline-style outline-width outline overflow padding-top padding-right padding-bottom padding-left padding page "+"page-break-after page-break-before page-break-inside pause pause-after pause-before pitch pitch-range play-during position "+"quotes right richness size slope src speak-header speak-numeral speak-punctuation speak speech-rate stemh stemv stress "+"table-layout text-align top text-decoration text-indent text-shadow text-transform unicode-bidi unicode-range units-per-em "+"vertical-align visibility voice-family volume white-space widows width widths word-spacing x-height z-index";var b="above absolute all always aqua armenian attr aural auto avoid baseline behind below bidi-override black blink block blue bold bolder "+"both bottom braille capitalize caption center center-left center-right circle close-quote code collapse compact condensed "+"continuous counter counters crop cross crosshair cursive dashed decimal decimal-leading-zero default digits disc dotted double "+"embed embossed e-resize expanded extra-condensed extra-expanded fantasy far-left far-right fast faster fixed format fuchsia "+"gray green groove handheld hebrew help hidden hide high higher icon inline-table inline inset inside invert italic "+"justify landscape large larger left-side left leftwards level lighter lime line-through list-item local loud lower-alpha "+"lowercase lower-greek lower-latin lower-roman lower low ltr marker maroon medium message-box middle mix move narrower "+"navy ne-resize no-close-quote none no-open-quote no-repeat normal nowrap n-resize nw-resize oblique olive once open-quote outset "+"outside overline pointer portrait pre print projection purple red relative repeat repeat-x repeat-y rgb ridge right right-side "+"rightwards rtl run-in screen scroll semi-condensed semi-expanded separate se-resize show silent silver slower slow "+"small small-caps small-caption smaller soft solid speech spell-out square s-resize static status-bar sub super sw-resize "+"table-caption table-cell table-column table-column-group table-footer-group table-header-group table-row table-row-group teal "+"text-bottom text-top thick thin top transparent tty tv ultra-condensed ultra-expanded underline upper-alpha uppercase upper-latin "+"upper-roman url visible wait white wider w-resize x-fast x-high x-large x-loud x-low x-slow x-small x-soft xx-large xx-small yellow"; - var e="[mM]onospace [tT]ahoma [vV]erdana [aA]rial [hH]elvetica [sS]ans-serif [sS]erif [cC]ourier mono sans serif";this.regexList=[{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\#[a-fA-F0-9]{3,6}/g,css:"value"},{regex:/(-?\d+)(\.\d+)?(px|em|pt|\:|\%|)/g,css:"value"},{regex:/!important/g,css:"color3"},{regex:new RegExp(a(d),"gm"),css:"keyword"},{regex:new RegExp(c(b),"g"),css:"value"},{regex:new RegExp(this.getKeywords(e),"g"),css:"color1"}];this.forHtmlScript({left:/(<|<)\s*style.*?(>|>)/gi,right:/(<|<)\/\s*style\s*(>|>)/gi})};SyntaxHighlighter.brushes.CSS.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.CSS.aliases=["css"];SyntaxHighlighter.brushes.Delphi=function(){var a="abs addr and ansichar ansistring array as asm begin boolean byte cardinal "+"case char class comp const constructor currency destructor div do double "+"downto else end except exports extended false file finalization finally "+"for function goto if implementation in inherited int64 initialization "+"integer interface is label library longint longword mod nil not object "+"of on or packed pansichar pansistring pchar pcurrency pdatetime pextended "+"pint64 pointer private procedure program property pshortstring pstring "+"pvariant pwidechar pwidestring protected public published raise real real48 "+"record repeat set shl shortint shortstring shr single smallint string then "+"threadvar to true try type unit until uses val var varirnt while widechar "+"widestring with word write writeln xor";this.regexList=[{regex:/\(\*[\s\S]*?\*\)/gm,css:"comments"},{regex:/{(?!\$)[\s\S]*?}/gm,css:"comments"},{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\{\$[a-zA-Z]+ .+\}/g,css:"color1"},{regex:/\b[\d\.]+\b/g,css:"value"},{regex:/\$[a-zA-Z0-9]+\b/g,css:"value"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"keyword"}]};SyntaxHighlighter.brushes.Delphi.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Delphi.aliases=["delphi","pascal","pas"];SyntaxHighlighter.brushes.Erlang=function(){var a="after and andalso band begin bnot bor bsl bsr bxor "+"case catch cond div end fun if let not of or orelse "+"query receive rem try when xor"+" module export import define";this.regexList=[{regex:new RegExp("[A-Z][A-Za-z0-9_]+","g"),css:"constants"},{regex:new RegExp("\\%.+","gm"),css:"comments"},{regex:new RegExp("\\?[A-Za-z0-9_]+","g"),css:"preprocessor"},{regex:new RegExp("[a-z0-9_]+:[a-z0-9_]+","g"),css:"functions"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"}]};SyntaxHighlighter.brushes.Erlang.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Erlang.aliases=["erl","erlang"];SyntaxHighlighter.brushes.Groovy=function(){var d="as assert break case catch class continue def default do else extends finally "+"if in implements import instanceof interface new package property return switch "+"throw throws try while public protected private static";var c="void boolean byte char short int long float double";var b="null";var a="allProperties count get size "+"collect each eachProperty eachPropertyName eachWithIndex find findAll "+"findIndexOf grep inject max min reverseEach sort "+"asImmutable asSynchronized flatten intersect join pop reverse subMap toList "+"padRight padLeft contains eachMatch toCharacter toLong toUrl tokenize "+"eachFile eachFileRecurse eachB yte eachLine readBytes readLine getText "+"splitEachLine withReader append encodeBase64 decodeBase64 filterLine "+"transformChar transformLine withOutputStream withPrintWriter withStream "+"withStreams withWriter withWriterAppend write writeLine "+"dump inspect invokeMethod print println step times upto use waitForOrKill "+"getText";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/""".*"""/g,css:"string"},{regex:new RegExp("\\b([\\d]+(\\.[\\d]+)?|0x[a-f0-9]+)\\b","gi"),css:"value"},{regex:new RegExp(this.getKeywords(d),"gm"),css:"keyword"},{regex:new RegExp(this.getKeywords(c),"gm"),css:"color1"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"constants"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"functions"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.Groovy.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Groovy.aliases=["groovy"];SyntaxHighlighter.brushes.Java=function(){var a="abstract assert boolean break byte case catch char class const "+"continue default do double else enum extends "+"false final finally float for goto if implements import "+"instanceof int interface long native new null "+"package private protected public return "+"short static strictfp super switch synchronized this throw throws true "+"transient try void volatile while"; - this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:/\/\*([^\*][\s\S]*)?\*\//gm,css:"comments"},{regex:/\/\*(?!\*\/)\*[\s\S]*?\*\//gm,css:"preprocessor"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi,css:"value"},{regex:/(?!\@interface\b)\@[\$\w]+\b/g,css:"color1"},{regex:/\@interface\b/g,css:"color2"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"}];this.forHtmlScript({left:/(<|<)%[@!=]?/g,right:/%(>|>)/g})};SyntaxHighlighter.brushes.Java.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Java.aliases=["java"];SyntaxHighlighter.brushes.JavaFX=function(){var b="Boolean Byte Character Double Duration "+"Float Integer Long Number Short String Void";var a="abstract after and as assert at before bind bound break catch class "+"continue def delete else exclusive extends false finally first for from "+"function if import in indexof init insert instanceof into inverse last "+"lazy mixin mod nativearray new not null on or override package postinit "+"protected public public-init public-read replace return reverse sizeof "+"step super then this throw true try tween typeof var where while with "+"attribute let private readonly static trigger";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:/(-?\.?)(\b(\d*\.?\d+|\d+\.?\d*)(e[+-]?\d+)?|0x[a-f\d]+)\b\.?/gi,css:"color2"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"variable"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.JavaFX.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.JavaFX.aliases=["jfx","javafx"];SyntaxHighlighter.brushes.JScript=function(){var a="break case catch continue "+"default delete do else false "+"for function if in instanceof "+"new null return super switch "+"this throw true try typeof var while with";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\s*#.*/gm,css:"preprocessor"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.scriptScriptTags)};SyntaxHighlighter.brushes.JScript.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.JScript.aliases=["js","jscript","javascript"];SyntaxHighlighter.brushes.Perl=function(){var a="abs accept alarm atan2 bind binmode chdir chmod chomp chop chown chr "+"chroot close closedir connect cos crypt defined delete each endgrent "+"endhostent endnetent endprotoent endpwent endservent eof exec exists "+"exp fcntl fileno flock fork format formline getc getgrent getgrgid "+"getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr "+"getnetbyname getnetent getpeername getpgrp getppid getpriority "+"getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid "+"getservbyname getservbyport getservent getsockname getsockopt glob "+"gmtime grep hex index int ioctl join keys kill lc lcfirst length link "+"listen localtime lock log lstat map mkdir msgctl msgget msgrcv msgsnd "+"oct open opendir ord pack pipe pop pos print printf prototype push "+"quotemeta rand read readdir readline readlink readpipe recv rename "+"reset reverse rewinddir rindex rmdir scalar seek seekdir select semctl "+"semget semop send setgrent sethostent setnetent setpgrp setpriority "+"setprotoent setpwent setservent setsockopt shift shmctl shmget shmread "+"shmwrite shutdown sin sleep socket socketpair sort splice split sprintf "+"sqrt srand stat study substr symlink syscall sysopen sysread sysseek "+"system syswrite tell telldir time times tr truncate uc ucfirst umask "+"undef unlink unpack unshift utime values vec wait waitpid warn write";var b="bless caller continue dbmclose dbmopen die do dump else elsif eval exit "+"for foreach goto if import last local my next no our package redo ref "+"require return sub tie tied unless untie until use wantarray while";this.regexList=[{regex:new RegExp("#[^!].*$","gm"),css:"comments"},{regex:new RegExp("^\\s*#!.*$","gm"),css:"preprocessor"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:new RegExp("(\\$|@|%)\\w+","g"),css:"variable"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"functions"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags) -};SyntaxHighlighter.brushes.Perl.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Perl.aliases=["perl","Perl","pl"];SyntaxHighlighter.brushes.Php=function(){var a="abs acos acosh addcslashes addslashes "+"array_change_key_case array_chunk array_combine array_count_values array_diff "+"array_diff_assoc array_diff_key array_diff_uassoc array_diff_ukey array_fill "+"array_filter array_flip array_intersect array_intersect_assoc array_intersect_key "+"array_intersect_uassoc array_intersect_ukey array_key_exists array_keys array_map "+"array_merge array_merge_recursive array_multisort array_pad array_pop array_product "+"array_push array_rand array_reduce array_reverse array_search array_shift "+"array_slice array_splice array_sum array_udiff array_udiff_assoc "+"array_udiff_uassoc array_uintersect array_uintersect_assoc "+"array_uintersect_uassoc array_unique array_unshift array_values array_walk "+"array_walk_recursive atan atan2 atanh base64_decode base64_encode base_convert "+"basename bcadd bccomp bcdiv bcmod bcmul bindec bindtextdomain bzclose bzcompress "+"bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite ceil chdir "+"checkdate checkdnsrr chgrp chmod chop chown chr chroot chunk_split class_exists "+"closedir closelog copy cos cosh count count_chars date decbin dechex decoct "+"deg2rad delete ebcdic2ascii echo empty end ereg ereg_replace eregi eregi_replace error_log "+"error_reporting escapeshellarg escapeshellcmd eval exec exit exp explode extension_loaded "+"feof fflush fgetc fgetcsv fgets fgetss file_exists file_get_contents file_put_contents "+"fileatime filectime filegroup fileinode filemtime fileowner fileperms filesize filetype "+"floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv fputs fread fscanf "+"fseek fsockopen fstat ftell ftok getallheaders getcwd getdate getenv gethostbyaddr gethostbyname "+"gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid getmyuid getopt "+"getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext "+"gettimeofday gettype glob gmdate gmmktime ini_alter ini_get ini_get_all ini_restore ini_set "+"interface_exists intval ip2long is_a is_array is_bool is_callable is_dir is_double "+"is_executable is_file is_finite is_float is_infinite is_int is_integer is_link is_long "+"is_nan is_null is_numeric is_object is_readable is_real is_resource is_scalar is_soap_fault "+"is_string is_subclass_of is_uploaded_file is_writable is_writeable mkdir mktime nl2br "+"parse_ini_file parse_str parse_url passthru pathinfo readlink realpath rewind rewinddir rmdir "+"round str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split "+"str_word_count strcasecmp strchr strcmp strcoll strcspn strftime strip_tags stripcslashes "+"stripos stripslashes stristr strlen strnatcasecmp strnatcmp strncasecmp strncmp strpbrk "+"strpos strptime strrchr strrev strripos strrpos strspn strstr strtok strtolower strtotime "+"strtoupper strtr strval substr substr_compare";var c="and or xor array as break case "+"cfunction class const continue declare default die do else "+"elseif enddeclare endfor endforeach endif endswitch endwhile "+"extends for foreach function include include_once global if "+"new old_function return static switch use require require_once "+"var while abstract interface public implements extends private protected throw";var b="__FILE__ __LINE__ __METHOD__ __FUNCTION__ __CLASS__";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\$\w+/g,css:"variable"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"functions"},{regex:new RegExp(this.getKeywords(b),"gmi"),css:"constants"},{regex:new RegExp(this.getKeywords(c),"gm"),css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.phpScriptTags)};SyntaxHighlighter.brushes.Php.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Php.aliases=["php"];SyntaxHighlighter.brushes.Plain=function(){};SyntaxHighlighter.brushes.Plain.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Plain.aliases=["text","plain"];SyntaxHighlighter.brushes.Python=function(){var c="and assert break class continue def del elif else "+"except exec finally for from global if import in is "+"lambda not or pass print raise return try yield while";var a="__import__ abs all any apply basestring bin bool buffer callable "+"chr classmethod cmp coerce compile complex delattr dict dir "+"divmod enumerate eval execfile file filter float format frozenset "+"getattr globals hasattr hash help hex id input int intern "+"isinstance issubclass iter len list locals long map max min next "+"object oct open ord pow print property range raw_input reduce "+"reload repr reversed round set setattr slice sorted staticmethod "+"str sum super tuple type type unichr unicode vars xrange zip"; - var b="None True False self cls class_";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLinePerlComments,css:"comments"},{regex:/^\s*@\w+/gm,css:"decorator"},{regex:/(['\"]{3})([^\1])*?\1/gm,css:"comments"},{regex:/"(?!")(?:\.|\\\"|[^\""\n])*"/gm,css:"string"},{regex:/'(?!')(?:\.|(\\\')|[^\''\n])*'/gm,css:"string"},{regex:/\+|\-|\*|\/|\%|=|==/gm,css:"keyword"},{regex:/\b\d+\.?\w*/g,css:"value"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"functions"},{regex:new RegExp(this.getKeywords(c),"gm"),css:"keyword"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"color1"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.Python.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Python.aliases=["py","python"];SyntaxHighlighter.brushes.Ruby=function(){var a="alias and BEGIN begin break case class def define_method defined do each else elsif "+"END end ensure false for if in module new next nil not or raise redo rescue retry return "+"self super then throw true undef unless until when while yield";var b="Array Bignum Binding Class Continuation Dir Exception FalseClass File::Stat File Fixnum Fload "+"Hash Integer IO MatchData Method Module NilClass Numeric Object Proc Range Regexp String Struct::TMS Symbol "+"ThreadGroup Thread Time TrueClass";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLinePerlComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/\b[A-Z0-9_]+\b/g,css:"constants"},{regex:/:[a-z][A-Za-z0-9_]*/g,css:"color2"},{regex:/(\$|@@|@)\w+/g,css:"variable bold"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"color1"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.Ruby.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Ruby.aliases=["ruby","rails","ror","rb"];SyntaxHighlighter.brushes.Scala=function(){var b="val sealed case def true trait implicit forSome import match object null finally super "+"override try lazy for var catch throw type extends class while with new final yield abstract "+"else do if return protected private this package false";var a="[_:=><%#@]+";this.regexList=[{regex:SyntaxHighlighter.regexLib.singleLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineCComments,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineSingleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:/0x[a-f0-9]+|\d+(\.\d+)?/gi,css:"value"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"keyword"},{regex:new RegExp(a,"gm"),css:"keyword"}]};SyntaxHighlighter.brushes.Scala.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Scala.aliases=["scala"];SyntaxHighlighter.brushes.Sql=function(){var b="abs avg case cast coalesce convert count current_timestamp "+"current_user day isnull left lower month nullif replace right "+"session_user space substring sum system_user upper user year";var c="absolute action add after alter as asc at authorization begin bigint "+"binary bit by cascade char character check checkpoint close collate "+"column commit committed connect connection constraint contains continue "+"create cube current current_date current_time cursor database date "+"deallocate dec decimal declare default delete desc distinct double drop "+"dynamic else end end-exec escape except exec execute false fetch first "+"float for force foreign forward free from full function global goto grant "+"group grouping having hour ignore index inner insensitive insert instead "+"int integer intersect into is isolation key last level load local max min "+"minute modify move name national nchar next no numeric of off on only "+"open option order out output partial password precision prepare primary "+"prior privileges procedure public read real references relative repeatable "+"restrict return returns revoke rollback rollup rows rule schema scroll "+"second section select sequence serializable set size smallint static "+"statistics table temp temporary then time timestamp to top transaction "+"translation trigger true truncate uncommitted union unique update values "+"varchar varying view when where with work";var a="all and any between cross in join like not null or outer some";this.regexList=[{regex:/--(.*)$/gm,css:"comments"},{regex:SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.multiLineSingleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords(b),"gmi"),css:"color2"},{regex:new RegExp(this.getKeywords(a),"gmi"),css:"color1"},{regex:new RegExp(this.getKeywords(c),"gmi"),css:"keyword"}]};SyntaxHighlighter.brushes.Sql.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Sql.aliases=["sql"]; -SyntaxHighlighter.brushes.Vb=function(){var a="AddHandler AddressOf AndAlso Alias And Ansi As Assembly Auto "+"Boolean ByRef Byte ByVal Call Case Catch CBool CByte CChar CDate "+"CDec CDbl Char CInt Class CLng CObj Const CShort CSng CStr CType "+"Date Decimal Declare Default Delegate Dim DirectCast Do Double Each "+"Else ElseIf End Enum Erase Error Event Exit False Finally For Friend "+"Function Get GetType GoSub GoTo Handles If Implements Imports In "+"Inherits Integer Interface Is Let Lib Like Long Loop Me Mod Module "+"MustInherit MustOverride MyBase MyClass Namespace New Next Not Nothing "+"NotInheritable NotOverridable Object On Option Optional Or OrElse "+"Overloads Overridable Overrides ParamArray Preserve Private Property "+"Protected Public RaiseEvent ReadOnly ReDim REM RemoveHandler Resume "+"Return Select Set Shadows Shared Short Single Static Step Stop String "+"Structure Sub SyncLock Then Throw To True Try TypeOf Unicode Until "+"Variant When While With WithEvents WriteOnly Xor";this.regexList=[{regex:/'.*$/gm,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:/^\s*#.*$/gm,css:"preprocessor"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"}];this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags)};SyntaxHighlighter.brushes.Vb.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Vb.aliases=["vb","vbnet"];SyntaxHighlighter.brushes.Lua=function(){var a="and break do else elseif end false for function if in "+"local nil not or repeat return then true until while";var b="_G _VERSION assert collectgarbage dofile error getfenv "+"getmetatable ipairs load module next pairs pcall print "+" rawequal rawget rawset require select setfenv setmetatable "+"tonumber tostring type unpack xpcall "+"coroutine.create coroutine.resume coroutine.running "+"coroutine.status coroutine.wrap coroutine.yield "+"debug.debug debug.getfenv debug.gethook debug.getinfo "+"debug.getlocal debug.getmetatable debug.getregistry "+"debug.getupvalue debug.setfenv debug.sethook debug.setlocal "+"debug.setmetatable debug.setupvalue debug.traceback "+"file:close file:flush file:lines file:read file:seek "+"file:setvbuf file:write"+"io.close io.flush io.input io.lines io.open io.output "+"io.popen io.read io.stderr io.stdin io.stdout io.tmpfile "+"io.type io.write "+"math.abs math.acos math.asin math.atan math.atan2 math.ceil "+"math.cos math.cosh math.deg math.exp math.floor math.fmod "+"math.frexp math.huge math.ldexp math.log math.log10 math.max "+"math.min math.modf math.pi math.pow math.rad math.random "+"math.randomseed math.sin math.sinh math.sqrt math.tan math.tanh "+"os.clock os.date os.difftime os.execute os.exit os.getenv os.remove "+"os.rename os.setlocale os.time os.tmpname "+"package.cpath package.loaded package.loaders package.loadlib "+"package.path package.preload package.seeall "+"string.byte string.char string.dump string.find string.format "+"string.gmatch string.gsub string.len string.lower string.match "+"string.rep string.reverse string.sub string.upper table.concat "+"table.insert table.maxn table.remove table.sort";this.regexList=[{regex:/--.*/gm,css:"comments"},{regex:/--\[\[[\S\s]*\]\]/gm,css:"comments"},{regex:SyntaxHighlighter.regexLib.doubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.singleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.multiLineDoubleQuotedString,css:"string"},{regex:SyntaxHighlighter.regexLib.multiLineSingleQuotedString,css:"string"},{regex:new RegExp(this.getKeywords(a),"gm"),css:"keyword"},{regex:new RegExp(this.getKeywords(b),"gm"),css:"functions"}]};SyntaxHighlighter.brushes.Lua.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Lua.aliases=["lua"];SyntaxHighlighter.brushes.Xml=function(){function a(e,i){var f=SyntaxHighlighter.Match,h=e[0],c=new XRegExp("(<|<)[\\s\\/\\?]*(?[:\\w-\\.]+)","xg").exec(h),b=[];if(e.attributes!=null){var d,g=new XRegExp("(? [\\w:\\-\\.]+)"+"\\s*=\\s*"+"(? \".*?\"|'.*?'|\\w+)","xg");while((d=g.exec(h))!=null){b.push(new f(d.name,e.index+d.index,"color1"));b.push(new f(d.value,e.index+d.index+d[0].indexOf(d.value),"string"))}}if(c!=null){b.push(new f(c.name,e.index+c[0].indexOf(c.name),"keyword"))}return b}this.regexList=[{regex:new XRegExp("(\\<|<)\\!\\[[\\w\\s]*?\\[(.|\\s)*?\\]\\](\\>|>)","gm"),css:"color2"},{regex:SyntaxHighlighter.regexLib.xmlComments,css:"comments"},{regex:new XRegExp("(<|<)[\\s\\/\\?]*(\\w+)(?.*?)[\\s\\/\\?]*(>|>)","sg"),func:a}]};SyntaxHighlighter.brushes.Xml.prototype=new SyntaxHighlighter.Highlighter();SyntaxHighlighter.brushes.Xml.aliases=["xml","xhtml","xslt","html"]; \ No newline at end of file diff --git a/app/src/main/assets/client.js b/app/src/main/assets/client.js deleted file mode 100644 index cce1c5bb4e775fc09d42e301822b1c1bb55d9f81..0000000000000000000000000000000000000000 --- a/app/src/main/assets/client.js +++ /dev/null @@ -1,20 +0,0 @@ -function showImagePreview(url) { - var idx = 0; - for(var i=0;i)/gim; - var arr = []; - while(tem=reg.exec(htmlstr)){ - arr.push(tem[2]); - } - return arr; -} diff --git a/app/src/main/assets/css/common.css b/app/src/main/assets/css/common.css deleted file mode 100644 index db9299d5e1a767105b69cd9218799c76521eb303..0000000000000000000000000000000000000000 --- a/app/src/main/assets/css/common.css +++ /dev/null @@ -1,204 +0,0 @@ -body { - background-color: #f6f6f6; - word-wrap: break-word; - overflow: auto; - overflow-x: hidden; -} - -.about { - float: left; - padding-left:0; - padding-top: 0; - margin-top: 5px; -} - -.about li { - line-height: 24px; -} - -img { - max-width:100%; -} - -img.alignleft { - float:left; - max-width:120px; - margin:0 10px 5px 0; - border:1px solid #ccc; - background:#fff;padding:2px; -} - -pre { - font-size:9pt; - line-height:12pt; - font-family:Courier New,Arial;border:1px solid #ddd; - border-left:5px solid #6CE26C;background:#f6f6f6; - padding:5px; - overflow: auto; -} - -a.tag { - font-size:15px; - text-decoration:none; - background-color:#cfc; - color:#060; - border-bottom:1px solid #B1D3EB; - border-right:1px solid #B1D3EB; - color:#3E6D8E;margin:2px 2px 2px 0; - padding:2px 4px; - white-space:nowrap;position:relative -} - -a{ - text-decoration:none; - color: #3E62A6 -} - -.title { - color: #333333; - font-size: 22px; - line-height: 24px; - font-weight: bold; - margin-top: 15px -} - -.title img { - width: 28px; - vertical-align:middle; - margin-right: 8 -} - -.title .recommend { - width:20px -} - -.authortime { - font-size: 13px; - color: #aaaaaa; - margin: 4px 0 2px 0 -} - -.authortime a { - color: #0b9a27 -} - -.author { - font-size: 13px; -} - -.contentstyle { - color: #333333; - font-size: 16px; - font-weight: normal; -} - -// 相关软件 -.oschina_software { - color: #999999 -} - -// 软件详情 -.software_attr { - background: #f6f6f6; - font-size: 16px; -} - -.software_attr { - list-style-type: none; - border: 1px solid #eee; - padding: 5px -} - -.software_attr li { - padding: 0 0 5 0 -} - -.software_urls { - list-style-type: none; -} - -.software_urls { - margin: 10px 10px 10px 0px; - margin: 10 0 50 0 -} - -.software_urls li { - float: left; - margin-right: 8px; - color: #fff; -} - -.software_urls li a { - border-radius: 5px; - background: #557DBA; - color: #fff; - width: 20px; - height: 30px; - line-height: 28px; - font-size: 12pt; - text-align: center; - text-decoration: none; - padding: 5 10 5 10 - -} - -body.night .contentstyle { - color: #FFF; -} - -.contentstyle p { - line-height: 120%; - letter-spacing: 0.3px; -} - -body.night { - opacity: 0.5; -} - -body.night { - background: #222222; -} - -body.night .about { - color: #999999 -} - -body.night .oschina_software { - color: #999999 -} - -body.night p { - color: #999999 -} - -body.night a { - color: #4877b1 -} - -body.night .title { - color: #a8a8a8; -} - -body.night .authortime { - color: #696969; -} - -body.night .authortime a { - color: #0b9a27 -} - -body.night .software_urls li a { - background: #696969; - color: #fff;r - width: 20px; - height: 30px; - line-height: 28px; - font-size: 12pt; - text-align: center; - text-decoration: none; - padding: 5 10 5 10 -} - -body.night pre { - background: #222222 -} diff --git a/app/src/main/assets/detail_page.html b/app/src/main/assets/detail_page.html deleted file mode 100644 index 88083ecdf2e651ff6b799b9702eddc224ad5f60c..0000000000000000000000000000000000000000 --- a/app/src/main/assets/detail_page.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - -
- - - - diff --git a/app/src/main/assets/detail_page.js b/app/src/main/assets/detail_page.js deleted file mode 100644 index 967815059bd9d38afc637aa2cfc0dcde066fd71b..0000000000000000000000000000000000000000 --- a/app/src/main/assets/detail_page.js +++ /dev/null @@ -1,55 +0,0 @@ -var title; -var author; -var time; -var body; -var images; -var imageCount = 0; - -function load_day() { - document.bgColor="#FF0000"; - var font = document.getElementById("font"); - if (!font) { - return; - } - font.style.color="white"; -} - -function load_night() { - document.bgColor="#1f1f1f"; - var font = document.getElementById("font"); - if (!font) { - return; - } - font.style.color="black"; -} - -function fill(detailBody) { - var myBody = document.getElementById('body'); - myBody.innerHTML = detailBody -} - -function changeFontSize(body) { - var myBody = document.getElementById('article_body'); - myBody.style.fontSize="22px" - myBody.innerHTML = body -} - -function showSuperBigSize() { - var myBody = document.getElementById('article_body'); - myBody.style.fontSize="26px"; -} - -function showBigSize() { - var myBody = document.getElementById('article_body'); - myBody.style.fontSize="22px"; -} - -function showMidSize() { - var myBody = document.getElementById('article_body'); - myBody.style.fontSize="18px"; -} - -function showSmallSize() { - var myBody = document.getElementById('article_body'); - myBody.style.fontSize="16px"; -} \ No newline at end of file diff --git a/app/src/main/assets/fontawesome-webfont.ttf b/app/src/main/assets/fontawesome-webfont.ttf deleted file mode 100644 index ed9372f8ea0fbaa04f42630a48887e4b38945345..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/fontawesome-webfont.ttf and /dev/null differ diff --git a/app/src/main/assets/ic_soft_recommend.png b/app/src/main/assets/ic_soft_recommend.png deleted file mode 100644 index 67af3bf1c99a92f01a93aee51cc0cf81378b7c6a..0000000000000000000000000000000000000000 Binary files a/app/src/main/assets/ic_soft_recommend.png and /dev/null differ diff --git a/app/src/main/assets/shCore.css b/app/src/main/assets/shCore.css deleted file mode 100644 index 4ba88f04216967dc49d0670976d08f9e85b88ec2..0000000000000000000000000000000000000000 --- a/app/src/main/assets/shCore.css +++ /dev/null @@ -1,303 +0,0 @@ -.syntaxhighlighter, -.syntaxhighlighter div, -.syntaxhighlighter code, -.syntaxhighlighter table, -.syntaxhighlighter table td, -.syntaxhighlighter table tr, -.syntaxhighlighter table tbody -{ - margin: 0 !important; - padding: 0 !important; - border: 0 !important; - outline: 0 !important; - background: none !important; - text-align: left !important; - float: none !important; - vertical-align: baseline !important; - position: static !important; - left: auto !important; - top: auto !important; - right: auto !important; - bottom: auto !important; - height: auto !important; - width: auto !important; - line-height: 1.1em !important; - font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; - font-weight: normal !important; - font-style: normal !important; - font-size: 10pt !important; - min-height: inherit !important; /* For IE8, FF & WebKit */ - min-height: auto !important; /* For IE7 */ -} - -.syntaxhighlighter -{ - width: 99% !important; /* 99% fixes IE8 horizontal scrollbar */ - margin: 1em 0 1em 0 !important; - padding: 1px !important; /* adds a little border on top and bottom */ - position: relative !important; -} - -.syntaxhighlighter .bold -{ - font-weight: bold !important; -} - -.syntaxhighlighter .italic -{ - font-style: italic !important; -} - -.syntaxhighlighter .line -{ -} - -.syntaxhighlighter .no-wrap .line .content -{ - white-space: pre !important; -} - -.syntaxhighlighter .line table -{ - border-collapse: collapse !important; - style=table-layout:fixed; - style=word-wrap:break-word; -} - -.syntaxhighlighter .line td -{ - vertical-align: top !important; -} - -.syntaxhighlighter .line .number -{ - width: 1.8em !important; -} - -.syntaxhighlighter .line .number code -{ - width: 1.8em !important; - padding-right: .3em !important; - text-align: right !important; - display: block !important; -} - -.syntaxhighlighter .line .content -{ - padding-left: .5em !important; -} - -.syntaxhighlighter .line .spaces -{ -} - -/* Disable border and margin on the lines when no gutter option is set */ -.syntaxhighlighter.nogutter .line .content -{ - border-left: none !important; -} - -.syntaxhighlighter .bar -{ - display: none !important; -} - -.syntaxhighlighter .bar.show -{ - display: block !important; -} - -.syntaxhighlighter.collapsed .bar -{ - display: block !important; -} - -/* Adjust some properties when collapsed */ - -.syntaxhighlighter.collapsed .lines -{ - display: none !important; -} - -.syntaxhighlighter .lines.no-wrap -{ - overflow: auto !important; - overflow-y: hidden !important; -} - -/* Styles for the toolbar */ - -.syntaxhighlighter .toolbar -{ - position: absolute !important; - right: 0px !important; - top: 0px !important; - font-size: 1px !important; - padding: 8px 8px 8px 0 !important; /* in px because images don't scale with ems */ -} - -.syntaxhighlighter.collapsed .toolbar -{ - font-size: 80% !important; - padding: .2em 0 .5em .5em !important; - position: static !important; -} - -.syntaxhighlighter .toolbar a.item, -.syntaxhighlighter .toolbar .item -{ - display: block !important; - float: left !important; - margin-left: 8px !important; - background-repeat: no-repeat !important; - overflow: hidden !important; - text-indent: -5000px !important; -} - -.syntaxhighlighter.collapsed .toolbar .item -{ - display: none !important; -} - -.syntaxhighlighter.collapsed .toolbar .item.expandSource -{ - background-image: url(magnifier.png) !important; - display: inline !important; - text-indent: 0 !important; - width: auto !important; - float: none !important; - height: 16px !important; - padding-left: 20px !important; -} - -.syntaxhighlighter .toolbar .item.viewSource -{ - background-image: url(page_white_code.png) !important; -} - -.syntaxhighlighter .toolbar .item.printSource -{ - background-image: url(printer.png) !important; -} - -.syntaxhighlighter .toolbar .item.copyToClipboard -{ - text-indent: 0 !important; - background: none !important; - overflow: visible !important; -} - -.syntaxhighlighter .toolbar .item.about -{ - background-image: url(help.png) !important; -} - -/** - * Print view. - * Colors are based on the default theme without background. - */ - -.syntaxhighlighter.printing, -.syntaxhighlighter.printing .line.alt1 .content, -.syntaxhighlighter.printing .line.alt2 .content, -.syntaxhighlighter.printing .line.highlighted .number, -.syntaxhighlighter.printing .line.highlighted.alt1 .content, -.syntaxhighlighter.printing .line.highlighted.alt2 .content, -{ - background: none !important; -} - -/* Gutter line numbers */ -.syntaxhighlighter.printing .line .number -{ - color: #bbb !important; -} - -/* Add border to the lines */ -.syntaxhighlighter.printing .line .content -{ - color: #000 !important; -} - -/* Toolbar when visible */ -.syntaxhighlighter.printing .toolbar -{ - display: none !important; -} - -.syntaxhighlighter.printing a -{ - text-decoration: none !important; -} - -.syntaxhighlighter.printing .plain, -.syntaxhighlighter.printing .plain a -{ - color: #000 !important; -} - -.syntaxhighlighter.printing .comments, -.syntaxhighlighter.printing .comments a -{ - color: #008200 !important; -} - -.syntaxhighlighter.printing .string, -.syntaxhighlighter.printing .string a -{ - color: blue !important; -} - -.syntaxhighlighter.printing .keyword -{ - color: #069 !important; - font-weight: bold !important; -} - -.syntaxhighlighter.printing .preprocessor -{ - color: gray !important; -} - -.syntaxhighlighter.printing .variable -{ - color: #a70 !important; -} - -.syntaxhighlighter.printing .value -{ - color: #090 !important; -} - -.syntaxhighlighter.printing .functions -{ - color: #ff1493 !important; -} - -.syntaxhighlighter.printing .constants -{ - color: #0066CC !important; -} - -.syntaxhighlighter.printing .script -{ - font-weight: bold !important; -} - -.syntaxhighlighter.printing .color1, -.syntaxhighlighter.printing .color1 a -{ - color: #808080 !important; -} - -.syntaxhighlighter.printing .color2, -.syntaxhighlighter.printing .color2 a -{ - color: #ff1493 !important; -} - -.syntaxhighlighter.printing .color3, -.syntaxhighlighter.printing .color3 a -{ - color: red !important; -} diff --git a/app/src/main/assets/shCore.js b/app/src/main/assets/shCore.js deleted file mode 100644 index 58a420d8f086a253ea5e584c7ec87763dd435c41..0000000000000000000000000000000000000000 --- a/app/src/main/assets/shCore.js +++ /dev/null @@ -1,32 +0,0 @@ -eval(function(p, a, c, k, e, d) { - e = function(c) { - return (c < a ? '' : e(parseInt(c / a))) - + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c - .toString(36)) - }; - if (!''.replace(/^/, String)) { - while (c--) { - d[e(c)] = k[c] || e(c) - } - k = [ function(e) { - return d[e] - } ]; - e = function() { - return '\\w+' - }; - c = 1 - } - ; - while (c--) { - if (k[c]) { - p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]) - } - } - return p -} - ( - 'c(!1k.2G){h 2G=l(){h p={6b:{"1o-U":"","84-2d":1,"83-2d-82":I,"1M":v,"8z-8H":I,"1H-2L":4,"3j":I,"1y":I,"67":N,"8B-8o":I,"7X":N,"5h-1n":I,"1F-1m":N},M:{4Q:I,6f:v,5o:16,5k:16,8s:N,8G:N,89:"58",1g:{5p:"54 1j",5b:"9O 1j",5j:"9P 6k 6q",76:"9N C 9M 26 9J 6q 9K",3o:"3o",6F:"?",1x:"2G\\n\\n",6M:"9L\'t 9Q 2V D: ",86:"9R 9W\'t 9X D 1F-1m 9V: ",78:"<1F 9r=\\"2o://5x.6J.6u/9y/9z\\"><6y><9F 2o-9G=\\"9E-9D\\" 60=\\"1X/1F; 9A=9B-8\\" /><39>9C 2G<2Z 1t=\\"3H-9Z:an,ao,am,al-ai;aj-43:#ak;43:#ap;3H-2L:aq;1X-6z:6A;\\">2G6O 2.1.a5 (a6 24 a4)2o://6G.3xa1 a2 a7 f 1m, a8 8P 6k 8N 8R 8S!8W C 8V 8U.8X 8J-8K 8O 9h."},8C:N},1q:{4U:v,9g:v,3D:v,6g:{}},2n:{},8l:{9f:/\\/\\*[\\s\\S]*?\\*\\//3v,9d:/\\/\\/.*$/3v,9e:/#.*$/3v,9j:/"([^\\\\"\\n]|\\\\.)*"/g,9o:/\'([^\\\\\'\\n]|\\\\.)*\'/g,8Y:/"([^\\\\"]|\\\\.)*"/g,9m:/\'([^\\\\\']|\\\\.)*\'/g,9k:/(&X;|<)!--[\\s\\S]*?--(&Y;|>)/3v,3Q:/&X;\\w+:\\/\\/[\\w-.\\/?%&=@:;]*&Y;|\\w+:\\/\\/[\\w-.\\/?%&=@:;]*/g,9c:{F:/(&X;|<)\\?=?/g,19:/\\?(&Y;|>)/g},92:{F:/(&X;|<)%=?/g,19:/%(&Y;|>)/g},91:{F:/(&X;|<)\\s*1m.*?(&Y;|>)/4v,19:/(&X;|<)\\/\\s*1m\\s*(&Y;|>)/4v}},1y:{18:l(3f){h 3C=Q.1N("3c"),5s=p.1y.7d;3C.L="1y";D(h 35 26 5s){h 6h=5s[35],5r=W 6h(3f),1U=5r.18();3f.6a[35]=5r;c(1U==v){1J}c(7I(1U)=="90"){1U=p.1y.6l(1U,3f.1h,35)}1U.L+="5v "+35;3C.2u(1U)}q 3C},6l:l(5K,6m,5D){h a=Q.1N("a"),5M=a.1t,5u=p.M,5L=5u.5o,5N=5u.5k;a.1Q="#"+5D;a.39=5K;a.5g=6m;a.75=5D;a.27=5K;c(38(5L)==N){5M.1W=5L+"73"}c(38(5N)==N){5M.2s=5N+"73"}a.96=l(e){9n{p.1y.7a(f,e||1k.6V,f.5g,f.75)}97(e){p.A.1x(e.77)}q N};q a},7a:l(7f,7e,7b,7h,7c){h 5G=p.1q.6g[7b],5H;c(5G==v||(5H=5G.6a[7h])==v){q v}q 5H.2B(7f,7e,7c)},7d:{5p:l(59){f.18=l(){c(59.T("67")!=I){q}q p.M.1g.5p};f.2B=l(5a,8T,8M){h B=59.B;5a.8v.4u(5a);B.L=B.L.E("5O","")}},5b:l(71){f.18=l(){q p.M.1g.5b};f.2B=l(aV,bV,bW){h 3Y=p.A.3E(71.5f).E(/"+3Y+"");2t.Q.4c()}},5j:l(65){h 3k,bY,5i=65.1h;f.18=l(){h 2Q=p.M;c(2Q.6f==v){q v}l 1I(52){h 5e="";D(h 56 26 52){5e+=""}q 5e};l 2q(5l){h 5n="";D(h 5m 26 5l){5n+=" "+5m+"=\'"+5l[5m]+"\'"}q 5n};h 68={1W:2Q.5o,2s:2Q.5k,1h:5i+"c0",4j:"bQ/x-6Z-6U",39:p.M.1g.5j},5V={bP:"ay",bG:"bH",bF:"5g="+5i,bD:"N"},5W=2Q.6f,3O;c(/bI/i.1R(7j.6B)){3O="<4d"+2q({bJ:"bO:bN-bM-bK-bL-c4",cl:"2o://cj.c7.3x/ce/6Z/ck/6U/c9.ci#6O=9,0,0,0"})+2q(68)+">"+1I(5V)+1I({c8:5W})+""}G{3O=""}3k=Q.1N("B");3k.27=3O;q 3k};f.2B=l(co,cn,63){h 72=63.bA;6S(72){2O"7l":h 64=p.A.2I(p.A.3E(65.5f).E(/&X;/g,"<").E(/&Y;/g,">").E(/&aT;/g,"&"));c(1k.74){1k.74.aU("1X",64)}G{q p.A.2I(64)}2O"aS":p.A.1x(p.M.1g.76);2y;2O"aP":p.A.1x(63.77);2y}}},bB:l(61){f.18=l(){q p.M.1g.3o};f.2B=l(aW,b1,b2){h 29=Q.1N("b0"),1G=v;c(p.1q.3D!=v){Q.2Z.4u(p.1q.3D)}p.1q.3D=29;29.1t.aX="aY:aO;1W:6w;2s:6w;F:-6o;4G:-6o;";Q.2Z.2u(29);1G=29.5Z.Q;6D(1G,1k.Q);1G.3I(""+61.B.27+"");1G.4c();29.5Z.4Y();29.5Z.3o();l 6D(6I,6C){h 2E=6C.4D("4e");D(h i=0;i<2E.u;i++){c(2E[i].6i.70()=="6P"&&/aC\\.1a$/.1R(2E[i].1Q)){6I.3I("<4e 4j=\\"1X/1a\\" 6i=\\"6P\\" 1Q=\\""+2E[i].1Q+"\\">")}}}}},az:l(aA){f.18=l(){q p.M.1g.6F};f.2B=l(aG,aL){h 2t=p.A.4M("","44",aK,aJ,"6s=0"),1G=2t.Q;1G.3I(p.M.1g.78);1G.4c();2t.4Y()}}}},A:{Z:l(4a,6L,3U){3U=3w.aH(3U||0,0);D(h i=3U;i<4a.u;i++){c(4a[i]==6L){q i}}q-1},6d:l(7g){q 7g+3w.aI(3w.b3()*b4).2h()},6c:l(47,46){h 3m={},28;D(28 26 47){3m[28]=47[28]}D(28 26 46){3m[28]=46[28]}q 3m},7t:l(4L){6S(4L){2O"I":q I;2O"N":q N}q 4L},4M:l(3Q,6W,4H,4O,2R){h x=(6T.1W-4H)/2,y=(6T.2s-4O)/2;2R+=", F="+x+", 4G="+y+", 1W="+4H+", 2s="+4O;2R=2R.E(/^,/,"");h 4V=1k.bn(3Q,6W,2R);4V.4Y();q 4V},7y:l(1E,1Y,1Z){c(1E.6X){1E["e"+1Y+1Z]=1Z;1E[1Y+1Z]=l(){1E["e"+1Y+1Z](1k.6V)};1E.6X("bt"+1Y,1E[1Y+1Z])}G{1E.by(1Y,1Z,N)}},1x:l(z){1x(p.M.1g.1x+z)},4P:l(4h,6N){h 2w=p.1q.4U,3W=v;c(2w==v){2w={};D(h 2W 26 p.2n){h 3g=p.2n[2W].bx;c(3g==v){1J}p.2n[2W].U=2W.70();D(h i=0;i<3g.u;i++){2w[3g[i]]=2W}}p.1q.4U=2w}3W=p.2n[2w[4h]];c(3W==v&&6N!=N){p.A.1x(p.M.1g.6M+4h)}q 3W},4x:l(z,6Q){h 2C=z.1O("\\n");D(h i=0;i<2C.u;i++){2C[i]=6Q(2C[i])}q 2C.5A("\\n")},7A:l(z){q z.E(/^[ ]*[\\n]+|[\\n]*[ ]*$/g,"")},8b:l(z){h 42,4E={},4S=W V("^\\\\[(?<4T>(.*?))\\\\]$"),6R=W V("(?[\\\\w-]+)"+"\\\\s*:\\\\s*"+"(?<23>"+"[\\\\w-%#]+|"+"\\\\[.*?\\\\]|"+"\\".*?\\"|"+"\'.*?\'"+")\\\\s*;?","g");2r((42=6R.R(z))!=v){h 2f=42.23.E(/^[\'"]|[\'"]$/g,"");c(2f!=v&&4S.1R(2f)){h m=4S.R(2f);2f=m.4T.u>0?m.4T.1O(/\\s*,\\s*/):[]}4E[42.U]=2f}q 4E},7Q:l(z,1a){c(z==v||z.u==0||z=="\\n"){q z}z=z.E(/"+2j+""})}q z},81:l(79,7i){h 34=79.2h();2r(34.u<7i){34="0"+34}q 34},6p:l(){h 40=Q.1N("B"),3J,3i=0,4y=Q.2Z,1h=p.A.6d("6p"),36="",4A="";40.27=36+"6e\\">"+36+"1n\\">"+36+"2d\\">"+36+"60"+"\\"><4t 1o=\\"b7\\"><4t 1h=\\""+1h+"\\">&2m;"+4A+4A+33+33+33+33;4y.2u(40);3J=Q.b6(1h);c(/bb/i.1R(7j.6B)){h 6v=1k.bh(3J,v);3i=80(6v.bg("1W"))}G{3i=3J.bd}4y.4u(40);q 3i},8c:l(6n,6K){h 1H="";D(h i=0;i<6K;i++){1H+=" "}q 6n.E(/\\t/g,1H)},8D:l(2F,4w){h be=2F.1O("\\n"),1H="\\t",62="";D(h i=0;i<50;i++){62+=" "}l 8u(3n,17,8y){q 3n.22(0,17)+62.22(0,8y)+3n.22(17+1,3n.u)};2F=p.A.4x(2F,l(21){c(21.Z(1H)==-1){q 21}h 17=0;2r((17=21.Z(1H))!=-1){h 8r=4w-17%4w;21=8u(21,17,8r)}q 21});q 2F},3E:l(z){h br=/|&X;br\\s*\\/?&Y;/4v;c(p.M.8s==I){z=z.E(br,"\\n")}c(p.M.8G==I){z=z.E(br,"")}q z},2J:l(z){q z.E(/^\\s+|\\s+$/g,"")},2I:l(z){h 2a=p.A.3E(z).1O("\\n"),bf=W bi(),8g=/^\\s*/,20=bc;D(h i=0;i<2a.u&&20>0;i++){h 4z=2a[i];c(p.A.2J(4z).u==0){1J}h 4C=8g.R(4z);c(4C==v){q z}20=3w.20(4C[0].u,20)}c(20>0){D(h i=0;i<2a.u;i++){2a[i]=2a[i].22(20)}}q 2a.5A("\\n")},7W:l(31,30){c(31.H<30.H){q-1}G{c(31.H>30.H){q 1}G{c(31.u<30.u){q-1}G{c(31.u>30.u){q 1}}}}q 0},2S:l(8i,2Y){l 8p(4B,87){q[W p.4W(4B[0],4B.H,87.1a)]};h b5=0,4s=v,3Z=[],8h=2Y.4K?2Y.4K:8p;2r((4s=2Y.3K.R(8i))!=v){3Z=3Z.2l(8h(4s,2Y))}q 3Z},8m:l(8k){h X="&X;",Y="&Y;";q 8k.E(p.8l.3Q,l(m){h 4k="",4l="";c(m.Z(X)==0){4l=X;m=m.3M(X.u)}c(m.Z(Y)==m.u-Y.u){m=m.3M(0,m.u-Y.u);4k=Y}q 4l+""+m+""+4k})},8a:l(){h 3G=Q.4D("1m"),4i=[];D(h i=0;i<3G.u;i++){c(3G[i].4j=="6e"){4i.K(3G[i])}}q 4i},8t:l(4n){h 4m="",1u=p.A.2J(4n),3L=N;c(1u.Z(4m)==0){1u=1u.3M(4m.u);3L=I}c(1u.Z(3P)==1u.u-3P.u){1u=1u.3M(0,1u.u-3P.u);3L=I}q 3L?1u:4n}},1M:l(8e,4p){l 8f(4r){h 4q=[];D(h i=0;i<4r.u;i++){4q.K(4r[i])}q 4q};h 2k=4p?[4p]:8f(Q.4D(p.M.89)),8q="27",2v=v,4R=p.M;c(4R.4Q){2k=2k.2l(p.A.8a())}c(2k.u===0){q}D(h i=0;i<2k.u;i++){h 2T=2k[i],1T=p.A.8b(2T.L),1L,2D,1P;1T=p.A.6c(8e,1T);1L=1T["2V"];c(1L==v){1J}c(1T["1F-1m"]=="I"||p.6b["1F-1m"]==I){2v=W p.4b(1L);1L="b9"}G{h 3S=p.A.4P(1L);c(3S){1L=3S.U;2v=W 3S()}G{1J}}2D=2T[8q];c(4R.4Q){2D=p.A.8t(2D)}1T["2V-U"]=1L;2v.1M(2D,1T);1P=2v.B;c(p.M.8C){1P=Q.1N("bk");1P.23=2v.B.27;1P.1t.1W="bu";1P.1t.2s="bw"}2T.8v.bz(1P,2T)}},bs:l(7x){p.A.7y(1k,"bm",l(){p.1M(7x)})}};p.4W=l(4X,7B,1a){f.23=4X;f.H=7B;f.u=4X.u;f.1a=1a;f.5S=v};p.4W.1c.2h=l(){q f.23};p.4b=l(4F){h 3t=p.A.4P(4F),2p,4J=W p.2n.bl(),bo=v;c(3t==v){q}2p=W 3t();f.49=4J;c(2p.3N==v){p.A.1x(p.M.1g.86+4F);q}4J.5c.K({3K:2p.3N.C,4K:7E});l 3l(4N,7F){D(h j=0;j<4N.u;j++){4N[j].H+=7F}};l 7E(15,bq){h 7w=15.C,1l=[],4Z=2p.5c,7v=15.H+15.F.u,2P=2p.3N,1p;D(h i=0;i<4Z.u;i++){1p=p.A.2S(7w,4Z[i]);3l(1p,7v);1l=1l.2l(1p)}c(2P.F!=v&&15.F!=v){1p=p.A.2S(15.F,2P.F);3l(1p,15.H);1l=1l.2l(1p)}c(2P.19!=v&&15.19!=v){1p=p.A.2S(15.19,2P.19);3l(1p,15.H+15[0].bp(15.19));1l=1l.2l(1p)}D(h j=0;j<1l.u;j++){1l[j].5S=3t.U}q 1l}};p.4b.1c.1M=l(7k,7p){f.49.1M(7k,7p);f.B=f.49.B};p.7q=l(){};p.7q.1c={T:l(7u,7s){h 48=f.1I[7u];q p.A.7t(48==v?7s:48)},18:l(7H){q Q.1N(7H)},8n:l(32,7Y){h 3A=[];c(32!=v){D(h i=0;i<32.u;i++){c(7I(32[i])=="4d"){3A=3A.2l(p.A.2S(7Y,32[i]))}}}q 3A.aM(p.A.7W)},8F:l(){h 1V=f.2X;D(h i=0;i<1V.u;i++){c(1V[i]===v){1J}h 2z=1V[i],45=2z.H+2z.u;D(h j=i+1;j<1V.u&&1V[i]!==v;j++){h 25=1V[j];c(25===v){1J}G{c(25.H>45){2y}G{c(25.H==2z.H&&25.u>2z.u){f.2X[i]=v}G{c(25.H>=2z.H&&25.H<45){f.2X[j]=v}}}}}}},7Z:l(2U){h 3h=2U.1O("\\n"),3X=80(f.T("84-2d")),2i=f.T("83-2d-82"),7U=f.T("1M",[]),7M=f.T("3j");2U="";c(2i==I){2i=(3X+3h.u-1).2h().u}G{c(38(2i)==I){2i=0}}D(h i=0;i<3h.u;i++){h 1A=3h[i],66=/^(&2m;|\\s)+/.R(1A),51="aE"+(i%2==0?1:2),7N=p.A.81(3X+i,2i),7T=p.A.Z(7U,(3X+i).2h())!=-1,2H=v;c(66!=v){2H=66[0].2h();1A=1A.22(2H.u)}1A=p.A.2J(1A);c(1A.u==0){1A="&2m;"}c(7T){51+=" aN"}2U+=""+"<7P>"+"<7R>"+(7M?"<3T 1o=\\"aZ\\">"+7N+"":"")+"<3T 1o=\\"60\\">"+(2H!=v?""+2H.E(" ","&2m;")+"":"")+1A+""+""+""+""}q 2U},88:l(69,5T){h 17=0,3p="",3r=p.A.7Q,5R=f.T("2V-U","");l 5X(5Y){h 5Q=5Y?(5Y.5S||5R):5R;q 5Q?5Q+" ":""};D(h i=0;i<5T.u;i++){h 1v=5T[i],3y;c(1v===v||1v.u===0){1J}3y=5X(1v);3p+=3r(69.22(17,1v.H-17),3y+"7K")+3r(1v.23,3y+1v.1a);17=1v.H+1v.u}3p+=3r(69.22(17),5X()+"7K");q 3p},1M:l(C,7V){h cg=p.M,1q=p.1q,B,ca,3e,cd="cm";f.1I={};f.B=v;f.1n=v;f.C=v;f.1e=v;f.6a={};f.1h=p.A.6d("ch");1q.6g[f.1h]=f;c(C===v){C=""}f.1I=p.A.6c(p.6b,7V||{});c(f.T("7X")==I){f.1I.1y=f.1I.3j=N}f.B=B=f.18("3c");f.1n=f.18("3c");f.1n.L="1n";L="6e";B.1h=f.1h;c(f.T("67")){L+=" 5O"}c(f.T("3j")==N){L+=" c5"}c(f.T("5h-1n")==N){f.1n.L+=" bC-5h"}L+=" "+f.T("1o-U");L+=" "+f.T("2V-U");B.L=L;f.5f=C;f.C=p.A.7A(C).E(/\\r/g," ");3e=f.T("1H-2L");f.C=f.T("8z-8H")==I?p.A.8D(f.C,3e):p.A.8c(f.C,3e);f.C=p.A.2I(f.C);c(f.T("1y")){f.1e=f.18("3c");f.1e.L="1e";f.1e.2u(p.1y.18(f));B.2u(f.1e);h 1e=f.1e;l 53(){1e.L=1e.L.E("54","")};B.c1=l(){53();1e.L+=" 54"};B.c2=l(){53()}}B.2u(f.1n);f.2X=f.8n(f.5c,f.C);f.8F();C=f.88(f.C,f.2X);C=f.7Z(p.A.2J(C));c(f.T("8B-8o")){C=p.A.8m(C)}f.1n.27=C},9i:l(z){z=z.E(/^\\s+|\\s+$/g,"").E(/\\s+/g,"|");q"\\\\b(?:"+z+")\\\\b"},9l:l(2K){f.3N={F:{3K:2K.F,1a:"1m"},19:{3K:2K.19,1a:"1m"},C:W V("(?"+2K.F.1j+")"+"(?.*?)"+"(?<19>"+2K.19.1j+")","99")}}};q p}()}c(!1k.V){(l(){h 2A={R:10.1c.R,8w:5I.1c.8w,E:5I.1c.E,1O:5I.1c.1O},1D={13:/(?:[^\\\\([#\\s.]+|\\\\(?!k<[\\w$]+>|[7z]{[^}]+})[\\S\\s]?|\\((?=\\?(?!#|<[\\w$]+>)))+|(\\()(?:\\?(?:(#)[^)]*\\)|<([$\\w]+)>))?|\\\\(?:k<([\\w$]+)>|[7z]{([^}]+)})|(\\[\\^?)|([\\S\\s])/g,98:/(?:[^$]+|\\$(?![1-9$&`\']|{[$\\w]+}))+|\\$(?:([1-9]\\d*|[$&`\'])|{([$\\w]+)})/g,3d:/^(?:\\s+|#.*)+/,5B:/^(?:[?*+]|{\\d+(?:,\\d*)?})/,7J:/&&\\[\\^?/g,7O:/]/g},7G=l(5C,5v,5t){D(h i=5t||0;i<5C.u;i++){c(5C[i]===5v){q i}}q-1},8I=/()??/.R("")[1]!==3a,3b={};V=l(1d,1S){c(1d 5U 10){c(1S!==3a){3q 7n("4g\'t 4I 9a 8A 95 7r 10 5t 94")}q 1d.3z()}h 1S=1S||"",7S=1S.Z("s")>-1,7L=1S.Z("x")>-1,5z=N,3R=[],14=[],13=1D.13,J,cc,3V,37,3u;13.O=0;2r(J=2A.R.2e(13,1d)){c(J[2]){c(!1D.5B.1R(1d.1b(13.O))){14.K("(?:)")}}G{c(J[1]){3R.K(J[3]||v);c(J[3]){5z=I}14.K("(")}G{c(J[4]){37=7G(3R,J[4]);14.K(37>-1?"\\\\"+(37+1)+(38(1d.5w(13.O))?"":"(?:)"):J[0])}G{c(J[5]){14.K(3b.7o?3b.7o.7l(J[5],J[0].5w(1)==="P"):J[0])}G{c(J[6]){c(1d.5w(13.O)==="]"){14.K(J[6]==="["?"(?!)":"[\\\\S\\\\s]");13.O++}G{cc=V.8d("&&"+1d.1b(J.H),1D.7J,1D.7O,"",{7D:"\\\\"})[0];14.K(J[6]+cc+"]");13.O+=cc.u+1}}G{c(J[7]){c(7S&&J[7]==="."){14.K("[\\\\S\\\\s]")}G{c(7L&&1D.3d.1R(J[7])){3V=2A.R.2e(1D.3d,1d.1b(13.O-1))[0].u;c(!1D.5B.1R(1d.1b(13.O-1+3V))){14.K("(?:)")}13.O+=3V-1}G{14.K(J[7])}}}G{14.K(J[0])}}}}}}}3u=10(14.5A(""),2A.E.2e(1S,/[9Y]+/g,""));3u.1B={1j:1d,2g:5z?3R:v};q 3u};V.9s=l(U,o){3b[U]=o};10.1c.R=l(z){h 1f=2A.R.2e(f,z),U,i,5y;c(1f){c(8I&&1f.u>1){5y=W 10("^"+f.1j+"$(?!\\\\s)",f.5J());2A.E.2e(1f[0],5y,l(){D(i=1;i<8j.u-2;i++){c(8j[i]===3a){1f[i]=3a}}})}c(f.1B&&f.1B.2g){D(i=1;i<1f.u;i++){U=f.1B.2g[i-1];c(U){1f[U]=1f[i]}}}c(f.3s&&f.O>(1f.H+1f[0].u)){f.O--}}q 1f}})()}10.1c.5J=l(){q(f.3s?"g":"")+(f.aw?"i":"")+(f.8E?"m":"")+(f.3d?"x":"")+(f.a0?"y":"")};10.1c.3z=l(7C){h 5E=W V(f.1j,(7C||"")+f.5J());c(f.1B){5E.1B={1j:f.1B.1j,2g:f.1B.2g?f.1B.2g.1b(0):v}}q 5E};10.1c.2e=l(93,z){q f.R(z)};10.1c.9b=l(9p,8x){q f.R(8x[0])};V.57=l(55,5d){h 5P="/"+55+"/"+(5d||"");q V.57[5P]||(V.57[5P]=W V(55,5d))};V.41=l(z){q z.E(/[-[\\]{}()*+?.\\\\^$|,#\\s]/g,"\\\\$&")};V.8d=l(z,F,11,1i,2N){h 2N=2N||{},2M=2N.7D,12=2N.cb,1i=1i||"",5F=1i.Z("g")>-1,6Y=1i.Z("i")>-1,7m=1i.Z("m")>-1,5q=1i.Z("y")>-1,1i=1i.E(/y/g,""),F=F 5U 10?(F.3s?F:F.3z("g")):W V(F,"g"+1i),11=11 5U 10?(11.3s?11:11.3z("g")):W V(11,"g"+1i),1K=[],2x=0,1s=0,1r=0,1w=0,2c,2b,1z,1C,3B,4f;c(2M){c(2M.u>1){3q aR("4g\'t 4I aB aF 7r 41 85")}c(7m){3q 7n("4g\'t 4I 41 85 8A bv bj 8E ba")}3B=V.41(2M);4f=W 10("^(?:"+3B+"[\\\\S\\\\s]|(?:(?!"+F.1j+"|"+11.1j+")[^"+3B+"])+)+",6Y?"i":"")}2r(I){F.O=11.O=1r+(2M?(4f.R(z.1b(1r))||[""])[0].u:0);1z=F.R(z);1C=11.R(z);c(1z&&1C){c(1z.H<=1C.H){1C=v}G{1z=v}}c(1z||1C){1s=(1z||1C).H;1r=(1z?F:11).O}G{c(!2x){2y}}c(5q&&!2x&&1s>1w){2y}c(1z){c(!2x++){2c=1s;2b=1r}}G{c(1C&&2x){c(!--2x){c(12){c(12[0]&&2c>1w){1K.K([12[0],z.1b(1w,2c),1w,2c])}c(12[1]){1K.K([12[1],z.1b(2c,2b),2c,2b])}c(12[2]){1K.K([12[2],z.1b(2b,1s),2b,1s])}c(12[3]){1K.K([12[3],z.1b(1s,1r),1s,1r])}}G{1K.K(z.1b(2b,1s))}1w=1r;c(!5F){2y}}}G{F.O=11.O=0;3q bE("bZ 8L av 9t as")}}c(1s===1r){1r++}}c(5F&&!5q&&12&&12[0]&&z.u>1w){1K.K([12[0],z.1b(1w),1w,z.u])}F.O=11.O=0;q 1K};', - 62, - 769, - '||||||||||||if|||this||var||||function||||sh|return||||length|null||||str|utils|div|code|for|replace|left|else|index|true|_121|push|className|config|false|lastIndex||document|exec||getParam|name|XRegExp|new|lt|gt|indexOf|RegExp|_139|vN|part|_11f|_d3||pos|create|right|css|slice|prototype|_119|bar|_129|strings|id|_13a|source|window|_d6|script|lines|class|_da|vars|_145|_144|style|_b5|_103|_146|alert|toolbar|_149|_f4|_x|_14a|lib|obj|html|doc|tab|params|continue|_142|_c3|highlight|createElement|split|_c5|href|test|_11a|_c2|_8|_e7|width|text|_5a|_5b|min|_91|substr|value||_ec|in|innerHTML|_4f|_3c|_98|_148|_147|line|call|_6e|captureNames|toString|_f0|_75|_bc|concat|nbsp|brushes|http|_cd|attributes|while|height|wnd|appendChild|_be|_5f|_143|break|_e9|real|execute|_66|_c4|_40|_88|SyntaxHighlighter|_f9|unindent|trim|_10f|size|_13c|_13b|case|_d9|_28|_55|getMatches|_c1|_ed|brush|_61|matches|_a2|body|m2|m1|_e3|_81|_7a|_5|_80|_124|isNaN|title|undefined|_118|DIV|extended|_10b|_2|_62|_ee|_7d|gutter|_25|offsetMatches|_4e|_8e|print|_fd|throw|_fe|global|_cc|_125|gm|Math|com|_104|addFlags|_e5|_14b|_3|printFrame|fixInputString|_76|_af|font|write|_7c|regex|_b6|substring|htmlScript|_32|_b4|url|_11e|_c6|td|_49|len|_60|_ef|_22|_a7|_7b|escape|_6a|color|_blank|_ea|_4d|_4c|_e1|xmlBrush|_47|HtmlScript|close|object|link|esc|can|_5d|_b0|type|_ad|_ae|_b3|_b2|_73|_b8|_ba|_b9|_a6|span|removeChild|gi|_89|eachLine|_7e|_9d|_82|_a3|_9e|getElementsByTagName|_6b|_cb|top|_53|supply|_ce|func|_50|popup|_d0|_54|findBrush|useScriptTags|_bf|_6c|values|discoveredBrushes|win|Match|_c8|focus|_d7||_f6|_29|hide|show|_133|_2b|cache|pre|_19|_1a|viewSource|regexList|_134|_2a|originalCode|highlighterId|wrap|_27|copyToClipboard|toolbarItemHeight|_2c|_2e|_2d|toolbarItemWidth|expandSource|_141|_7|_4|from|_e|item|charAt|www|r2|_11d|join|quantifier|_113|_b|_12e|_13e|_17|_18|String|getNativeFlags|_9|_f|_d|_10|collapsed|key|_101|_ff|brushName|_fb|instanceof|_30|swf|getBrushNameCss|_100|contentWindow|content|_38|_8c|_35|_37|_24|_f5|collapse|_2f|_fa|toolbarCommands|defaults|merge|guid|syntaxhighlighter|clipboardSwf|highlighters|_6|rel|DTD|to|createButton|_a|_84|500px|measureSpace|clipboard|none|scrollbars|decoration|org|_83|0px|margin|head|align|center|userAgent|_3f|copyStyles|0099FF|help|alexgorbatchev|xhtml1|_3e|w3|_85|_48|noBrush|_5e|version|stylesheet|_65|_6d|switch|screen|flash|event|_52|attachEvent|_13f|shockwave|toLowerCase|_1e|_36|px|clipboardData|commandName|copyToClipboardConfirmation|message|aboutDialog|_78|executeCommand|_14|_16|items|_13|_12|_4b|_15|_79|navigator|_dd|get|_140|TypeError|unicode|_de|Highlighter|one|_e0|toBoolean|_df|_d8|_d5|_c7|addEvent|pP|trimFirstAndLastLines|_c9|_12d|escapeChar|process|_d1|_112|_e2|typeof|classLeft|plain|_11c|_f2|_f7|classRight|table|decorate|tr|_11b|_f8|_f1|_106|matchesSortCallback|light|_e4|createDisplayLines|parseInt|padNumber|numbers|pad|first|character|brushNotHtmlScript|_a4|processMatches|tagName|getSyntaxHighlighterScriptTags|parseParams|processTabs|matchRecursive|_b7|toArray|_9a|_a8|_a1|arguments|_a9|regexLib|processUrls|findMatches|links|defaultAdd|_bd|_93|bloggerMode|stripCData|insertSpaces|parentNode|match|args|_90|smart|when|auto|debug|processSmartTabs|multiline|removeNestedMatches|stripBrs|tabs|_117|2004|2009|data|_1c|keep|Alex|donate|2930402|development|active|_1b|highlighter|syntax|JavaScript|Copyright|multiLineDoubleQuotedString|hosted_button_id|string|scriptScriptTags|aspScriptTags|_12f|another|constructing|onclick|catch|replaceVar|sgi|flags|apply|phpScriptTags|singleLineCComments|singleLinePerlComments|multiLineCComments|spaceWidth|Gorbatchev|getKeywords|doubleQuotedString|xmlComments|forHtmlScript|multiLineSingleQuotedString|try|singleQuotedString|_131|bottom|xmlns|addPlugin|unbalanced|dtd|transitional|EN|TR|1999|xhtml|charset|utf|About|Type|Content|meta|equiv|Transitional|XHTML|your|now|Can|is|The|view|copy|find|Brush|PUBLIC|W3C|DOCTYPE|option|wasn|configured|sx|family|sticky|If|you|target|2010|382|June|like|please|webscr|cmd|_s|bin|cgi|https|paypal|4em|75em|serif|background|fff|sans|Helvetica|Geneva|Arial|000|1em|large|delimiters|xx|3em|contains|ignoreCase|xclick|always|about|_42|more|shCore|printing|alt|than|_43|max|round|250|500|_44|sort|highlighted|absolute|error|spaces|SyntaxError|ok|amp|setData|_1f|_39|cssText|position|number|IFRAME|_3a|_3b|random|1000000|_a5|getElementById|block|CDATA|htmlscript|flag|opera|1000|offsetWidth|_8a|_99|getPropertyValue|getComputedStyle|Array|the|textarea|Xml|load|open|_cf|lastIndexOf|_d4||all|on|70em|using|30em|aliases|addEventListener|replaceChild|command|printSource|no|menu|Error|flashVars|wmode|transparent|msie|classid|11cf|96b8|ae6d|d27cdb6e|clsid|allowScriptAccess|application|location|resizable|400|750|_20|_21|menubar|_26|subject|_clipboard|onmouseover|onmouseout|param|444553540000|nogutter|embed|macromedia|movie|swflash|_10a|valueNames||_10c|pub|src|conf|highlighter_|cab|download|cabs|codebase|important|_34|_33' - .split('|'), 0, {})) diff --git a/app/src/main/assets/shThemeDefault.css b/app/src/main/assets/shThemeDefault.css deleted file mode 100644 index 5430b05e61887c918850f36981ae429e74ac9df1..0000000000000000000000000000000000000000 --- a/app/src/main/assets/shThemeDefault.css +++ /dev/null @@ -1,142 +0,0 @@ -.syntaxhighlighter -{ - background-color: #fff !important; -} - -/* Highlighed line number */ -.syntaxhighlighter .line.highlighted .number -{ - color: black !important; -} - -/* Highlighed line */ -.syntaxhighlighter .line.highlighted.alt1, -.syntaxhighlighter .line.highlighted.alt2 -{ - background-color: #e0e0e0 !important; -} - -/* Gutter line numbers */ -.syntaxhighlighter .line .number -{ - color: #afafaf !important; -} - -/* Add border to the lines */ -.syntaxhighlighter .line .content -{ - border-left: 3px solid #6CE26C !important; - color: #000 !important; -} - -.syntaxhighlighter.printing .line .content -{ - border: 0 !important; -} - -/* First line */ -.syntaxhighlighter .line.alt1 -{ - background-color: #fff !important; - word-wrap:break-word -} - -/* Second line */ -.syntaxhighlighter .line.alt2 -{ - background-color: #F8F8F8 !important; -} - -.syntaxhighlighter .toolbar -{ - background-color: #F8F8F8 !important; - border: #E7E5DC solid 1px !important; - display:none; -} - -.syntaxhighlighter .toolbar a -{ - color: #a0a0a0 !important; - display:none; -} - -.syntaxhighlighter .toolbar a:hover -{ - color: red !important; - display:none; -} - -/************************************ - * Actual syntax highlighter colors. - ************************************/ -.syntaxhighlighter .plain, -.syntaxhighlighter .plain a -{ - color: #000 !important; -} - -.syntaxhighlighter .comments, -.syntaxhighlighter .comments a -{ - color: #008200 !important; -} - -.syntaxhighlighter .string, -.syntaxhighlighter .string a -{ - color: blue !important; -} - -.syntaxhighlighter .keyword -{ - color: #069 !important; - font-weight: bold !important; -} - -.syntaxhighlighter .preprocessor -{ - color: gray !important; -} - -.syntaxhighlighter .variable -{ - color: #a70 !important; -} - -.syntaxhighlighter .value -{ - color: #090 !important; -} - -.syntaxhighlighter .functions -{ - color: #ff1493 !important; -} - -.syntaxhighlighter .constants -{ - color: #0066CC !important; -} - -.syntaxhighlighter .script -{ - background-color: yellow !important; -} - -.syntaxhighlighter .color1, -.syntaxhighlighter .color1 a -{ - color: #808080 !important; -} - -.syntaxhighlighter .color2, -.syntaxhighlighter .color2 a -{ - color: #ff1493 !important; -} - -.syntaxhighlighter .color3, -.syntaxhighlighter .color3 a -{ - color: red !important; -} diff --git a/app/src/main/java/com/dtr/zxing/activity/CaptureActivity.java b/app/src/main/java/com/dtr/zxing/activity/CaptureActivity.java deleted file mode 100644 index abc909303f7cb5db7ba4568f91290791fd6108fa..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/activity/CaptureActivity.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.dtr.zxing.activity; - -import android.annotation.SuppressLint; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.graphics.Rect; -import android.os.Bundle; -import android.os.Handler; -import android.text.ClipboardManager; -import android.util.Log; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.view.animation.Animation; -import android.view.animation.TranslateAnimation; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import cz.msebera.android.httpclient.Header; - -import com.dtr.zxing.camera.CameraManager; -import com.dtr.zxing.decode.DecodeThread; -import com.dtr.zxing.utils.BeepManager; -import com.dtr.zxing.utils.CaptureActivityHandler; -import com.dtr.zxing.utils.InactivityTimer; -import com.google.zxing.Result; -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.AppException; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.bean.BarCode; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.SingInResult; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - - -import java.io.IOException; -import java.lang.reflect.Field; - -/** - * This activity opens the camera and does the actual scanning on a background - * thread. It draws a viewfinder to help the user place the barcode correctly, - * shows feedback as the image processing is happening, and then overlays the - * results when a scan is successful. - * - * @author dswitkin@google.com (Daniel Switkin) - * @author Sean Owen - */ -public final class CaptureActivity extends BaseActivity implements - SurfaceHolder.Callback { - - private static final String TAG = CaptureActivity.class.getSimpleName(); - - private CameraManager cameraManager; - private CaptureActivityHandler handler; - private InactivityTimer inactivityTimer; - private BeepManager beepManager; - - private SurfaceView scanPreview = null; - private RelativeLayout scanContainer; - private RelativeLayout scanCropView; - private ImageView scanLine; - private ImageView mFlash; - - private Rect mCropRect = null; - - public Handler getHandler() { - return handler; - } - - public CameraManager getCameraManager() { - return cameraManager; - } - - private boolean isHasSurface = false; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - - Window window = getWindow(); - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - setContentView(R.layout.activity_qr_scan); - - scanPreview = (SurfaceView) findViewById(R.id.capture_preview); - scanContainer = (RelativeLayout) findViewById(R.id.capture_container); - scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); - scanLine = (ImageView) findViewById(R.id.capture_scan_line); - mFlash = (ImageView) findViewById(R.id.capture_flash); - mFlash.setOnClickListener(this); - - inactivityTimer = new InactivityTimer(this); - beepManager = new BeepManager(this); - - TranslateAnimation animation = new TranslateAnimation( - Animation.RELATIVE_TO_PARENT, 0.0f, - Animation.RELATIVE_TO_PARENT, 0.0f, - Animation.RELATIVE_TO_PARENT, 0.0f, - Animation.RELATIVE_TO_PARENT, 0.9f); - animation.setDuration(4500); - animation.setRepeatCount(-1); - animation.setRepeatMode(Animation.RESTART); - scanLine.startAnimation(animation); - } - - @SuppressLint("NewApi") - @Override - protected boolean hasActionBar() { - - if (android.os.Build.VERSION.SDK_INT >= 11) { - getSupportActionBar().hide(); - return true; - } else { - return false; - } - - } - - @Override - protected void onResume() { - super.onResume(); - - // CameraManager must be initialized here, not in onCreate(). This is - // necessary because we don't - // want to open the camera driver and measure the screen size if we're - // going to show the help on - // first launch. That led to bugs where the scanning rectangle was the - // wrong size and partially - // off screen. - cameraManager = new CameraManager(getApplication()); - - handler = null; - - if (isHasSurface) { - // The activity was paused but not stopped, so the surface still - // exists. Therefore - // surfaceCreated() won't be called, so init the camera here. - initCamera(scanPreview.getHolder()); - } else { - // Install the callback and wait for surfaceCreated() to init the - // camera. - scanPreview.getHolder().addCallback(this); - } - - inactivityTimer.onResume(); - } - - @Override - protected void onPause() { - if (handler != null) { - handler.quitSynchronously(); - handler = null; - } - inactivityTimer.onPause(); - beepManager.close(); - cameraManager.closeDriver(); - if (!isHasSurface) { - scanPreview.getHolder().removeCallback(this); - } - super.onPause(); - } - - @Override - protected void onDestroy() { - inactivityTimer.shutdown(); - super.onDestroy(); - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - if (holder == null) { - Log.e(TAG, - "*** WARNING *** surfaceCreated() gave us a null surface!"); - } - if (!isHasSurface) { - isHasSurface = true; - initCamera(holder); - } - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - isHasSurface = false; - } - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - - } - - /** - * A valid barcode has been found, so give an indication of success and show - * the results. - * - * @param rawResult The contents of the barcode. - * @param bundle The extras - */ - public void handleDecode(final Result rawResult, Bundle bundle) { - inactivityTimer.onActivity(); - beepManager.playBeepSoundAndVibrate(); - - // 通过这种方式可以获取到扫描的图片 -// bundle.putInt("width", mCropRect.width()); -// bundle.putInt("height", mCropRect.height()); -// bundle.putString("result", rawResult.getText()); -// -// startActivity(new Intent(CaptureActivity.this, ResultActivity.class) -// .putExtras(bundle)); - - handler.postDelayed(new Runnable() { - - @Override - public void run() { - handleText(rawResult.getText()); - } - }, 800); - } - - private void handleText(String text) { - - if (StringUtils.isUrl(text)) { - showUrlOption(text); - } else { - handleOtherText(text); - } - } - - private void showUrlOption(final String url) { - if (url.contains("scan_login")) { - showConfirmLogin(url); - return; - } - if (url.contains("oschina.net")) { - UIHelper.showUrlRedirect(CaptureActivity.this, url); - finish(); - return; - } - DialogHelp.getConfirmDialog(this, "可能存在风险,是否打开链接?
" + url, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - UIHelper.showUrlRedirect(CaptureActivity.this, url); - finish(); - } - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - finish(); - } - }).show(); - } - - private void showConfirmLogin(final String url) { - if (!AppContext.getInstance().isLogin()) { - showLogin(); - return; - } - DialogHelp.getConfirmDialog(this, "扫描成功,是否进行网页登陆", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - handleScanLogin(url); - finish(); - } - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - finish(); - } - }).show(); - } - - private void handleScanLogin(final String url) { - OSChinaApi.scanQrCodeLogin(url, new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - ResultBean result = XmlUtils.toBean(ResultBean.class, arg2); - if (result != null && result.getResult() != null - && result.getResult().OK()) { - AppContext.showToast(result.getResult().getErrorMessage()); - finish(); - } else { - handler.sendEmptyMessage(R.id.restart_preview); - AppContext.showToast(result != null - && result.getResult() != null ? result.getResult() - .getErrorMessage() : "登陆失败"); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - handler.sendEmptyMessage(R.id.restart_preview); - if (arg2 != null) { - AppContext.showToast(new String(arg2)); - } else { - AppContext.showToast("网页登陆失败"); - } - } - - @Override - public void onStart() { - super.onStart(); - showWaitDialog("已扫描,正在登陆..."); - } - - @Override - public void onFinish() { - super.onFinish(); - hideWaitDialog(); - } - }); - } - - private void handleOtherText(final String text) { - // 判断是否符合基本的json格式 - if (!text.matches("^\\{.*")) { - showCopyTextOption(text); - } else { - try { - BarCode barcode = BarCode.parse(text); - int type = barcode.getType(); - switch (type) { - case BarCode.SIGN_IN:// 签到 - handleSignIn(barcode); - break; - default: - break; - } - } catch (AppException e) { - showCopyTextOption(text); - } - } - } - - private void handleSignIn(BarCode barCode) { - if (barCode.isRequireLogin() && !AppContext.getInstance().isLogin()) { - showLogin(); - return; - } - showWaitDialog("正在签到..."); - AsyncHttpResponseHandler handler = new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - SingInResult res = SingInResult.parse(new String(arg2)); - if (res.isOk()) { - DialogHelp.getMessageDialog(CaptureActivity.this, res.getMessage()).show(); - } else { - DialogHelp.getMessageDialog(CaptureActivity.this, res.getErrorMes()).show(); - } - } catch (AppException e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - hideWaitDialog(); - DialogHelp.getMessageDialog(CaptureActivity.this, arg3.getMessage()).show(); - } - - @Override - public void onFinish() { - super.onFinish(); - hideWaitDialog(); - } - }; - OSChinaApi.singnIn(barCode.getUrl(), handler); - } - - private void showLogin() { - DialogHelp.getConfirmDialog(this, "请先登录,再进行", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - UIHelper.showLoginActivity(CaptureActivity.this); - } - }).show(); - } - - private void showCopyTextOption(final String text) { - DialogHelp.getConfirmDialog(this, text, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - ClipboardManager cbm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); - cbm.setText(text); - AppContext.showToast("复制成功"); - finish(); - } - }, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - finish(); - } - }).show(); - } - - private void initCamera(SurfaceHolder surfaceHolder) { - if (surfaceHolder == null) { - throw new IllegalStateException("No SurfaceHolder provided"); - } - if (cameraManager.isOpen()) { - Log.w(TAG, - "initCamera() while already open -- late SurfaceView callback?"); - return; - } - try { - cameraManager.openDriver(surfaceHolder); - // Creating the handler starts the preview, which can also throw a - // RuntimeException. - if (handler == null) { - handler = new CaptureActivityHandler(this, cameraManager, - DecodeThread.ALL_MODE); - } - - initCrop(); - } catch (IOException ioe) { - Log.w(TAG, ioe); - displayFrameworkBugMessageAndExit(); - } catch (RuntimeException e) { - Log.w(TAG, "Unexpected error initializing camera", e); - displayFrameworkBugMessageAndExit(); - } - } - - private void displayFrameworkBugMessageAndExit() { - // camera error - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getString(R.string.app_name)); - builder.setMessage("相机打开出错,请稍后重试"); - builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - finish(); - } - - }); - builder.setOnCancelListener(new DialogInterface.OnCancelListener() { - - @Override - public void onCancel(DialogInterface dialog) { - finish(); - } - }); - builder.show(); - } - - public void restartPreviewAfterDelay(long delayMS) { - if (handler != null) { - handler.sendEmptyMessageDelayed(R.id.restart_preview, delayMS); - } - } - - public Rect getCropRect() { - return mCropRect; - } - - /** - * 初始化截取的矩形区域 - */ - private void initCrop() { - int cameraWidth = cameraManager.getCameraResolution().y; - int cameraHeight = cameraManager.getCameraResolution().x; - - /** 获取布局中扫描框的位置信息 */ - int[] location = new int[2]; - scanCropView.getLocationInWindow(location); - - int cropLeft = location[0]; - int cropTop = location[1] - getStatusBarHeight(); - - int cropWidth = scanCropView.getWidth(); - int cropHeight = scanCropView.getHeight(); - - /** 获取布局容器的宽高 */ - int containerWidth = scanContainer.getWidth(); - int containerHeight = scanContainer.getHeight(); - - /** 计算最终截取的矩形的左上角顶点x坐标 */ - int x = cropLeft * cameraWidth / containerWidth; - /** 计算最终截取的矩形的左上角顶点y坐标 */ - int y = cropTop * cameraHeight / containerHeight; - - /** 计算最终截取的矩形的宽度 */ - int width = cropWidth * cameraWidth / containerWidth; - /** 计算最终截取的矩形的高度 */ - int height = cropHeight * cameraHeight / containerHeight; - - /** 生成最终的截取的矩形 */ - mCropRect = new Rect(x, y, width + x, height + y); - } - - private int getStatusBarHeight() { - try { - Class c = Class.forName("com.android.internal.R$dimen"); - Object obj = c.newInstance(); - Field field = c.getField("status_bar_height"); - int x = Integer.parseInt(field.get(obj).toString()); - return getResources().getDimensionPixelSize(x); - } catch (Exception e) { - e.printStackTrace(); - } - return 0; - } - - @Override - public void onClick(View v) { - // TODO Auto-generated method stub - switch (v.getId()) { - case R.id.capture_flash: - light(); - break; - - default: - break; - } - } - - private boolean flag; - - protected void light() { - if (flag == true) { - flag = false; - // 开闪光灯 - cameraManager.openLight(); - mFlash.setBackgroundResource(R.drawable.flash_open); - } else { - flag = true; - // 关闪光灯 - cameraManager.offLight(); - mFlash.setBackgroundResource(R.drawable.flash_default); - } - } - - @Override - public void initView() { - // TODO Auto-generated method stub - - } - - @Override - public void initData() { - // TODO Auto-generated method stub - - } -} \ No newline at end of file diff --git a/app/src/main/java/com/dtr/zxing/camera/AutoFocusManager.java b/app/src/main/java/com/dtr/zxing/camera/AutoFocusManager.java deleted file mode 100644 index 0def96bdbdd7ebd387eaa6ebe02182b2e2d46fcb..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/camera/AutoFocusManager.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.camera; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.hardware.Camera; -import android.os.AsyncTask; -import android.os.Build; -import android.util.Log; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.concurrent.RejectedExecutionException; - -public class AutoFocusManager implements Camera.AutoFocusCallback { - - private static final String TAG = AutoFocusManager.class.getSimpleName(); - - private static final long AUTO_FOCUS_INTERVAL_MS = 2000L; - private static final Collection FOCUS_MODES_CALLING_AF; - - static { - FOCUS_MODES_CALLING_AF = new ArrayList(2); - FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_AUTO); - FOCUS_MODES_CALLING_AF.add(Camera.Parameters.FOCUS_MODE_MACRO); - } - - private boolean stopped; - private boolean focusing; - private final boolean useAutoFocus; - private final Camera camera; - private AsyncTask outstandingTask; - - public AutoFocusManager(Context context, Camera camera) { - this.camera = camera; - String currentFocusMode = camera.getParameters().getFocusMode(); - useAutoFocus = FOCUS_MODES_CALLING_AF.contains(currentFocusMode); - Log.i(TAG, "Current focus mode '" + currentFocusMode + "'; use auto focus? " + useAutoFocus); - start(); - } - - @Override - public synchronized void onAutoFocus(boolean success, Camera theCamera) { - focusing = false; - autoFocusAgainLater(); - } - - @SuppressLint("NewApi") - private synchronized void autoFocusAgainLater() { - if (!stopped && outstandingTask == null) { - AutoFocusTask newTask = new AutoFocusTask(); - try { - if (Build.VERSION.SDK_INT >= 11) { - newTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } else { - newTask.execute(); - } - outstandingTask = newTask; - } catch (RejectedExecutionException ree) { - Log.w(TAG, "Could not request auto focus", ree); - } - } - } - - public synchronized void start() { - if (useAutoFocus) { - outstandingTask = null; - if (!stopped && !focusing) { - try { - camera.autoFocus(this); - focusing = true; - } catch (RuntimeException re) { - // Have heard RuntimeException reported in Android 4.0.x+; - // continue? - Log.w(TAG, "Unexpected exception while focusing", re); - // Try again later to keep cycle going - autoFocusAgainLater(); - } - } - } - } - - private synchronized void cancelOutstandingTask() { - if (outstandingTask != null) { - if (outstandingTask.getStatus() != AsyncTask.Status.FINISHED) { - outstandingTask.cancel(true); - } - outstandingTask = null; - } - } - - public synchronized void stop() { - stopped = true; - if (useAutoFocus) { - cancelOutstandingTask(); - // Doesn't hurt to call this even if not focusing - try { - camera.cancelAutoFocus(); - } catch (RuntimeException re) { - // Have heard RuntimeException reported in Android 4.0.x+; - // continue? - Log.w(TAG, "Unexpected exception while cancelling focusing", re); - } - } - } - - private final class AutoFocusTask extends AsyncTask { - @Override - protected Object doInBackground(Object... voids) { - try { - Thread.sleep(AUTO_FOCUS_INTERVAL_MS); - } catch (InterruptedException e) { - // continue - } - start(); - return null; - } - } - -} diff --git a/app/src/main/java/com/dtr/zxing/camera/CameraConfigurationManager.java b/app/src/main/java/com/dtr/zxing/camera/CameraConfigurationManager.java deleted file mode 100644 index 787f86ffbaf517e6d3ec19e277476960aad3158a..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/camera/CameraConfigurationManager.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.dtr.zxing.camera; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Point; -import android.hardware.Camera; -import android.util.Log; -import android.view.Display; -import android.view.WindowManager; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; - -/** - * - * 邮箱: 1076559197@qq.com | tauchen1990@gmail.com - * - * 作者: 陈涛 - * - * 日期: 2014年8月20日 - * - * 描述: 该类主要负责设置相机的参数信息,获取最佳的预览界面 - * - */ -public final class CameraConfigurationManager { - - private static final String TAG = "CameraConfiguration"; - - private static final int MIN_PREVIEW_PIXELS = 480 * 320; - private static final double MAX_ASPECT_DISTORTION = 0.15; - - private final Context context; - - // 屏幕分辨率 - private Point screenResolution; - // 相机分辨率 - private Point cameraResolution; - - public CameraConfigurationManager(Context context) { - this.context = context; - } - - public void initFromCameraParameters(Camera camera) { - Camera.Parameters parameters = camera.getParameters(); - WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); - Display display = manager.getDefaultDisplay(); - Point theScreenResolution = new Point(); - theScreenResolution = getDisplaySize(display); - - screenResolution = theScreenResolution; - Log.i(TAG, "Screen resolution: " + screenResolution); - - /** 因为换成了竖屏显示,所以不替换屏幕宽高得出的预览图是变形的 */ - Point screenResolutionForCamera = new Point(); - screenResolutionForCamera.x = screenResolution.x; - screenResolutionForCamera.y = screenResolution.y; - - if (screenResolution.x < screenResolution.y) { - screenResolutionForCamera.x = screenResolution.y; - screenResolutionForCamera.y = screenResolution.x; - } - - cameraResolution = findBestPreviewSizeValue(parameters, screenResolutionForCamera); - Log.i(TAG, "Camera resolution x: " + cameraResolution.x); - Log.i(TAG, "Camera resolution y: " + cameraResolution.y); - } - - @SuppressWarnings("deprecation") - @SuppressLint("NewApi") - private Point getDisplaySize(final Display display) { - final Point point = new Point(); - try { - display.getSize(point); - } catch (NoSuchMethodError ignore) { - point.x = display.getWidth(); - point.y = display.getHeight(); - } - return point; - } - - public void setDesiredCameraParameters(Camera camera, boolean safeMode) { - Camera.Parameters parameters = camera.getParameters(); - - if (parameters == null) { - Log.w(TAG, "Device error: no camera parameters are available. Proceeding without configuration."); - return; - } - - Log.i(TAG, "Initial camera parameters: " + parameters.flatten()); - - if (safeMode) { - Log.w(TAG, "In camera config safe mode -- most settings will not be honored"); - } - - parameters.setPreviewSize(cameraResolution.x, cameraResolution.y); - camera.setParameters(parameters); - - Camera.Parameters afterParameters = camera.getParameters(); - Camera.Size afterSize = afterParameters.getPreviewSize(); - if (afterSize != null && (cameraResolution.x != afterSize.width || cameraResolution.y != afterSize.height)) { - Log.w(TAG, "Camera said it supported preview size " + cameraResolution.x + 'x' + cameraResolution.y + ", but after setting it, preview size is " + afterSize.width + 'x' + afterSize.height); - cameraResolution.x = afterSize.width; - cameraResolution.y = afterSize.height; - } - - /** 设置相机预览为竖屏 */ - camera.setDisplayOrientation(90); - } - - public Point getCameraResolution() { - return cameraResolution; - } - - public Point getScreenResolution() { - return screenResolution; - } - - /** - * 从相机支持的分辨率中计算出最适合的预览界面尺寸 - * - * @param parameters - * @param screenResolution - * @return - */ - private Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { - List rawSupportedSizes = parameters.getSupportedPreviewSizes(); - if (rawSupportedSizes == null) { - Log.w(TAG, "Device returned no supported preview sizes; using default"); - Camera.Size defaultSize = parameters.getPreviewSize(); - return new Point(defaultSize.width, defaultSize.height); - } - - // Sort by size, descending - List supportedPreviewSizes = new ArrayList(rawSupportedSizes); - Collections.sort(supportedPreviewSizes, new Comparator() { - @Override - public int compare(Camera.Size a, Camera.Size b) { - int aPixels = a.height * a.width; - int bPixels = b.height * b.width; - if (bPixels < aPixels) { - return -1; - } - if (bPixels > aPixels) { - return 1; - } - return 0; - } - }); - - if (Log.isLoggable(TAG, Log.INFO)) { - StringBuilder previewSizesString = new StringBuilder(); - for (Camera.Size supportedPreviewSize : supportedPreviewSizes) { - previewSizesString.append(supportedPreviewSize.width).append('x').append(supportedPreviewSize.height).append(' '); - } - Log.i(TAG, "Supported preview sizes: " + previewSizesString); - } - - double screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y; - - // Remove sizes that are unsuitable - Iterator it = supportedPreviewSizes.iterator(); - while (it.hasNext()) { - Camera.Size supportedPreviewSize = it.next(); - int realWidth = supportedPreviewSize.width; - int realHeight = supportedPreviewSize.height; - if (realWidth * realHeight < MIN_PREVIEW_PIXELS) { - it.remove(); - continue; - } - - boolean isCandidatePortrait = realWidth < realHeight; - int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; - int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; - - double aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight; - double distortion = Math.abs(aspectRatio - screenAspectRatio); - if (distortion > MAX_ASPECT_DISTORTION) { - it.remove(); - continue; - } - - if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { - Point exactPoint = new Point(realWidth, realHeight); - Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); - return exactPoint; - } - } - - // If no exact match, use largest preview size. This was not a great - // idea on older devices because - // of the additional computation needed. We're likely to get here on - // newer Android 4+ devices, where - // the CPU is much more powerful. - if (!supportedPreviewSizes.isEmpty()) { - Camera.Size largestPreview = supportedPreviewSizes.get(0); - Point largestSize = new Point(largestPreview.width, largestPreview.height); - Log.i(TAG, "Using largest suitable preview size: " + largestSize); - return largestSize; - } - - // If there is nothing at all suitable, return current preview size - Camera.Size defaultPreview = parameters.getPreviewSize(); - Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); - Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); - - return defaultSize; - } -} diff --git a/app/src/main/java/com/dtr/zxing/camera/CameraManager.java b/app/src/main/java/com/dtr/zxing/camera/CameraManager.java deleted file mode 100644 index f7e4bbfdec6bb38bef1c0786fee6fbae7e493ea8..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/camera/CameraManager.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.camera; - -import android.content.Context; -import android.graphics.Point; -import android.hardware.Camera; -import android.hardware.Camera.Parameters; -import android.hardware.Camera.Size; -import android.os.Handler; -import android.util.Log; -import android.view.SurfaceHolder; - -import com.dtr.zxing.camera.open.OpenCameraInterface; - -import java.io.IOException; - -/** - * This object wraps the Camera service object and expects to be the only one - * talking to it. The implementation encapsulates the steps needed to take - * preview-sized images, which are used for both preview and decoding. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public class CameraManager { - - private static final String TAG = CameraManager.class.getSimpleName(); - - private final Context context; - private final CameraConfigurationManager configManager; - private Camera camera; - private AutoFocusManager autoFocusManager; - private Parameters parameter; - - private boolean initialized; - private boolean previewing; - private int requestedCameraId = -1; - /** - * Preview frames are delivered here, which we pass on to the registered - * handler. Make sure to clear the handler so it will only receive one - * message. - */ - private final PreviewCallback previewCallback; - - public CameraManager(Context context) { - this.context = context; - this.configManager = new CameraConfigurationManager(context); - previewCallback = new PreviewCallback(configManager); - } - - /** - * Opens the camera driver and initializes the hardware parameters. - * - * @param holder - * The surface object which the camera will draw preview frames - * into. - * @throws java.io.IOException - * Indicates the camera driver failed to open. - */ - public synchronized void openDriver(SurfaceHolder holder) - throws IOException { - Camera theCamera = camera; - if (theCamera == null) { - - if (requestedCameraId >= 0) { - theCamera = OpenCameraInterface.open(requestedCameraId); - } else { - theCamera = OpenCameraInterface.open(); - } - - if (theCamera == null) { - throw new IOException(); - } - camera = theCamera; - } - theCamera.setPreviewDisplay(holder); - - if (!initialized) { - initialized = true; - configManager.initFromCameraParameters(theCamera); - } - - Camera.Parameters parameters = theCamera.getParameters(); - String parametersFlattened = parameters == null ? null : parameters - .flatten(); // Save - // these, - // temporarily - try { - configManager.setDesiredCameraParameters(theCamera, false); - } catch (RuntimeException re) { - // Driver failed - Log.w(TAG, - "Camera rejected parameters. Setting only minimal safe-mode parameters"); - Log.i(TAG, "Resetting to saved camera params: " - + parametersFlattened); - // Reset: - if (parametersFlattened != null) { - parameters = theCamera.getParameters(); - parameters.unflatten(parametersFlattened); - try { - theCamera.setParameters(parameters); - configManager.setDesiredCameraParameters(theCamera, true); - } catch (RuntimeException re2) { - // Well, darn. Give up - Log.w(TAG, - "Camera rejected even safe-mode parameters! No configuration"); - } - } - } - - } - - public synchronized boolean isOpen() { - return camera != null; - } - - /** - * Closes the camera driver if still in use. - */ - public synchronized void closeDriver() { - if (camera != null) { - camera.release(); - camera = null; - // Make sure to clear these each time we close the camera, so that - // any scanning rect - // requested by intent is forgotten. - } - } - - /** - * Asks the camera hardware to begin drawing preview frames to the screen. - */ - public synchronized void startPreview() { - Camera theCamera = camera; - if (theCamera != null && !previewing) { - theCamera.startPreview(); - previewing = true; - autoFocusManager = new AutoFocusManager(context, camera); - } - } - - /** - * Tells the camera to stop drawing preview frames. - */ - public synchronized void stopPreview() { - if (autoFocusManager != null) { - autoFocusManager.stop(); - autoFocusManager = null; - } - if (camera != null && previewing) { - camera.stopPreview(); - previewCallback.setHandler(null, 0); - previewing = false; - } - } - - /** - * A single preview frame will be returned to the handler supplied. The data - * will arrive as byte[] in the message.obj field, with width and height - * encoded as message.arg1 and message.arg2, respectively. - * - * @param handler - * The handler to send the message to. - * @param message - * The what field of the message to be sent. - */ - public synchronized void requestPreviewFrame(Handler handler, int message) { - Camera theCamera = camera; - if (theCamera != null && previewing) { - previewCallback.setHandler(handler, message); - theCamera.setOneShotPreviewCallback(previewCallback); - } - } - - /** - * Allows third party apps to specify the camera ID, rather than determine - * it automatically based on available cameras and their orientation. - * - * @param cameraId - * camera ID of the camera to use. A negative value means - * "no preference". - */ - public synchronized void setManualCameraId(int cameraId) { - requestedCameraId = cameraId; - } - - /** - * 获取相机分辨率 - * - * @return - */ - public Point getCameraResolution() { - return configManager.getCameraResolution(); - } - - public Size getPreviewSize() { - if (null != camera) { - return camera.getParameters().getPreviewSize(); - } - return null; - } - - public void openLight() { - if (camera != null) { - parameter = camera.getParameters(); - parameter.setFlashMode(Parameters.FLASH_MODE_TORCH); - camera.setParameters(parameter); - } - } - - public void offLight() { - if (camera != null) { - parameter = camera.getParameters(); - parameter.setFlashMode(Parameters.FLASH_MODE_OFF); - camera.setParameters(parameter); - } - } -} diff --git a/app/src/main/java/com/dtr/zxing/camera/PreviewCallback.java b/app/src/main/java/com/dtr/zxing/camera/PreviewCallback.java deleted file mode 100644 index c27c6928ffb430d6d238d5cd01cecf59e89e30dd..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/camera/PreviewCallback.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.camera; - -import android.graphics.Point; -import android.hardware.Camera; -import android.os.Handler; -import android.os.Message; -import android.util.Log; - -public class PreviewCallback implements Camera.PreviewCallback { - - private static final String TAG = PreviewCallback.class.getSimpleName(); - - private final CameraConfigurationManager configManager; - private Handler previewHandler; - private int previewMessage; - - public PreviewCallback(CameraConfigurationManager configManager) { - this.configManager = configManager; - } - - public void setHandler(Handler previewHandler, int previewMessage) { - this.previewHandler = previewHandler; - this.previewMessage = previewMessage; - } - - @Override - public void onPreviewFrame(byte[] data, Camera camera) { - Point cameraResolution = configManager.getCameraResolution(); - Handler thePreviewHandler = previewHandler; - if (cameraResolution != null && thePreviewHandler != null) { - Message message = thePreviewHandler.obtainMessage(previewMessage, cameraResolution.x, cameraResolution.y, data); - message.sendToTarget(); - previewHandler = null; - } else { - Log.d(TAG, "Got preview callback, but no handler or resolution available"); - } - } - -} diff --git a/app/src/main/java/com/dtr/zxing/camera/open/OpenCameraInterface.java b/app/src/main/java/com/dtr/zxing/camera/open/OpenCameraInterface.java deleted file mode 100644 index f2866216845d16402ee707eb6eb134cd797f6442..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/camera/open/OpenCameraInterface.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2012 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.camera.open; - -import android.hardware.Camera; -import android.util.Log; - -public class OpenCameraInterface { - - private static final String TAG = OpenCameraInterface.class.getName(); - - /** - * Opens the requested camera with {@link android.hardware.Camera#open(int)}, if one exists. - * - * @param cameraId - * camera ID of the camera to use. A negative value means - * "no preference" - * @return handle to {@link android.hardware.Camera} that was opened - */ - public static Camera open(int cameraId) { - - int numCameras = Camera.getNumberOfCameras(); - if (numCameras == 0) { - Log.w(TAG, "No cameras!"); - return null; - } - - boolean explicitRequest = cameraId >= 0; - - if (!explicitRequest) { - // Select a camera if no explicit camera requested - int index = 0; - while (index < numCameras) { - Camera.CameraInfo cameraInfo = new Camera.CameraInfo(); - Camera.getCameraInfo(index, cameraInfo); - if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) { - break; - } - index++; - } - - cameraId = index; - } - - Camera camera; - if (cameraId < numCameras) { - Log.i(TAG, "Opening camera #" + cameraId); - camera = Camera.open(cameraId); - } else { - if (explicitRequest) { - Log.w(TAG, "Requested camera does not exist: " + cameraId); - camera = null; - } else { - Log.i(TAG, "No camera facing back; returning camera #0"); - camera = Camera.open(0); - } - } - - return camera; - } - - /** - * Opens a rear-facing camera with {@link android.hardware.Camera#open(int)}, if one exists, - * or opens camera 0. - * - * @return handle to {@link android.hardware.Camera} that was opened - */ - public static Camera open() { - return open(-1); - } - -} diff --git a/app/src/main/java/com/dtr/zxing/decode/DecodeFormatManager.java b/app/src/main/java/com/dtr/zxing/decode/DecodeFormatManager.java deleted file mode 100644 index bdfe47088dd6fdf02ba8bdd2390871347e62df0c..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/decode/DecodeFormatManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.decode; - -import com.google.zxing.BarcodeFormat; - -import java.util.Collection; -import java.util.EnumSet; -import java.util.Set; - -public class DecodeFormatManager { - - // 1D解码 - private static final Set PRODUCT_FORMATS; - private static final Set INDUSTRIAL_FORMATS; - private static final Set ONE_D_FORMATS; - - // 二维码解码 - private static final Set QR_CODE_FORMATS; - - static { - PRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A, BarcodeFormat.UPC_E, BarcodeFormat.EAN_13, BarcodeFormat.EAN_8, BarcodeFormat.RSS_14, BarcodeFormat.RSS_EXPANDED); - INDUSTRIAL_FORMATS = EnumSet.of(BarcodeFormat.CODE_39, BarcodeFormat.CODE_93, BarcodeFormat.CODE_128, BarcodeFormat.ITF, BarcodeFormat.CODABAR); - ONE_D_FORMATS = EnumSet.copyOf(PRODUCT_FORMATS); - ONE_D_FORMATS.addAll(INDUSTRIAL_FORMATS); - - QR_CODE_FORMATS = EnumSet.of(BarcodeFormat.QR_CODE); - } - - public static Collection getQrCodeFormats() { - return QR_CODE_FORMATS; - } - - public static Collection getBarCodeFormats() { - return ONE_D_FORMATS; - } -} diff --git a/app/src/main/java/com/dtr/zxing/decode/DecodeHandler.java b/app/src/main/java/com/dtr/zxing/decode/DecodeHandler.java deleted file mode 100644 index 312b27340a10acf61895566240e846c0f57becc3..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/decode/DecodeHandler.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.decode; - -import android.graphics.Bitmap; -import android.graphics.Rect; -import android.hardware.Camera.Size; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.Message; - -import com.dtr.zxing.activity.CaptureActivity; -import com.google.zxing.BinaryBitmap; -import com.google.zxing.DecodeHintType; -import com.google.zxing.MultiFormatReader; -import com.google.zxing.PlanarYUVLuminanceSource; -import com.google.zxing.ReaderException; -import com.google.zxing.Result; -import com.google.zxing.common.HybridBinarizer; - -import java.io.ByteArrayOutputStream; -import java.util.Map; - -import net.oschina.app.R; - -public class DecodeHandler extends Handler { - - private final CaptureActivity activity; - private final MultiFormatReader multiFormatReader; - private boolean running = true; - - public DecodeHandler(CaptureActivity activity, Map hints) { - multiFormatReader = new MultiFormatReader(); - multiFormatReader.setHints(hints); - this.activity = activity; - } - - @Override - public void handleMessage(Message message) { - if (!running) { - return; - } - switch (message.what) { - case R.id.decode: - decode((byte[]) message.obj, message.arg1, message.arg2); - break; - case R.id.quit: - running = false; - Looper.myLooper().quit(); - break; - } - } - - /** - * Decode the data within the viewfinder rectangle, and time how long it - * took. For efficiency, reuse the same reader objects from one decode to - * the next. - * - * @param data - * The YUV preview frame. - * @param width - * The width of the preview frame. - * @param height - * The height of the preview frame. - */ - private void decode(byte[] data, int width, int height) { - Size size = activity.getCameraManager().getPreviewSize(); - - // 这里需要将获取的data翻转一下,因为相机默认拿的的横屏的数据 - byte[] rotatedData = new byte[data.length]; - for (int y = 0; y < size.height; y++) { - for (int x = 0; x < size.width; x++) - rotatedData[x * size.height + size.height - y - 1] = data[x + y * size.width]; - } - - // 宽高也要调整 - int tmp = size.width; - size.width = size.height; - size.height = tmp; - - Result rawResult = null; - PlanarYUVLuminanceSource source = buildLuminanceSource(rotatedData, size.width, size.height); - if (source != null) { - BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); - try { - rawResult = multiFormatReader.decodeWithState(bitmap); - } catch (ReaderException re) { - // continue - } finally { - multiFormatReader.reset(); - } - } - - Handler handler = activity.getHandler(); - if (rawResult != null) { - // Don't log the barcode contents for security. - if (handler != null) { - Message message = Message.obtain(handler, R.id.decode_succeeded, rawResult); - Bundle bundle = new Bundle(); - bundleThumbnail(source, bundle); - message.setData(bundle); - message.sendToTarget(); - } - } else { - if (handler != null) { - Message message = Message.obtain(handler, R.id.decode_failed); - message.sendToTarget(); - } - } - - } - - private static void bundleThumbnail(PlanarYUVLuminanceSource source, Bundle bundle) { - int[] pixels = source.renderThumbnail(); - int width = source.getThumbnailWidth(); - int height = source.getThumbnailHeight(); - Bitmap bitmap = Bitmap.createBitmap(pixels, 0, width, width, height, Bitmap.Config.ARGB_8888); - ByteArrayOutputStream out = new ByteArrayOutputStream(); - bitmap.compress(Bitmap.CompressFormat.JPEG, 50, out); - bundle.putByteArray(DecodeThread.BARCODE_BITMAP, out.toByteArray()); - } - - /** - * A factory method to build the appropriate LuminanceSource object based on - * the format of the preview buffers, as described by Camera.Parameters. - * - * @param data - * A preview frame. - * @param width - * The width of the image. - * @param height - * The height of the image. - * @return A PlanarYUVLuminanceSource instance. - */ - public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) { - Rect rect = activity.getCropRect(); - if (rect == null) { - return null; - } - // Go ahead and assume it's YUV rather than die. - return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top, rect.width(), rect.height(), false); - } - -} diff --git a/app/src/main/java/com/dtr/zxing/decode/DecodeThread.java b/app/src/main/java/com/dtr/zxing/decode/DecodeThread.java deleted file mode 100644 index 1dac54d38a65a3f2a3ea00f4e3f12376fa7d9387..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/decode/DecodeThread.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.decode; - -import android.os.Handler; -import android.os.Looper; - -import com.dtr.zxing.activity.CaptureActivity; -import com.google.zxing.BarcodeFormat; -import com.google.zxing.DecodeHintType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.EnumSet; -import java.util.Map; -import java.util.concurrent.CountDownLatch; - -/** - * This thread does all the heavy lifting of decoding the images. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public class DecodeThread extends Thread { - - public static final String BARCODE_BITMAP = "barcode_bitmap"; - - public static final int BARCODE_MODE = 0X100; - public static final int QRCODE_MODE = 0X200; - public static final int ALL_MODE = 0X300; - - private final CaptureActivity activity; - private final Map hints; - private Handler handler; - private final CountDownLatch handlerInitLatch; - - public DecodeThread(CaptureActivity activity, int decodeMode) { - - this.activity = activity; - handlerInitLatch = new CountDownLatch(1); - - hints = new EnumMap(DecodeHintType.class); - - Collection decodeFormats = new ArrayList(); - decodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC)); - decodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417)); - - switch (decodeMode) { - case BARCODE_MODE: - decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); - break; - - case QRCODE_MODE: - decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); - break; - - case ALL_MODE: - decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats()); - decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats()); - break; - - default: - break; - } - - hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats); - } - - public Handler getHandler() { - try { - handlerInitLatch.await(); - } catch (InterruptedException ie) { - // continue? - } - return handler; - } - - @Override - public void run() { - Looper.prepare(); - handler = new DecodeHandler(activity, hints); - handlerInitLatch.countDown(); - Looper.loop(); - } - -} diff --git a/app/src/main/java/com/dtr/zxing/utils/BeepManager.java b/app/src/main/java/com/dtr/zxing/utils/BeepManager.java deleted file mode 100644 index fd7a2c2982d6ece420738840bdb1eefaae79e7be..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/utils/BeepManager.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.utils; - -import android.app.Activity; -import android.content.Context; -import android.content.SharedPreferences; -import android.content.res.AssetFileDescriptor; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.os.Vibrator; -import android.preference.PreferenceManager; -import android.util.Log; -import com.dtr.zxing.activity.CaptureActivity; - - -import java.io.Closeable; -import java.io.IOException; - -import net.oschina.app.R; - -/** - * Manages beeps and vibrations for {@link CaptureActivity}. - */ -public class BeepManager implements MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, Closeable { - - private static final String TAG = BeepManager.class.getSimpleName(); - - private static final float BEEP_VOLUME = 0.10f; - private static final long VIBRATE_DURATION = 200L; - - private final Activity activity; - private MediaPlayer mediaPlayer; - private boolean playBeep; - private boolean vibrate; - - public BeepManager(Activity activity) { - this.activity = activity; - this.mediaPlayer = null; - updatePrefs(); - } - - private synchronized void updatePrefs() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); - playBeep = shouldBeep(prefs, activity); - vibrate = true; - if (playBeep && mediaPlayer == null) { - // The volume on STREAM_SYSTEM is not adjustable, and users found it - // too loud, - // so we now play on the music stream. - activity.setVolumeControlStream(AudioManager.STREAM_MUSIC); - mediaPlayer = buildMediaPlayer(activity); - } - } - - public synchronized void playBeepSoundAndVibrate() { - if (playBeep && mediaPlayer != null) { - mediaPlayer.start(); - } - if (vibrate) { - Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); - vibrator.vibrate(VIBRATE_DURATION); - } - } - - private static boolean shouldBeep(SharedPreferences prefs, Context activity) { - boolean shouldPlayBeep = true; - if (shouldPlayBeep) { - // See if sound settings overrides this - AudioManager audioService = (AudioManager) activity.getSystemService(Context.AUDIO_SERVICE); - if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) { - shouldPlayBeep = false; - } - } - return shouldPlayBeep; - } - - private MediaPlayer buildMediaPlayer(Context activity) { - MediaPlayer mediaPlayer = new MediaPlayer(); - mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); - mediaPlayer.setOnCompletionListener(this); - mediaPlayer.setOnErrorListener(this); - try { - AssetFileDescriptor file = activity.getResources().openRawResourceFd(R.raw.qr_sacn); - try { - mediaPlayer.setDataSource(file.getFileDescriptor(), file.getStartOffset(), file.getLength()); - } finally { - file.close(); - } - mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME); - mediaPlayer.prepare(); - return mediaPlayer; - } catch (IOException ioe) { - Log.w(TAG, ioe); - mediaPlayer.release(); - return null; - } - } - - @Override - public void onCompletion(MediaPlayer mp) { - // When the beep has finished playing, rewind to queue up another one. - mp.seekTo(0); - } - - @Override - public synchronized boolean onError(MediaPlayer mp, int what, int extra) { - if (what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) { - // we are finished, so put up an appropriate error toast if required - // and finish - activity.finish(); - } else { - // possibly media player error, so release and recreate - mp.release(); - mediaPlayer = null; - updatePrefs(); - } - return true; - } - - @Override - public synchronized void close() { - if (mediaPlayer != null) { - mediaPlayer.release(); - mediaPlayer = null; - } - } - -} diff --git a/app/src/main/java/com/dtr/zxing/utils/CaptureActivityHandler.java b/app/src/main/java/com/dtr/zxing/utils/CaptureActivityHandler.java deleted file mode 100644 index d6272f44189a6a16bb3681b4767a2d2ac74a46cc..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/utils/CaptureActivityHandler.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.utils; - -import net.oschina.app.R; -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; - -import com.dtr.zxing.activity.CaptureActivity; -import com.dtr.zxing.camera.CameraManager; -import com.dtr.zxing.decode.DecodeThread; -import com.google.zxing.Result; - - -/** - * This class handles all the messaging which comprises the state machine for - * capture. - * - * @author dswitkin@google.com (Daniel Switkin) - */ -public class CaptureActivityHandler extends Handler { - - private final CaptureActivity activity; - private final DecodeThread decodeThread; - private final CameraManager cameraManager; - private State state; - - private enum State { - PREVIEW, SUCCESS, DONE - } - - public CaptureActivityHandler(CaptureActivity activity, CameraManager cameraManager, int decodeMode) { - this.activity = activity; - decodeThread = new DecodeThread(activity, decodeMode); - decodeThread.start(); - state = State.SUCCESS; - - // Start ourselves capturing previews and decoding. - this.cameraManager = cameraManager; - cameraManager.startPreview(); - restartPreviewAndDecode(); - } - - @Override - public void handleMessage(Message message) { - switch (message.what) { - case R.id.restart_preview: - restartPreviewAndDecode(); - break; - case R.id.decode_succeeded: - state = State.SUCCESS; - Bundle bundle = message.getData(); - - activity.handleDecode((Result) message.obj, bundle); - break; - case R.id.decode_failed: - // We're decoding as fast as possible, so when one decode fails, - // start another. - state = State.PREVIEW; - cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode); - break; - case R.id.return_scan_result: - activity.setResult(Activity.RESULT_OK, (Intent) message.obj); - activity.finish(); - break; - } - } - - public void quitSynchronously() { - state = State.DONE; - cameraManager.stopPreview(); - Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit); - quit.sendToTarget(); - try { - // Wait at most half a second; should be enough time, and onPause() - // will timeout quickly - decodeThread.join(500L); - } catch (InterruptedException e) { - // continue - } - - // Be absolutely sure we don't send any queued up messages - removeMessages(R.id.decode_succeeded); - removeMessages(R.id.decode_failed); - } - - private void restartPreviewAndDecode() { - if (state == State.SUCCESS) { - state = State.PREVIEW; - cameraManager.requestPreviewFrame(decodeThread.getHandler(), R.id.decode); - } - } - -} diff --git a/app/src/main/java/com/dtr/zxing/utils/InactivityTimer.java b/app/src/main/java/com/dtr/zxing/utils/InactivityTimer.java deleted file mode 100644 index 1230771b1e261f54ace4f24e5604619c91a201f0..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/dtr/zxing/utils/InactivityTimer.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2010 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.dtr.zxing.utils; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.AsyncTask; -import android.os.BatteryManager; -import android.os.Build; -import android.util.Log; - -/** - * Finishes an activity after a period of inactivity if the device is on battery - * power. - */ -public class InactivityTimer { - - private static final String TAG = InactivityTimer.class.getSimpleName(); - - private static final long INACTIVITY_DELAY_MS = 5 * 60 * 1000L; - - private Activity activity; - private BroadcastReceiver powerStatusReceiver; - private boolean registered; - private AsyncTask inactivityTask; - - public InactivityTimer(Activity activity) { - this.activity = activity; - powerStatusReceiver = new PowerStatusReceiver(); - registered = false; - onActivity(); - } - - @SuppressLint("NewApi") - public synchronized void onActivity() { - cancel(); - inactivityTask = new InactivityAsyncTask(); - if (Build.VERSION.SDK_INT >= 11) { - inactivityTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } else { - inactivityTask.execute(); - } - } - - public synchronized void onPause() { - cancel(); - if (registered) { - activity.unregisterReceiver(powerStatusReceiver); - registered = false; - } else { - Log.w(TAG, "PowerStatusReceiver was never registered?"); - } - } - - public synchronized void onResume() { - if (registered) { - Log.w(TAG, "PowerStatusReceiver was already registered?"); - } else { - activity.registerReceiver(powerStatusReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); - registered = true; - } - onActivity(); - } - - private synchronized void cancel() { - AsyncTask task = inactivityTask; - if (task != null) { - task.cancel(true); - inactivityTask = null; - } - } - - public void shutdown() { - cancel(); - } - - private class PowerStatusReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { - // 0 indicates that we're on battery - boolean onBatteryNow = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) <= 0; - if (onBatteryNow) { - InactivityTimer.this.onActivity(); - } else { - InactivityTimer.this.cancel(); - } - } - } - } - - private class InactivityAsyncTask extends AsyncTask { - @Override - protected Object doInBackground(Object... objects) { - try { - Thread.sleep(INACTIVITY_DELAY_MS); - Log.i(TAG, "Finishing activity due to inactivity"); - activity.finish(); - } catch (InterruptedException e) { - // continue without killing - } - return null; - } - } - -} diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/AccessibleDateAnimator.java b/app/src/main/java/com/fourmob/datetimepicker/date/AccessibleDateAnimator.java deleted file mode 100644 index d527c91ecfb8cf5d7cd156d10d2a4726e09d78c2..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/AccessibleDateAnimator.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import android.content.Context; -import android.text.format.DateUtils; -import android.util.AttributeSet; -import android.view.accessibility.AccessibilityEvent; -import android.widget.ViewAnimator; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class AccessibleDateAnimator extends ViewAnimator { - private long mDateMillis; - - public AccessibleDateAnimator(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public void setDateMillis(long dateMillis) { - mDateMillis = dateMillis; - } - - /** - * Announce the currently-selected date when launched. - */ - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { - // Clear the event's current text so that only the current date will - // be spoken. - event.getText().clear(); - int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR - | DateUtils.FORMAT_SHOW_WEEKDAY; - - String dateString = DateUtils.formatDateTime(getContext(), - mDateMillis, flags); - event.getText().add(dateString); - return true; - } - return super.dispatchPopulateAccessibilityEvent(event); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerController.java b/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerController.java deleted file mode 100644 index a8c6400bc0787f9913ec8bd480bb7347445332a1..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerController.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fourmob.datetimepicker.date; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -abstract interface DatePickerController { - public abstract int getFirstDayOfWeek(); - - public abstract int getMaxYear(); - - public abstract int getMinYear(); - - public abstract SimpleMonthAdapter.CalendarDay getSelectedDay(); - - public abstract void onDayOfMonthSelected(int year, int month, int day); - - public abstract void onYearSelected(int year); - - public abstract void registerOnDateChangedListener( - DatePickerDialog.OnDateChangedListener onDateChangedListener); - - public abstract void tryVibrate(); -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerDialog.java b/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerDialog.java deleted file mode 100644 index 7d862a3db2c0823c94d19ee2dd79054294295c4d..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/DatePickerDialog.java +++ /dev/null @@ -1,477 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import java.text.DateFormatSymbols; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Locale; - -import net.oschina.app.R; -import android.app.Activity; -import android.os.Bundle; -import android.os.SystemClock; -import android.os.Vibrator; -import android.support.v4.app.DialogFragment; -import android.text.format.DateUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.view.animation.AlphaAnimation; -import android.widget.Button; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.nineoldandroids.animation.ObjectAnimator; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class DatePickerDialog extends DialogFragment implements - View.OnClickListener, DatePickerController { - - private static final String KEY_SELECTED_YEAR = "year"; - private static final String KEY_SELECTED_MONTH = "month"; - private static final String KEY_SELECTED_DAY = "day"; - private static final String KEY_VIBRATE = "vibrate"; - - // https://code.google.com/p/android/issues/detail?id=13050 - private static final int MAX_YEAR = 2037; - private static final int MIN_YEAR = 1902; - - private static final int UNINITIALIZED = -1; - private static final int MONTH_AND_DAY_VIEW = 0; - private static final int YEAR_VIEW = 1; - - public static final int ANIMATION_DELAY = 500; - public static final String KEY_WEEK_START = "week_start"; - public static final String KEY_YEAR_START = "year_start"; - public static final String KEY_YEAR_END = "year_end"; - public static final String KEY_CURRENT_VIEW = "current_view"; - public static final String KEY_LIST_POSITION = "list_position"; - public static final String KEY_LIST_POSITION_OFFSET = "list_position_offset"; - - private static SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("dd", - Locale.getDefault()); - private static SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy", - Locale.getDefault()); - private final DateFormatSymbols mDateFormatSymbols = new DateFormatSymbols(); - - private final Calendar mCalendar = Calendar.getInstance(); - private final HashSet mListeners = new HashSet(); - private OnDateSetListener mCallBack; - - private AccessibleDateAnimator mAnimator; - private boolean mDelayAnimation = true; - private long mLastVibrate; - private int mCurrentView = UNINITIALIZED; - - private int mWeekStart = mCalendar.getFirstDayOfWeek(); - private int mMaxYear = MAX_YEAR; - private int mMinYear = MIN_YEAR; - - private String mDayPickerDescription; - private String mYearPickerDescription; - private String mSelectDay; - private String mSelectYear; - - private TextView mDayOfWeekView; - private DayPickerView mDayPickerView; - private Button mDoneButton; - private LinearLayout mMonthAndDayView; - private TextView mSelectedDayTextView; - private TextView mSelectedMonthTextView; - private Vibrator mVibrator; - private YearPickerView mYearPickerView; - private TextView mYearView; - - private boolean mVibrate = true; - private boolean mCloseOnSingleTapDay; - - private void adjustDayInMonthIfNeeded(int month, int year) { - int day = mCalendar.get(Calendar.DAY_OF_MONTH); - int daysInMonth = Utils.getDaysInMonth(month, year); - if (day > daysInMonth) { - mCalendar.set(Calendar.DAY_OF_MONTH, daysInMonth); - } - } - - public DatePickerDialog() { - // Empty constructor required for dialog fragment. DO NOT REMOVE - } - - public static DatePickerDialog newInstance( - OnDateSetListener onDateSetListener, int year, int month, int day) { - return newInstance(onDateSetListener, year, month, day, true); - } - - public static DatePickerDialog newInstance( - OnDateSetListener onDateSetListener, int year, int month, int day, - boolean vibrate) { - DatePickerDialog datePickerDialog = new DatePickerDialog(); - datePickerDialog.initialize(onDateSetListener, year, month, day, - vibrate); - return datePickerDialog; - } - - public void setVibrate(boolean vibrate) { - mVibrate = vibrate; - } - - private void setCurrentView(int currentView) { - setCurrentView(currentView, false); - } - - private void setCurrentView(int currentView, boolean forceRefresh) { - long timeInMillis = mCalendar.getTimeInMillis(); - switch (currentView) { - case MONTH_AND_DAY_VIEW: - ObjectAnimator monthDayAnim = Utils.getPulseAnimator( - mMonthAndDayView, 0.9F, 1.05F); - if (mDelayAnimation) { - monthDayAnim.setStartDelay(ANIMATION_DELAY); - mDelayAnimation = false; - } - mDayPickerView.onDateChanged(); - if (mCurrentView != currentView || forceRefresh) { - mMonthAndDayView.setSelected(true); - mYearView.setSelected(false); - mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); - mCurrentView = currentView; - } - monthDayAnim.start(); - String monthDayDesc = DateUtils.formatDateTime(getActivity(), - timeInMillis, DateUtils.FORMAT_SHOW_DATE); - mAnimator.setContentDescription(mDayPickerDescription + ": " - + monthDayDesc); - Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay); - break; - case YEAR_VIEW: - ObjectAnimator yearAnim = Utils.getPulseAnimator(mYearView, 0.85F, - 1.1F); - if (mDelayAnimation) { - yearAnim.setStartDelay(ANIMATION_DELAY); - mDelayAnimation = false; - } - mYearPickerView.onDateChanged(); - if (mCurrentView != currentView || forceRefresh) { - mMonthAndDayView.setSelected(false); - mYearView.setSelected(true); - mAnimator.setDisplayedChild(YEAR_VIEW); - mCurrentView = currentView; - } - yearAnim.start(); - String dayDesc = YEAR_FORMAT.format(timeInMillis); - mAnimator.setContentDescription(mYearPickerDescription + ": " - + dayDesc); - Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear); - break; - } - } - - private void updateDisplay(boolean announce) { - /* - * if (mDayOfWeekView != null) { - * mDayOfWeekView.setText(mCalendar.getDisplayName(Calendar.DAY_OF_WEEK, - * Calendar.LONG, - * Locale.getDefault()).toUpperCase(Locale.getDefault())); } - * - * mSelectedMonthTextView.setText(mCalendar.getDisplayName(Calendar.MONTH - * , Calendar.SHORT, - * Locale.getDefault()).toUpperCase(Locale.getDefault())); - */ - - if (this.mDayOfWeekView != null) { - this.mCalendar.setFirstDayOfWeek(mWeekStart); - this.mDayOfWeekView - .setText(mDateFormatSymbols.getWeekdays()[this.mCalendar - .get(Calendar.DAY_OF_WEEK)].toUpperCase(Locale - .getDefault())); - } - - this.mSelectedMonthTextView - .setText(mDateFormatSymbols.getMonths()[this.mCalendar - .get(Calendar.MONTH)].toUpperCase(Locale.getDefault())); - - mSelectedDayTextView.setText(DAY_FORMAT.format(mCalendar.getTime())); - mYearView.setText(YEAR_FORMAT.format(mCalendar.getTime())); - - // Accessibility. - long millis = mCalendar.getTimeInMillis(); - mAnimator.setDateMillis(millis); - int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_YEAR; - String monthAndDayText = DateUtils.formatDateTime(getActivity(), - millis, flags); - mMonthAndDayView.setContentDescription(monthAndDayText); - - if (announce) { - flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR; - String fullDateText = DateUtils.formatDateTime(getActivity(), - millis, flags); - Utils.tryAccessibilityAnnounce(mAnimator, fullDateText); - } - } - - private void updatePickers() { - Iterator iterator = mListeners.iterator(); - while (iterator.hasNext()) { - iterator.next().onDateChanged(); - } - } - - @Override - public int getFirstDayOfWeek() { - return mWeekStart; - } - - @Override - public int getMaxYear() { - return mMaxYear; - } - - @Override - public int getMinYear() { - return mMinYear; - } - - @Override - public SimpleMonthAdapter.CalendarDay getSelectedDay() { - return new SimpleMonthAdapter.CalendarDay(mCalendar); - } - - public void initialize(OnDateSetListener onDateSetListener, int year, - int month, int day, boolean vibrate) { - if (year > MAX_YEAR) - throw new IllegalArgumentException("year end must < " + MAX_YEAR); - if (year < MIN_YEAR) - throw new IllegalArgumentException("year end must > " + MIN_YEAR); - mCallBack = onDateSetListener; - mCalendar.set(Calendar.YEAR, year); - mCalendar.set(Calendar.MONTH, month); - mCalendar.set(Calendar.DAY_OF_MONTH, day); - mVibrate = vibrate; - } - - @Override - public void onClick(View view) { - tryVibrate(); - if (view.getId() == R.id.date_picker_year) - setCurrentView(YEAR_VIEW); - else if (view.getId() == R.id.date_picker_month_and_day) - setCurrentView(MONTH_AND_DAY_VIEW); - } - - @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - Activity activity = getActivity(); - activity.getWindow().setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); - mVibrator = ((Vibrator) activity.getSystemService("vibrator")); - if (bundle != null) { - mCalendar.set(Calendar.YEAR, bundle.getInt(KEY_SELECTED_YEAR)); - mCalendar.set(Calendar.MONTH, bundle.getInt(KEY_SELECTED_MONTH)); - mCalendar.set(Calendar.DAY_OF_MONTH, - bundle.getInt(KEY_SELECTED_DAY)); - mVibrate = bundle.getBoolean(KEY_VIBRATE); - } - } - - @Override - public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, - Bundle bundle) { - getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); - - View view = layoutInflater.inflate(R.layout.date_picker_dialog, null); - - mDayOfWeekView = ((TextView) view.findViewById(R.id.date_picker_header)); - mMonthAndDayView = ((LinearLayout) view - .findViewById(R.id.date_picker_month_and_day)); - mMonthAndDayView.setOnClickListener(this); - mSelectedMonthTextView = ((TextView) view - .findViewById(R.id.date_picker_month)); - mSelectedDayTextView = ((TextView) view - .findViewById(R.id.date_picker_day)); - mYearView = ((TextView) view.findViewById(R.id.date_picker_year)); - mYearView.setOnClickListener(this); - - int listPosition = -1; - int currentView = MONTH_AND_DAY_VIEW; - int listPositionOffset = 0; - if (bundle != null) { - mWeekStart = bundle.getInt(KEY_WEEK_START); - mMinYear = bundle.getInt(KEY_YEAR_START); - mMaxYear = bundle.getInt(KEY_YEAR_END); - currentView = bundle.getInt(KEY_CURRENT_VIEW); - listPosition = bundle.getInt(KEY_LIST_POSITION); - listPositionOffset = bundle.getInt(KEY_LIST_POSITION_OFFSET); - } - - Activity activity = getActivity(); - mDayPickerView = new DayPickerView(activity, this); - mYearPickerView = new YearPickerView(activity, this); - - mDayPickerDescription = "按月份划分的日期网格"; - mSelectDay = "选择月份和日期"; - mYearPickerDescription = "年份列表"; - mSelectYear = "选择年份"; - - mAnimator = ((AccessibleDateAnimator) view.findViewById(R.id.animator)); - mAnimator.addView(mDayPickerView); - mAnimator.addView(mYearPickerView); - mAnimator.setDateMillis(mCalendar.getTimeInMillis()); - - AlphaAnimation inAlphaAnimation = new AlphaAnimation(0.0F, 1.0F); - inAlphaAnimation.setDuration(300L); - mAnimator.setInAnimation(inAlphaAnimation); - - AlphaAnimation outAlphaAnimation = new AlphaAnimation(1.0F, 0.0F); - outAlphaAnimation.setDuration(300L); - mAnimator.setOutAnimation(outAlphaAnimation); - - mDoneButton = ((Button) view.findViewById(R.id.done)); - mDoneButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - onDoneButtonClick(); - } - }); - - updateDisplay(false); - setCurrentView(currentView, true); - - if (listPosition != -1) { - if (currentView == MONTH_AND_DAY_VIEW) { - mDayPickerView.postSetSelection(listPosition); - } - if (currentView == YEAR_VIEW) { - mYearPickerView.postSetSelectionFromTop(listPosition, - listPositionOffset); - } - } - return view; - } - - private void onDoneButtonClick() { - tryVibrate(); - if (mCallBack != null) { - mCallBack.onDateSet(this, mCalendar.get(Calendar.YEAR), - mCalendar.get(Calendar.MONTH), - mCalendar.get(Calendar.DAY_OF_MONTH)); - } - dismiss(); - } - - @Override - public void onDayOfMonthSelected(int year, int month, int day) { - mCalendar.set(Calendar.YEAR, year); - mCalendar.set(Calendar.MONTH, month); - mCalendar.set(Calendar.DAY_OF_MONTH, day); - updatePickers(); - updateDisplay(true); - - if (mCloseOnSingleTapDay) { - onDoneButtonClick(); - } - } - - @Override - public void onSaveInstanceState(Bundle bundle) { - super.onSaveInstanceState(bundle); - bundle.putInt(KEY_SELECTED_YEAR, mCalendar.get(Calendar.YEAR)); - bundle.putInt(KEY_SELECTED_MONTH, mCalendar.get(Calendar.MONTH)); - bundle.putInt(KEY_SELECTED_DAY, mCalendar.get(Calendar.DAY_OF_MONTH)); - bundle.putInt(KEY_WEEK_START, mWeekStart); - bundle.putInt(KEY_YEAR_START, mMinYear); - bundle.putInt(KEY_YEAR_END, mMaxYear); - bundle.putInt(KEY_CURRENT_VIEW, mCurrentView); - - int listPosition = -1; - if (mCurrentView == 0) { - listPosition = mDayPickerView.getMostVisiblePosition(); - } - if (mCurrentView == 1) { - listPosition = mYearPickerView.getFirstVisiblePosition(); - bundle.putInt(KEY_LIST_POSITION_OFFSET, - mYearPickerView.getFirstPositionOffset()); - } - bundle.putInt(KEY_LIST_POSITION, listPosition); - bundle.putBoolean(KEY_VIBRATE, mVibrate); - } - - @Override - public void onYearSelected(int year) { - adjustDayInMonthIfNeeded(mCalendar.get(Calendar.MONTH), year); - mCalendar.set(Calendar.YEAR, year); - updatePickers(); - setCurrentView(MONTH_AND_DAY_VIEW); - updateDisplay(true); - } - - @Override - public void registerOnDateChangedListener( - OnDateChangedListener onDateChangedListener) { - mListeners.add(onDateChangedListener); - } - - public void setFirstDayOfWeek(int startOfWeek) { - if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) { - throw new IllegalArgumentException( - "Value must be between Calendar.SUNDAY and " - + "Calendar.SATURDAY"); - } - mWeekStart = startOfWeek; - if (mDayPickerView != null) { - mDayPickerView.onChange(); - } - } - - public void setOnDateSetListener(OnDateSetListener onDateSetListener) { - mCallBack = onDateSetListener; - } - - public void setYearRange(int minYear, int maxYear) { - if (maxYear < minYear) - throw new IllegalArgumentException( - "Year end must be larger than year start"); - if (maxYear > MAX_YEAR) - throw new IllegalArgumentException("max year end must < " - + MAX_YEAR); - if (minYear < MIN_YEAR) - throw new IllegalArgumentException("min year end must > " - + MIN_YEAR); - mMinYear = minYear; - mMaxYear = maxYear; - if (mDayPickerView != null) - mDayPickerView.onChange(); - } - - @Override - public void tryVibrate() { - if (mVibrator != null && mVibrate) { - long timeInMillis = SystemClock.uptimeMillis(); - if (timeInMillis - mLastVibrate >= 125L) { - mVibrator.vibrate(5L); - mLastVibrate = timeInMillis; - } - } - } - - public void setCloseOnSingleTapDay(boolean closeOnSingleTapDay) { - mCloseOnSingleTapDay = closeOnSingleTapDay; - } - - static abstract interface OnDateChangedListener { - public abstract void onDateChanged(); - } - - public static abstract interface OnDateSetListener { - public abstract void onDateSet(DatePickerDialog datePickerDialog, - int year, int month, int day); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/DayPickerView.java b/app/src/main/java/com/fourmob/datetimepicker/date/DayPickerView.java deleted file mode 100644 index 495b7f20fbb3afd21008f5d9becf4c90ab7063a5..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/DayPickerView.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import android.annotation.TargetApi; -import android.content.Context; -import android.os.Build; -import android.os.Handler; -import android.view.View; -import android.view.ViewConfiguration; -import android.widget.AbsListView; -import android.widget.ListView; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class DayPickerView extends ListView implements - AbsListView.OnScrollListener, DatePickerDialog.OnDateChangedListener { - - protected static final int GOTO_SCROLL_DURATION = 250; - protected static final int SCROLL_CHANGE_DELAY = 40; - - public static int LIST_TOP_OFFSET = -1; - - protected Context mContext; - protected Handler mHandler = new Handler(); - - protected SimpleMonthAdapter mAdapter; - private final DatePickerController mController; - - protected int mCurrentMonthDisplayed; - protected int mCurrentScrollState = 0; - private boolean mPerformingScroll; - protected long mPreviousScrollPosition; - protected int mPreviousScrollState = 0; - - protected ScrollStateRunnable mScrollStateChangedRunnable = new ScrollStateRunnable(); - protected SimpleMonthAdapter.CalendarDay mSelectedDay = new SimpleMonthAdapter.CalendarDay(); - protected SimpleMonthAdapter.CalendarDay mTempDay = new SimpleMonthAdapter.CalendarDay(); - - protected int mNumWeeks = 6; - protected boolean mShowWeekNumber = false; - protected int mDaysPerWeek = 7; - - protected float mFriction = 1.0F; - - public DayPickerView(Context context, - DatePickerController datePickerController) { - super(context); - mController = datePickerController; - mController.registerOnDateChangedListener(this); - setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, - LayoutParams.MATCH_PARENT)); - setDrawSelectorOnTop(false); - init(context); - onDateChanged(); - } - - public int getMostVisiblePosition() { - final int firstPosition = getFirstVisiblePosition(); - final int height = getHeight(); - - int maxDisplayedHeight = 0; - int mostVisibleIndex = 0; - int i = 0; - int bottom = 0; - while (bottom < height) { - View child = getChildAt(i); - if (child == null) { - break; - } - bottom = child.getBottom(); - int displayedHeight = Math.min(bottom, height) - - Math.max(0, child.getTop()); - if (displayedHeight > maxDisplayedHeight) { - mostVisibleIndex = i; - maxDisplayedHeight = displayedHeight; - } - i++; - } - return firstPosition + mostVisibleIndex; - } - - public boolean goTo(SimpleMonthAdapter.CalendarDay day, boolean animate, - boolean setSelected, boolean forceScroll) { - // Set the selected day - if (setSelected) { - mSelectedDay.set(day); - } - - mTempDay.set(day); - final int position = (day.year - mController.getMinYear()) - * SimpleMonthAdapter.MONTHS_IN_YEAR + day.month; - - View child; - int i = 0; - int top = 0; - // Find a child that's completely in the view - do { - child = getChildAt(i++); - if (child == null) { - break; - } - top = child.getTop(); - } while (top < 0); - - // Compute the first and last position visible - int selectedPosition; - if (child != null) { - selectedPosition = getPositionForView(child); - } else { - selectedPosition = 0; - } - - if (setSelected) { - mAdapter.setSelectedDay(mSelectedDay); - } - - // Check if the selected day is now outside of our visible range - // and if so scroll to the month that contains it - if (position != selectedPosition || forceScroll) { - setMonthDisplayed(mTempDay); - mPreviousScrollState = OnScrollListener.SCROLL_STATE_FLING; - if (animate && Build.VERSION.SDK_INT >= 11) { - smoothScrollToPositionFromTop(position, LIST_TOP_OFFSET, - GOTO_SCROLL_DURATION); - return true; - } else { - postSetSelection(position); - } - } else if (setSelected) { - setMonthDisplayed(mSelectedDay); - } - return false; - } - - public void init(Context paramContext) { - mContext = paramContext; - setUpListView(); - setUpAdapter(); - setAdapter(mAdapter); - } - - @Override - protected void layoutChildren() { - super.layoutChildren(); - if (mPerformingScroll) { - mPerformingScroll = false; - } - } - - public void onChange() { - setUpAdapter(); - setAdapter(mAdapter); - } - - @Override - public void onDateChanged() { - goTo(mController.getSelectedDay(), false, true, true); - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, - int visibleItemCount, int totalItemCount) { - SimpleMonthView child = (SimpleMonthView) view.getChildAt(0); - if (child == null) { - return; - } - - // Figure out where we are - long currScroll = view.getFirstVisiblePosition() * child.getHeight() - - child.getBottom(); - mPreviousScrollPosition = currScroll; - mPreviousScrollState = mCurrentScrollState; - } - - @Override - public void onScrollStateChanged(AbsListView absListView, int scroll) { - mScrollStateChangedRunnable.doScrollStateChange(absListView, scroll); - } - - public void postSetSelection(final int position) { - clearFocus(); - post(new Runnable() { - @Override - public void run() { - DayPickerView.this.setSelection(position); - } - }); - onScrollStateChanged(this, 0); - } - - protected void setMonthDisplayed(SimpleMonthAdapter.CalendarDay calendarDay) { - this.mCurrentMonthDisplayed = calendarDay.month; - invalidateViews(); - } - - protected void setUpAdapter() { - if (mAdapter == null) { - mAdapter = new SimpleMonthAdapter(getContext(), mController); - } - mAdapter.setSelectedDay(this.mSelectedDay); - mAdapter.notifyDataSetChanged(); - } - - protected void setUpListView() { - setCacheColorHint(0); - setDivider(null); - setItemsCanFocus(true); - setFastScrollEnabled(false); - setVerticalScrollBarEnabled(false); - setOnScrollListener(this); - setFadingEdgeLength(0); - setFrictionIfSupported(ViewConfiguration.getScrollFriction() - * mFriction); - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - void setFrictionIfSupported(float friction) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { - setFriction(friction); - } - } - - protected class ScrollStateRunnable implements Runnable { - private int mNewState; - - /** - * Sets up the runnable with a short delay in case the scroll state - * immediately changes again. - * - * @param view - * The list view that changed state - * @param scrollState - * The new state it changed to - */ - public void doScrollStateChange(AbsListView view, int scrollState) { - mHandler.removeCallbacks(this); - mNewState = scrollState; - mHandler.postDelayed(this, SCROLL_CHANGE_DELAY); - } - - @Override - public void run() { - mCurrentScrollState = mNewState; - // Fix the position after a scroll or a fling ends - if (mNewState == OnScrollListener.SCROLL_STATE_IDLE - && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE - && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { - mPreviousScrollState = mNewState; - int i = 0; - View child = getChildAt(i); - while (child != null && child.getBottom() <= 0) { - child = getChildAt(++i); - } - if (child == null) { - // The view is no longer visible, just return - return; - } - int firstPosition = getFirstVisiblePosition(); - int lastPosition = getLastVisiblePosition(); - boolean scroll = firstPosition != 0 - && lastPosition != getCount() - 1; - final int top = child.getTop(); - final int bottom = child.getBottom(); - final int midpoint = getHeight() / 2; - if (scroll && top < LIST_TOP_OFFSET) { - if (bottom > midpoint) { - smoothScrollBy(top, GOTO_SCROLL_DURATION); - } else { - smoothScrollBy(bottom, GOTO_SCROLL_DURATION); - } - } - } else { - mPreviousScrollState = mNewState; - } - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthAdapter.java b/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthAdapter.java deleted file mode 100644 index b46aec39f6f69e7354a851ac04a82e2400242860..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthAdapter.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import java.util.Calendar; -import java.util.HashMap; - -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewGroup.LayoutParams; -import android.widget.AbsListView; -import android.widget.BaseAdapter; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class SimpleMonthAdapter extends BaseAdapter implements - SimpleMonthView.OnDayClickListener { - - protected static int WEEK_7_OVERHANG_HEIGHT = 7; - protected static final int MONTHS_IN_YEAR = 12; - - private final Context mContext; - private final DatePickerController mController; - - private CalendarDay mSelectedDay; - - public SimpleMonthAdapter(Context context, - DatePickerController datePickerController) { - mContext = context; - mController = datePickerController; - init(); - setSelectedDay(mController.getSelectedDay()); - } - - private boolean isSelectedDayInMonth(int year, int month) { - return (mSelectedDay.year == year) && (mSelectedDay.month == month); - } - - @Override - public int getCount() { - return ((mController.getMaxYear() - mController.getMinYear()) + 1) - * MONTHS_IN_YEAR; - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - SimpleMonthView v; - HashMap drawingParams = null; - if (convertView != null) { - v = (SimpleMonthView) convertView; - drawingParams = (HashMap) v.getTag(); - } else { - v = new SimpleMonthView(mContext); - v.setLayoutParams(new AbsListView.LayoutParams( - LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); - v.setClickable(true); - v.setOnDayClickListener(this); - } - if (drawingParams == null) { - drawingParams = new HashMap(); - } - drawingParams.clear(); - - final int month = position % MONTHS_IN_YEAR; - final int year = position / MONTHS_IN_YEAR + mController.getMinYear(); - - int selectedDay = -1; - if (isSelectedDayInMonth(year, month)) { - selectedDay = mSelectedDay.day; - } - - v.reuse(); - - drawingParams - .put(SimpleMonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay); - drawingParams.put(SimpleMonthView.VIEW_PARAMS_YEAR, year); - drawingParams.put(SimpleMonthView.VIEW_PARAMS_MONTH, month); - drawingParams.put(SimpleMonthView.VIEW_PARAMS_WEEK_START, - mController.getFirstDayOfWeek()); - v.setMonthParams(drawingParams); - v.invalidate(); - - return v; - } - - protected void init() { - mSelectedDay = new CalendarDay(System.currentTimeMillis()); - } - - @Override - public void onDayClick(SimpleMonthView simpleMonthView, - CalendarDay calendarDay) { - if (calendarDay != null) { - onDayTapped(calendarDay); - } - } - - protected void onDayTapped(CalendarDay calendarDay) { - mController.tryVibrate(); - mController.onDayOfMonthSelected(calendarDay.year, calendarDay.month, - calendarDay.day); - setSelectedDay(calendarDay); - } - - public void setSelectedDay(CalendarDay calendarDay) { - mSelectedDay = calendarDay; - notifyDataSetChanged(); - } - - public static class CalendarDay { - private Calendar calendar; - - int day; - int month; - int year; - - public CalendarDay() { - setTime(System.currentTimeMillis()); - } - - public CalendarDay(int year, int month, int day) { - setDay(year, month, day); - } - - public CalendarDay(long timeInMillis) { - setTime(timeInMillis); - } - - public CalendarDay(Calendar calendar) { - year = calendar.get(Calendar.YEAR); - month = calendar.get(Calendar.MONTH); - day = calendar.get(Calendar.DAY_OF_MONTH); - } - - private void setTime(long timeInMillis) { - if (calendar == null) { - calendar = Calendar.getInstance(); - } - calendar.setTimeInMillis(timeInMillis); - month = this.calendar.get(Calendar.MONTH); - year = this.calendar.get(Calendar.YEAR); - day = this.calendar.get(Calendar.DAY_OF_MONTH); - } - - public void set(CalendarDay calendarDay) { - year = calendarDay.year; - month = calendarDay.month; - day = calendarDay.day; - } - - public void setDay(int year, int month, int day) { - this.year = year; - this.month = month; - this.day = day; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthView.java b/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthView.java deleted file mode 100644 index 02cd291ae2dc166fd2d2643eae652f66208b3dfb..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/SimpleMonthView.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import java.security.InvalidParameterException; -import java.text.DateFormatSymbols; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Locale; - -import net.oschina.app.R; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Paint.Align; -import android.graphics.Paint.Style; -import android.graphics.Typeface; -import android.text.format.DateUtils; -import android.text.format.Time; -import android.view.MotionEvent; -import android.view.View; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class SimpleMonthView extends View { - - public static final String VIEW_PARAMS_HEIGHT = "height"; - public static final String VIEW_PARAMS_MONTH = "month"; - public static final String VIEW_PARAMS_YEAR = "year"; - public static final String VIEW_PARAMS_SELECTED_DAY = "selected_day"; - public static final String VIEW_PARAMS_WEEK_START = "week_start"; - public static final String VIEW_PARAMS_NUM_DAYS = "num_days"; - public static final String VIEW_PARAMS_FOCUS_MONTH = "focus_month"; - public static final String VIEW_PARAMS_SHOW_WK_NUM = "show_wk_num"; - - private static final int SELECTED_CIRCLE_ALPHA = 60; - protected static int DEFAULT_HEIGHT = 32; - protected static final int DEFAULT_NUM_ROWS = 6; - protected static int DAY_SELECTED_CIRCLE_SIZE; - protected static int DAY_SEPARATOR_WIDTH = 1; - protected static int MINI_DAY_NUMBER_TEXT_SIZE; - protected static int MIN_HEIGHT = 10; - protected static int MONTH_DAY_LABEL_TEXT_SIZE; - protected static int MONTH_HEADER_SIZE; - protected static int MONTH_LABEL_TEXT_SIZE; - - protected static float mScale = 0.0F; - protected int mPadding = 0; - - private final String mDayOfWeekTypeface; - private final String mMonthTitleTypeface; - - protected Paint mMonthDayLabelPaint; - protected Paint mMonthNumPaint; - protected Paint mMonthTitleBGPaint; - protected Paint mMonthTitlePaint; - protected Paint mSelectedCirclePaint; - protected int mDayTextColor; - protected int mMonthTitleBGColor; - protected int mMonthTitleColor; - protected int mTodayNumberColor; - - private final StringBuilder mStringBuilder; - - protected int mFirstJulianDay = -1; - protected int mFirstMonth = -1; - protected int mLastMonth = -1; - protected boolean mHasToday = false; - protected int mSelectedDay = -1; - protected int mToday = -1; - protected int mWeekStart = 1; - protected int mNumDays = 7; - protected int mNumCells = mNumDays; - protected int mSelectedLeft = -1; - protected int mSelectedRight = -1; - private int mDayOfWeekStart = 0; - protected int mMonth; - protected int mRowHeight = DEFAULT_HEIGHT; - protected int mWidth; - protected int mYear; - - private final Calendar mCalendar; - private final Calendar mDayLabelCalendar; - - private int mNumRows = DEFAULT_NUM_ROWS; - - private final DateFormatSymbols mDateFormatSymbols = new DateFormatSymbols(); - - private OnDayClickListener mOnDayClickListener; - - public SimpleMonthView(Context context) { - super(context); - Resources resources = context.getResources(); - mDayLabelCalendar = Calendar.getInstance(); - mCalendar = Calendar.getInstance(); - - mDayOfWeekTypeface = "sans-serif"; - mMonthTitleTypeface = "sans-serif"; - mDayTextColor = resources.getColor(R.color.date_picker_text_normal); - mTodayNumberColor = resources.getColor(R.color.blue); - mMonthTitleColor = resources.getColor(R.color.white); - mMonthTitleBGColor = resources.getColor(R.color.circle_background); - - mStringBuilder = new StringBuilder(50); - - MINI_DAY_NUMBER_TEXT_SIZE = resources - .getDimensionPixelSize(R.dimen.day_number_size); - MONTH_LABEL_TEXT_SIZE = resources - .getDimensionPixelSize(R.dimen.month_label_size); - MONTH_DAY_LABEL_TEXT_SIZE = resources - .getDimensionPixelSize(R.dimen.month_day_label_text_size); - MONTH_HEADER_SIZE = resources - .getDimensionPixelOffset(R.dimen.month_list_item_header_height); - DAY_SELECTED_CIRCLE_SIZE = resources - .getDimensionPixelSize(R.dimen.day_number_select_circle_radius); - - mRowHeight = ((resources - .getDimensionPixelOffset(R.dimen.date_picker_view_animator_height) - MONTH_HEADER_SIZE) / 6); - - initView(); - } - - private int calculateNumRows() { - int offset = findDayOffset(); - int dividend = (offset + mNumCells) / mNumDays; - int remainder = (offset + mNumCells) % mNumDays; - return (dividend + (remainder > 0 ? 1 : 0)); - } - - private void drawMonthDayLabels(Canvas canvas) { - int y = MONTH_HEADER_SIZE - (MONTH_DAY_LABEL_TEXT_SIZE / 2); - int dayWidthHalf = (mWidth - mPadding * 2) / (mNumDays * 2); - - for (int i = 0; i < mNumDays; i++) { - int calendarDay = (i + mWeekStart) % mNumDays; - int x = (2 * i + 1) * dayWidthHalf + mPadding; - mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); - canvas.drawText( - mDateFormatSymbols.getShortWeekdays()[mDayLabelCalendar - .get(Calendar.DAY_OF_WEEK)].toUpperCase(Locale - .getDefault()), x, y, mMonthDayLabelPaint); - } - } - - private void drawMonthTitle(Canvas canvas) { - int x = (mWidth + 2 * mPadding) / 2; - int y = (MONTH_HEADER_SIZE - MONTH_DAY_LABEL_TEXT_SIZE) / 2 - + (MONTH_LABEL_TEXT_SIZE / 3); - canvas.drawText(getMonthAndYearString(), x, y, mMonthTitlePaint); - } - - private int findDayOffset() { - return (mDayOfWeekStart < mWeekStart ? (mDayOfWeekStart + mNumDays) - : mDayOfWeekStart) - mWeekStart; - } - - private String getMonthAndYearString() { - int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR - | DateUtils.FORMAT_NO_MONTH_DAY; - mStringBuilder.setLength(0); - long millis = mCalendar.getTimeInMillis(); - return DateUtils.formatDateRange(getContext(), millis, millis, flags); - } - - private void onDayClick(SimpleMonthAdapter.CalendarDay calendarDay) { - if (mOnDayClickListener != null) { - mOnDayClickListener.onDayClick(this, calendarDay); - } - } - - private boolean sameDay(int monthDay, Time time) { - return (mYear == time.year) && (mMonth == time.month) - && (monthDay == time.monthDay); - } - - protected void drawMonthNums(Canvas canvas) { - int y = (mRowHeight + MINI_DAY_NUMBER_TEXT_SIZE) / 2 - - DAY_SEPARATOR_WIDTH + MONTH_HEADER_SIZE; - int paddingDay = (mWidth - 2 * mPadding) / (2 * mNumDays); - int dayOffset = findDayOffset(); - int day = 1; - - while (day <= mNumCells) { - int x = paddingDay * (1 + dayOffset * 2) + mPadding; - if (mSelectedDay == day) { - canvas.drawCircle(x, y - MINI_DAY_NUMBER_TEXT_SIZE / 3, - DAY_SELECTED_CIRCLE_SIZE, mSelectedCirclePaint); - } - if (mHasToday && (mToday == day)) { - mMonthNumPaint.setColor(mTodayNumberColor); - } else { - mMonthNumPaint.setColor(mDayTextColor); - } - - canvas.drawText(String.format("%d", day), x, y, mMonthNumPaint); - - dayOffset++; - if (dayOffset == mNumDays) { - dayOffset = 0; - y += mRowHeight; - } - day++; - } - } - - public SimpleMonthAdapter.CalendarDay getDayFromLocation(float x, float y) { - int padding = mPadding; - if ((x < padding) || (x > mWidth - mPadding)) { - return null; - } - - int yDay = (int) (y - MONTH_HEADER_SIZE) / mRowHeight; - int day = 1 - + ((int) ((x - padding) * mNumDays / (mWidth - padding - mPadding)) - findDayOffset()) - + yDay * mNumDays; - - return new SimpleMonthAdapter.CalendarDay(mYear, mMonth, day); - } - - protected void initView() { - mMonthTitlePaint = new Paint(); - mMonthTitlePaint.setFakeBoldText(true); - mMonthTitlePaint.setAntiAlias(true); - mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE); - mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, - Typeface.BOLD)); - mMonthTitlePaint.setColor(mDayTextColor); - mMonthTitlePaint.setTextAlign(Align.CENTER); - mMonthTitlePaint.setStyle(Style.FILL); - - mMonthTitleBGPaint = new Paint(); - mMonthTitleBGPaint.setFakeBoldText(true); - mMonthTitleBGPaint.setAntiAlias(true); - mMonthTitleBGPaint.setColor(mMonthTitleBGColor); - mMonthTitleBGPaint.setTextAlign(Align.CENTER); - mMonthTitleBGPaint.setStyle(Style.FILL); - - mSelectedCirclePaint = new Paint(); - mSelectedCirclePaint.setFakeBoldText(true); - mSelectedCirclePaint.setAntiAlias(true); - mSelectedCirclePaint.setColor(mTodayNumberColor); - mSelectedCirclePaint.setTextAlign(Align.CENTER); - mSelectedCirclePaint.setStyle(Style.FILL); - mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA); - - mMonthDayLabelPaint = new Paint(); - mMonthDayLabelPaint.setAntiAlias(true); - mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE); - mMonthDayLabelPaint.setColor(mDayTextColor); - mMonthDayLabelPaint.setTypeface(Typeface.create(mDayOfWeekTypeface, - Typeface.NORMAL)); - mMonthDayLabelPaint.setStyle(Style.FILL); - mMonthDayLabelPaint.setTextAlign(Align.CENTER); - mMonthDayLabelPaint.setFakeBoldText(true); - - mMonthNumPaint = new Paint(); - mMonthNumPaint.setAntiAlias(true); - mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE); - mMonthNumPaint.setStyle(Style.FILL); - mMonthNumPaint.setTextAlign(Align.CENTER); - mMonthNumPaint.setFakeBoldText(false); - } - - @Override - protected void onDraw(Canvas canvas) { - drawMonthTitle(canvas); - drawMonthDayLabels(canvas); - drawMonthNums(canvas); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), - mRowHeight * mNumRows + MONTH_HEADER_SIZE); - } - - @Override - protected void onSizeChanged(int w, int h, int oldw, int oldh) { - mWidth = w; - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_UP) { - SimpleMonthAdapter.CalendarDay calendarDay = getDayFromLocation( - event.getX(), event.getY()); - if (calendarDay != null) { - onDayClick(calendarDay); - } - } - return true; - } - - public void reuse() { - mNumRows = DEFAULT_NUM_ROWS; - requestLayout(); - } - - public void setMonthParams(HashMap params) { - if (!params.containsKey(VIEW_PARAMS_MONTH) - && !params.containsKey(VIEW_PARAMS_YEAR)) { - throw new InvalidParameterException( - "You must specify month and year for this view"); - } - setTag(params); - - if (params.containsKey(VIEW_PARAMS_HEIGHT)) { - mRowHeight = params.get(VIEW_PARAMS_HEIGHT); - if (mRowHeight < MIN_HEIGHT) { - mRowHeight = MIN_HEIGHT; - } - } - if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) { - mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY); - } - - mMonth = params.get(VIEW_PARAMS_MONTH); - mYear = params.get(VIEW_PARAMS_YEAR); - - final Time today = new Time(Time.getCurrentTimezone()); - today.setToNow(); - mHasToday = false; - mToday = -1; - - mCalendar.set(Calendar.MONTH, mMonth); - mCalendar.set(Calendar.YEAR, mYear); - mCalendar.set(Calendar.DAY_OF_MONTH, 1); - mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK); - - if (params.containsKey(VIEW_PARAMS_WEEK_START)) { - mWeekStart = params.get(VIEW_PARAMS_WEEK_START); - } else { - mWeekStart = mCalendar.getFirstDayOfWeek(); - } - - mNumCells = Utils.getDaysInMonth(mMonth, mYear); - for (int i = 0; i < mNumCells; i++) { - final int day = i + 1; - if (sameDay(day, today)) { - mHasToday = true; - mToday = day; - } - } - - mNumRows = calculateNumRows(); - } - - public void setOnDayClickListener(OnDayClickListener onDayClickListener) { - mOnDayClickListener = onDayClickListener; - } - - public static abstract interface OnDayClickListener { - public abstract void onDayClick(SimpleMonthView simpleMonthView, - SimpleMonthAdapter.CalendarDay calendarDay); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/TextViewWithCircularIndicator.java b/app/src/main/java/com/fourmob/datetimepicker/date/TextViewWithCircularIndicator.java deleted file mode 100644 index 5f355d201cbea137ea343fcc6d828e9b41e61b00..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/TextViewWithCircularIndicator.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import net.oschina.app.R; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.util.AttributeSet; -import android.widget.TextView; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class TextViewWithCircularIndicator extends TextView { - - private final int mCircleColor; - private final Paint mCirclePaint = new Paint(); - private boolean mDrawCircle; - private final String mItemIsSelectedText; - - public TextViewWithCircularIndicator(Context context, - AttributeSet attributeSet) { - super(context, attributeSet); - - Resources res = context.getResources(); - mCircleColor = res.getColor(R.color.blue); - mItemIsSelectedText = "已选择"; - - init(); - } - - private void init() { - mCirclePaint.setFakeBoldText(true); - mCirclePaint.setAntiAlias(true); - mCirclePaint.setColor(mCircleColor); - mCirclePaint.setTextAlign(Paint.Align.CENTER); - mCirclePaint.setStyle(Paint.Style.FILL); - mCirclePaint.setAlpha(60); - } - - public void drawIndicator(boolean drawIndicator) { - mDrawCircle = drawIndicator; - } - - @Override - public CharSequence getContentDescription() { - CharSequence text = getText(); - if (mDrawCircle) { - text = String.format(mItemIsSelectedText, text); - } - return text; - } - - @Override - public void onDraw(Canvas canvas) { - super.onDraw(canvas); - if (mDrawCircle) { - int width = getWidth(); - int heigth = getHeight(); - int radius = Math.min(width, heigth) / 2; - canvas.drawCircle(width / 2, heigth / 2, radius, mCirclePaint); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/Utils.java b/app/src/main/java/com/fourmob/datetimepicker/date/Utils.java deleted file mode 100644 index d70d427c9953116c01d9f0f34c21a5713163ac47..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/Utils.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import java.util.Calendar; - -import android.annotation.SuppressLint; -import android.os.Build; -import android.view.View; -import android.view.accessibility.AccessibilityManager; - -import com.nineoldandroids.animation.Keyframe; -import com.nineoldandroids.animation.ObjectAnimator; -import com.nineoldandroids.animation.PropertyValuesHolder; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class Utils { - - public static final int PULSE_ANIMATOR_DURATION = 544; - - public static int getDaysInMonth(int month, int year) { - switch (month) { - case Calendar.JANUARY: - case Calendar.MARCH: - case Calendar.MAY: - case Calendar.JULY: - case Calendar.AUGUST: - case Calendar.OCTOBER: - case Calendar.DECEMBER: - return 31; - case Calendar.APRIL: - case Calendar.JUNE: - case Calendar.SEPTEMBER: - case Calendar.NOVEMBER: - return 30; - case Calendar.FEBRUARY: - return (year % 4 == 0) ? 29 : 28; - default: - throw new IllegalArgumentException("Invalid Month"); - } - } - - public static ObjectAnimator getPulseAnimator(View labelToAnimate, - float decreaseRatio, float increaseRatio) { - Keyframe k0 = Keyframe.ofFloat(0f, 1f); - Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio); - Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio); - Keyframe k3 = Keyframe.ofFloat(1f, 1f); - - PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", - k0, k1, k2, k3); - PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", - k0, k1, k2, k3); - ObjectAnimator pulseAnimator = ObjectAnimator.ofPropertyValuesHolder( - labelToAnimate, scaleX, scaleY); - pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION); - - return pulseAnimator; - } - - public static boolean isJellybeanOrLater() { - return Build.VERSION.SDK_INT >= 16; - } - - /** - * Try to speak the specified text, for accessibility. Only available on JB - * or later. - * - * @param text - * Text to announce. - */ - @SuppressLint("NewApi") - public static void tryAccessibilityAnnounce(View view, CharSequence text) { - if (isJellybeanOrLater() && view != null && text != null) { - view.announceForAccessibility(text); - } - } - - public static boolean isTouchExplorationEnabled( - AccessibilityManager accessibilityManager) { - if (Build.VERSION.SDK_INT >= 14) { - return accessibilityManager.isTouchExplorationEnabled(); - } else { - return false; - } - } -} diff --git a/app/src/main/java/com/fourmob/datetimepicker/date/YearPickerView.java b/app/src/main/java/com/fourmob/datetimepicker/date/YearPickerView.java deleted file mode 100644 index a971fe4ec957fa206fd62de83fa038d67ac9247a..0000000000000000000000000000000000000000 --- a/app/src/main/java/com/fourmob/datetimepicker/date/YearPickerView.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.fourmob.datetimepicker.date; - -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.R; -import android.content.Context; -import android.content.res.Resources; -import android.graphics.drawable.StateListDrawable; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.ListView; -import android.widget.TextView; - -/** - * 摘取自https://github.com/flavienlaurent/datetimepicker - * - * @author kymjs - * - */ -public class YearPickerView extends ListView implements - AdapterView.OnItemClickListener, DatePickerDialog.OnDateChangedListener { - - private YearAdapter mAdapter; - private final int mChildSize; - private final DatePickerController mController; - private TextViewWithCircularIndicator mSelectedView; - private final int mViewSize; - - public YearPickerView(Context context, - DatePickerController datePickerController) { - super(context); - mController = datePickerController; - mController.registerOnDateChangedListener(this); - - setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, - LayoutParams.WRAP_CONTENT)); - - Resources resources = context.getResources(); - mViewSize = resources - .getDimensionPixelOffset(R.dimen.date_picker_view_animator_height); - mChildSize = resources - .getDimensionPixelOffset(R.dimen.year_label_height); - - setVerticalFadingEdgeEnabled(true); - setFadingEdgeLength(mChildSize / 3); - init(context); - setOnItemClickListener(this); - setSelector(new StateListDrawable()); - setDividerHeight(0); - onDateChanged(); - } - - private static int getYearFromTextView(TextView view) { - return Integer.valueOf(view.getText().toString()); - } - - private void init(Context context) { - ArrayList years = new ArrayList(); - for (int year = mController.getMinYear(); year <= mController - .getMaxYear(); year++) { - years.add(String.format("%d", year)); - } - mAdapter = new YearAdapter(context, R.layout.year_label_text_view, - years); - setAdapter(mAdapter); - } - - public int getFirstPositionOffset() { - final View firstChild = getChildAt(0); - if (firstChild == null) { - return 0; - } - return firstChild.getTop(); - } - - @Override - public void onDateChanged() { - mAdapter.notifyDataSetChanged(); - postSetSelectionCentered(mController.getSelectedDay().year - - mController.getMinYear()); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - mController.tryVibrate(); - TextViewWithCircularIndicator clickedView = (TextViewWithCircularIndicator) view; - if (clickedView != null) { - if (clickedView != mSelectedView) { - if (mSelectedView != null) { - mSelectedView.drawIndicator(false); - mSelectedView.requestLayout(); - } - clickedView.drawIndicator(true); - clickedView.requestLayout(); - mSelectedView = clickedView; - } - mController.onYearSelected(getYearFromTextView(clickedView)); - mAdapter.notifyDataSetChanged(); - } - } - - public void postSetSelectionCentered(int position) { - postSetSelectionFromTop(position, mViewSize / 2 - mChildSize / 2); - } - - public void postSetSelectionFromTop(final int position, final int y) { - post(new Runnable() { - @Override - public void run() { - setSelectionFromTop(position, y); - requestLayout(); - } - }); - } - - private class YearAdapter extends ArrayAdapter { - - public YearAdapter(Context context, int resource, List years) { - super(context, resource, years); - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - TextViewWithCircularIndicator v = (TextViewWithCircularIndicator) super - .getView(position, convertView, parent); - v.requestLayout(); - int year = getYearFromTextView(v); - boolean selected = mController.getSelectedDay().year == year; - v.drawIndicator(selected); - if (selected) { - mSelectedView = v; - } - return v; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/AppConfig.java b/app/src/main/java/net/oschina/app/AppConfig.java deleted file mode 100644 index f6cf28166feb3c74019c7742fda10bb67fce9623..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/AppConfig.java +++ /dev/null @@ -1,146 +0,0 @@ -package net.oschina.app; - -import android.content.Context; -import android.content.SharedPreferences; -import android.os.Environment; -import android.preference.PreferenceManager; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.Properties; - -/** - * 应用程序配置类:用于保存用户相关信息及设置 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月25日 下午5:29:00 - * - */ -public class AppConfig { - - private final static String APP_CONFIG = "config"; - - public final static String CONF_COOKIE = "cookie"; - - public final static String CONF_APP_UNIQUEID = "APP_UNIQUEID"; - - public static final String KEY_LOAD_IMAGE = "KEY_LOAD_IMAGE"; - public static final String KEY_NOTIFICATION_ACCEPT = "KEY_NOTIFICATION_ACCEPT"; - public static final String KEY_NOTIFICATION_SOUND = "KEY_NOTIFICATION_SOUND"; - public static final String KEY_NOTIFICATION_VIBRATION = "KEY_NOTIFICATION_VIBRATION"; - public static final String KEY_NOTIFICATION_DISABLE_WHEN_EXIT = "KEY_NOTIFICATION_DISABLE_WHEN_EXIT"; - public static final String KEY_CHECK_UPDATE = "KEY_CHECK_UPDATE"; - public static final String KEY_DOUBLE_CLICK_EXIT = "KEY_DOUBLE_CLICK_EXIT"; - - public static final String KEY_TWEET_DRAFT = "KEY_TWEET_DRAFT"; - public static final String KEY_NOTE_DRAFT = "KEY_NOTE_DRAFT"; - - public static final String KEY_FRITST_START = "KEY_FRIST_START"; - - public static final String KEY_NIGHT_MODE_SWITCH="night_mode_switch"; - - public static final String APP_QQ_KEY = "100942993"; - - // 默认存放图片的路径 - public final static String DEFAULT_SAVE_IMAGE_PATH = Environment - .getExternalStorageDirectory() - + File.separator - + "OSChina" - + File.separator + "osc_img" + File.separator; - - // 默认存放文件下载的路径 - public final static String DEFAULT_SAVE_FILE_PATH = Environment - .getExternalStorageDirectory() - + File.separator - + "OSChina" - + File.separator + "download" + File.separator; - - private Context mContext; - private static AppConfig appConfig; - - public static AppConfig getAppConfig(Context context) { - if (appConfig == null) { - appConfig = new AppConfig(); - appConfig.mContext = context; - } - return appConfig; - } - - /** - * 获取Preference设置 - */ - public static SharedPreferences getSharedPreferences(Context context) { - return PreferenceManager.getDefaultSharedPreferences(context); - } - - public String get(String key) { - Properties props = get(); - return (props != null) ? props.getProperty(key) : null; - } - - public Properties get() { - FileInputStream fis = null; - Properties props = new Properties(); - try { - // 读取files目录下的config - // fis = activity.openFileInput(APP_CONFIG); - - // 读取app_config目录下的config - File dirConf = mContext.getDir(APP_CONFIG, Context.MODE_PRIVATE); - fis = new FileInputStream(dirConf.getPath() + File.separator - + APP_CONFIG); - - props.load(fis); - } catch (Exception e) { - } finally { - try { - fis.close(); - } catch (Exception e) { - } - } - return props; - } - - private void setProps(Properties p) { - FileOutputStream fos = null; - try { - // 把config建在files目录下 - // fos = activity.openFileOutput(APP_CONFIG, Context.MODE_PRIVATE); - - // 把config建在(自定义)app_config的目录下 - File dirConf = mContext.getDir(APP_CONFIG, Context.MODE_PRIVATE); - File conf = new File(dirConf, APP_CONFIG); - fos = new FileOutputStream(conf); - - p.store(fos, null); - fos.flush(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - fos.close(); - } catch (Exception e) { - } - } - } - - public void set(Properties ps) { - Properties props = get(); - props.putAll(ps); - setProps(props); - } - - public void set(String key, String value) { - Properties props = get(); - props.setProperty(key, value); - setProps(props); - } - - public void remove(String... key) { - Properties props = get(); - for (String k : key) - props.remove(k); - setProps(props); - } -} diff --git a/app/src/main/java/net/oschina/app/AppContext.java b/app/src/main/java/net/oschina/app/AppContext.java deleted file mode 100644 index f79b7c3a05224195f559f695d519bfd919257611..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/AppContext.java +++ /dev/null @@ -1,347 +0,0 @@ -package net.oschina.app; - -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager.NameNotFoundException; - -import com.loopj.android.http.AsyncHttpClient; -import com.loopj.android.http.PersistentCookieStore; - -import net.oschina.app.api.ApiHttpClient; -import net.oschina.app.base.BaseApplication; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.User; -import net.oschina.app.cache.DataCleanManager; -import net.oschina.app.util.CyptoUtils; -import net.oschina.app.util.MethodsCompat; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TLog; -import net.oschina.app.util.UIHelper; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.http.HttpConfig; -import org.kymjs.kjframe.utils.KJLoger; - -import java.util.Properties; -import java.util.UUID; - -import static net.oschina.app.AppConfig.KEY_FRITST_START; -import static net.oschina.app.AppConfig.KEY_LOAD_IMAGE; -import static net.oschina.app.AppConfig.KEY_NIGHT_MODE_SWITCH; -import static net.oschina.app.AppConfig.KEY_TWEET_DRAFT; - -/** - * 全局应用程序类:用于保存和调用全局应用配置及访问网络数据 - * - * @author 火蚁 (http://my.oschina.net/LittleDY) - * @version 1.0 - * @created 2014-04-22 - */ -public class AppContext extends BaseApplication { - - public static final int PAGE_SIZE = 20;// 默认分页大小 - - private static AppContext instance; - - private int loginUid; - - private boolean login; - - @Override - public void onCreate() { - super.onCreate(); - instance = this; - init(); - initLogin(); - -// Thread.setDefaultUncaughtExceptionHandler(AppException -// .getAppExceptionHandler(this)); - UIHelper.sendBroadcastForNotice(this); - } - - private void init() { - // 初始化网络请求 - AsyncHttpClient client = new AsyncHttpClient(); - PersistentCookieStore myCookieStore = new PersistentCookieStore(this); - client.setCookieStore(myCookieStore); - ApiHttpClient.setHttpClient(client); - ApiHttpClient.setCookie(ApiHttpClient.getCookie(this)); - - // Log控制器 - KJLoger.openDebutLog(true); - TLog.DEBUG = BuildConfig.DEBUG; - - // Bitmap缓存地址 - HttpConfig.CACHEPATH = "OSChina/imagecache"; - } - - private void initLogin() { - User user = getLoginUser(); - if (null != user && user.getId() > 0) { - login = true; - loginUid = user.getId(); - } else { - this.cleanLoginInfo(); - } - } - - /** - * 获得当前app运行的AppContext - * - * @return - */ - public static AppContext getInstance() { - return instance; - } - - public boolean containsProperty(String key) { - Properties props = getProperties(); - return props.containsKey(key); - } - - public void setProperties(Properties ps) { - AppConfig.getAppConfig(this).set(ps); - } - - public Properties getProperties() { - return AppConfig.getAppConfig(this).get(); - } - - public void setProperty(String key, String value) { - AppConfig.getAppConfig(this).set(key, value); - } - - /** - * 获取cookie时传AppConfig.CONF_COOKIE - * - * @param key - * @return - */ - public String getProperty(String key) { - String res = AppConfig.getAppConfig(this).get(key); - return res; - } - - public void removeProperty(String... key) { - AppConfig.getAppConfig(this).remove(key); - } - - /** - * 获取App唯一标识 - * - * @return - */ - public String getAppId() { - String uniqueID = getProperty(AppConfig.CONF_APP_UNIQUEID); - if (StringUtils.isEmpty(uniqueID)) { - uniqueID = UUID.randomUUID().toString(); - setProperty(AppConfig.CONF_APP_UNIQUEID, uniqueID); - } - return uniqueID; - } - - /** - * 获取App安装包信息 - * - * @return - */ - public PackageInfo getPackageInfo() { - PackageInfo info = null; - try { - info = getPackageManager().getPackageInfo(getPackageName(), 0); - } catch (NameNotFoundException e) { - e.printStackTrace(System.err); - } - if (info == null) - info = new PackageInfo(); - return info; - } - - /** - * 保存登录信息 - * - * @param user 用户信息 - */ - @SuppressWarnings("serial") - public void saveUserInfo(final User user) { - this.loginUid = user.getId(); - this.login = true; - setProperties(new Properties() { - { - setProperty("user.uid", String.valueOf(user.getId())); - setProperty("user.name", user.getName()); - setProperty("user.face", user.getPortrait());// 用户头像-文件名 - setProperty("user.account", user.getAccount()); - setProperty("user.pwd", - CyptoUtils.encode("oschinaApp", user.getPwd())); - setProperty("user.location", user.getLocation()); - setProperty("user.followers", - String.valueOf(user.getFollowers())); - setProperty("user.fans", String.valueOf(user.getFans())); - setProperty("user.score", String.valueOf(user.getScore())); - setProperty("user.favoritecount", - String.valueOf(user.getFavoritecount())); - setProperty("user.gender", String.valueOf(user.getGender())); - setProperty("user.isRememberMe", - String.valueOf(user.isRememberMe()));// 是否记住我的信息 - } - }); - } - - /** - * 更新用户信息 - * - * @param user - */ - @SuppressWarnings("serial") - public void updateUserInfo(final User user) { - setProperties(new Properties() { - { - setProperty("user.name", user.getName()); - setProperty("user.face", user.getPortrait());// 用户头像-文件名 - setProperty("user.followers", - String.valueOf(user.getFollowers())); - setProperty("user.fans", String.valueOf(user.getFans())); - setProperty("user.score", String.valueOf(user.getScore())); - setProperty("user.favoritecount", - String.valueOf(user.getFavoritecount())); - setProperty("user.gender", String.valueOf(user.getGender())); - } - }); - } - - /** - * 获得登录用户的信息 - * - * @return - */ - public User getLoginUser() { - User user = new User(); - user.setId(StringUtils.toInt(getProperty("user.uid"), 0)); - user.setName(getProperty("user.name")); - user.setPortrait(getProperty("user.face")); - user.setAccount(getProperty("user.account")); - user.setLocation(getProperty("user.location")); - user.setFollowers(StringUtils.toInt(getProperty("user.followers"), 0)); - user.setFans(StringUtils.toInt(getProperty("user.fans"), 0)); - user.setScore(StringUtils.toInt(getProperty("user.score"), 0)); - user.setFavoritecount(StringUtils.toInt( - getProperty("user.favoritecount"), 0)); - user.setRememberMe(StringUtils.toBool(getProperty("user.isRememberMe"))); - user.setGender(getProperty("user.gender")); - return user; - } - - /** - * 清除登录信息 - */ - public void cleanLoginInfo() { - this.loginUid = 0; - this.login = false; - removeProperty("user.uid", "user.name", "user.face", "user.location", - "user.followers", "user.fans", "user.score", - "user.isRememberMe", "user.gender", "user.favoritecount"); - } - - public int getLoginUid() { - return loginUid; - } - - public boolean isLogin() { - return login; - } - - /** - * 用户注销 - */ - public void Logout() { - cleanLoginInfo(); - ApiHttpClient.cleanCookie(); - this.cleanCookie(); - this.login = false; - this.loginUid = 0; - - Intent intent = new Intent(Constants.INTENT_ACTION_LOGOUT); - sendBroadcast(intent); - } - - /** - * 清除保存的缓存 - */ - public void cleanCookie() { - removeProperty(AppConfig.CONF_COOKIE); - } - - /** - * 清除app缓存 - */ - public void clearAppCache() { - DataCleanManager.cleanDatabases(this); - // 清除数据缓存 - DataCleanManager.cleanInternalCache(this); - // 2.2版本才有将应用缓存转移到sd卡的功能 - if (isMethodsCompat(android.os.Build.VERSION_CODES.FROYO)) { - DataCleanManager.cleanCustomCache(MethodsCompat - .getExternalCacheDir(this)); - } - // 清除编辑器保存的临时内容 - Properties props = getProperties(); - for (Object key : props.keySet()) { - String _key = key.toString(); - if (_key.startsWith("temp")) - removeProperty(_key); - } - Core.getKJBitmap().cleanCache(); - } - - public static void setLoadImage(boolean flag) { - set(KEY_LOAD_IMAGE, flag); - } - - /** - * 判断当前版本是否兼容目标版本的方法 - * - * @param VersionCode - * @return - */ - public static boolean isMethodsCompat(int VersionCode) { - int currentVersion = android.os.Build.VERSION.SDK_INT; - return currentVersion >= VersionCode; - } - - public static String getTweetDraft() { - return getPreferences().getString( - KEY_TWEET_DRAFT + getInstance().getLoginUid(), ""); - } - - public static void setTweetDraft(String draft) { - set(KEY_TWEET_DRAFT + getInstance().getLoginUid(), draft); - } - - public static String getNoteDraft() { - return getPreferences().getString( - AppConfig.KEY_NOTE_DRAFT + getInstance().getLoginUid(), ""); - } - - public static void setNoteDraft(String draft) { - set(AppConfig.KEY_NOTE_DRAFT + getInstance().getLoginUid(), draft); - } - - public static boolean isFristStart() { - return getPreferences().getBoolean(KEY_FRITST_START, true); - } - - public static void setFristStart(boolean frist) { - set(KEY_FRITST_START, frist); - } - - //夜间模式 - public static boolean getNightModeSwitch() { - return getPreferences().getBoolean(KEY_NIGHT_MODE_SWITCH, false); - } - - // 设置夜间模式 - public static void setNightModeSwitch(boolean on) { - set(KEY_NIGHT_MODE_SWITCH, on); - } -} diff --git a/app/src/main/java/net/oschina/app/AppException.java b/app/src/main/java/net/oschina/app/AppException.java deleted file mode 100644 index e4d9caa700661a6714ecc727a0be04ed5c3d3734..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/AppException.java +++ /dev/null @@ -1,233 +0,0 @@ -package net.oschina.app; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.Thread.UncaughtExceptionHandler; -import java.net.ConnectException; -import java.net.SocketException; -import java.net.UnknownHostException; - -import net.oschina.app.util.UIHelper; - -import org.kymjs.kjframe.utils.FileUtils; -import org.kymjs.kjframe.utils.SystemTool; - -import android.content.Context; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Build; -import android.os.Looper; -import cz.msebera.android.httpclient.HttpException; - -/** - * 应用程序异常:用于捕获异常和提示错误信息 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @author kymjs (kymjs123@gmali.com) - * @created 2014年9月25日 下午5:34:05 - * - */ -@SuppressWarnings("serial") -public class AppException extends Exception implements UncaughtExceptionHandler { - - /** 定义异常类型 */ - public final static byte TYPE_NETWORK = 0x01; - public final static byte TYPE_SOCKET = 0x02; - public final static byte TYPE_HTTP_CODE = 0x03; - public final static byte TYPE_HTTP_ERROR = 0x04; - public final static byte TYPE_XML = 0x05; - public final static byte TYPE_IO = 0x06; - public final static byte TYPE_RUN = 0x07; - public final static byte TYPE_JSON = 0x08; - public final static byte TYPE_FILENOTFOUND = 0x09; - - private byte type;// 异常的类型 - // 异常的状态码,这里一般是网络请求的状态码 - private int code; - - /** 系统默认的UncaughtException处理类 */ - private AppContext mContext; - - private AppException(Context context) { - this.mContext = (AppContext) context; - } - - private AppException(byte type, int code, Exception excp) { - super(excp); - this.type = type; - this.code = code; - } - - public int getCode() { - return this.code; - } - - public int getType() { - return this.type; - } - - public static AppException http(int code) { - return new AppException(TYPE_HTTP_CODE, code, null); - } - - public static AppException http(Exception e) { - return new AppException(TYPE_HTTP_ERROR, 0, e); - } - - public static AppException socket(Exception e) { - return new AppException(TYPE_SOCKET, 0, e); - } - - public static AppException file(Exception e) { - return new AppException(TYPE_FILENOTFOUND, 0, e); - } - - // io异常 - public static AppException io(Exception e) { - return io(e, 0); - } - - // io异常 - public static AppException io(Exception e, int code) { - if (e instanceof UnknownHostException || e instanceof ConnectException) { - return new AppException(TYPE_NETWORK, code, e); - } else if (e instanceof IOException) { - return new AppException(TYPE_IO, code, e); - } - return run(e); - } - - public static AppException xml(Exception e) { - return new AppException(TYPE_XML, 0, e); - } - - public static AppException json(Exception e) { - return new AppException(TYPE_JSON, 0, e); - } - - // 网络请求异常 - public static AppException network(Exception e) { - if (e instanceof UnknownHostException || e instanceof ConnectException) { - return new AppException(TYPE_NETWORK, 0, e); - } else if (e instanceof HttpException) { - return http(e); - } else if (e instanceof SocketException) { - return socket(e); - } - return http(e); - } - - public static AppException run(Exception e) { - return new AppException(TYPE_RUN, 0, e); - } - - /** - * 获取APP异常崩溃处理对象 - * - * @param context - * @return - */ - public static AppException getAppExceptionHandler(Context context) { - return new AppException(context.getApplicationContext()); - } - - @Override - public void uncaughtException(Thread thread, Throwable ex) { - if (!handleException(ex)) { - System.exit(0); - } - } - - /** - * 自定义异常处理:收集错误信息&发送错误报告 - * - * @param ex - * @return true:处理了该异常信息;否则返回false - */ - private boolean handleException(final Throwable ex) { - if (ex == null || mContext == null) { - return false; - } - boolean success = true; - try { - success = saveToSDCard(ex); - } catch (Exception e) { - } finally { - if (!success) { - return false; - } else { - final Context context = AppManager.getAppManager() - .currentActivity(); - // 显示异常信息&发送报告 - new Thread() { - @Override - public void run() { - Looper.prepare(); - // 拿到未捕获的异常, - UIHelper.sendAppCrashReport(context); - Looper.loop(); - } - }.start(); - } - } - return true; - } - - private boolean saveToSDCard(Throwable ex) throws Exception { - boolean append = false; - File file = FileUtils.getSaveFile("OSChina", "OSCLog.log"); - if (System.currentTimeMillis() - file.lastModified() > 5000) { - append = true; - } - PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter( - file, append))); - // 导出发生异常的时间 - pw.println(SystemTool.getDataTime("yyyy-MM-dd-HH-mm-ss")); - // 导出手机信息 - dumpPhoneInfo(pw); - pw.println(); - // 导出异常的调用栈信息 - ex.printStackTrace(pw); - pw.println(); - pw.close(); - return append; - } - - private void dumpPhoneInfo(PrintWriter pw) throws NameNotFoundException { - // 应用的版本名称和版本号 - PackageManager pm = mContext.getPackageManager(); - PackageInfo pi = pm.getPackageInfo(mContext.getPackageName(), - PackageManager.GET_ACTIVITIES); - pw.print("App Version: "); - pw.print(pi.versionName); - pw.print('_'); - pw.println(pi.versionCode); - pw.println(); - - // android版本号 - pw.print("OS Version: "); - pw.print(Build.VERSION.RELEASE); - pw.print("_"); - pw.println(Build.VERSION.SDK_INT); - pw.println(); - - // 手机制造商 - pw.print("Vendor: "); - pw.println(Build.MANUFACTURER); - pw.println(); - - // 手机型号 - pw.print("Model: "); - pw.println(Build.MODEL); - pw.println(); - - // cpu架构 - pw.print("CPU ABI: "); - pw.println(Build.CPU_ABI); - pw.println(); - } -} diff --git a/app/src/main/java/net/oschina/app/AppManager.java b/app/src/main/java/net/oschina/app/AppManager.java deleted file mode 100644 index fde4ac328af0ca1c69b8ccf12811e0e4c8a1ddba..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/AppManager.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.oschina.app; - -import java.util.Stack; - -import android.app.Activity; -import android.content.Context; - -/** - * activity堆栈式管理 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月30日 下午6:22:05 - * - */ -public class AppManager { - - private static Stack activityStack; - private static AppManager instance; - - private AppManager() {} - - /** - * 单一实例 - */ - public static AppManager getAppManager() { - if (instance == null) { - instance = new AppManager(); - } - return instance; - } - - /** - * 添加Activity到堆栈 - */ - public void addActivity(Activity activity) { - if (activityStack == null) { - activityStack = new Stack(); - } - activityStack.add(activity); - } - - /** - * 获取当前Activity(堆栈中最后一个压入的) - */ - public Activity currentActivity() { - Activity activity = activityStack.lastElement(); - return activity; - } - - /** - * 结束当前Activity(堆栈中最后一个压入的) - */ - public void finishActivity() { - Activity activity = activityStack.lastElement(); - finishActivity(activity); - } - - /** - * 结束指定的Activity - */ - public void finishActivity(Activity activity) { - if (activity != null && !activity.isFinishing()) { - activityStack.remove(activity); - activity.finish(); - activity = null; - } - } - - /** - * 结束指定类名的Activity - */ - public void finishActivity(Class cls) { - for (Activity activity : activityStack) { - if (activity.getClass().equals(cls)) { - finishActivity(activity); - break; - } - } - } - - /** - * 结束所有Activity - */ - public void finishAllActivity() { - for (int i = 0, size = activityStack.size(); i < size; i++) { - if (null != activityStack.get(i)) { - //finishActivity方法中的activity.isFinishing()方法会导致某些activity无法销毁 - //貌似跳转的时候最后一个activity 是finishing状态,所以没有执行 - //内部实现不是很清楚,但是实测结果如此,使用下面代码则没有问题 - // find by TopJohn - //finishActivity(activityStack.get(i)); - - activityStack.get(i).finish(); - //break; - } - } - activityStack.clear(); - } - - /** - * 获取指定的Activity - * - * @author kymjs - */ - public static Activity getActivity(Class cls) { - if (activityStack != null) - for (Activity activity : activityStack) { - if (activity.getClass().equals(cls)) { - return activity; - } - } - return null; - } - - /** - * 退出应用程序 - */ - public void AppExit(Context context) { - try { - finishAllActivity(); - // 杀死该应用进程 - android.os.Process.killProcess(android.os.Process.myPid()); - System.exit(0); - } catch (Exception e) { - } - } -} diff --git a/app/src/main/java/net/oschina/app/AppStart.java b/app/src/main/java/net/oschina/app/AppStart.java deleted file mode 100644 index 03161d07331d60e1a43f6584e54f655181e07aed..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/AppStart.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.oschina.app; - -import java.io.File; - -import net.oschina.app.ui.MainActivity; -import net.oschina.app.util.TDevice; - -import org.kymjs.kjframe.http.KJAsyncTask; -import org.kymjs.kjframe.utils.FileUtils; -import org.kymjs.kjframe.utils.PreferenceHelper; - -import android.app.Activity; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; - -/** - * 应用启动界面 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月22日 上午11:51:56 - * - */ -public class AppStart extends Activity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // 防止第三方跳转时出现双实例 - Activity aty = AppManager.getActivity(MainActivity.class); - if (aty != null && !aty.isFinishing()) { - finish(); - } - // SystemTool.gc(this); //针对性能好的手机使用,加快应用相应速度 - - final View view = View.inflate(this, R.layout.app_start, null); - setContentView(view); - // 渐变展示启动屏 - AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f); - aa.setDuration(800); - view.startAnimation(aa); - aa.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationEnd(Animation arg0) { - redirectTo(); - } - - @Override - public void onAnimationRepeat(Animation animation) {} - - @Override - public void onAnimationStart(Animation animation) {} - }); - } - - @Override - protected void onResume() { - super.onResume(); - int cacheVersion = PreferenceHelper.readInt(this, "first_install", - "first_install", -1); - int currentVersion = TDevice.getVersionCode(); - if (cacheVersion < currentVersion) { - PreferenceHelper.write(this, "first_install", "first_install", - currentVersion); - cleanImageCache(); - } - } - - private void cleanImageCache() { - final File folder = FileUtils.getSaveFolder("OSChina/imagecache"); - KJAsyncTask.execute(new Runnable() { - @Override - public void run() { - for (File file : folder.listFiles()) { - file.delete(); - } - } - }); - } - - /** - * 跳转到... - */ - private void redirectTo() { - Intent uploadLog = new Intent(this, LogUploadService.class); - startService(uploadLog); - Intent intent = new Intent(this, MainActivity.class); - startActivity(intent); - finish(); - } -} diff --git a/app/src/main/java/net/oschina/app/LogUploadService.java b/app/src/main/java/net/oschina/app/LogUploadService.java deleted file mode 100644 index b0dd7ef6c5aa355e7b28e819118da0fd6f5f732f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/LogUploadService.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.oschina.app; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.util.StringUtils; - -import cz.msebera.android.httpclient.Header; -import org.kymjs.kjframe.utils.FileUtils; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -public class LogUploadService extends Service { - - @Override - public IBinder onBind(Intent intent) { - return null; - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - final File log = FileUtils.getSaveFile("OSChina", "OSCLog.log"); - String data = null; - try { - FileInputStream inputStream = new FileInputStream(log); - data = StringUtils.toConvertString(inputStream); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - if (!StringUtils.isEmpty(data)) { - OSChinaApi.uploadLog(data, new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - log.delete(); - LogUploadService.this.stopSelf(); - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - LogUploadService.this.stopSelf(); - } - }); - } else { - LogUploadService.this.stopSelf(); - } - return super.onStartCommand(intent, flags, startId); - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/ActiveAdapter.java b/app/src/main/java/net/oschina/app/adapter/ActiveAdapter.java deleted file mode 100644 index 8b0b3400a970e9a0e024d58c164fe1d4febbcbaf..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/ActiveAdapter.java +++ /dev/null @@ -1,222 +0,0 @@ -package net.oschina.app.adapter; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.text.Html; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.TextUtils; -import android.text.style.ImageSpan; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Active; -import net.oschina.app.bean.Active.ObjectReply; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.ui.ImagePreviewActivity; -import net.oschina.app.util.BitmapHelper; -import net.oschina.app.util.ImageUtils; -import net.oschina.app.util.PlatfromUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.bitmap.BitmapCallBack; -import org.kymjs.kjframe.utils.DensityUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class ActiveAdapter extends ListBaseAdapter { - private final static String AT_HOST_PRE = "http://my.oschina.net"; - private final static String MAIN_HOST = "http://www.oschina.net"; - - public ActiveAdapter() { - } - - private Bitmap recordBitmap; - private int rectSize; - - private void initRecordImg(Context cxt) { - recordBitmap = BitmapFactory.decodeResource(cxt.getResources(), - R.drawable.audio3); - recordBitmap = ImageUtils.zoomBitmap(recordBitmap, - DensityUtils.dip2px(cxt, 20f), DensityUtils.dip2px(cxt, 20f)); - } - - private void initImageSize(Context cxt) { - if (cxt != null && rectSize == 0) { - rectSize = (int) cxt.getResources().getDimension(R.dimen.space_100); - } else { - rectSize = 300; - } - } - - @Override - @SuppressLint("InflateParams") - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh; - initImageSize(parent.getContext()); - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_active, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final Active item = (Active) mDatas.get(position); - - vh.name.setText(item.getAuthor()); - - vh.action.setText(UIHelper.parseActiveAction(item.getObjectType(), - item.getObjectCatalog(), item.getObjectTitle())); - - if (TextUtils.isEmpty(item.getMessage())) { - vh.body.setVisibility(View.GONE); - } else { - vh.body.setMovementMethod(MyLinkMovementMethod.a()); - vh.body.setFocusable(false); - vh.body.setDispatchToParent(true); - vh.body.setLongClickable(false); - - Spanned span = Html.fromHtml(modifyPath(item.getMessage())); - - if (!StringUtils.isEmpty(item.getTweetattach())) { - if (recordBitmap == null) { - initRecordImg(parent.getContext()); - } - ImageSpan recordImg = new ImageSpan(parent.getContext(), - recordBitmap); - SpannableString str = new SpannableString("c"); - str.setSpan(recordImg, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - vh.body.setText(str); - span = InputHelper.displayEmoji(parent.getContext() - .getResources(), span); - vh.body.append(span); - } else { - span = InputHelper.displayEmoji(parent.getContext() - .getResources(), span); - vh.body.setText(span); - } - MyURLSpan.parseLinkText(vh.body, span); - } - - ObjectReply reply = item.getObjectReply(); - if (reply != null) { - vh.reply.setMovementMethod(MyLinkMovementMethod.a()); - vh.reply.setFocusable(false); - vh.reply.setDispatchToParent(true); - vh.reply.setLongClickable(false); - Spanned span = UIHelper.parseActiveReply(reply.objectName, - reply.objectBody); - vh.reply.setText(span);// - MyURLSpan.parseLinkText(vh.reply, span); - vh.lyReply.setVisibility(TextView.VISIBLE); - } else { - vh.reply.setText(""); - vh.lyReply.setVisibility(TextView.GONE); - } - - vh.time.setText(StringUtils.friendly_time(item.getPubDate())); - - PlatfromUtil.setPlatFromString(vh.from, item.getAppClient()); - - vh.commentCount.setText(item.getCommentCount() + ""); - - vh.avatar.setUserInfo(item.getAuthorId(), item.getAuthor()); - vh.avatar.setAvatarUrl(item.getPortrait()); - - if (!TextUtils.isEmpty(item.getTweetimage())) { - setTweetImage(parent, vh, item); - } else { - vh.pic.setVisibility(View.GONE); - vh.pic.setImageBitmap(null); - } - - return convertView; - } - - /** - * 动态设置图片显示样式 - */ - private void setTweetImage(final ViewGroup parent, final ViewHolder vh, - final Active item) { - vh.pic.setVisibility(View.VISIBLE); - - new Core.Builder().url(item.getTweetimage()).view(vh.pic).loadBitmapRes(R.drawable - .pic_bg).size(rectSize, rectSize).bitmapCallBack(new BitmapCallBack() { - @Override - public void onSuccess(Bitmap bitmap) { - super.onSuccess(bitmap); - if (bitmap != null) { - bitmap = BitmapHelper.scaleWithXY(bitmap, rectSize / bitmap.getHeight()); - vh.pic.setImageBitmap(bitmap); - } - } - }).doTask(); - - vh.pic.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ImagePreviewActivity.showImagePrivew(parent.getContext(), 0, - new String[]{getOriginalUrl(item.getTweetimage())}); - } - }); - } - - private String modifyPath(String message) { - message = message.replaceAll("(]+href=\")/([\\S]+)\"", "$1" - + AT_HOST_PRE + "/$2\""); - message = message.replaceAll( - "(]+href=\")http://m.oschina.net([\\S]+)\"", "$1" - + MAIN_HOST + "$2\""); - return message; - } - - private String getOriginalUrl(String url) { - return url.replaceAll("_thumb", ""); - } - - static class ViewHolder { - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_action) - TextView action; - @InjectView(R.id.tv_action_name) - TextView actionName; - @InjectView(R.id.tv_comment_count) - TextView commentCount; - @InjectView(R.id.tv_body) - TweetTextView body; - @InjectView(R.id.tv_reply) - TweetTextView reply; - @InjectView(R.id.iv_pic) - ImageView pic; - @InjectView(R.id.ly_reply) - View lyReply; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/BlogAdapter.java b/app/src/main/java/net/oschina/app/adapter/BlogAdapter.java deleted file mode 100644 index 41d6734ba65fc0b33ce3aa20f0c124be14a8ec60..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/BlogAdapter.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.oschina.app.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Blog; -import net.oschina.app.bean.BlogList; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * @author HuangWenwei - * - * @date 2014年9月29日 - */ -public class BlogAdapter extends ListBaseAdapter { - - static class ViewHolder { - - @InjectView(R.id.tv_title) - TextView title; - @InjectView(R.id.tv_description) - TextView description; - @InjectView(R.id.tv_source) - TextView source; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_comment_count) - TextView comment_count; - @InjectView(R.id.iv_tip) - ImageView tip; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_news, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - Blog blog = mDatas.get(position); - - vh.tip.setVisibility(View.VISIBLE); - if (blog.getDocumenttype() == Blog.DOC_TYPE_ORIGINAL) { - vh.tip.setImageResource(R.drawable.widget_original_icon); - } else { - vh.tip.setImageResource(R.drawable.widget_repaste_icon); - } - - vh.title.setText(blog.getTitle()); - - if (AppContext.isOnReadedPostList(BlogList.PREF_READED_BLOG_LIST, - blog.getId() + "")) { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleReadedColor())); - } else { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleUnReadedColor())); - } - - vh.description.setVisibility(View.GONE); - String description = blog.getBody(); - if (null != description && !StringUtils.isEmpty(description)) { - vh.description.setVisibility(View.VISIBLE); - vh.description.setText(description.trim()); - } - - vh.source.setText(blog.getAuthor()); - vh.time.setText(StringUtils.friendly_time(blog.getPubDate())); - vh.comment_count.setText(blog.getCommentCount() + ""); - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/CommentAdapter.java b/app/src/main/java/net/oschina/app/adapter/CommentAdapter.java deleted file mode 100644 index 4fda914f919a72bd9c5d9d058ae7bf24c74dfe75..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/CommentAdapter.java +++ /dev/null @@ -1,160 +0,0 @@ -package net.oschina.app.adapter; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.text.Html; -import android.text.Spanned; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Comment; -import net.oschina.app.bean.Comment.Refer; -import net.oschina.app.bean.Comment.Reply; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.util.PlatfromUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.FloorView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; - -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class CommentAdapter extends ListBaseAdapter { - - @SuppressLint({ "InflateParams", "CutPasteId" }) - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_comment, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - try { - - final Comment item = mDatas.get(position); - - // 若Authorid为0,则显示非会员 - vh.name.setText(item.getAuthor() - + (item.getAuthorId() == 0 ? "(非会员)" : "")); - - vh.content.setMovementMethod(MyLinkMovementMethod.a()); - vh.content.setFocusable(false); - vh.content.setDispatchToParent(true); - vh.content.setLongClickable(false); - Spanned span = Html.fromHtml(TweetTextView.modifyPath(item - .getContent())); - span = InputHelper.displayEmoji(parent.getContext().getResources(), - span.toString()); - vh.content.setText(span); - MyURLSpan.parseLinkText(vh.content, span); - - vh.time.setText(StringUtils.friendly_time(item.getPubDate())); - - PlatfromUtil.setPlatFromString(vh.from, item.getAppClient()); - - // setup refers - setupRefers(parent.getContext(), vh, item.getRefers()); - - // setup replies - setupReplies(parent.getContext(), vh, item.getReplies()); - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.avatar.setUserInfo(item.getAuthorId(), item.getAuthor()); - } catch (Exception e) { - } - return convertView; - } - - private void setupRefers(Context context, ViewHolder vh, List refers) { - vh.refers.removeAllViews(); - if (refers == null || refers.size() <= 0) { - vh.refers.setVisibility(View.GONE); - } else { - vh.refers.setVisibility(View.VISIBLE); - - vh.refers.setComments(refers); - } - } - - private void setupReplies(Context context, ViewHolder vh, - List replies) { - vh.relies.removeAllViews(); - if (replies == null || replies.size() <= 0) { - vh.relies.setVisibility(View.GONE); - } else { - vh.relies.setVisibility(View.VISIBLE); - - // add count layout - View countView = getLayoutInflater(context).inflate( - R.layout.list_cell_reply_count, null, false); - TextView count = (TextView) countView - .findViewById(R.id.tv_comment_reply_count); - count.setText(context.getResources().getString( - R.string.comment_reply_count, replies.size())); - vh.relies.addView(countView); - - // add reply item - for (Reply reply : replies) { - LinearLayout replyItemView = (LinearLayout) getLayoutInflater( - context).inflate(R.layout.list_cell_reply_name_content, - null, false); - - replyItemView.setOrientation(LinearLayout.HORIZONTAL); - - replyItemView - .setBackgroundResource(R.drawable.comment_background); - - TextView name = (TextView) replyItemView - .findViewById(R.id.tv_reply_name); - name.setText(reply.rauthor + ":"); - - TweetTextView replyContent = (TweetTextView) replyItemView - .findViewById(R.id.tv_reply_content); - replyContent.setMovementMethod(MyLinkMovementMethod.a()); - replyContent.setFocusable(false); - replyContent.setDispatchToParent(true); - replyContent.setLongClickable(false); - Spanned rcontent = Html.fromHtml(reply.rcontent); - replyContent.setText(rcontent); - MyURLSpan.parseLinkText(replyContent, rcontent); - - vh.relies.addView(replyItemView); - } - } - } - - static class ViewHolder { - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_content) - TweetTextView content; - @InjectView(R.id.ly_relies) - LinearLayout relies; - @InjectView(R.id.ly_refers) - FloorView refers; - - ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/EventAdapter.java b/app/src/main/java/net/oschina/app/adapter/EventAdapter.java deleted file mode 100644 index eb42ca3a4a7a03e0edbba812f6981ea9772bf8bb..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/EventAdapter.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.oschina.app.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Event; -import net.oschina.app.bean.EventList; - -import org.kymjs.kjframe.Core; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 活动列表适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月9日 下午6:22:54 - */ -public class EventAdapter extends ListBaseAdapter { - - private int eventType = EventList.EVENT_LIST_TYPE_NEW_EVENT; - - static class ViewHolder { - - @InjectView(R.id.iv_event_status) - ImageView status; - @InjectView(R.id.iv_event_img) - ImageView img; - @InjectView(R.id.tv_event_title) - TextView title; - @InjectView(R.id.tv_event_time) - TextView time; - @InjectView(R.id.tv_event_spot) - TextView spot; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - - public void setEventType(int eventType) { - this.eventType = eventType; - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_event, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - Event item = mDatas.get(position); - - setEventStatus(item, vh); - - new Core.Builder().view(vh.img).url(item.getCover()).doTask(); - vh.title.setText(item.getTitle()); - vh.time.setText(item.getStartTime()); - vh.spot.setText(item.getSpot()); - - return convertView; - } - - private void setEventStatus(Event event, ViewHolder vh) { - - switch (this.eventType) { - case EventList.EVENT_LIST_TYPE_NEW_EVENT: - if (event.getApplyStatus() == Event.APPLYSTATUS_CHECKING - || event.getApplyStatus() == Event.APPLYSTATUS_CHECKED) { - vh.status - .setImageResource(R.drawable.icon_event_status_checked); - vh.status.setVisibility(View.VISIBLE); - } else { - vh.status.setVisibility(View.GONE); - } - break; - case EventList.EVENT_LIST_TYPE_MY_EVENT: - if (event.getApplyStatus() == Event.APPLYSTATUS_ATTEND) { - vh.status.setImageResource(R.drawable.icon_event_status_attend); - } else if (event.getStatus() == Event.EVNET_STATUS_APPLYING) { - vh.status - .setImageResource(R.drawable.icon_event_status_checked); - } else { - vh.status.setImageResource(R.drawable.icon_event_status_over); - } - vh.status.setVisibility(View.VISIBLE); - break; - default: - break; - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/EventApplyAdapter.java b/app/src/main/java/net/oschina/app/adapter/EventApplyAdapter.java deleted file mode 100644 index 2b8f0b3711991af070e17937e6978043d574b71e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/EventApplyAdapter.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Apply; -import net.oschina.app.widget.AvatarView; -import android.annotation.SuppressLint; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 活动参会人员适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月12日 下午8:10:43 - * - */ -public class EventApplyAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_friend, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final Apply item = (Apply) mDatas.get(position); - - vh.name.setText(item.getName()); - vh.avatar.setUserInfo(item.getId(), item.getName()); - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.from.setVisibility(View.GONE); - vh.desc.setText(item.getCompany() + " " + item.getJob()); - - return convertView; - } - - static class ViewHolder { - - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_desc) - TextView desc; - @InjectView(R.id.tv_from) TextView from; - @InjectView(R.id.iv_gender) - ImageView gender; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/FindUserAdapter.java b/app/src/main/java/net/oschina/app/adapter/FindUserAdapter.java deleted file mode 100644 index c6a538dc894c782f8c4c2d55ca55442ce764eb39..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/FindUserAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.User; -import net.oschina.app.widget.AvatarView; -import android.annotation.SuppressLint; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 好友列表适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:22:27 - * - */ -public class FindUserAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_friend, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final User item = (User) mDatas.get(position); - - vh.name.setText(item.getName()); - - vh.from.setText(item.getFrom()); - vh.desc.setVisibility(View.GONE); - int genderIcon = R.drawable.userinfo_icon_male; - if ("女".equals(item.getGender())) { - genderIcon = R.drawable.userinfo_icon_female; - } - - vh.gender.setImageResource(genderIcon); - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.avatar.setUserInfo(item.getId(), item.getName()); - - return convertView; - } - - static class ViewHolder { - - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_desc) - TextView desc; - @InjectView(R.id.iv_gender) - ImageView gender; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/FriendAdapter.java b/app/src/main/java/net/oschina/app/adapter/FriendAdapter.java deleted file mode 100644 index 2992593916d34ddfdc16d4f17fb0e5d67b62494e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/FriendAdapter.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Friend; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; -import android.annotation.SuppressLint; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 好友列表适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:22:27 - * - */ -public class FriendAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_friend, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final Friend item = mDatas.get(position); - - vh.name.setText(item.getName()); - String from = item.getFrom(); - if (from != null || !StringUtils.isEmpty(from)) { - vh.from.setText(from); - } else { - vh.from.setVisibility(View.GONE); - } - String desc = item.getExpertise(); - if (desc != null || !StringUtils.isEmpty(from) || !"<无>".equals(desc)) { - vh.desc.setText(item.getExpertise()); - } else { - vh.desc.setVisibility(View.GONE); - } - - vh.gender - .setImageResource(item.getGender() == 1 ? R.drawable.userinfo_icon_male - : R.drawable.userinfo_icon_female); - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.avatar.setUserInfo(item.getUserid(), item.getName()); - - return convertView; - } - - static class ViewHolder { - - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_desc) - TextView desc; - @InjectView(R.id.iv_gender) - ImageView gender; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/MessageAdapter.java b/app/src/main/java/net/oschina/app/adapter/MessageAdapter.java deleted file mode 100644 index 4a0c74d2f21792d6bbe484f5f84a2a81465e29a5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/MessageAdapter.java +++ /dev/null @@ -1,85 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Messages; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; -import android.text.Html; -import android.text.Spanned; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class MessageAdapter extends ListBaseAdapter { - - @Override - protected boolean loadMoreHasBg() { - return false; - } - - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_message, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final Messages item = (Messages) mDatas.get(position); - - if (AppContext.getInstance().getLoginUid() == item.getSenderId()) { - vh.sender.setVisibility(View.VISIBLE); - } else { - vh.sender.setVisibility(View.GONE); - } - - vh.name.setText(item.getFriendName()); - - vh.content.setMovementMethod(MyLinkMovementMethod.a()); - vh.content.setFocusable(false); - vh.content.setDispatchToParent(true); - vh.content.setLongClickable(false); - Spanned span = Html.fromHtml(item.getContent()); - vh.content.setText(span); - MyURLSpan.parseLinkText(vh.content, span); - - vh.time.setText(StringUtils.friendly_time(item.getPubDate())); - vh.count.setText(parent.getResources().getString( - R.string.message_count, item.getMessageCount())); - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.avatar.setUserInfo(item.getSenderId(), item.getSender()); - return convertView; - } - - static class ViewHolder { - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_sender) - TextView sender; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_count) - TextView count; - @InjectView(R.id.tv_content) - TweetTextView content; - - ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/MessageDetailAdapter.java b/app/src/main/java/net/oschina/app/adapter/MessageDetailAdapter.java deleted file mode 100644 index f93e83a2758ece46bba2e99af8193566b25895ff..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/MessageDetailAdapter.java +++ /dev/null @@ -1,253 +0,0 @@ -package net.oschina.app.adapter; - -import android.text.Html; -import android.text.Spanned; -import android.view.View; -import android.view.ViewGroup; -import android.widget.IconTextView; -import android.widget.ImageView; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.ApiHttpClient; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.MessageDetail; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.util.ChatImageDisplayer; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.KJBitmap; -import org.kymjs.kjframe.bitmap.BitmapConfig; -import org.kymjs.kjframe.http.HttpConfig; - -import java.lang.reflect.Field; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import butterknife.OnClick; - -/** - * 铂金小鸟 2015-09-16 修改(聊天界面改进) - */ -public class MessageDetailAdapter extends ListBaseAdapter { - - KJBitmap mKjBitmap = Core.getKJBitmap(); - - private OnRetrySendMessageListener mOnRetrySendMessageListener; - - @Override - protected boolean loadMoreHasBg() { - return false; - } - - public MessageDetailAdapter() { - try { - //初始化display,设置图片的最大宽高和最小宽高 - ChatImageDisplayer displayer = new ChatImageDisplayer(new BitmapConfig()); - int maxWidth = TDevice.getDisplayMetrics().widthPixels / 2; - int maxHeight = maxWidth; - int minWidth = maxWidth / 2; - int minHeight = minWidth; - displayer.setImageSize(maxWidth, maxHeight, minWidth, minHeight); - //kjBitmap 不能设置自定义的displayer,这里通过反射设置自定义的displayer - Class classType = mKjBitmap.getClass(); - Field field = classType.getDeclaredField("displayer"); - field.setAccessible(true); - field.set(mKjBitmap, displayer); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - final MessageDetail item = mDatas.get(mDatas.size() - position - 1); - - int itemType = 0; - if (item.getAuthorId() == AppContext.getInstance().getLoginUid()) { - itemType = 1; - } - boolean needCreateView = false; - ViewHolder vh = null; - if (convertView == null) { - needCreateView = true; - } else { - vh = (ViewHolder) convertView.getTag(); - } - - if (vh == null || vh.type != itemType) { - needCreateView = true; - } - - if (needCreateView) { - convertView = getLayoutInflater(parent.getContext()).inflate( - itemType == 0 ? R.layout.list_cell_chat_from : R.layout.list_cell_chat_to, - null); - vh = new ViewHolder(convertView); - vh.type = itemType; - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.avatar.setUserInfo(item.getAuthorId(), item.getAuthor()); - - //判断是不是图片 - if (item.getBtype() == 3) { - showImage(vh, item); - } else /*if(item.getBtype()==1)*/ { - //文本消息 - showText(vh, item); - } - showStatus(vh, item); - - //检查是否需要显示时间 - if (item.isShowDate()) { - vh.time.setText(StringUtils.friendly_time3(item.getPubDate())); - vh.time.setVisibility(View.VISIBLE); - } else { - vh.time.setVisibility(View.GONE); - } - - return convertView; - } - - /** - * 显示文字消息 - * - * @param vh - * @param msg - */ - private void showText(ViewHolder vh, MessageDetail msg) { - vh.image.setVisibility(View.GONE); - vh.content.setVisibility(View.VISIBLE); - Spanned span = Html.fromHtml(msg.getContent()); - span = InputHelper.displayEmoji(vh.content.getResources(), span); - vh.content.setText(span); - MyURLSpan.parseLinkText(vh.content, span); - } - - /** - * 显示图片 - * - * @param vh - * @param msg - */ - private void showImage(ViewHolder vh, MessageDetail msg) { - vh.content.setVisibility(View.GONE); - vh.image.setVisibility(View.VISIBLE); - //加载图片 - vh.image.setImageResource(R.drawable.load_img_loading); - HttpConfig.sCookie = ApiHttpClient.getCookie(AppContext.getInstance()); - mKjBitmap.display(vh.image, msg.getContent(), R.drawable.load_img_error, 0, 0, - null); - } - - /** - * 显示消息状态 - * - * @param vh - * @param msg - */ - private void showStatus(ViewHolder vh, MessageDetail msg) { - //如果msg正在发送,则显示progressBar. 发送错误显示错误图标 - if (msg.getStatus() != null && msg.getStatus() != MessageDetail.MessageStatus.NORMAL) { - vh.msgStatusPanel.setVisibility(View.VISIBLE); - if (msg.getStatus() == MessageDetail.MessageStatus.SENDING) { - //sending 正在发送 - vh.progressBar.setVisibility(View.VISIBLE); - vh.error.setVisibility(View.GONE); - vh.error.setTag(null); - } else { - //error 发送出错 - vh.progressBar.setVisibility(View.GONE); - vh.error.setVisibility(View.VISIBLE); - //设置tag为msg id,以便点击重试发送 - vh.error.setTag(msg.getId()); - - } - } else { - //注意,此处隐藏要用INVISIBLE,不能使用GONE - vh.msgStatusPanel.setVisibility(View.INVISIBLE); - vh.error.setTag(null); - } - } - - public OnRetrySendMessageListener getOnRetrySendMessageListener() { - return mOnRetrySendMessageListener; - } - - public void setOnRetrySendMessageListener(OnRetrySendMessageListener - onRetrySendMessageListener) { - this.mOnRetrySendMessageListener = onRetrySendMessageListener; - } - - @Override - protected boolean hasFooterView() { - return false; - } - - class ViewHolder { - int type; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_content) - TweetTextView content; - @InjectView(R.id.iv_img) - ImageView image; - @InjectView(R.id.progress) - ProgressBar progressBar; - @InjectView(R.id.rl_msg_status_panel) - RelativeLayout msgStatusPanel; - @InjectView(R.id.itv_error) - IconTextView error; - - ViewHolder(View view) { - ButterKnife.inject(this, view); - - content.setMovementMethod(MyLinkMovementMethod.a()); - content.setFocusable(false); - content.setDispatchToParent(true); - content.setLongClickable(false); - } - - @OnClick(R.id.iv_img) - void viewImage(View v) { - if (v.getTag() != null) { - String url = (String) v.getTag(); - UIHelper.showImagePreview(v.getContext(), new String[]{url}); - } - } - - /** - * 重试发送 - * - * @param v - */ - @OnClick(R.id.itv_error) - void retry(View v) { - if (v.getTag() != null && mOnRetrySendMessageListener != null) { - mOnRetrySendMessageListener.onRetrySendMessage((int) v.getTag()); - } - } - } - - - public interface OnRetrySendMessageListener { - void onRetrySendMessage(int msgId); - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/NewsAdapter.java b/app/src/main/java/net/oschina/app/adapter/NewsAdapter.java deleted file mode 100644 index 19382b7e166493e41a057dbb60252dd98a1a8332..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/NewsAdapter.java +++ /dev/null @@ -1,84 +0,0 @@ -package net.oschina.app.adapter; - -import android.annotation.SuppressLint; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.News; -import net.oschina.app.bean.NewsList; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class NewsAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_news, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - News news = mDatas.get(position); - vh.title.setText(news.getTitle()); - - if (AppContext.isOnReadedPostList(NewsList.PREF_READED_NEWS_LIST, - news.getId() + "")) { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleReadedColor())); - } else { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleUnReadedColor())); - } - - String description = news.getBody(); - vh.description.setVisibility(View.GONE); - if (description != null && !StringUtils.isEmpty(description)) { - vh.description.setVisibility(View.VISIBLE); - vh.description.setText(description.trim()); - } - - vh.source.setText(news.getAuthor()); - if (StringUtils.isToday(news.getPubDate())) { - vh.tip.setVisibility(View.VISIBLE); - } else { - vh.tip.setVisibility(View.GONE); - } - vh.time.setText(StringUtils.friendly_time(news.getPubDate())); - vh.comment_count.setText(news.getCommentCount() + ""); - - return convertView; - } - - static class ViewHolder { - @InjectView(R.id.tv_title) - TextView title; - @InjectView(R.id.tv_description) - TextView description; - @InjectView(R.id.tv_source) - TextView source; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_comment_count) - TextView comment_count; - @InjectView(R.id.iv_tip) - ImageView tip; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/PostAdapter.java b/app/src/main/java/net/oschina/app/adapter/PostAdapter.java deleted file mode 100644 index f51d60b36c361e2f52b4353fbba7aece3a8a16ce..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/PostAdapter.java +++ /dev/null @@ -1,89 +0,0 @@ -package net.oschina.app.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Post; -import net.oschina.app.bean.PostList; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.widget.AvatarView; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * post(讨论区帖子)适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月9日 下午6:22:54 - */ -public class PostAdapter extends ListBaseAdapter { - - static class ViewHolder { - - @InjectView(R.id.tv_title) - TextView title; - @InjectView(R.id.tv_description) - TextView description; - @InjectView(R.id.tv_author) - TextView author; - @InjectView(R.id.tv_date) - TextView time; - @InjectView(R.id.tv_count) - TextView comment_count; - - @InjectView(R.id.iv_face) - public AvatarView face; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_post, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - Post post = (Post) mDatas.get(position); - - vh.face.setUserInfo(post.getAuthorId(), post.getAuthor()); - vh.face.setAvatarUrl(post.getPortrait()); - vh.title.setText(post.getTitle()); - String body = post.getBody(); - vh.description.setVisibility(View.GONE); - if (null != body || !StringUtils.isEmpty(body)) { - vh.description.setVisibility(View.VISIBLE); - vh.description.setText(HTMLUtil.replaceTag(post.getBody()).trim()); - } - - if (AppContext.isOnReadedPostList(PostList.PREF_READED_POST_LIST, - post.getId() + "")) { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleReadedColor())); - } else { - vh.title.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleUnReadedColor())); - } - - vh.author.setText(post.getAuthor()); - vh.time.setText(StringUtils.friendly_time(post.getPubDate())); - vh.comment_count.setText(post.getAnswerCount() + "回 / " - + post.getViewCount() + "阅"); - - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/RecycleBin.java b/app/src/main/java/net/oschina/app/adapter/RecycleBin.java deleted file mode 100644 index e46514b864d4bdf989d5d762e4901e6f7e8b7435..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/RecycleBin.java +++ /dev/null @@ -1,155 +0,0 @@ -package net.oschina.app.adapter; - -import android.annotation.SuppressLint; -import android.os.Build; -import android.util.SparseArray; -import android.view.View; - -/** - * The RecycleBin facilitates reuse of views across layouts. The RecycleBin has two levels of - * storage: ActiveViews and ScrapViews. ActiveViews are those views which were onscreen at the - * start of a layout. By construction, they are displaying current information. At the end of - * layout, all views in ActiveViews are demoted to ScrapViews. ScrapViews are old views that - * could potentially be used by the adapter to avoid allocating views unnecessarily. - *

- * This class was taken from Android's implementation of {@link android.widget.AbsListView} which - * is copyrighted 2006 The Android Open Source Project. - */ -public class RecycleBin { - /** - * Views that were on screen at the start of layout. This array is populated at the start of - * layout, and at the end of layout all view in activeViews are moved to scrapViews. - * Views in activeViews represent a contiguous range of Views, with position of the first - * view store in mFirstActivePosition. - */ - private View[] activeViews = new View[0]; - private int[] activeViewTypes = new int[0]; - - /** Unsorted views that can be used by the adapter as a convert view. */ - private SparseArray[] scrapViews; - - private int viewTypeCount; - - private SparseArray currentScrapViews; - - public void setViewTypeCount(int viewTypeCount) { - if (viewTypeCount < 1) { - throw new IllegalArgumentException("Can't have a viewTypeCount < 1"); - } - //noinspection unchecked - SparseArray[] scrapViews = new SparseArray[viewTypeCount]; - for (int i = 0; i < viewTypeCount; i++) { - scrapViews[i] = new SparseArray(); - } - this.viewTypeCount = viewTypeCount; - currentScrapViews = scrapViews[0]; - this.scrapViews = scrapViews; - } - - protected boolean shouldRecycleViewType(int viewType) { - return viewType >= 0; - } - - /** @return A view from the ScrapViews collection. These are unordered. */ - View getScrapView(int position, int viewType) { - if (viewTypeCount == 1) { - return retrieveFromScrap(currentScrapViews, position); - } else if (viewType >= 0 && viewType < scrapViews.length) { - return retrieveFromScrap(scrapViews[viewType], position); - } - return null; - } - - /** - * Put a view into the ScrapViews list. These views are unordered. - * - * @param scrap The view to add - */ - @SuppressLint("NewApi") -void addScrapView(View scrap, int position, int viewType) { - if (viewTypeCount == 1) { - currentScrapViews.put(position, scrap); - } else { - scrapViews[viewType].put(position, scrap); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - scrap.setAccessibilityDelegate(null); - } - } - - /** Move all views remaining in activeViews to scrapViews. */ - @SuppressLint("NewApi") -void scrapActiveViews() { - final View[] activeViews = this.activeViews; - final int[] activeViewTypes = this.activeViewTypes; - final boolean multipleScraps = viewTypeCount > 1; - - SparseArray scrapViews = currentScrapViews; - final int count = activeViews.length; - for (int i = count - 1; i >= 0; i--) { - final View victim = activeViews[i]; - if (victim != null) { - int whichScrap = activeViewTypes[i]; - - activeViews[i] = null; - activeViewTypes[i] = -1; - - if (!shouldRecycleViewType(whichScrap)) { - continue; - } - - if (multipleScraps) { - scrapViews = this.scrapViews[whichScrap]; - } - scrapViews.put(i, victim); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - victim.setAccessibilityDelegate(null); - } - } - } - - pruneScrapViews(); - } - - /** - * Makes sure that the size of scrapViews does not exceed the size of activeViews. - * (This can happen if an adapter does not recycle its views). - */ - private void pruneScrapViews() { - final int maxViews = activeViews.length; - final int viewTypeCount = this.viewTypeCount; - final SparseArray[] scrapViews = this.scrapViews; - for (int i = 0; i < viewTypeCount; ++i) { - final SparseArray scrapPile = scrapViews[i]; - int size = scrapPile.size(); - final int extras = size - maxViews; - size--; - for (int j = 0; j < extras; j++) { - scrapPile.remove(scrapPile.keyAt(size--)); - } - } - } - - static View retrieveFromScrap(SparseArray scrapViews, int position) { - int size = scrapViews.size(); - if (size > 0) { - // See if we still have a view for this position. - for (int i = 0; i < size; i++) { - int fromPosition = scrapViews.keyAt(i); - View view = scrapViews.get(fromPosition); - if (fromPosition == position) { - scrapViews.remove(fromPosition); - return view; - } - } - int index = size - 1; - View r = scrapViews.valueAt(index); - scrapViews.remove(scrapViews.keyAt(index)); - return r; - } else { - return null; - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/RecyclingPagerAdapter.java b/app/src/main/java/net/oschina/app/adapter/RecyclingPagerAdapter.java deleted file mode 100644 index 84e7d8859c0061d5d9fac6f4250a5765765bc807..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/RecyclingPagerAdapter.java +++ /dev/null @@ -1,122 +0,0 @@ -package net.oschina.app.adapter; - -import android.support.v4.view.PagerAdapter; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; - -/** - * A {@link PagerAdapter} which behaves like an {@link android.widget.Adapter} - * with view types and view recycling. - */ -public abstract class RecyclingPagerAdapter extends PagerAdapter { - static final int IGNORE_ITEM_VIEW_TYPE = AdapterView.ITEM_VIEW_TYPE_IGNORE; - - private final RecycleBin recycleBin; - - public RecyclingPagerAdapter() { - this(new RecycleBin()); - } - - RecyclingPagerAdapter(RecycleBin recycleBin) { - this.recycleBin = recycleBin; - recycleBin.setViewTypeCount(getViewTypeCount()); - } - - @Override - public void notifyDataSetChanged() { - recycleBin.scrapActiveViews(); - super.notifyDataSetChanged(); - } - - @Override - public final Object instantiateItem(ViewGroup container, int position) { - int viewType = getItemViewType(position); - View view = null; - if (viewType != IGNORE_ITEM_VIEW_TYPE) { - view = recycleBin.getScrapView(position, viewType); - } - view = getView(position, view, container); - container.addView(view); - return view; - } - - @Override - public final void destroyItem(ViewGroup container, int position, - Object object) { - View view = (View) object; - container.removeView(view); - int viewType = getItemViewType(position); - if (viewType != IGNORE_ITEM_VIEW_TYPE) { - recycleBin.addScrapView(view, position, viewType); - } - } - - @Override - public final boolean isViewFromObject(View view, Object object) { - return view == object; - } - - /** - *

- * Returns the number of types of Views that will be created by - * {@link #getView}. Each type represents a set of views that can be - * converted in {@link #getView}. If the adapter always returns the same - * type of View for all items, this method should return 1. - *

- *

- * This method will only be called when when the adapter is set on the the - * {@link AdapterView}. - *

- * - * @return The number of types of Views that will be created by this adapter - */ - public int getViewTypeCount() { - return 1; - } - - /** - * Get the type of View that will be created by {@link #getView} for the - * specified item. - * - * @param position - * The position of the item within the adapter's data set whose - * view type we want. - * @return An integer representing the type of View. Two views should share - * the same type if one can be converted to the other in - * {@link #getView}. Note: Integers must be in the range 0 to - * {@link #getViewTypeCount} - 1. {@link #IGNORE_ITEM_VIEW_TYPE} can - * also be returned. - * @see #IGNORE_ITEM_VIEW_TYPE - */ - public int getItemViewType(int position) { - return 0; - } - - /** - * Get a View that displays the data at the specified position in the data - * set. You can either create a View manually or inflate it from an XML - * layout file. When the View is inflated, the parent View (GridView, - * ListView...) will apply default layout parameters unless you use - * {@link android.view.LayoutInflater#inflate(int, android.view.ViewGroup, boolean)} - * to specify a root view and to prevent attachment to the root. - * - * @param position - * The position of the item within the adapter's data set of the - * item whose view we want. - * @param convertView - * The old view to reuse, if possible. Note: You should check - * that this view is non-null and of an appropriate type before - * using. If it is not possible to convert this view to display - * the correct data, this method can create a new view. - * Heterogeneous lists can specify their number of view types, so - * that this View is always of the right type (see - * {@link #getViewTypeCount()} and {@link #getItemViewType(int)} - * ). - * @param parent - * The parent that this view will eventually be attached to - * @return A View corresponding to the data at the specified position. - */ - public abstract View getView(int position, View convertView, - ViewGroup container); -} diff --git a/app/src/main/java/net/oschina/app/adapter/SearchAdapter.java b/app/src/main/java/net/oschina/app/adapter/SearchAdapter.java deleted file mode 100644 index 9e77e3c0b86ede480514a34f114568f9c5d4b984..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/SearchAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.SearchResult; -import net.oschina.app.util.StringUtils; -import android.annotation.SuppressLint; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class SearchAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_news, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - SearchResult item = (SearchResult) mDatas.get(position); - - vh.title.setText(item.getTitle()); - - if (item.getDescription() == null || StringUtils.isEmpty(item.getDescription())) { - vh.description.setVisibility(View.GONE); - } else { - vh.description.setVisibility(View.VISIBLE); - vh.description.setText(item.getDescription()); - } - - if (!StringUtils.isEmpty(item.getAuthor())) { - vh.source.setText(item.getAuthor()); - } else { - vh.source.setVisibility(View.GONE); - } - - if (!StringUtils.isEmpty(item.getPubDate())) { - vh.time.setText(StringUtils.friendly_time(item.getPubDate())); - } else { - vh.time.setVisibility(View.GONE); - } - - vh.tip.setVisibility(View.GONE); - vh.comment_count.setVisibility(View.GONE); - return convertView; - } - - static class ViewHolder { - @InjectView(R.id.tv_title)TextView title; - @InjectView(R.id.tv_description)TextView description; - @InjectView(R.id.tv_source)TextView source; - @InjectView(R.id.tv_time)TextView time; - @InjectView(R.id.tv_comment_count)TextView comment_count; - @InjectView(R.id.iv_tip)ImageView tip; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/SearchFriendAdapter.java b/app/src/main/java/net/oschina/app/adapter/SearchFriendAdapter.java deleted file mode 100644 index 313cc6c8703140fb5a651c0c9074d256cf566115..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/SearchFriendAdapter.java +++ /dev/null @@ -1,111 +0,0 @@ -package net.oschina.app.adapter; - -import android.content.Context; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.style.ForegroundColorSpan; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.CheckBox; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.ui.SelectFriendsActivity; -import net.oschina.app.widget.AvatarView; - -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - *

Created 15/8/27 下午9:29.

- *

Email:730395591@qq.com

- *

LeonLee Blog

- * - * @author 李文龙(LeonLee - * - * 搜索好友结果适配器 - */ -public class SearchFriendAdapter extends BaseAdapter { - - final List mSearchResults; - private LayoutInflater mInflater; - - public SearchFriendAdapter(List list) { - this.mSearchResults = list; - } - - protected LayoutInflater getLayoutInflater(Context context) { - if (mInflater == null) { - mInflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - return mInflater; - } - - @Override - public int getCount() { - return mSearchResults.size(); - } - - @Override - public SelectFriendsActivity.SearchItem getItem(int position) { - return mSearchResults.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final NormalViewHolder holder; - if(convertView == null) { - convertView = getLayoutInflater(parent.getContext()).inflate(R.layout.list_cell_select_friend, parent, false); - holder = new NormalViewHolder(convertView); - convertView.setTag(holder); - } else { - holder = (NormalViewHolder) convertView.getTag(); - } - holder.bind(getItem(position)); - return convertView; - } - - static class NormalViewHolder { - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.cb_check) - CheckBox checkBox; - - NormalViewHolder(View view) { - ButterKnife.inject(this, view); - avatar.setClickable(false); - } - - public void bind(SelectFriendsActivity.SearchItem item) { - SelectFriendsActivity.FriendItem friendItem = item.getFriendItem(); - avatar.setAvatarUrl(friendItem.getFriend().getPortrait()); - checkBox.setChecked(friendItem.isSelected()); - - avatar.setDisplayCircle(false); - - int start = item.getStartIndex(); - if(start != -1) { - SpannableString ss = new SpannableString(friendItem.getFriend().getName()); - ss.setSpan(new ForegroundColorSpan(item.getHightLightColor()), start, - start + item.getKeyLength(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE); - name.setText(ss); - } else { - name.setText(friendItem.getFriend().getName()); - } - - } - } - -} diff --git a/app/src/main/java/net/oschina/app/adapter/SelectFriendAdapter.java b/app/src/main/java/net/oschina/app/adapter/SelectFriendAdapter.java deleted file mode 100644 index b2b85e972781371137a62b545c46f9c97e5a3184..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/SelectFriendAdapter.java +++ /dev/null @@ -1,219 +0,0 @@ -package net.oschina.app.adapter; - -import android.content.Context; -import android.util.SparseArray; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.CheckBox; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.ui.SelectFriendsActivity; -import net.oschina.app.widget.AvatarView; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - *

Created 15/8/26 下午2:09.

- *

Email:730395591@qq.com

- *

LeonLee Blog

- * - * @author 李文龙(LeonLee) - */ -public class SelectFriendAdapter extends BaseAdapter { - - private static final char DEFAULT_OTHER_LETTER = '#'; - - private static final int VIEWTYPE_HEADER = 0; - private static final int VIEWTYPE_NORMAL = 1; - - private List mList = new ArrayList<>(); - //记录索引值对应的位置 - private SparseArray mPositionArray = new SparseArray<>(); - - private LayoutInflater mInflater; - - public SelectFriendAdapter() { - - } - - protected LayoutInflater getLayoutInflater(Context context) { - if (mInflater == null) { - mInflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - return mInflater; - } - - public void setFriendItems(List list) { - mPositionArray.clear(); - mList.clear(); - - //非字母开头的列表 - List otherList = null; - - char lastIndex = '0'; - for(SelectFriendsActivity.FriendItem item : list) { - char indexLetter; - char c = item.getFirstLetter(); - if(c >= 'A' && c <= 'Z') { - indexLetter = c; - } else if(c >= 'a' && c <= 'z') { - indexLetter = (char)(c - 'a' + 'A'); - } else { - indexLetter = DEFAULT_OTHER_LETTER; - } - if(indexLetter == DEFAULT_OTHER_LETTER) { - if(otherList == null) { - otherList = new ArrayList<>(); - } - otherList.add(new NormalItemData(item)); - } else { - if (indexLetter != lastIndex) { - mPositionArray.append(indexLetter, mList.size()); - mList.add(new HeaderItemData(String.valueOf(indexLetter))); - lastIndex = indexLetter; - } - mList.add(new NormalItemData(item)); - } - } - //将没有索引的数据列表放到最后 - if(otherList != null && !otherList.isEmpty()) { - mPositionArray.append(DEFAULT_OTHER_LETTER, mList.size()); - mList.add(new HeaderItemData(String.valueOf(DEFAULT_OTHER_LETTER))); - mList.addAll(otherList); - } - - notifyDataSetChanged(); - } - - /** 根据索引获取位置*/ - public int getPositionByIndex(char indexLetter) { - Integer value = mPositionArray.get(indexLetter); - if(value == null) { - return -1; - } - return value; - } - - public SelectFriendsActivity.FriendItem getFriendItem(int position) { - ItemData data = getItem(position); - if(data instanceof NormalItemData) { - return ((NormalItemData)data).friendItem; - } - return null; - } - - @Override - public int getCount() { - return mList.size(); - } - - @Override - public ItemData getItem(int position) { - return mList.get(position); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public int getViewTypeCount() { - return 2; - } - - @Override - public int getItemViewType(int position) { - return (getItem(position) instanceof HeaderItemData) ? VIEWTYPE_HEADER : VIEWTYPE_NORMAL; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final ItemData itemData = getItem(position); - if(itemData instanceof HeaderItemData) { - final HeaderViewHolder holder; - if(convertView == null) { - convertView = getLayoutInflater(parent.getContext()).inflate(R.layout.list_index_header, parent, false); - holder = new HeaderViewHolder(convertView); - convertView.setTag(holder); - convertView.setEnabled(false); - } else { - holder = (HeaderViewHolder) convertView.getTag(); - } - holder.bind(((HeaderItemData)itemData).index); - } else { - final NormalViewHolder holder; - if(convertView == null) { - convertView = getLayoutInflater(parent.getContext()).inflate(R.layout.list_cell_select_friend, parent, false); - holder = new NormalViewHolder(convertView); - convertView.setTag(holder); - } else { - holder = (NormalViewHolder) convertView.getTag(); - } - holder.bind(((NormalItemData)itemData).friendItem); - } - - return convertView; - } - - private interface ItemData {} - - static class HeaderItemData implements ItemData { - String index; - public HeaderItemData(String index) { - this.index = index; - } - } - - static class NormalItemData implements ItemData { - SelectFriendsActivity.FriendItem friendItem; - - public NormalItemData(SelectFriendsActivity.FriendItem friendItem) { - this.friendItem = friendItem; - } - } - - static class HeaderViewHolder { - @InjectView(R.id.header_text) - TextView text; - - HeaderViewHolder(View view) { - ButterKnife.inject(this, view); - } - - public void bind(String index) { - text.setText(index); - } - } - - static class NormalViewHolder { - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.cb_check) - CheckBox checkBox; - - NormalViewHolder(View view) { - ButterKnife.inject(this, view); - avatar.setClickable(false); - } - - public void bind(SelectFriendsActivity.FriendItem item) { - name.setText(item.getFriend().getName()); - avatar.setAvatarUrl(item.getFriend().getPortrait()); - checkBox.setChecked(item.isSelected()); - - avatar.setDisplayCircle(false); - - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/SoftwareAdapter.java b/app/src/main/java/net/oschina/app/adapter/SoftwareAdapter.java deleted file mode 100644 index 2aea0ca4d3ae357829cbfe0d7ad42c8493b9dcf2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/SoftwareAdapter.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.oschina.app.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.SoftwareDec; -import net.oschina.app.bean.SoftwareList; -import net.oschina.app.util.ThemeSwitchUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class SoftwareAdapter extends ListBaseAdapter { - - static class ViewHold { - @InjectView(R.id.tv_title) - TextView name; - @InjectView(R.id.tv_software_des) - TextView des; - - public ViewHold(View view) { - ButterKnife.inject(this, view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - - ViewHold vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate(R.layout.list_cell_software, null); - vh = new ViewHold(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHold) convertView.getTag(); - } - - SoftwareDec softwareDes = (SoftwareDec) mDatas.get(position); - vh.name.setText(softwareDes.getName()); - - if (AppContext.isOnReadedPostList(SoftwareList.PREF_READED_SOFTWARE_LIST, - softwareDes.getName())) { - vh.name.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleReadedColor())); - } else { - vh.name.setTextColor(parent.getContext().getResources() - .getColor(ThemeSwitchUtils.getTitleUnReadedColor())); - } - - vh.des.setText(softwareDes.getDescription()); - - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/SoftwareCatalogListAdapter.java b/app/src/main/java/net/oschina/app/adapter/SoftwareCatalogListAdapter.java deleted file mode 100644 index 68a4b02716ad43bdf64f1f5427285a796ae15e99..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/SoftwareCatalogListAdapter.java +++ /dev/null @@ -1,39 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.SoftwareCatalogList.SoftwareType; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class SoftwareCatalogListAdapter extends ListBaseAdapter { - - static class ViewHold{ - @InjectView(R.id.tv_software_catalog_name)TextView name; - public ViewHold(View view) { - ButterKnife.inject(this,view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - - ViewHold vh = null; - - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate(R.layout.list_cell_softwarecatalog, null); - vh = new ViewHold(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHold)convertView.getTag(); - } - - SoftwareType softwareType = (SoftwareType) mDatas.get(position); - vh.name.setText(softwareType.getName()); - return convertView; - - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/TweetAdapter.java b/app/src/main/java/net/oschina/app/adapter/TweetAdapter.java deleted file mode 100644 index 8fcb096eac337d80fc1ba44066eacb77eba515db..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/TweetAdapter.java +++ /dev/null @@ -1,251 +0,0 @@ -package net.oschina.app.adapter; - -import android.content.Context; -import android.content.DialogInterface; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.text.Html; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.TextUtils; -import android.text.style.ImageSpan; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Tweet; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.ui.ImagePreviewActivity; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.ImageUtils; -import net.oschina.app.util.KJAnimations; -import net.oschina.app.util.PlatfromUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TypefaceUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.TweetTextView; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.utils.DensityUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import cz.msebera.android.httpclient.Header; - -public class TweetAdapter extends ListBaseAdapter { - - static class ViewHolder { - @InjectView(R.id.tv_tweet_name) - TextView author; - @InjectView(R.id.tv_tweet_time) - TextView time; - @InjectView(R.id.tweet_item) - TweetTextView content; - @InjectView(R.id.tv_tweet_comment_count) - TextView commentcount; - @InjectView(R.id.tv_tweet_platform) - TextView platform; - @InjectView(R.id.iv_tweet_face) - AvatarView face; - @InjectView(R.id.iv_tweet_image) - ImageView image; - @InjectView(R.id.tv_like_state) - TextView tvLikeState; - @InjectView(R.id.tv_del) - TextView del; - @InjectView(R.id.tv_likeusers) - TextView likeUsers; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - image.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - String url = (String) v.getTag(); - int index = url.lastIndexOf("?"); - if (index > 0) { - url = url.substring(0, index); - } - ImagePreviewActivity.showImagePrivew(v.getContext(), 0, new String[]{url}); - } - }); - } - } - - private Bitmap recordBitmap; - private Context context; - - final private AsyncHttpResponseHandler handler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - } - }; - - private void initRecordImg(Context cxt) { - recordBitmap = BitmapFactory.decodeResource(cxt.getResources(), - R.drawable.audio3); - recordBitmap = ImageUtils.zoomBitmap(recordBitmap, - DensityUtils.dip2px(cxt, 20f), DensityUtils.dip2px(cxt, 20f)); - } - - @Override - protected View getRealView(final int position, View convertView, ViewGroup parent) { - context = parent.getContext(); - final ViewHolder vh; - if (convertView == null || convertView.getTag() == null) { - convertView = View.inflate(context, R.layout.list_cell_tweet, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - final Tweet tweet = mDatas.get(position); - - if (tweet.getAuthorid() == AppContext.getInstance().getLoginUid()) { - vh.del.setVisibility(View.VISIBLE); - vh.del.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - optionDel(context, tweet, position); - } - }); - } else { - vh.del.setVisibility(View.GONE); - } - - vh.face.setUserInfo(tweet.getAuthorid(), tweet.getAuthor()); - vh.face.setAvatarUrl(tweet.getPortrait()); - vh.author.setText(tweet.getAuthor()); - vh.time.setText(StringUtils.friendly_time(tweet.getPubDate())); - vh.content.setMovementMethod(MyLinkMovementMethod.a()); - vh.content.setFocusable(false); - vh.content.setDispatchToParent(true); - vh.content.setLongClickable(false); - - Spanned span = Html.fromHtml(tweet.getBody().trim()); - - if (!StringUtils.isEmpty(tweet.getAttach())) { - if (recordBitmap == null) { - initRecordImg(context); - } - ImageSpan recordImg = new ImageSpan(context, recordBitmap); - SpannableString str = new SpannableString("c"); - str.setSpan(recordImg, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - vh.content.setText(str); - span = InputHelper.displayEmoji(context.getResources(), span); - vh.content.append(span); - } else { - span = InputHelper.displayEmoji(context.getResources(), span); - vh.content.setText(span); - } - - vh.commentcount.setText(tweet.getCommentCount()); - - showTweetImage(vh, tweet.getImgSmall(), tweet.getImgBig()); - tweet.setLikeUsers(context, vh.likeUsers, true); - - if (tweet.getLikeUser() == null) { - vh.tvLikeState.setVisibility(View.GONE); - } else { - vh.tvLikeState.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - updateLikeState(vh, tweet); - } else { - AppContext.showToast("先登陆再赞~"); - UIHelper.showLoginActivity(context); - } - } - }); - } - - TypefaceUtils.setTypeface(vh.tvLikeState); - if (tweet.getIsLike() == 1) { - vh.tvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color - .day_colorPrimary)); - } else { - vh.tvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color - .gray)); - } - PlatfromUtil.setPlatFromString(vh.platform, tweet.getAppclient()); - return convertView; - } - - private void updateLikeState(ViewHolder vh, Tweet tweet) { - if (tweet.getIsLike() == 1) { - tweet.setIsLike(0); - tweet.setLikeCount(tweet.getLikeCount() - 1); - if (!tweet.getLikeUser().isEmpty()) { - tweet.getLikeUser().remove(0); - } - OSChinaApi.pubUnLikeTweet(tweet.getId(), tweet.getAuthorid(), - handler); - vh.tvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color - .gray)); - } else { - vh.tvLikeState.setAnimation(KJAnimations.getScaleAnimation(1.5f, 300)); - tweet.getLikeUser().add(0, AppContext.getInstance().getLoginUser()); - OSChinaApi.pubLikeTweet(tweet.getId(), tweet.getAuthorid(), handler); - vh.tvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color - .day_colorPrimary)); - tweet.setIsLike(1); - tweet.setLikeCount(tweet.getLikeCount() + 1); - } - tweet.setLikeUsers(context, vh.likeUsers, true); - } - - private void optionDel(Context context, final Tweet tweet, final int position) { - - DialogHelp.getConfirmDialog(context, "确定删除吗?", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - OSChinaApi.deleteTweet(tweet.getAuthorid(), tweet.getId(), - new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, - byte[] arg2) { - mDatas.remove(position); - notifyDataSetChanged(); - } - - @Override - public void onFailure(int arg0, Header[] arg1, - byte[] arg2, Throwable arg3) { - } - }); - } - }).show(); - } - - /** - * 动态设置动弹列表图片显示规则 - */ - private void showTweetImage(final ViewHolder vh, String imgSmall, final String imgBig) { - if (!TextUtils.isEmpty(imgBig)) { - vh.image.setTag(imgBig); - new Core.Builder().view(vh.image).size(300, 300).url(imgBig + "?300X300") - .loadBitmapRes(R.drawable.pic_bg).doTask(); - vh.image.setVisibility(AvatarView.VISIBLE); - } else { - vh.image.setVisibility(AvatarView.GONE); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/TweetLikeAdapter.java b/app/src/main/java/net/oschina/app/adapter/TweetLikeAdapter.java deleted file mode 100644 index 2dc6aa678e1621568112a25b4b9b3ddad07960ee..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/TweetLikeAdapter.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.oschina.app.adapter; - -import android.annotation.SuppressLint; -import android.text.Spanned; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.TweetLike; -import net.oschina.app.util.PlatfromUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 动弹点赞适配器 TweetLikeAdapter.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * @data 2015-4-10 上午10:19:19 - */ -public class TweetLikeAdapter extends ListBaseAdapter { - - @SuppressLint("InflateParams") - @Override - protected View getRealView(int position, View convertView, - final ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_tweet_like, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - final TweetLike item = (TweetLike) mDatas.get(position); - - vh.name.setText(item.getUser().getName().trim()); - - vh.action.setText("赞了我的动弹"); - - vh.time.setText(StringUtils.friendly_time(item.getDatatime().trim())); - - PlatfromUtil.setPlatFromString(vh.from, item.getAppClient()); - vh.avatar.setUserInfo(item.getUser().getId(), item.getUser().getName()); - vh.avatar.setAvatarUrl(item.getUser().getPortrait()); - - vh.reply.setMovementMethod(MyLinkMovementMethod.a()); - vh.reply.setFocusable(false); - vh.reply.setDispatchToParent(true); - vh.reply.setLongClickable(false); - Spanned span = UIHelper.parseActiveReply(item.getTweet().getAuthor(), - item.getTweet().getBody()); - vh.reply.setText(span); - MyURLSpan.parseLinkText(vh.reply, span); - - return convertView; - } - - static class ViewHolder { - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_action) - TextView action; - @InjectView(R.id.tv_reply) - TweetTextView reply; - @InjectView(R.id.iv_avatar) - AvatarView avatar; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/adapter/TweetLikeUsersAdapter.java b/app/src/main/java/net/oschina/app/adapter/TweetLikeUsersAdapter.java deleted file mode 100644 index 96110041bf15d11281f5e348d6ec55b420bcfed4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/TweetLikeUsersAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.oschina.app.adapter; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.User; -import net.oschina.app.widget.AvatarView; - -/** - * TweetLikeUsersAdapter.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-3-26 下午4:11:25 - */ -public class TweetLikeUsersAdapter extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - // TODO Auto-generated method stub - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_tweet_like_user, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - User item = mDatas.get(position); - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.name.setText(item.getName()); - return convertView; - } - - static class ViewHolder { - - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_name) - TextView name; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} - diff --git a/app/src/main/java/net/oschina/app/adapter/UserFavoriteAdapter.java b/app/src/main/java/net/oschina/app/adapter/UserFavoriteAdapter.java deleted file mode 100644 index 405820f3e1f5c68f107ae293a523de19f049fe8d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/UserFavoriteAdapter.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.oschina.app.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Favorite; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class UserFavoriteAdapter extends ListBaseAdapter { - - static class ViewHolder { - - @InjectView(R.id.tv_favorite_title) TextView title; - - public ViewHolder(View view) { - ButterKnife.inject(this,view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_favorite, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - Favorite favorite = (Favorite) mDatas.get(position); - - vh.title.setText(favorite.getTitle()); - return convertView; - } - -} diff --git a/app/src/main/java/net/oschina/app/adapter/ViewPageFragmentAdapter.java b/app/src/main/java/net/oschina/app/adapter/ViewPageFragmentAdapter.java deleted file mode 100644 index e216768150fde748f7c538d659053a2ca95c4800..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/ViewPageFragmentAdapter.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.oschina.app.adapter; - -import java.util.ArrayList; - -import net.oschina.app.R; -import net.oschina.app.widget.PagerSlidingTabStrip; -import android.annotation.SuppressLint; -import android.content.Context; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.view.PagerAdapter; -import android.support.v4.view.ViewPager; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.TextView; - -@SuppressLint("Recycle") -public class ViewPageFragmentAdapter extends FragmentStatePagerAdapter { - - private final Context mContext; - protected PagerSlidingTabStrip mPagerStrip; - private final ViewPager mViewPager; - private final ArrayList mTabs = new ArrayList(); - - public ViewPageFragmentAdapter(FragmentManager fm, - PagerSlidingTabStrip pageStrip, ViewPager pager) { - super(fm); - mContext = pager.getContext(); - mPagerStrip = pageStrip; - mViewPager = pager; - mViewPager.setAdapter(this); - mPagerStrip.setViewPager(mViewPager); - } - - public void addTab(String title, String tag, Class clss, Bundle args) { - ViewPageInfo viewPageInfo = new ViewPageInfo(title, tag, clss, args); - addFragment(viewPageInfo); - } - - public void addAllTab(ArrayList mTabs) { - for (ViewPageInfo viewPageInfo : mTabs) { - addFragment(viewPageInfo); - } - } - - private void addFragment(ViewPageInfo info) { - if (info == null) { - return; - } - - // 加入tab title - View v = LayoutInflater.from(mContext).inflate( - R.layout.base_viewpage_fragment_tab_item, null, false); - TextView title = (TextView) v.findViewById(R.id.tab_title); - title.setText(info.title); - mPagerStrip.addTab(v); - - mTabs.add(info); - notifyDataSetChanged(); - } - - /** - * 移除第一次 - */ - public void remove() { - remove(0); - } - - /** - * 移除一个tab - * - * @param index - * 备注:如果index小于0,则从第一个开始删 如果大于tab的数量值则从最后一个开始删除 - */ - public void remove(int index) { - if (mTabs.isEmpty()) { - return; - } - if (index < 0) { - index = 0; - } - if (index >= mTabs.size()) { - index = mTabs.size() - 1; - } - mTabs.remove(index); - mPagerStrip.removeTab(index, 1); - notifyDataSetChanged(); - } - - /** - * 移除所有的tab - */ - public void removeAll() { - if (mTabs.isEmpty()) { - return; - } - mPagerStrip.removeAllTab(); - mTabs.clear(); - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return mTabs.size(); - } - - @Override - public int getItemPosition(Object object) { - return PagerAdapter.POSITION_NONE; - } - - @Override - public Fragment getItem(int position) { - ViewPageInfo info = mTabs.get(position); - return Fragment.instantiate(mContext, info.clss.getName(), info.args); - } - - @Override - public CharSequence getPageTitle(int position) { - return mTabs.get(position).title; - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/adapter/ViewPageInfo.java b/app/src/main/java/net/oschina/app/adapter/ViewPageInfo.java deleted file mode 100644 index 61307db2ee4c5f03961c4449330b5529aed5edd5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/adapter/ViewPageInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.oschina.app.adapter; - -import android.os.Bundle; - -public final class ViewPageInfo { - - public final String tag; - public final Class clss; - public final Bundle args; - public final String title; - - public ViewPageInfo(String _title, String _tag, Class _class, Bundle _args) { - title = _title; - tag = _tag; - clss = _class; - args = _args; - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/api/ApiClientHelper.java b/app/src/main/java/net/oschina/app/api/ApiClientHelper.java deleted file mode 100644 index f6da3026481e84c4c39d322bbb664e9d76ef2374..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/ApiClientHelper.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.oschina.app.api; - -import net.oschina.app.AppContext; - -public class ApiClientHelper { - - /** - * 获得请求的服务端数据的userAgent - * @param appContext - * @return - */ - public static String getUserAgent(AppContext appContext) { - StringBuilder ua = new StringBuilder("OSChina.NET"); - ua.append('/' + appContext.getPackageInfo().versionName + '_' - + appContext.getPackageInfo().versionCode);// app版本信息 - ua.append("/Android");// 手机系统平台 - ua.append("/" + android.os.Build.VERSION.RELEASE);// 手机系统版本 - ua.append("/" + android.os.Build.MODEL); // 手机型号 - ua.append("/" + appContext.getAppId());// 客户端唯一标识 - return ua.toString(); - } -} diff --git a/app/src/main/java/net/oschina/app/api/ApiHttpClient.java b/app/src/main/java/net/oschina/app/api/ApiHttpClient.java deleted file mode 100644 index 47e124aff7a4da23d0e3d9488cee70197dca2a3c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/ApiHttpClient.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.oschina.app.api; - -import android.content.Context; -import android.util.Log; -import cz.msebera.android.httpclient.client.params.ClientPNames; - -import com.loopj.android.http.AsyncHttpClient; -import com.loopj.android.http.AsyncHttpResponseHandler; -import com.loopj.android.http.RequestParams; - -import net.oschina.app.AppContext; -import net.oschina.app.util.TLog; - -import java.util.Locale; - -public class ApiHttpClient { - - public final static String HOST = "www.oschina.net"; - private static String API_URL = "http://www.oschina.net/%s"; -// public final static String HOST = "192.168.1.101"; -// private static String API_URL = "http://192.168.1.101/%s"; - public static final String DELETE = "DELETE"; - public static final String GET = "GET"; - public static final String POST = "POST"; - public static final String PUT = "PUT"; - public static AsyncHttpClient client; - - public ApiHttpClient() { - } - - public static AsyncHttpClient getHttpClient() { - return client; - } - - public static void cancelAll(Context context) { - client.cancelRequests(context, true); - } - - public static void clearUserCookies(Context context) { - // (new HttpClientCookieStore(context)).a(); - } - - public static void delete(String partUrl, AsyncHttpResponseHandler handler) { - client.delete(getAbsoluteApiUrl(partUrl), handler); - log(new StringBuilder("DELETE ").append(partUrl).toString()); - } - - public static void get(String partUrl, AsyncHttpResponseHandler handler) { - client.get(getAbsoluteApiUrl(partUrl), handler); - log(new StringBuilder("GET ").append(partUrl).toString()); - } - - public static void get(String partUrl, RequestParams params, - AsyncHttpResponseHandler handler) { - client.get(getAbsoluteApiUrl(partUrl), params, handler); - log(new StringBuilder("GET ").append(partUrl).append("&") - .append(params).toString()); - } - - public static String getAbsoluteApiUrl(String partUrl) { - String url = partUrl; - if (!partUrl.startsWith("http:") && !partUrl.startsWith("https:")) { - url = String.format(API_URL, partUrl); - } - Log.d("BASE_CLIENT", "request:" + url); - return url; - } - - public static String getApiUrl() { - return API_URL; - } - - public static void getDirect(String url, AsyncHttpResponseHandler handler) { - client.get(url, handler); - log(new StringBuilder("GET ").append(url).toString()); - } - - public static void log(String log) { - Log.d("BaseApi", log); - TLog.log("Test", log); - } - - public static void post(String partUrl, AsyncHttpResponseHandler handler) { - client.post(getAbsoluteApiUrl(partUrl), handler); - log(new StringBuilder("POST ").append(partUrl).toString()); - } - - public static void post(String partUrl, RequestParams params, - AsyncHttpResponseHandler handler) { - client.post(getAbsoluteApiUrl(partUrl), params, handler); - log(new StringBuilder("POST ").append(partUrl).append("&") - .append(params).toString()); - } - - public static void postDirect(String url, RequestParams params, - AsyncHttpResponseHandler handler) { - client.post(url, params, handler); - log(new StringBuilder("POST ").append(url).append("&").append(params) - .toString()); - } - - public static void put(String partUrl, AsyncHttpResponseHandler handler) { - client.put(getAbsoluteApiUrl(partUrl), handler); - log(new StringBuilder("PUT ").append(partUrl).toString()); - } - - public static void put(String partUrl, RequestParams params, - AsyncHttpResponseHandler handler) { - client.put(getAbsoluteApiUrl(partUrl), params, handler); - log(new StringBuilder("PUT ").append(partUrl).append("&") - .append(params).toString()); - } - - public static void setApiUrl(String apiUrl) { - API_URL = apiUrl; - } - - public static void setHttpClient(AsyncHttpClient c) { - client = c; - client.addHeader("Accept-Language", Locale.getDefault().toString()); - client.addHeader("Host", HOST); - client.addHeader("Connection", "Keep-Alive"); - client.getHttpClient().getParams() - .setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true); - - setUserAgent(ApiClientHelper.getUserAgent(AppContext.getInstance())); - } - - public static void setUserAgent(String userAgent) { - client.setUserAgent(userAgent); - } - - public static void setCookie(String cookie) { - client.addHeader("Cookie", cookie); - } - - private static String appCookie; - - public static void cleanCookie() { - appCookie = ""; - } - - public static String getCookie(AppContext appContext) { - if (appCookie == null || appCookie == "") { - appCookie = appContext.getProperty("cookie"); - } - return appCookie; - } -} diff --git a/app/src/main/java/net/oschina/app/api/ApiResponse.java b/app/src/main/java/net/oschina/app/api/ApiResponse.java deleted file mode 100644 index 119d9af584fa5d1a703fee3af0bb831b56ab6217..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/ApiResponse.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.oschina.app.api; - -import org.json.JSONObject; - -public class ApiResponse { - protected Object _data; - protected String _message; - protected int _errorCode; - protected boolean _isOk; - private long _total; - private String _serverTime; - private boolean isCanceled; - - public ApiResponse(JSONObject json) { - if (json != null) { - setData(json.optJSONObject("data") == null ? json - .optJSONArray("data") : json.optJSONObject("data")); - setMessage(json.optString("result_desc")); - setErrorCode(json.optInt("result_code")); - setOk(getErrorCode() == 0); - setServerTime(json.optString("timestamp")); - } - } - - public Object getData() { - return _data; - } - - public void setData(Object _data) { - this._data = _data; - } - - public boolean isOk() { - return _isOk; - } - - public void setOk(boolean _isOk) { - this._isOk = _isOk; - } - - public String getMessage() { - return _message; - } - - public void setMessage(String _message) { - this._message = _message; - } - - public int getErrorCode() { - return _errorCode; - } - - public void setErrorCode(int _errorCode) { - this._errorCode = _errorCode; - } - - @Override - public String toString() { - return "data:" + getData() + " message:" + getMessage() + " errocode:" - + _errorCode; - } - - public void update(ApiResponse response) { - _message = response.getMessage(); - } - - public void setTotal(long total) { - _total = total; - } - - public long getTotal() { - return _total; - } - - public String getServerTime() { - return _serverTime; - } - - public void setServerTime(String _serverTime) { - this._serverTime = _serverTime; - } - - public boolean isCanceled() { - return isCanceled; - } - - public void setCanceled(boolean isCanceled) { - this.isCanceled = isCanceled; - } -} diff --git a/app/src/main/java/net/oschina/app/api/OperationResponseHandler.java b/app/src/main/java/net/oschina/app/api/OperationResponseHandler.java deleted file mode 100644 index 604fdca13259aaea817a747d3ad98c12e09703e9..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/OperationResponseHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.oschina.app.api; - -import java.io.ByteArrayInputStream; - - -import android.os.Looper; -import cz.msebera.android.httpclient.Header; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -public class OperationResponseHandler extends AsyncHttpResponseHandler { - - private Object[] args; - - public OperationResponseHandler(Looper looper, Object... args) { - super(looper); - this.args = args; - } - - public OperationResponseHandler(Object... args) { - this.args = args; - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { - onFailure(arg0, arg3.getMessage(), args); - } - - public void onFailure(int code, String errorMessage, Object[] args) { - } - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - onSuccess(arg0, new ByteArrayInputStream(arg2), args); - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, e.getMessage(), args); - } - } - - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - - } -} diff --git a/app/src/main/java/net/oschina/app/api/remote/OSChinaApi.java b/app/src/main/java/net/oschina/app/api/remote/OSChinaApi.java deleted file mode 100644 index cc5097959e8b65cb2ab05b106b1c4143db18d645..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/remote/OSChinaApi.java +++ /dev/null @@ -1,1029 +0,0 @@ -package net.oschina.app.api.remote; - -import android.text.TextUtils; - -import com.loopj.android.http.AsyncHttpResponseHandler; -import com.loopj.android.http.RequestParams; - -import net.oschina.app.AppContext; -import net.oschina.app.AppException; -import net.oschina.app.api.ApiHttpClient; -import net.oschina.app.bean.EventApplyData; -import net.oschina.app.bean.NewsList; -import net.oschina.app.bean.Report; -import net.oschina.app.bean.Tweet; -import net.oschina.app.team.bean.Team; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TLog; - -import org.kymjs.kjframe.utils.KJLoger; - -import java.io.File; -import java.io.FileNotFoundException; -import java.net.URLEncoder; - -public class OSChinaApi { - - /** - * 登陆 - * - * @param username - * @param password - * @param handler - */ - public static void login(String username, String password, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("username", username); - params.put("pwd", password); - params.put("keep_login", 1); - String loginurl = "action/api/login_validate"; - ApiHttpClient.post(loginurl, params, handler); - } - - public static void openIdLogin(String s) { - - } - - /** - * 获取新闻列表 - * - * @param catalog - * 类别 (1,2,3) - * @param page - * 第几页 - * @param handler - */ - public static void getNewsList(int catalog, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - if (catalog == NewsList.CATALOG_WEEK) { - params.put("show", "week"); - } else if (catalog == NewsList.CATALOG_MONTH) { - params.put("show", "month"); - } - ApiHttpClient.get("action/api/news_list", params, handler); - } - - public static void getBlogList(String type, int pageIndex, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("type", type); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/blog_list", params, handler); - } - - public static void getPostList(int catalog, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/post_list", params, handler); - } - - public static void getPostListByTag(String tag, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("tag", tag); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/post_list", params, handler); - } - - public static void getTweetList(int uid, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/tweet_list", params, handler); - } - - public static void getTweetTopicList(int page, String topic, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("pageIndex", page); - params.put("title", topic); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/tweet_topic_list", params, handler); - } - - public static void getTweetLikeList(AsyncHttpResponseHandler handler) { - ApiHttpClient.get("action/api/my_tweet_like_list", handler); - } - - public static void pubLikeTweet(int tweetId, int authorId, - AsyncHttpResponseHandler handler) { - - RequestParams params = new RequestParams(); - params.put("tweetid", tweetId); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("ownerOfTweet", authorId); - ApiHttpClient.post("action/api/tweet_like", params, handler); - } - - public static void pubUnLikeTweet(int tweetId, int authorId, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("tweetid", tweetId); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("ownerOfTweet", authorId); - ApiHttpClient.post("action/api/tweet_unlike", params, handler); - } - - public static void getTweetLikeList(int tweetId, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("tweetid", tweetId); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/tweet_like_list", params, handler); - - } - - public static void getActiveList(int uid, int catalog, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("catalog", catalog); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/active_list", params, handler); - } - - public static void getFriendList(int uid, int relation, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("relation", relation); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/friends_list", params, handler); - } - - /** - * 获取所有关注好友列表 - * - * @param uid - * 指定用户UID - * @param handler - * */ - public static void getAllFriendsList(int uid, int relation, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("relation", relation); - params.put("all", 1); - ApiHttpClient.get("action/api/friends_list", params, handler); - } - - /** - * 获取用户收藏 - * - * @param uid - * 指定用户UID - * @param type - * 收藏类型: 0:全部收藏 1:软件 2:话题 3:博客 4:新闻 5:代码 - * @param page - * @param handler - */ - public static void getFavoriteList(int uid, int type, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("type", type); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/favorite_list", params, handler); - } - - /** - * 分类列表 - * - * @param tag - * 第一级:0 - * @param handler - */ - public static void getSoftwareCatalogList(int tag, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("tag", tag); - ApiHttpClient.get("action/api/softwarecatalog_list", params, handler); - } - - public static void getSoftwareTagList(int searchTag, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("searchTag", searchTag); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/softwaretag_list", params, handler); - } - - /** - * @param searchTag - *   软件分类  推荐:recommend 最新:time 热门:view 国产:list_cn - * @param page - * @param handler - */ - public static void getSoftwareList(String searchTag, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("searchTag", searchTag); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/software_list", params, handler); - } - - /** - * 获取评论列表 - * - * @PARAM ID - * @PARAM CATALOG - * 1新闻 2帖子 3动弹 4动态 - * @PARAM PAGE - * @PARAM HANDLER - */ - public static void getCommentList(int id, int catalog, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("id", id); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - params.put("clientType", "android"); - ApiHttpClient.get("action/api/comment_list", params, handler); - } - - public static void getBlogCommentList(int id, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("id", id); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/blogcomment_list", params, handler); - } - - public static void getChatMessageList(int friendId, int page, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("id", friendId); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/message_detail", params, handler); - } - - public static void getUserInformation(int uid, int hisuid, String hisname, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("hisuid", hisuid); - params.put("hisname", hisname); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/user_information", params, handler); - } - - @SuppressWarnings("deprecation") - public static void getUserBlogList(int authoruid, final String authorname, - final int uid, final int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("authoruid", authoruid); - params.put("authorname", URLEncoder.encode(authorname)); - params.put("uid", uid); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/userblog_list", params, handler); - } - - public static void updateRelation(int uid, int hisuid, int newrelation, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("hisuid", hisuid); - params.put("newrelation", newrelation); - ApiHttpClient.post("action/api/user_updaterelation", params, handler); - } - - public static void getMyInformation(int uid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - ApiHttpClient.get("action/api/my_information", params, handler); - } - - /** - * 获取新闻明细 - * - * @param id 新闻的id - * @param handler - */ - public static void getNewsDetail(int id, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("id", id); - ApiHttpClient.get("action/api/news_detail", params, handler); - } - - public static void getBlogDetail(int id, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("id", id); - ApiHttpClient.get("action/api/blog_detail", params, handler); - } - - /** - * 获取软件详情 - * - * @param ident - * @param handler - */ - public static void getSoftwareDetail(String ident, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("ident", - ident); - ApiHttpClient.get("action/api/software_detail", params, handler); - } - - /*** - * 通过id获取软件详情 - * @param id - * @param handler - */ - public static void getSoftwareDetail(int id, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("id", - id); - ApiHttpClient.get("action/api/software_detail", params, handler); - } - - public static void getPostDetail(int id, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("id", id); - ApiHttpClient.get("action/api/post_detail", params, handler); - } - - public static void getTweetDetail(int id, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams("id", id); - ApiHttpClient.get("action/api/tweet_detail", params, handler); - } - - /** - * 用户针对某个新闻,帖子,动弹,消息发表评论的接口,参数使用POST方式提交 - * - * @param catalog - *    1新闻  2 帖子  3 动弹  4消息中心 - * @param id - * 被评论的某条新闻,帖子,动弹或者某条消息的id - * @param uid - * 当天登陆用户的UID - * @param content - * 发表的评论内容 - * @param isPostToMyZone - * 是否转发到我的空间,0不转发  1转发到我的空间(注意该功能之对某条动弹进行评论是有效,其他情况下服务器借口可以忽略该参数) - * @param handler - */ - public static void publicComment(int catalog, int id, int uid, - String content, int isPostToMyZone, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("id", id); - params.put("uid", uid); - params.put("content", content); - params.put("isPostToMyZone", isPostToMyZone); - ApiHttpClient.post("action/api/comment_pub", params, handler); - } - - public static void replyComment(int id, int catalog, int replyid, - int authorid, int uid, String content, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("id", id); - params.put("uid", uid); - params.put("content", content); - params.put("replyid", replyid); - params.put("authorid", authorid); - ApiHttpClient.post("action/api/comment_reply", params, handler); - } - - public static void publicBlogComment(int blog, int uid, String content, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("blog", blog); - params.put("uid", uid); - params.put("content", content); - ApiHttpClient.post("action/api/blogcomment_pub", params, handler); - } - - public static void replyBlogComment(int blog, int uid, String content, - int reply_id, int objuid, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("blog", blog); - params.put("uid", uid); - params.put("content", content); - params.put("reply_id", reply_id); - params.put("objuid", objuid); - ApiHttpClient.post("action/api/blogcomment_pub", params, handler); - } - - public static void pubTweet(Tweet tweet, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", tweet.getAuthorid()); - params.put("msg", tweet.getBody()); - - // Map files = new HashMap(); - if (!TextUtils.isEmpty(tweet.getImageFilePath())) { - try { - params.put("img", new File(tweet.getImageFilePath())); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - if (!TextUtils.isEmpty(tweet.getAudioPath())) { - try { - params.put("amr", new File(tweet.getAudioPath())); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - ApiHttpClient.post("action/api/tweet_pub", params, handler); - } - - public static void pubSoftWareTweet(Tweet tweet, int softid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", tweet.getAuthorid()); - params.put("msg", tweet.getBody()); - params.put("project", softid); - ApiHttpClient.post("action/api/software_tweet_pub", params, handler); - } - - public static void deleteTweet(int uid, int tweetid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("tweetid", tweetid); - ApiHttpClient.post("action/api/tweet_delete", params, handler); - } - - public static void deleteComment(int id, int catalog, int replyid, - int authorid, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("id", id); - params.put("catalog", catalog); - params.put("replyid", replyid); - params.put("authorid", authorid); - ApiHttpClient.post("action/api/comment_delete", params, handler); - } - - public static void deleteBlog(int uid, int authoruid, int id, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("authoruid", authoruid); - params.put("id", id); - ApiHttpClient.post("action/api/userblog_delete", params, handler); - } - - public static void deleteBlogComment(int uid, int blogid, int replyid, - int authorid, int owneruid, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("blogid", blogid); - params.put("replyid", replyid); - params.put("authorid", authorid); - params.put("owneruid", owneruid); - ApiHttpClient.post("action/api/blogcomment_delete", params, handler); - } - - /** - * 用户添加收藏 - * - * @param uid - * 用户UID - * @param objid - * 比如是新闻ID 或者问答ID 或者动弹ID - * @param type - * 1:软件 2:话题 3:博客 4:新闻 5:代码 - */ - public static void addFavorite(int uid, int objid, int type, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("objid", objid); - params.put("type", type); - ApiHttpClient.post("action/api/favorite_add", params, handler); - } - - public static void delFavorite(int uid, int objid, int type, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("objid", objid); - params.put("type", type); - ApiHttpClient.post("action/api/favorite_delete", params, handler); - } - - public static void getSearchList(String catalog, String content, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("content", content); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/search_list", params, handler); - } - - public static void publicMessage(int uid, int receiver, String content, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("receiver", receiver); - params.put("content", content); - - ApiHttpClient.post("action/api/message_pub", params, handler); - } - - public static void deleteMessage(int uid, int friendid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("friendid", friendid); - ApiHttpClient.post("action/api/message_delete", params, handler); - } - - public static void forwardMessage(int uid, String receiverName, - String content, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("receiverName", receiverName); - params.put("content", content); - ApiHttpClient.post("action/api/message_pub", params, handler); - } - - public static void getMessageList(int uid, int pageIndex, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/message_list", params, handler); - } - - public static void updatePortrait(int uid, File portrait, - AsyncHttpResponseHandler handler) throws FileNotFoundException { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("portrait", portrait); - ApiHttpClient.post("action/api/portrait_update", params, handler); - } - - public static void getNotices(AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - ApiHttpClient.get("action/api/user_notice", params, handler); - } - - /** - * 清空通知消息 - * - * @param uid - * @param type - * 1:@我的信息 2:未读消息 3:评论个数 4:新粉丝个数 - * @return - * @throws AppException - */ - public static void clearNotice(int uid, int type, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("type", type); - ApiHttpClient.post("action/api/notice_clear", params, handler); - } - - public static void singnIn(String url, AsyncHttpResponseHandler handler) { - ApiHttpClient.getDirect(url, handler); - } - - /** - * 获取软件的动态列表 - * - * @param softid - * @param handler - */ - public static void getSoftTweetList(int softid, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("project", softid); - params.put("pageIndex", page); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/software_tweet_list", params, handler); - } - - public static void checkUpdate(AsyncHttpResponseHandler handler) { - ApiHttpClient.get("MobileAppVersion.xml", handler); - } - - /** - * 查找用户 - * - * @param username - * @param handler - */ - public static void findUser(String username, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("name", username); - ApiHttpClient.get("action/api/find_user", params, handler); - } - - /** - * 获取活动列表 - * - * @param pageIndex - * @param uid - * <= 0 近期活动 实际的用户ID 则获取用户参与的活动列表,需要已登陆的用户 - * @param handler - */ - public static void getEventList(int pageIndex, int uid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("pageIndex", pageIndex); - params.put("uid", uid); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/event_list", params, handler); - } - - /** - * 获取某活动已出席的人员列表 - * - * @param eventId - * @param pageIndex - * @param handler - */ - public static void getEventApplies(int eventId, int pageIndex, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("pageIndex", pageIndex); - params.put("event_id", eventId); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/event_attend_user", params, handler); - } - - /** - * 举报 - * - * @param report - * @param handler - */ - public static void report(Report report, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("obj_id", report.getObjId()); - params.put("url", report.getUrl()); - params.put("obj_type", report.getObjType()); - params.put("reason", report.getReason()); - if (report.getOtherReason() != null - && !StringUtils.isEmpty(report.getOtherReason())) { - params.put("memo", report.getOtherReason()); - } - ApiHttpClient.post("action/communityManage/report", params, handler); - } - - /** - * 摇一摇,随机数据 - * - * @param handler - */ - public static void shake(AsyncHttpResponseHandler handler) { - shake(-1, handler); - } - - /** - * 摇一摇指定请求类型 - */ - public static void shake(int type, AsyncHttpResponseHandler handler) { - String inter = "action/api/rock_rock"; - if (type > 0) { - inter = (inter + "/?type=" + type); - } - ApiHttpClient.get(inter, handler); - } - - /** - * 活动报名 - * - * @param data - * @param handler - */ - public static void eventApply(EventApplyData data, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("event", data.getEvent()); - params.put("user", data.getUser()); - params.put("name", data.getName()); - params.put("gender", data.getGender()); - params.put("mobile", data.getPhone()); - params.put("company", data.getCompany()); - params.put("job", data.getJob()); - if (!StringUtils.isEmpty(data.getRemark())) { - params.put("misc_info", data.getRemark()); - } - ApiHttpClient.post("action/api/event_apply", params, handler); - } - - private static void uploadLog(String data, String report, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("app", "1"); - params.put("report", report); - params.put("msg", data); - ApiHttpClient.post("action/api/user_report_to_admin", params, handler); - } - - /** - * BUG上报 - * - * @param data - * @param handler - */ - public static void uploadLog(String data, AsyncHttpResponseHandler handler) { - uploadLog(data, "1", handler); - } - - /** - * 反馈意见 - * - * @param data - * @param handler - */ - public static void feedback(String data, AsyncHttpResponseHandler handler) { - uploadLog(data, "2", handler); - } - - /** - * team动态 - * - * @param team - * @param page - * @param handler - */ - public static void teamDynamic(Team team, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - // int uid = AppContext.getInstance().getLoginUid(); - // params.put("uid", uid); - params.put("teamid", team.getId()); - params.put("pageIndex", page); - params.put("pageSize", 20); - params.put("type", "all"); - ApiHttpClient.get("action/api/team_active_list", params, handler); - } - - /** - * 获取team列表 - * - * @param handler - */ - public static void teamList(AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - ApiHttpClient.get("action/api/team_list", params, handler); - } - - /** - * 获取team成员列表 - * - * @param handler - */ - public static void getTeamMemberList(int teamid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - ApiHttpClient.get("action/api/team_member_list", params, handler); - } - - /** - * 获取team成员个人信息 - * - * @param handler - */ - public static void getTeamUserInfo(String teamid, String uid, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("uid", uid); - params.put("pageIndex", pageIndex); - params.put("pageSize", 20); - ApiHttpClient.get("action/api/team_user_information", params, handler); - } - - /** - * 获取我的任务中进行中、未完成、已完成等状态的数量 - */ - public static void getMyIssueState(String teamid, String uid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("uid", uid); - ApiHttpClient.get("action/api/team_user_issue_information", params, - handler); - } - - /** - * 获取指定用户的动态 - */ - public static void getUserDynamic(int teamid, String uid, int pageIndex, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("pageIndex", pageIndex); - params.put("pageSize", 20); - params.put("type", "git"); - params.put("uid", uid); - ApiHttpClient.get("action/api/team_active_list", params, handler); - } - - /** - * 动态详情 - * - * @param activeid - * @param teamid - * @param uid - * @param handler - */ - public static void getDynamicDetail(int activeid, int teamid, int uid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("uid", uid); - params.put("activeid", activeid); - ApiHttpClient.get("action/api/team_active_detail", params, handler); - } - - /** - * 获取指定用户的任务 - */ - public static void getMyIssue(String teamid, String uid, int pageIndex, - String type, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("uid", uid); - params.put("pageIndex", pageIndex); - params.put("pageSize", 20); - params.put("state", type); - params.put("projectid", "-1"); - ApiHttpClient.get("action/api/team_issue_list", params, handler); - } - - /** - * 获取指定周周报 - * - * @param teamid - * @param year - * @param week - * @param handler - */ - public static void getDiaryFromWhichWeek(int teamid, int year, int week, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("year", year); - params.put("week", week); - ApiHttpClient.get("action/api/team_diary_list", params, handler); - } - - /** - * 删除一个便签 - * - * @param id - * 便签id - * @param uid - * 用户id - */ - public static void deleteNoteBook(int id, int uid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("id", id); // 便签id - ApiHttpClient - .get("action/api/team_stickynote_recycle", params, handler); - } - - public static void getNoteBook(int uid, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - ApiHttpClient.get("action/api/team_sticky_list", params, handler); - } - - /** - * 获取指定周报的详细信息 - * - * @param teamid - * @param diaryid - * @param handler - */ - public static void getDiaryDetail(int teamid, int diaryid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("diaryid", diaryid); - ApiHttpClient.get("action/api/team_diary_detail", params, handler); - } - - /** - * diary评论列表 - * - * @param teamid - * @param diaryid - * @param handler - */ - public static void getDiaryComment(int teamid, int diaryid, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamid); - params.put("id", diaryid); - params.put("type", "diary"); - params.put("pageIndex", 0); - params.put("pageSize", "20"); - KJLoger.debug(teamid + "==getDiaryComment接口=" + diaryid); - ApiHttpClient - .get("action/api/team_reply_list_by_type", params, handler); - } - - /** - * 周报评论(以后可改为全局评论) - * - * @param uid - * @param teamid - * @param diaryId - * @param content - * @param handler - */ - public static void sendComment(int uid, int teamid, int diaryId, - String content, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("teamid", teamid); - params.put("type", "118"); - params.put("tweetid", diaryId); - params.put("content", content); - ApiHttpClient.post("action/api/team_tweet_reply", params, handler); - } - - /*** - * 客户端扫描二维码登陆 - * - * @author 火蚁 2015-3-13 上午11:45:47 - * - * @return void - * @param url - * @param handler - */ - public static void scanQrCodeLogin(String url, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - String uuid = url.substring(url.lastIndexOf("=") + 1); - params.put("uuid", uuid); - ApiHttpClient.getDirect(url, handler); - } - - /*** - * 使用第三方登陆 - * @param catalog 类别 - * @param openIdInfo 第三方的info - * @param handler handler - */ - public static void open_login(String catalog, String openIdInfo, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("openid_info", openIdInfo); - ApiHttpClient.post("action/api/openid_login", params, handler); - } - - /*** - * 第三方登陆账号绑定 - * @param catalog 类别(QQ、wechat) - * @param openIdInfo 第三方info - * @param userName 用户名 - * @param pwd 密码 - * @param handler handler - */ - public static void bind_openid(String catalog, String openIdInfo, String userName, String pwd, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("openid_info", openIdInfo); - params.put("username", userName); - params.put("pwd", pwd); - ApiHttpClient.post("action/api/openid_bind", params, handler); - } - - /*** - * 使用第三方账号注册 - * @param catalog 类别(qq、wechat) - * @param openIdInfo 第三方info - * @param handler handler - */ - public static void openid_reg(String catalog, String openIdInfo, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("catalog", catalog); - params.put("openid_info", openIdInfo); - ApiHttpClient.post("action/api/openid_reg", params, handler); - } -} diff --git a/app/src/main/java/net/oschina/app/api/remote/OSChinaTeamApi.java b/app/src/main/java/net/oschina/app/api/remote/OSChinaTeamApi.java deleted file mode 100644 index 584b19d7746fa260450acdbe96a3300a5b25ac61..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/api/remote/OSChinaTeamApi.java +++ /dev/null @@ -1,426 +0,0 @@ -package net.oschina.app.api.remote; - -import java.io.File; -import java.io.FileNotFoundException; - -import net.oschina.app.AppContext; -import net.oschina.app.api.ApiHttpClient; -import net.oschina.app.team.bean.TeamIssue; -import net.oschina.app.team.bean.TeamProject; -import android.text.TextUtils; - -import com.loopj.android.http.AsyncHttpResponseHandler; -import com.loopj.android.http.RequestParams; - -/** - * osc team api集合类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月14日 下午3:32:18 - * - */ -public class OSChinaTeamApi { - - /** - * 获取团队项目列表 - * - * @param teamId - * @param handler - */ - public static void getTeamProjectList(int teamId, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - ApiHttpClient.get("action/api/team_project_list", params, handler); - } - - /** - * 获取team动态列表 - * - * @param teamId - * @param activeId - * @param pageIndex - * @param handler - */ - public static void getTeamCommentList(int teamId, int activeId, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("id", activeId); - params.put("pageIndex", pageIndex); - params.put("pageSize", 20); - ApiHttpClient.get("action/api/team_reply_list_by_activeid", params, - handler); - } - - /*** - * 获取团队绑定项目的成员列表(包括管理员以及开发者) - * - * @author 火蚁 2015-2-5 下午6:45:41 - * - * @return void - * @param teamId - * @param teamProject - * @param handler - */ - public static void getTeamProjectMemberList(int teamId, - TeamProject teamProject, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("projectid", teamProject.getGit().getId()); - String source = teamProject.getSource(); - if (source != null && !TextUtils.isEmpty(source)) { - - params.put("source", teamProject.getSource()); - } - ApiHttpClient.get("action/api/team_project_member_list", params, - handler); - } - - /*** - * 获取项目的动态列表 - * - * @author 火蚁 2015-3-2 下午5:18:54 - * - * @return void - * @param teamId - * @param project - * @param type - * "all"(default),"issue","code","other" - * @param page - * @param handler - */ - public static void getTeamProjectActiveList(int teamId, - TeamProject project, String type, int page, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("projectid", project.getGit().getId()); - if (!TextUtils.isEmpty(project.getSource())) { - params.put("source", project.getSource()); - } - params.put("type", type); - params.put("pageIndex", page); - ApiHttpClient.get("action/api/team_project_active_list", params, - handler); - } - - /** - * 获取某项目的任务列表 - * - * @param uId - * 用户id - * @param teamId - * 团队id - * @param projectId - * 项目id(当<=0或不设置时,查询非项目的任务列表) - * @param source - * "Git@OSC","GitHub"(只有设置了projectid值,这里才需要设置该值) - */ - public static void getTeamCatalogIssueList(int uId, int teamId, - int projectId, String source, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uId); - params.put("teamid", teamId); - params.put("projectid", projectId); - params.put("source", source); - ApiHttpClient.get("action/api/team_project_catalog_list", params, - handler); - } - - /** - * 获取指定任务列表的任务列表 - * - * @param teamId - * @param projectId - * 项目id(-1获取非项目任务列表, 0获取所有任务列表) - * @param catalogId - * 任务列表的的目录id - * @param source - * "Team@OSC"(default),"Git@OSC","GitHub",如果指定了projectid的值, - * 这个值就是必须的 - * @param uid - * 如果指定该值,则获取该id用户相关的任务 - * @param state - * "all"(default),"opened","closed","outdate" - * @param scope - * "tome"(default,指派给我的任务),"meto"(我指派的任务) - * @param pageIndex - * @param pageSize - * @param handler - */ - public static void getTeamIssueList(int teamId, int projectId, - int catalogId, String source, int uid, String state, String scope, - int pageIndex, int pageSize, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("projectid", projectId); - params.put("catalogid", catalogId); - params.put("source", source); - params.put("uid", uid); - params.put("state", state); - params.put("scope", scope); - params.put("pageIndex", pageIndex); - params.put("pageSize", pageSize); - ApiHttpClient.get("action/api/team_issue_list", params, handler); - } - - /*** - * 改变一个任务的状态 - * - * @author 火蚁 2015-3-6 上午11:44:01 - * - * @return void - * @param teamId - * @param issue - * @param target - * 修改的属性("state" : 状态, "assignee" 指派人, "deadline" : 截止日期) - * @param handler - */ - public static void changeIssueState(int teamId, TeamIssue issue, - String target, AsyncHttpResponseHandler handler) { - if (issue == null) - return; - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("teamid", teamId); - params.put("target", target); - params.put("issueid", issue.getId()); - if (target.equals("state")) { - params.put("state", issue.getState()); - } else if (target.equals("assignee")) { - params.put("assignee", issue.getToUser().getId()); - } else if (target.equals("deadline")) { - params.put("deadline", issue.getDeadlineTime()); - } - ApiHttpClient.post("action/api/team_issue_update", params, handler); - } - - public static void pubTeamNewIssue(RequestParams params, - AsyncHttpResponseHandler handler) { - ApiHttpClient.post("action/api/team_issue_pub", params, handler); - } - - /*** - * 获取团队的讨论区列表 - * - * @param type - * @param teamId - * @param uid - * @param pageIndex - * @param handler - */ - public static void getTeamDiscussList(String type, int teamId, int uid, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("type", type); - params.put("teamid", teamId); - params.put("uid", uid); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/team_discuss_list", params, handler); - } - - /*** - * 获取讨论贴详情 - * - * @author 火蚁 2015-2-2 下午6:19:54 - * - * @return void - * @param teamId - * @param discussId - * @param handler - */ - public static void getTeamDiscussDetail(int teamId, int discussId, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("discussid", discussId); - ApiHttpClient.get("action/api/team_discuss_detail", params, handler); - } - - /*** - * 发表讨论贴评论 - * - * @author 火蚁 2015-2-3 下午2:42:54 - * - * @return void - * @param uid - * @param teamId - * @param dicussId - * @param content - * @param handler - */ - public static void pubTeamDiscussReply(int uid, int teamId, int discussId, - String content, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("teamid", teamId); - params.put("discussid", discussId); - params.put("content", content); - ApiHttpClient.post("action/api/team_discuss_reply", params, handler); - } - - /*** - * 发表一条综合评论 动态、分享内容、周报 - * - * @author 火蚁 2015-3-6 下午3:31:07 - * - * @return void - * @param teamId - * @param type - * 普通动态-110,分享内容-114, 周报-118 - * @param tweetId - * @param content - * @param handler - */ - public static void pubTeamTweetReply(int teamId, int type, long tweetId, - String content, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("type", type); - params.put("teamid", teamId); - params.put("tweetid", tweetId); - params.put("content", content); - ApiHttpClient.post("action/api/team_tweet_reply", params, handler); - } - - /*** - * 获取团队任务详情 - * - * @author 火蚁 2015-1-27 下午7:47:17 - * - */ - public static void getTeamIssueDetail(int teamId, int issueId, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("issueid", issueId); - ApiHttpClient.get("action/api/team_issue_detail", params, handler); - } - - /*** - * 获取团队的周报列表 - * - * @param uid - * @param teamId - * @param year - * @param week - * @param pageIndex - * @param handler - */ - public static void getTeamDiaryList(int uid, int teamId, int year, - int week, int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", uid); - params.put("teamid", teamId); - params.put("year", year); - params.put("week", week); - params.put("pageIndex", pageIndex); - params.put("pageSize", AppContext.PAGE_SIZE); - ApiHttpClient.get("action/api/team_diary_list", params, handler); - } - - /*** - * 任务、周报、讨论的回复列表 - * - * @author 火蚁 2015-2-2 上午11:39:04 - * - * @return void - * @param teamId - * @param id - * @param type - * 评论列表的类型(周报diary,讨论discuss,任务issue) - * @param pageIndex - * @param handler - */ - public static void getTeamReplyList(int teamId, int id, String type, - int pageIndex, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("id", id); - params.put("type", type); - params.put("pageIndex", pageIndex); - ApiHttpClient - .get("action/api/team_reply_list_by_type", params, handler); - - } - - /*** - * 发表一个新的团队动态 - * - * @author 火蚁 2015-3-9 下午2:46:13 - * - * @return void - * @param teamId - * @param content - * @param img - * @param handler - */ - public static void pubTeamNewActive(int teamId, String content, File img, - AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("teamid", teamId); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("msg", content); - params.put("appid", 3); - if (img != null) { - - try { - params.put("img", img); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - } - ApiHttpClient.post("action/api/team_tweet_pub", params, handler); - } - - /*** - * 更新子任务属性 - * - * @author 火蚁 2015-3-10 下午4:53:49 - * - * @return void - * @param teamId - * @param target - * @param childIssue - * @param handler - */ - public static void updateChildIssue(int teamId, String target, - TeamIssue childIssue, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("teamid", teamId); - params.put("childissueid", childIssue.getId()); - params.put("target", target); - if (target.equals("state")) { - params.put("state", childIssue.getState()); - } else { - params.put("title", childIssue.getTitle()); - } - ApiHttpClient.post("action/api/team_issue_update_child_issue", params, - handler); - } - - /*** - * 发表任务评论 - * - * @author 火蚁 2015-3-13 下午6:22:41 - * - * @return void - * @param teamId - * @param issueId - * @param content - * @param handler - */ - public static void pubTeamIssueReply(int teamId, int issueId, - String content, AsyncHttpResponseHandler handler) { - RequestParams params = new RequestParams(); - params.put("uid", AppContext.getInstance().getLoginUid()); - params.put("teamid", teamId); - params.put("content", content); - params.put("issueid", issueId); - ApiHttpClient.post("action/api/team_issue_reply", params, handler); - } -} diff --git a/app/src/main/java/net/oschina/app/base/BaseActivity.java b/app/src/main/java/net/oschina/app/base/BaseActivity.java deleted file mode 100644 index 99c32cd5802a89115de2d82d4d62bc1b035725e5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseActivity.java +++ /dev/null @@ -1,217 +0,0 @@ -package net.oschina.app.base; - -import android.app.ProgressDialog; -import android.os.Bundle; -import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarActivity; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.AppManager; -import net.oschina.app.R; -import net.oschina.app.interf.BaseViewInterface; -import net.oschina.app.ui.dialog.CommonToast; -import net.oschina.app.ui.dialog.DialogControl; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.TDevice; - -import org.kymjs.kjframe.utils.StringUtils; - -import butterknife.ButterKnife; - -/** - * baseActionBar Activity - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月25日 上午11:30:15 引用自:tonlin - */ -public abstract class BaseActivity extends ActionBarActivity implements - DialogControl, View.OnClickListener, BaseViewInterface { - public static final String INTENT_ACTION_EXIT_APP = "INTENT_ACTION_EXIT_APP"; - - private boolean _isVisible; - private ProgressDialog _waitDialog; - - protected LayoutInflater mInflater; - protected ActionBar mActionBar; - private TextView mTvActionTitle; - - @Override - protected void onDestroy() { - super.onDestroy(); - TDevice.hideSoftKeyboard(getCurrentFocus()); - ButterKnife.reset(this); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (AppContext.getNightModeSwitch()) { - setTheme(R.style.AppBaseTheme_Night); - } else { - setTheme(R.style.AppBaseTheme_Light); - } - AppManager.getAppManager().addActivity(this); - if (!hasActionBar()) { - // supportRequestWindowFeature(Window.FEATURE_NO_TITLE); - } - onBeforeSetContentLayout(); - if (getLayoutId() != 0) { - setContentView(getLayoutId()); - } - mActionBar = getSupportActionBar(); - mInflater = getLayoutInflater(); - if (hasActionBar()) { - initActionBar(mActionBar); - } - - // 通过注解绑定控件 - ButterKnife.inject(this); - - init(savedInstanceState); - initView(); - initData(); - _isVisible = true; - } - - protected void onBeforeSetContentLayout() {} - - protected boolean hasActionBar() { - return true; - } - - protected int getLayoutId() { - return 0; - } - - protected View inflateView(int resId) { - return mInflater.inflate(resId, null); - } - - protected int getActionBarTitle() { - return R.string.app_name; - } - - protected boolean hasBackButton() { - return false; - } - - protected void init(Bundle savedInstanceState) {} - - protected void initActionBar(ActionBar actionBar) { - if (actionBar == null) - return; - if (hasBackButton()) { - mActionBar.setDisplayHomeAsUpEnabled(true); - mActionBar.setHomeButtonEnabled(true); - } else { - actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE); - actionBar.setDisplayUseLogoEnabled(false); - int titleRes = getActionBarTitle(); - if (titleRes != 0) { - actionBar.setTitle(titleRes); - } - } - } - - public void setActionBarTitle(int resId) { - if (resId != 0) { - setActionBarTitle(getString(resId)); - } - } - - public void setActionBarTitle(String title) { - if (StringUtils.isEmpty(title)) { - title = getString(R.string.app_name); - } - if (hasActionBar() && mActionBar != null) { - if (mTvActionTitle != null) { - mTvActionTitle.setText(title); - } - mActionBar.setTitle(title); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - onBackPressed(); - break; - - default: - break; - } - return super.onOptionsItemSelected(item); - } - - @Override - protected void onPause() { - super.onPause(); - } - - @Override - protected void onResume() { - super.onResume(); - } - - public void showToast(int msgResid, int icon, int gravity) { - showToast(getString(msgResid), icon, gravity); - } - - public void showToast(String message, int icon, int gravity) { - CommonToast toast = new CommonToast(this); - toast.setMessage(message); - toast.setMessageIc(icon); - toast.setLayoutGravity(gravity); - toast.show(); - } - - @Override - public ProgressDialog showWaitDialog() { - return showWaitDialog(R.string.loading); - } - - @Override - public ProgressDialog showWaitDialog(int resid) { - return showWaitDialog(getString(resid)); - } - - @Override - public ProgressDialog showWaitDialog(String message) { - if (_isVisible) { - if (_waitDialog == null) { - _waitDialog = DialogHelp.getWaitDialog(this, message); - } - if (_waitDialog != null) { - _waitDialog.setMessage(message); - _waitDialog.show(); - } - return _waitDialog; - } - return null; - } - - @Override - public void hideWaitDialog() { - if (_isVisible && _waitDialog != null) { - try { - _waitDialog.dismiss(); - _waitDialog = null; - } catch (Exception ex) { - ex.printStackTrace(); - } - } - } - - @Override - public boolean onMenuOpened(int featureId, Menu menu) { - - // setOverflowIconVisible(featureId, menu); - return super.onMenuOpened(featureId, menu); - } -} diff --git a/app/src/main/java/net/oschina/app/base/BaseApplication.java b/app/src/main/java/net/oschina/app/base/BaseApplication.java deleted file mode 100644 index 975c33f795db1ec96c248a3af38455603d3059ef..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseApplication.java +++ /dev/null @@ -1,264 +0,0 @@ -package net.oschina.app.base; - -import android.annotation.SuppressLint; -import android.annotation.TargetApi; -import android.app.Activity; -import android.app.Application; -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.content.res.Resources; -import android.os.Build; -import android.util.DisplayMetrics; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; - -import net.oschina.app.R; -import net.oschina.app.util.StringUtils; - -@SuppressLint("InflateParams") -public class BaseApplication extends Application { - private static String PREF_NAME = "creativelocker.pref"; - private static String LAST_REFRESH_TIME = "last_refresh_time.pref"; - static Context _context; - static Resources _resource; - private static String lastToast = ""; - private static long lastToastTime; - - private static boolean sIsAtLeastGB; - - static { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - sIsAtLeastGB = true; - } - } - - @Override - public void onCreate() { - super.onCreate(); - _context = getApplicationContext(); - _resource = _context.getResources(); - } - - public static synchronized BaseApplication context() { - return (BaseApplication) _context; - } - - public static Resources resources() { - return _resource; - } - - /** - * 放入已读文章列表中 - * - */ - public static void putReadedPostList(String prefFileName, String key, - String value) { - SharedPreferences preferences = getPreferences(prefFileName); - int size = preferences.getAll().size(); - Editor editor = preferences.edit(); - if (size >= 100) { - editor.clear(); - } - editor.putString(key, value); - apply(editor); - } - - /** - * 读取是否是已读的文章列表 - * - * @return - */ - public static boolean isOnReadedPostList(String prefFileName, String key) { - return getPreferences(prefFileName).contains(key); - } - - /** - * 记录列表上次刷新时间 - * - * @param key - * @param value - * @return void - * @author 火蚁 - * 2015-2-9 下午2:21:37 - */ - public static void putToLastRefreshTime(String key, String value) { - SharedPreferences preferences = getPreferences(LAST_REFRESH_TIME); - Editor editor = preferences.edit(); - editor.putString(key, value); - apply(editor); - } - - /** - * 获取列表的上次刷新时间 - * - * @param key - * @return - * @author 火蚁 - * 2015-2-9 下午2:22:04 - */ - public static String getLastRefreshTime(String key) { - return getPreferences(LAST_REFRESH_TIME).getString(key, StringUtils.getCurTimeStr()); - } - - @TargetApi(Build.VERSION_CODES.GINGERBREAD) - public static void apply(SharedPreferences.Editor editor) { - if (sIsAtLeastGB) { - editor.apply(); - } else { - editor.commit(); - } - } - - public static void set(String key, int value) { - Editor editor = getPreferences().edit(); - editor.putInt(key, value); - apply(editor); - } - - public static void set(String key, boolean value) { - Editor editor = getPreferences().edit(); - editor.putBoolean(key, value); - apply(editor); - } - - public static void set(String key, String value) { - Editor editor = getPreferences().edit(); - editor.putString(key, value); - apply(editor); - } - - public static boolean get(String key, boolean defValue) { - return getPreferences().getBoolean(key, defValue); - } - - public static String get(String key, String defValue) { - return getPreferences().getString(key, defValue); - } - - public static int get(String key, int defValue) { - return getPreferences().getInt(key, defValue); - } - - public static long get(String key, long defValue) { - return getPreferences().getLong(key, defValue); - } - - public static float get(String key, float defValue) { - return getPreferences().getFloat(key, defValue); - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static SharedPreferences getPreferences() { - SharedPreferences pre = context().getSharedPreferences(PREF_NAME, - Context.MODE_MULTI_PROCESS); - return pre; - } - - @TargetApi(Build.VERSION_CODES.HONEYCOMB) - public static SharedPreferences getPreferences(String prefName) { - return context().getSharedPreferences(prefName, - Context.MODE_MULTI_PROCESS); - } - - public static int[] getDisplaySize() { - return new int[]{getPreferences().getInt("screen_width", 480), - getPreferences().getInt("screen_height", 854)}; - } - - public static void saveDisplaySize(Activity activity) { - DisplayMetrics displaymetrics = new DisplayMetrics(); - activity.getWindowManager().getDefaultDisplay() - .getMetrics(displaymetrics); - SharedPreferences.Editor editor = getPreferences().edit(); - editor.putInt("screen_width", displaymetrics.widthPixels); - editor.putInt("screen_height", displaymetrics.heightPixels); - editor.putFloat("density", displaymetrics.density); - editor.commit(); - } - - public static String string(int id) { - return _resource.getString(id); - } - - public static String string(int id, Object... args) { - return _resource.getString(id, args); - } - - public static void showToast(int message) { - showToast(message, Toast.LENGTH_LONG, 0); - } - - public static void showToast(String message) { - showToast(message, Toast.LENGTH_LONG, 0, Gravity.BOTTOM); - } - - public static void showToast(int message, int icon) { - showToast(message, Toast.LENGTH_LONG, icon); - } - - public static void showToast(String message, int icon) { - showToast(message, Toast.LENGTH_LONG, icon, Gravity.BOTTOM); - } - - public static void showToastShort(int message) { - showToast(message, Toast.LENGTH_SHORT, 0); - } - - public static void showToastShort(String message) { - showToast(message, Toast.LENGTH_SHORT, 0, Gravity.BOTTOM); - } - - public static void showToastShort(int message, Object... args) { - showToast(message, Toast.LENGTH_SHORT, 0, Gravity.BOTTOM, args); - } - - public static void showToast(int message, int duration, int icon) { - showToast(message, duration, icon, Gravity.BOTTOM); - } - - public static void showToast(int message, int duration, int icon, - int gravity) { - showToast(context().getString(message), duration, icon, gravity); - } - - public static void showToast(int message, int duration, int icon, - int gravity, Object... args) { - showToast(context().getString(message, args), duration, icon, gravity); - } - - public static void showToast(String message, int duration, int icon, - int gravity) { - if (message != null && !message.equalsIgnoreCase("")) { - long time = System.currentTimeMillis(); - if (!message.equalsIgnoreCase(lastToast) - || Math.abs(time - lastToastTime) > 2000) { - View view = LayoutInflater.from(context()).inflate( - R.layout.view_toast, null); - ((TextView) view.findViewById(R.id.title_tv)).setText(message); - if (icon != 0) { - ((ImageView) view.findViewById(R.id.icon_iv)) - .setImageResource(icon); - ((ImageView) view.findViewById(R.id.icon_iv)) - .setVisibility(View.VISIBLE); - } - Toast toast = new Toast(context()); - toast.setView(view); - if (gravity == Gravity.CENTER) { - toast.setGravity(gravity, 0, 0); - } else { - toast.setGravity(gravity, 0, 35); - } - - toast.setDuration(duration); - toast.show(); - lastToast = message; - lastToastTime = System.currentTimeMillis(); - } - } - } -} diff --git a/app/src/main/java/net/oschina/app/base/BaseFragment.java b/app/src/main/java/net/oschina/app/base/BaseFragment.java deleted file mode 100644 index 73caa6d8bc12ea6d157c2dbc21a146586b9b77b2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseFragment.java +++ /dev/null @@ -1,119 +0,0 @@ -package net.oschina.app.base; - -import android.app.ProgressDialog; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentActivity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.interf.BaseFragmentInterface; -import net.oschina.app.ui.dialog.DialogControl; - -/** - * 碎片基类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月25日 上午11:18:46 - * - */ -public class BaseFragment extends Fragment implements - android.view.View.OnClickListener, BaseFragmentInterface { - public static final int STATE_NONE = 0; - public static final int STATE_REFRESH = 1; - public static final int STATE_LOADMORE = 2; - public static final int STATE_NOMORE = 3; - public static final int STATE_PRESSNONE = 4;// 正在下拉但还没有到刷新的状态 - public static int mState = STATE_NONE; - - protected LayoutInflater mInflater; - - public AppContext getApplication() { - return (AppContext) getActivity().getApplication(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - this.mInflater = inflater; - View view = super.onCreateView(inflater, container, savedInstanceState); - return view; - } - - @Override - public void onResume() { - super.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - } - - protected int getLayoutId() { - return 0; - } - - protected View inflateView(int resId) { - return this.mInflater.inflate(resId, null); - } - - public boolean onBackPressed() { - return false; - } - - protected void hideWaitDialog() { - FragmentActivity activity = getActivity(); - if (activity instanceof DialogControl) { - ((DialogControl) activity).hideWaitDialog(); - } - } - - protected ProgressDialog showWaitDialog() { - return showWaitDialog(R.string.loading); - } - - protected ProgressDialog showWaitDialog(int resid) { - FragmentActivity activity = getActivity(); - if (activity instanceof DialogControl) { - return ((DialogControl) activity).showWaitDialog(resid); - } - return null; - } - - protected ProgressDialog showWaitDialog(String str) { - FragmentActivity activity = getActivity(); - if (activity instanceof DialogControl) { - return ((DialogControl) activity).showWaitDialog(str); - } - return null; - } - - @Override - public void initView(View view) { - - } - - @Override - public void initData() { - - } - - @Override - public void onClick(View v) { - - } -} diff --git a/app/src/main/java/net/oschina/app/base/BaseListFragment.java b/app/src/main/java/net/oschina/app/base/BaseListFragment.java deleted file mode 100644 index f7790bbee384f7942e6babe27628bf2a68d2fee2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseListFragment.java +++ /dev/null @@ -1,606 +0,0 @@ -package net.oschina.app.base; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.v4.widget.SwipeRefreshLayout; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView; -import android.widget.AbsListView.OnScrollListener; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ListView; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.ListEntity; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.cache.CacheManager; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -@SuppressLint("NewApi") -public abstract class BaseListFragment extends BaseFragment - implements SwipeRefreshLayout.OnRefreshListener, OnItemClickListener, - OnScrollListener { - - public static final String BUNDLE_KEY_CATALOG = "BUNDLE_KEY_CATALOG"; - - @InjectView(R.id.swiperefreshlayout) - protected SwipeRefreshLayout mSwipeRefreshLayout; - - @InjectView(R.id.listview) - protected ListView mListView; - - protected ListBaseAdapter mAdapter; - - @InjectView(R.id.error_layout) - protected EmptyLayout mErrorLayout; - - protected int mStoreEmptyState = -1; - - protected int mCurrentPage = 0; - - protected int mCatalog = 1; - // 错误信息 - protected Result mResult; - - private AsyncTask> mCacheTask; - private ParserTask mParserTask; - - @Override - protected int getLayoutId() { - return R.layout.fragment_pull_refresh_listview; - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View view = inflater.inflate(getLayoutId(), container, false); - return view; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - ButterKnife.inject(this, view); - initView(view); - } - - @Override - public void onCreate(android.os.Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mCatalog = args.getInt(BUNDLE_KEY_CATALOG, 0); - } - } - - @Override - public void initView(View view) { - mSwipeRefreshLayout.setOnRefreshListener(this); - mSwipeRefreshLayout.setColorSchemeResources( - R.color.swiperefresh_color1, R.color.swiperefresh_color2, - R.color.swiperefresh_color3, R.color.swiperefresh_color4); - - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - mCurrentPage = 0; - mState = STATE_REFRESH; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } - }); - - mListView.setOnItemClickListener(this); - mListView.setOnScrollListener(this); - - if (mAdapter != null) { - mListView.setAdapter(mAdapter); - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - } else { - mAdapter = getListAdapter(); - mListView.setAdapter(mAdapter); - - if (requestDataIfViewCreated()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - mState = STATE_NONE; - requestData(false); - } else { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - } - - } - if (mStoreEmptyState != -1) { - mErrorLayout.setErrorType(mStoreEmptyState); - } - } - - @Override - public void onDestroyView() { - mStoreEmptyState = mErrorLayout.getErrorState(); - super.onDestroyView(); - } - - @Override - public void onDestroy() { - cancelReadCacheTask(); - cancelParserTask(); - super.onDestroy(); - } - - protected abstract ListBaseAdapter getListAdapter(); - - // 下拉刷新数据 - @Override - public void onRefresh() { - if (mState == STATE_REFRESH) { - return; - } - // 设置顶部正在刷新 - mListView.setSelection(0); - setSwipeRefreshLoadingState(); - mCurrentPage = 0; - mState = STATE_REFRESH; - requestData(true); - } - - protected boolean requestDataIfViewCreated() { - return true; - } - - protected String getCacheKeyPrefix() { - return null; - } - - protected ListEntity parseList(InputStream is) throws Exception { - return null; - } - - protected ListEntity readList(Serializable seri) { - return null; - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) {} - - private String getCacheKey() { - return new StringBuilder(getCacheKeyPrefix()).append("_") - .append(mCurrentPage).toString(); - } - - // 是否需要自动刷新 - protected boolean needAutoRefresh() { - return true; - } - - /*** - * 获取列表数据 - * - * - * @author 火蚁 2015-2-9 下午3:16:12 - * - * @return void - * @param refresh - */ - protected void requestData(boolean refresh) { - String key = getCacheKey(); - if (isReadCacheData(refresh)) { - readCacheData(key); - } else { - // 取新的数据 - sendRequestData(); - } - } - - /*** - * 判断是否需要读取缓存的数据 - * - * @author 火蚁 2015-2-10 下午2:41:02 - * - * @return boolean - * @param refresh - * @return - */ - protected boolean isReadCacheData(boolean refresh) { - String key = getCacheKey(); - if (!TDevice.hasInternet()) { - return true; - } - // 第一页若不是主动刷新,缓存存在,优先取缓存的 - if (CacheManager.isExistDataCache(getActivity(), key) && !refresh - && mCurrentPage == 0) { - return true; - } - // 其他页数的,缓存存在以及还没有失效,优先取缓存的 - if (CacheManager.isExistDataCache(getActivity(), key) - && !CacheManager.isCacheDataFailure(getActivity(), key) - && mCurrentPage != 0) { - return true; - } - - return false; - } - - // 是否到时间去刷新数据了 - private boolean onTimeRefresh() { - String lastRefreshTime = AppContext.getLastRefreshTime(getCacheKey()); - String currTime = StringUtils.getCurTimeStr(); - long diff = StringUtils.calDateDifferent(lastRefreshTime, currTime); - return needAutoRefresh() && diff > getAutoRefreshTime(); - } - - /*** - * 自动刷新的时间 - * - * 默认:自动刷新的时间为半天时间 - * - * @author 火蚁 2015-2-9 下午5:55:11 - * - * @return long - * @return - */ - protected long getAutoRefreshTime() { - return 12 * 60 * 60; - } - - @Override - public void onResume() { - super.onResume(); - if (onTimeRefresh()) { - onRefresh(); - } - } - - protected void sendRequestData() {} - - private void readCacheData(String cacheKey) { - cancelReadCacheTask(); - mCacheTask = new CacheTask(getActivity()).execute(cacheKey); - } - - private void cancelReadCacheTask() { - if (mCacheTask != null) { - mCacheTask.cancel(true); - mCacheTask = null; - } - } - - private class CacheTask extends AsyncTask> { - private final WeakReference mContext; - - private CacheTask(Context context) { - mContext = new WeakReference(context); - } - - @Override - protected ListEntity doInBackground(String... params) { - Serializable seri = CacheManager.readObject(mContext.get(), - params[0]); - if (seri == null) { - return null; - } else { - return readList(seri); - } - } - - @Override - protected void onPostExecute(ListEntity list) { - super.onPostExecute(list); - if (list != null) { - executeOnLoadDataSuccess(list.getList()); - } else { - executeOnLoadDataError(null); - } - executeOnLoadFinish(); - } - } - - private class SaveCacheTask extends AsyncTask { - private final WeakReference mContext; - private final Serializable seri; - private final String key; - - private SaveCacheTask(Context context, Serializable seri, String key) { - mContext = new WeakReference(context); - this.seri = seri; - this.key = key; - } - - @Override - protected Void doInBackground(Void... params) { - CacheManager.saveObject(mContext.get(), seri, key); - return null; - } - } - - protected AsyncHttpResponseHandler mHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int statusCode, Header[] headers, - byte[] responseBytes) { - if (mCurrentPage == 0 && needAutoRefresh()) { - AppContext.putToLastRefreshTime(getCacheKey(), - StringUtils.getCurTimeStr()); - } - if (isAdded()) { - if (mState == STATE_REFRESH) { - onRefreshNetworkSuccess(); - } - executeParserTask(responseBytes); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - if (isAdded()) { - readCacheData(getCacheKey()); - } - } - }; - - protected void executeOnLoadDataSuccess(List data) { - if (data == null) { - data = new ArrayList(); - } - - if (mResult != null && !mResult.OK()) { - AppContext.showToast(mResult.getErrorMessage()); - // 注销登陆,密码已经修改,cookie,失效了 - AppContext.getInstance().Logout(); - } - - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (mCurrentPage == 0) { - mAdapter.clear(); - } - - for (int i = 0; i < data.size(); i++) { - if (compareTo(mAdapter.getData(), data.get(i))) { - data.remove(i); - i--; - } - } - int adapterState = ListBaseAdapter.STATE_EMPTY_ITEM; - if ((mAdapter.getCount() + data.size()) == 0) { - adapterState = ListBaseAdapter.STATE_EMPTY_ITEM; - } else if (data.size() == 0 - || (data.size() < getPageSize() && mCurrentPage == 0)) { - adapterState = ListBaseAdapter.STATE_NO_MORE; - mAdapter.notifyDataSetChanged(); - } else { - adapterState = ListBaseAdapter.STATE_LOAD_MORE; - } - mAdapter.setState(adapterState); - mAdapter.addData(data); - // 判断等于是因为最后有一项是listview的状态 - if (mAdapter.getCount() == 1) { - - if (needShowEmptyNoData()) { - mErrorLayout.setErrorType(EmptyLayout.NODATA); - } else { - mAdapter.setState(ListBaseAdapter.STATE_EMPTY_ITEM); - mAdapter.notifyDataSetChanged(); - } - } - } - - /** - * 是否需要隐藏listview,显示无数据状态 - * - * @author 火蚁 2015-1-27 下午6:18:59 - * - */ - protected boolean needShowEmptyNoData() { - return true; - } - - protected boolean compareTo(List data, Entity enity) { - int s = data.size(); - if (enity != null) { - for (int i = 0; i < s; i++) { - if (enity.getId() == data.get(i).getId()) { - return true; - } - } - } - return false; - } - - protected int getPageSize() { - return AppContext.PAGE_SIZE; - } - - protected void onRefreshNetworkSuccess() {} - - protected void executeOnLoadDataError(String error) { - if (mCurrentPage == 0 - && !CacheManager.isExistDataCache(getActivity(), getCacheKey())) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - } else { - - //在无网络时,滚动到底部时,mCurrentPage先自加了,然而在失败时却 - //没有减回来,如果刻意在无网络的情况下上拉,可以出现漏页问题 - //find by TopJohn - mCurrentPage--; - - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - mAdapter.setState(ListBaseAdapter.STATE_NETWORK_ERROR); - mAdapter.notifyDataSetChanged(); - } - } - - // 完成刷新 - protected void executeOnLoadFinish() { - setSwipeRefreshLoadedState(); - mState = STATE_NONE; - } - - /** 设置顶部正在加载的状态 */ - protected void setSwipeRefreshLoadingState() { - if (mSwipeRefreshLayout != null) { - mSwipeRefreshLayout.setRefreshing(true); - // 防止多次重复刷新 - mSwipeRefreshLayout.setEnabled(false); - } - } - - /** 设置顶部加载完毕的状态 */ - protected void setSwipeRefreshLoadedState() { - if (mSwipeRefreshLayout != null) { - mSwipeRefreshLayout.setRefreshing(false); - mSwipeRefreshLayout.setEnabled(true); - } - } - - private void executeParserTask(byte[] data) { - cancelParserTask(); - mParserTask = new ParserTask(data); - mParserTask.execute(); - } - - private void cancelParserTask() { - if (mParserTask != null) { - mParserTask.cancel(true); - mParserTask = null; - } - } - - class ParserTask extends AsyncTask { - - private final byte[] reponseData; - private boolean parserError; - private List list; - - public ParserTask(byte[] data) { - this.reponseData = data; - } - - @Override - protected String doInBackground(Void... params) { - try { - ListEntity data = parseList(new ByteArrayInputStream( - reponseData)); - new SaveCacheTask(getActivity(), data, getCacheKey()).execute(); - list = data.getList(); - if (list == null) { - ResultBean resultBean = XmlUtils.toBean(ResultBean.class, - reponseData); - if (resultBean != null) { - mResult = resultBean.getResult(); - } - } - } catch (Exception e) { - e.printStackTrace(); - - parserError = true; - } - return null; - } - - @Override - protected void onPostExecute(String result) { - super.onPostExecute(result); - if (parserError) { - readCacheData(getCacheKey()); - } else { - executeOnLoadDataSuccess(list); - executeOnLoadFinish(); - } - } - } - - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - if (mAdapter == null || mAdapter.getCount() == 0) { - return; - } - // 数据已经全部加载,或数据为空时,或正在加载,不处理滚动事件 - if (mState == STATE_LOADMORE || mState == STATE_REFRESH) { - return; - } - // 判断是否滚动到底部 - boolean scrollEnd = false; - try { - if (view.getPositionForView(mAdapter.getFooterView()) == view - .getLastVisiblePosition()) - scrollEnd = true; - } catch (Exception e) { - scrollEnd = false; - } - - if (mState == STATE_NONE && scrollEnd) { - if (mAdapter.getState() == ListBaseAdapter.STATE_LOAD_MORE - || mAdapter.getState() == ListBaseAdapter.STATE_NETWORK_ERROR) { - mCurrentPage++; - mState = STATE_LOADMORE; - requestData(false); - mAdapter.setFooterViewLoading(); - } - } - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, - int visibleItemCount, int totalItemCount) { - // 数据已经全部加载,或数据为空时,或正在加载,不处理滚动事件 - // if (mState == STATE_NOMORE || mState == STATE_LOADMORE - // || mState == STATE_REFRESH) { - // return; - // } - // if (mAdapter != null - // && mAdapter.getDataSize() > 0 - // && mListView.getLastVisiblePosition() == (mListView.getCount() - 1)) - // { - // if (mState == STATE_NONE - // && mAdapter.getState() == ListBaseAdapter.STATE_LOAD_MORE) { - // mState = STATE_LOADMORE; - // mCurrentPage++; - // requestData(true); - // } - // } - } - - /** - * 保存已读的文章列表 - * - * @param view - * @param prefFileName - * @param key - */ - protected void saveToReadedList(final View view, final String prefFileName, - final String key) { - // 放入已读列表 - AppContext.putReadedPostList(prefFileName, key, "true"); - TextView tvTitle = (TextView) view.findViewById(R.id.tv_title); - if (tvTitle != null) { - tvTitle.setTextColor(AppContext.getInstance().getResources().getColor(ThemeSwitchUtils.getTitleReadedColor())); - } - } -} diff --git a/app/src/main/java/net/oschina/app/base/BaseNewActivity.java b/app/src/main/java/net/oschina/app/base/BaseNewActivity.java deleted file mode 100644 index 77a7283aebf500fd0e0cf35dcef8f5fd92bb2f44..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseNewActivity.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.oschina.app.base; - -import android.support.v7.app.AppCompatActivity; - -/** - * Created by 火蚁 on 15/5/18. - */ -public class BaseNewActivity extends AppCompatActivity { - - -} diff --git a/app/src/main/java/net/oschina/app/base/BaseViewPagerFragment.java b/app/src/main/java/net/oschina/app/base/BaseViewPagerFragment.java deleted file mode 100644 index f7b55f2c5c6ebc0866603f38d7c3c5a3a6b0cd52..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BaseViewPagerFragment.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.oschina.app.base; - -import net.oschina.app.R; -import net.oschina.app.adapter.ViewPageFragmentAdapter; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.widget.PagerSlidingTabStrip; -import android.os.Bundle; -import android.support.v4.view.ViewPager; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -/** - * 带有导航条的基类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 下午4:59:50 - * - */ -public abstract class BaseViewPagerFragment extends BaseFragment { - - protected PagerSlidingTabStrip mTabStrip; - protected ViewPager mViewPager; - protected ViewPageFragmentAdapter mTabsAdapter; - protected EmptyLayout mErrorLayout; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - return inflater.inflate(R.layout.base_viewpage_fragment, null); - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - mTabStrip = (PagerSlidingTabStrip) view - .findViewById(R.id.pager_tabstrip); - - mViewPager = (ViewPager) view.findViewById(R.id.pager); - - mErrorLayout = (EmptyLayout) view.findViewById(R.id.error_layout); - - mTabsAdapter = new ViewPageFragmentAdapter(getChildFragmentManager(), - mTabStrip, mViewPager); - setScreenPageLimit(); - onSetupTabAdapter(mTabsAdapter); - // if (savedInstanceState != null) { - // int pos = savedInstanceState.getInt("position"); - // mViewPager.setCurrentItem(pos, true); - // } - } - - protected void setScreenPageLimit() { - } - - // @Override - // public void onSaveInstanceState(Bundle outState) { - // //No call for super(). Bug on API Level > 11. - // if (outState != null && mViewPager != null) { - // outState.putInt("position", mViewPager.getCurrentItem()); - // } - // //super.onSaveInstanceState(outState); - // } - - protected abstract void onSetupTabAdapter(ViewPageFragmentAdapter adapter); -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/base/BeseHaveHeaderListFragment.java b/app/src/main/java/net/oschina/app/base/BeseHaveHeaderListFragment.java deleted file mode 100644 index b4a85e125d2e7fed6b9705708daffbd07338cf25..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/BeseHaveHeaderListFragment.java +++ /dev/null @@ -1,178 +0,0 @@ -package net.oschina.app.base; - -import java.io.ByteArrayInputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; - -import net.oschina.app.bean.Entity; -import net.oschina.app.cache.CacheManager; -import net.oschina.app.ui.empty.EmptyLayout; - -import cz.msebera.android.httpclient.Header; - -import android.app.Activity; -import android.content.Context; -import android.os.AsyncTask; -import android.os.Bundle; -import android.view.View; -import butterknife.ButterKnife; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -/** - * 需要加入header的BaseListFragment - * - * @desc 应用场景:如动弹详情、团队任务详情这些, 即是头部显示详情,然后下面显示评论列表的 - * - * BeseHaveHeaderListFragment.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-1-27 下午3:02:42 - */ -public abstract class BeseHaveHeaderListFragment - extends BaseListFragment { - - protected T2 detailBean;// list 头部的详情实体类 - - protected Activity aty; - - protected final AsyncHttpResponseHandler mDetailHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - if (arg2 != null) { - T2 detail = getDetailBean(new ByteArrayInputStream(arg2)); - if (detail != null) { - requstListData(); - executeOnLoadDetailSuccess(detail); - new SaveCacheTask(getActivity(), detail, - getDetailCacheKey()).execute(); - } else { - onFailure(arg0, arg1, arg2, null); - } - } else { - throw new RuntimeException("load detail error"); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - readDetailCacheData(getDetailCacheKey()); - } - }; - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - // 通过注解绑定控件 - ButterKnife.inject(this, view); - mListView.addHeaderView(initHeaderView()); - aty = getActivity(); - super.initView(view); - requestDetailData(isRefresh()); - } - - protected boolean isRefresh() { - return false; - } - - protected abstract void requestDetailData(boolean isRefresh); - - protected abstract View initHeaderView(); - - protected abstract String getDetailCacheKey(); - - protected abstract void executeOnLoadDetailSuccess(T2 detailBean); - - protected abstract T2 getDetailBean(ByteArrayInputStream is); - - @Override - protected boolean requestDataIfViewCreated() { - return false; - } - - private void requstListData() { - mState = STATE_REFRESH; - mAdapter.setState(ListBaseAdapter.STATE_LOAD_MORE); - sendRequestData(); - } - - /*** - * 带有header view的listfragment不需要显示是否数据为空 - */ - @Override - protected boolean needShowEmptyNoData() { - return false; - } - - protected void readDetailCacheData(String cacheKey) { - new ReadCacheTask(getActivity()).execute(cacheKey); - } - - private class SaveCacheTask extends AsyncTask { - private final WeakReference mContext; - private final Serializable seri; - private final String key; - - private SaveCacheTask(Context context, Serializable seri, String key) { - mContext = new WeakReference(context); - this.seri = seri; - this.key = key; - } - - @Override - protected Void doInBackground(Void... params) { - CacheManager.saveObject(mContext.get(), seri, key); - return null; - } - } - - private class ReadCacheTask extends AsyncTask { - private final WeakReference mContext; - - private ReadCacheTask(Context context) { - mContext = new WeakReference(context); - } - - @Override - protected T2 doInBackground(String... params) { - if (mContext.get() != null) { - Serializable seri = CacheManager.readObject(mContext.get(), - params[0]); - if (seri == null) { - return null; - } else { - return (T2) seri; - } - } - return null; - } - - @Override - protected void onPostExecute(T2 t) { - super.onPostExecute(t); - if (t != null) { - requstListData(); - executeOnLoadDetailSuccess(t); - } - } - } - - @Override - protected void executeOnLoadDataError(String error) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - mAdapter.setState(ListBaseAdapter.STATE_NETWORK_ERROR); - mAdapter.notifyDataSetChanged(); - } - - @SuppressWarnings("unchecked") - protected T findHeaderView(View headerView, int viewId) { - return (T) headerView.findViewById(viewId); - } -} diff --git a/app/src/main/java/net/oschina/app/base/CommonDetailFragment.java b/app/src/main/java/net/oschina/app/base/CommonDetailFragment.java deleted file mode 100644 index 3c64d4835d76413d4b9d4d6d56428a0ece25df2f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/CommonDetailFragment.java +++ /dev/null @@ -1,558 +0,0 @@ -package net.oschina.app.base; - -import android.content.Context; -import android.content.DialogInterface; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AlertDialog; -import android.text.Editable; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.webkit.WebView; - -import com.loopj.android.http.AsyncHttpResponseHandler; -import com.loopj.android.http.TextHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.bean.Report; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.cache.CacheManager; -import net.oschina.app.emoji.OnSendClickListener; -import net.oschina.app.ui.DetailActivity; -import net.oschina.app.ui.ReportDialog; -import net.oschina.app.ui.ShareDialog; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.FontSizeUtils; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; - -import butterknife.ButterKnife; - -/** - * 通用的详情fragment - * Created by 火蚁 on 15/5/25. - */ -public abstract class CommonDetailFragment extends BaseFragment implements OnSendClickListener { - - protected int mId; - - protected EmptyLayout mEmptyLayout; - - protected int mCommentCount = 0; - - protected WebView mWebView; - - protected T mDetail; - - private AsyncTask mCacheTask; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setHasOptionsMenu(true); - } - - @Override - protected int getLayoutId() { - return R.layout.fragment_news_detail; - } - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(getLayoutId(), container, - false); - mCommentCount = getActivity().getIntent().getIntExtra("comment_count", - 0); - mId = getActivity().getIntent().getIntExtra("id", 0); - ButterKnife.inject(this, view); - initView(view); - initData(); - requestData(false); - return view; - } - - @Override - public void initView(View view) { - mEmptyLayout = (EmptyLayout) view.findViewById(R.id.error_layout); - setCommentCount(mCommentCount); - mWebView = (WebView) view.findViewById(R.id.webview); - UIHelper.initWebView(mWebView); - } - - protected void setCommentCount(int commentCount) { - ((DetailActivity) getActivity()).toolFragment - .setCommentCount(commentCount); - } - - private void requestData(boolean refresh) { - String key = getCacheKey(); - if (TDevice.hasInternet() - && (!CacheManager.isExistDataCache(getActivity(), key) || refresh)) { - sendRequestDataForNet(); - } else { - readCacheData(key); - } - } - - @Override - public void onDestroyView() { - recycleWebView(); - super.onDestroyView(); - } - - private void recycleWebView() { - if (mWebView != null) { - mWebView.setVisibility(View.GONE); - mWebView.removeAllViews(); - mWebView.destroy(); - mWebView = null; - } - } - - private void readCacheData(String cacheKey) { - cancelReadCache(); - mCacheTask = new CacheTask(getActivity()).execute(cacheKey); - } - - private void cancelReadCache() { - if (mCacheTask != null) { - mCacheTask.cancel(true); - mCacheTask = null; - } - } - - protected AsyncHttpResponseHandler mDetailHeandler = new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - T detail = parseData(new ByteArrayInputStream(arg2)); - if (detail != null) { - mEmptyLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - executeOnLoadDataSuccess(detail); - saveCache(detail); - } else { - executeOnLoadDataError(); - } - } catch (Exception e) { - e.printStackTrace(); - executeOnLoadDataError(); - } - } - - @Override - public void onStart() { - super.onStart(); - mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - readCacheData(getCacheKey()); - } - }; - - private class CacheTask extends AsyncTask { - private final WeakReference mContext; - - private CacheTask(Context context) { - mContext = new WeakReference(context); - } - - @Override - protected T doInBackground(String... params) { - if (mContext.get() != null) { - Serializable seri = CacheManager.readObject(mContext.get(), - params[0]); - if (seri == null) { - return null; - } else { - return (T)seri; - } - } - return null; - } - - @Override - protected void onPostExecute(T detail) { - super.onPostExecute(detail); - mEmptyLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (detail != null) { - executeOnLoadDataSuccess(detail); - } else { - executeOnLoadDataError(); - } - } - - @Override - protected void onPreExecute() { - super.onPreExecute(); - mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - } - } - - protected void executeOnLoadDataSuccess(T detail) { - this.mDetail = detail; - if (this.mDetail == null || TextUtils.isEmpty(this.getWebViewBody(detail))) { - executeOnLoadDataError(); - return; - } - - mWebView.loadDataWithBaseURL("", this.getWebViewBody(detail), "text/html", "UTF-8", ""); - // 显示存储的字体大小 - mWebView.loadUrl(FontSizeUtils.getSaveFontSize()); - boolean favoriteState = getFavoriteState() == 1; - setFavoriteState(favoriteState); - - // 判断最新的评论数是否大于 - if (getCommentCount() > mCommentCount) { - mCommentCount = getCommentCount(); - } - setCommentCount(mCommentCount); - } - - protected void executeOnLoadDataError() { - mEmptyLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mEmptyLayout.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - mState = STATE_REFRESH; - mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } - }); - } - - protected void saveCache(T detail) { - new SaveCacheTask(getActivity(), detail, getCacheKey()).execute(); - } - - private class SaveCacheTask extends AsyncTask { - private final WeakReference mContext; - private final Serializable seri; - private final String key; - - private SaveCacheTask(Context context, Serializable seri, String key) { - mContext = new WeakReference(context); - this.seri = seri; - this.key = key; - } - - @Override - protected Void doInBackground(Void... params) { - CacheManager.saveObject(mContext.get(), seri, key); - return null; - } - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.common_detail_menu, menu); - super.onCreateOptionsMenu(menu, inflater); - } - - int i = 0; - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.refresh: - sendRequestDataForNet(); - return false; - case R.id.font_size: - showChangeFontSize(); - break; - default: - break; - } - return super.onOptionsItemSelected(item); - } - - AlertDialog fontSizeChange; - - private void showChangeFontSize() { - - final String[] items = getResources().getStringArray( - R.array.font_size); - fontSizeChange = DialogHelp.getSingleChoiceDialog(getActivity(), items, FontSizeUtils.getSaveFontSizeIndex(), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - // 更改字体大小 - FontSizeUtils.saveFontSize(i); - mWebView.loadUrl(FontSizeUtils.getFontSize(i)); - fontSizeChange.dismiss(); - } - }).show(); - } - - // 收藏或者取消收藏 - public void handleFavoriteOrNot() { - if (mDetail == null) { - return; - } - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_no_internet); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - int uid = AppContext.getInstance().getLoginUid(); - final boolean isFavorited = getFavoriteState() == 1 ? true : false; - AsyncHttpResponseHandler mFavoriteHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - Result res = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)).getResult(); - if (res.OK()) { - AppContext.showToast(res.getErrorMessage()); - boolean newFavorited = !isFavorited; - setFavoriteState(newFavorited); - // 更新收藏的状态 - updateFavoriteChanged(!newFavorited ? 0 : 1); - } else { - onFailure(arg0, arg1, arg2, null); - } - - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - AppContext.showToastShort(R.string.add_favorite_faile); - } - - @Override - public void onStart() { - super.onStart(); - showWaitDialog("请稍候..."); - } - - @Override - public void onFinish() { - super.onFinish(); - hideWaitDialog(); - } - }; - - if (isFavorited) { - OSChinaApi.delFavorite(uid, mId, - getFavoriteTargetType(), mFavoriteHandler); - } else { - OSChinaApi.addFavorite(uid, mId, - getFavoriteTargetType(), mFavoriteHandler); - } - } - - private void setFavoriteState(boolean isFavorited) { - ((DetailActivity) getActivity()).toolFragment.setFavorite(isFavorited); - } - - // 举报帖子 - public void onReportMenuClick() { - if (mId == 0 || mDetail == null) { - AppContext.showToast("正在加载,请稍等..."); - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - int reportId = mId; - - final ReportDialog dialog = new ReportDialog(getActivity(), - getRepotrUrl(), reportId, getReportType()); - dialog.setCancelable(true); - dialog.setTitle(R.string.report); - dialog.setCanceledOnTouchOutside(true); - dialog.setNegativeButton(R.string.cancle, null); - final TextHttpResponseHandler mReportHandler = new TextHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, String arg2) { - if (TextUtils.isEmpty(arg2)) { - AppContext.showToastShort(R.string.tip_report_success); - } else { - AppContext.showToastShort(new String(arg2)); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, String arg2, - Throwable arg3) { - AppContext.showToastShort(R.string.tip_report_faile); - } - - @Override - public void onFinish() { - hideWaitDialog(); - } - }; - dialog.setPositiveButton(R.string.ok, - new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface d, int which) { - Report report = null; - if ((report = dialog.getReport()) != null) { - showWaitDialog(R.string.progress_submit); - OSChinaApi.report(report, mReportHandler); - } - d.dismiss(); - } - }); - dialog.show(); - } - // 分享 - public void handleShare() { - if (mDetail == null || TextUtils.isEmpty(getShareContent()) - || TextUtils.isEmpty(getShareUrl()) || TextUtils.isEmpty(getShareTitle())) { - AppContext.showToast("内容加载失败..."); - return; - } - final ShareDialog dialog = new ShareDialog(getActivity()); - dialog.setCancelable(true); - dialog.setCanceledOnTouchOutside(true); - dialog.setTitle(R.string.share_to); - dialog.setShareInfo(getShareTitle(), getShareContent(), getShareUrl()); - dialog.show(); - } - // 显示评论列表 - public void onCilckShowComment() { - showCommentView(); - } - - // 刷新数据 - protected void refresh() { - sendRequestDataForNet(); - } - - protected AsyncHttpResponseHandler mCommentHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - ResultBean rsb = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)); - Result res = rsb.getResult(); - if (res.OK()) { - hideWaitDialog(); - AppContext.showToastShort(res.getErrorMessage()); - // 评论成功之后,评论数加1 - setCommentCount(mCommentCount + 1); - } else { - hideWaitDialog(); - AppContext.showToastShort(res.getErrorMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - ((DetailActivity) getActivity()).emojiFragment.clean(); - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - hideWaitDialog(); - AppContext.showToastShort(R.string.comment_publish_faile); - } - - @Override - public void onFinish() { - ((DetailActivity) getActivity()).emojiFragment.hideAllKeyBoard(); - }; - }; - - // 发表评论 - @Override - public void onClickSendButton(Editable str) { - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (TextUtils.isEmpty(str)) { - AppContext.showToastShort(R.string.tip_comment_content_empty); - return; - } - showWaitDialog(R.string.progress_submit); - - OSChinaApi.publicComment(getCommentType(), mId, AppContext - .getInstance().getLoginUid(), str.toString(), 0, - mCommentHandler); - } - - @Override - public void onClickFlagButton() { - - } - - /*** - * 获取去除html标签的body - * - * @param body - * @return - */ - protected String getFilterHtmlBody(String body) { - if (body == null) - return ""; - return HTMLUtil.delHTMLTag(body.trim()); - } - - // 获取缓存的key - protected abstract String getCacheKey(); - // 从网络中读取数据 - protected abstract void sendRequestDataForNet(); - // 解析数据 - protected abstract T parseData(InputStream is); - // 返回填充到webview中的内容 - protected abstract String getWebViewBody(T detail); - // 显示评论列表 - protected abstract void showCommentView(); - // 获取评论的类型 - protected abstract int getCommentType(); - protected abstract String getShareTitle(); - protected abstract String getShareContent(); - protected abstract String getShareUrl(); - // 返回举报的url - protected String getRepotrUrl() {return "";} - // 返回举报的类型 - protected byte getReportType() {return Report.TYPE_QUESTION;} - - // 获取收藏类型(如新闻、博客、帖子) - protected abstract int getFavoriteTargetType(); - protected abstract int getFavoriteState(); - protected abstract void updateFavoriteChanged(int newFavoritedState); - protected abstract int getCommentCount(); -} diff --git a/app/src/main/java/net/oschina/app/base/ListBaseAdapter.java b/app/src/main/java/net/oschina/app/base/ListBaseAdapter.java deleted file mode 100644 index 4468bc4c74de089e8a029212fd3d4bf2f6f67e54..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/base/ListBaseAdapter.java +++ /dev/null @@ -1,301 +0,0 @@ -package net.oschina.app.base; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.text.Html; -import android.text.Spanned; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.LinearLayout; -import android.widget.ProgressBar; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.bean.Entity; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.widget.MyLinkMovementMethod; -import net.oschina.app.widget.MyURLSpan; -import net.oschina.app.widget.TweetTextView; - -import java.util.ArrayList; -import java.util.List; - -public class ListBaseAdapter extends BaseAdapter { - public static final int STATE_EMPTY_ITEM = 0; - public static final int STATE_LOAD_MORE = 1; - public static final int STATE_NO_MORE = 2; - public static final int STATE_NO_DATA = 3; - public static final int STATE_LESS_ONE_PAGE = 4; - public static final int STATE_NETWORK_ERROR = 5; - public static final int STATE_OTHER = 6; - - protected int state = STATE_LESS_ONE_PAGE; - - protected int _loadmoreText; - protected int _loadFinishText; - protected int _noDateText; - protected int mScreenWidth; - - private LayoutInflater mInflater; - - protected LayoutInflater getLayoutInflater(Context context) { - if (mInflater == null) { - mInflater = (LayoutInflater) context - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - } - return mInflater; - } - - public void setScreenWidth(int width) { - mScreenWidth = width; - } - - public void setState(int state) { - this.state = state; - } - - public int getState() { - return this.state; - } - - protected ArrayList mDatas = new ArrayList(); - - public ListBaseAdapter() { - _loadmoreText = R.string.loading; - _loadFinishText = R.string.loading_no_more; - _noDateText = R.string.error_view_no_data; - } - - @Override - public int getCount() { - switch (getState()) { - case STATE_EMPTY_ITEM: - return getDataSizePlus1(); - case STATE_NETWORK_ERROR: - case STATE_LOAD_MORE: - return getDataSizePlus1(); - case STATE_NO_DATA: - return 1; - case STATE_NO_MORE: - return getDataSizePlus1(); - case STATE_LESS_ONE_PAGE: - return getDataSize(); - default: - break; - } - return getDataSize(); - } - - public int getDataSizePlus1(){ - if(hasFooterView()){ - return getDataSize() + 1; - } - return getDataSize(); - } - - public int getDataSize() { - return mDatas.size(); - } - - @Override - public T getItem(int arg0) { - if (mDatas.size() > arg0) { - return mDatas.get(arg0); - } - return null; - } - - @Override - public long getItemId(int arg0) { - return arg0; - } - - public void setData(ArrayList data) { - mDatas = data; - notifyDataSetChanged(); - } - - public ArrayList getData() { - return mDatas == null ? (mDatas = new ArrayList()) : mDatas; - } - - public void addData(List data) { - if (mDatas != null && data != null && !data.isEmpty()) { - mDatas.addAll(data); - } - notifyDataSetChanged(); - } - - public void addItem(T obj) { - if (mDatas != null) { - mDatas.add(obj); - } - notifyDataSetChanged(); - } - - public void addItem(int pos, T obj) { - if (mDatas != null) { - mDatas.add(pos, obj); - } - notifyDataSetChanged(); - } - - public void removeItem(Object obj) { - mDatas.remove(obj); - notifyDataSetChanged(); - } - - public void clear() { - mDatas.clear(); - notifyDataSetChanged(); - } - - public void setLoadmoreText(int loadmoreText) { - _loadmoreText = loadmoreText; - } - - public void setLoadFinishText(int loadFinishText) { - _loadFinishText = loadFinishText; - } - - public void setNoDataText(int noDataText) { - _noDateText = noDataText; - } - - protected boolean loadMoreHasBg() { - return true; - } - - @SuppressWarnings("deprecation") - @SuppressLint("InflateParams") - @Override - public View getView(int position, View convertView, ViewGroup parent) { - if (position == getCount() - 1&&hasFooterView()) {// 最后一条 - // if (position < _data.size()) { - // position = getCount() - 2; // footview - // } - if (getState() == STATE_LOAD_MORE || getState() == STATE_NO_MORE - || state == STATE_EMPTY_ITEM - || getState() == STATE_NETWORK_ERROR) { - this.mFooterView = (LinearLayout) LayoutInflater.from( - parent.getContext()).inflate(R.layout.list_cell_footer, - null); - if (!loadMoreHasBg()) { - mFooterView.setBackgroundDrawable(null); - } - ProgressBar progress = (ProgressBar) mFooterView - .findViewById(R.id.progressbar); - TextView text = (TextView) mFooterView.findViewById(R.id.text); - switch (getState()) { - case STATE_LOAD_MORE: - setFooterViewLoading(); - break; - case STATE_NO_MORE: - mFooterView.setVisibility(View.VISIBLE); - progress.setVisibility(View.GONE); - text.setVisibility(View.VISIBLE); - text.setText(_loadFinishText); - break; - case STATE_EMPTY_ITEM: - progress.setVisibility(View.GONE); - mFooterView.setVisibility(View.VISIBLE); - text.setText(_noDateText); - break; - case STATE_NETWORK_ERROR: - mFooterView.setVisibility(View.VISIBLE); - progress.setVisibility(View.GONE); - text.setVisibility(View.VISIBLE); - if (TDevice.hasInternet()) { - text.setText("加载出错了"); - } else { - text.setText("没有可用的网络"); - } - break; - default: - progress.setVisibility(View.GONE); - mFooterView.setVisibility(View.GONE); - text.setVisibility(View.GONE); - break; - } - return mFooterView; - } - } - if (position < 0) { - position = 0; // 若列表没有数据,是没有footview/headview的 - } - return getRealView(position, convertView, parent); - } - - protected View getRealView(int position, View convertView, ViewGroup parent) { - return null; - } - - private LinearLayout mFooterView; - - protected boolean hasFooterView(){ - return true; - } - - public View getFooterView() { - return this.mFooterView; - } - - public void setFooterViewLoading(String loadMsg) { - ProgressBar progress = (ProgressBar) mFooterView - .findViewById(R.id.progressbar); - TextView text = (TextView) mFooterView.findViewById(R.id.text); - mFooterView.setVisibility(View.VISIBLE); - progress.setVisibility(View.VISIBLE); - text.setVisibility(View.VISIBLE); - if (StringUtils.isEmpty(loadMsg)) { - text.setText(_loadmoreText); - } else { - text.setText(loadMsg); - } - } - - public void setFooterViewLoading() { - setFooterViewLoading(""); - } - - public void setFooterViewText(String msg) { - ProgressBar progress = (ProgressBar) mFooterView - .findViewById(R.id.progressbar); - TextView text = (TextView) mFooterView.findViewById(R.id.text); - mFooterView.setVisibility(View.VISIBLE); - progress.setVisibility(View.GONE); - text.setVisibility(View.VISIBLE); - text.setText(msg); - } - - protected void setContent(TweetTextView contentView, String content) { - contentView.setMovementMethod(MyLinkMovementMethod.a()); - contentView.setFocusable(false); - contentView.setDispatchToParent(true); - contentView.setLongClickable(false); - Spanned span = Html.fromHtml(TweetTextView.modifyPath(content)); - span = InputHelper.displayEmoji(contentView.getResources(), - span.toString()); - contentView.setText(span); - MyURLSpan.parseLinkText(contentView, span); - } - - protected void setText(TextView textView, String text, boolean needGone) { - if (text == null || TextUtils.isEmpty(text)) { - if (needGone) { - textView.setVisibility(View.GONE); - } - } else { - textView.setText(text); - } - } - - protected void setText(TextView textView, String text) { - setText(textView, text, false); - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Active.java b/app/src/main/java/net/oschina/app/bean/Active.java deleted file mode 100644 index 0bce263dee26ebef44e6a3d4694bd92ba6bc18c1..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Active.java +++ /dev/null @@ -1,240 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 动态实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月22日 下午3:22:09 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("active") -public class Active extends Entity { - - public final static int CATALOG_OTHER = 0;// 其他 - public final static int CATALOG_NEWS = 1;// 新闻 - public final static int CATALOG_POST = 2;// 帖子 - public final static int CATALOG_TWEET = 3;// 动弹 - public final static int CATALOG_BLOG = 4;// 博客 - - public final static int CLIENT_MOBILE = 2; - public final static int CLIENT_ANDROID = 3; - public final static int CLIENT_IPHONE = 4; - public final static int CLIENT_WINDOWS_PHONE = 5; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("message") - private String message; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("activetype") - private int activeType; - - @XStreamAlias("objectID") - private int objectId; - - @XStreamAlias("catalog") - private int catalog; - - @XStreamAlias("objecttype") - private int objectType; - - @XStreamAlias("objectcatalog") - private int objectCatalog; - - @XStreamAlias("objecttitle") - private String objectTitle; - - @XStreamAlias("objectreply") - private ObjectReply objectReply; - - @XStreamAlias("commentCount") - private int commentCount; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("tweetimage") - private String tweetimage; - - @XStreamAlias("tweetattach") - private String tweetattach; - - @XStreamAlias("appclient") - private int appClient; - - @XStreamAlias("url") - private String url; - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(int authorId) { - this.authorId = authorId; - } - - public int getActiveType() { - return activeType; - } - - public void setActiveType(int activeType) { - this.activeType = activeType; - } - - public int getObjectId() { - return objectId; - } - - public void setObjectId(int objectId) { - this.objectId = objectId; - } - - public int getCatalog() { - return catalog; - } - - public void setCatalog(int catalog) { - this.catalog = catalog; - } - - public int getObjectType() { - return objectType; - } - - public void setObjectType(int objectType) { - this.objectType = objectType; - } - - public int getObjectCatalog() { - return objectCatalog; - } - - public void setObjectCatalog(int objectCatalog) { - this.objectCatalog = objectCatalog; - } - - public String getObjectTitle() { - return objectTitle; - } - - public void setObjectTitle(String objectTitle) { - this.objectTitle = objectTitle; - } - - public ObjectReply getObjectReply() { - return objectReply; - } - - public void setObjectReply(ObjectReply objectReply) { - this.objectReply = objectReply; - } - - public int getCommentCount() { - return commentCount; - } - - public void setCommentCount(int commentCount) { - this.commentCount = commentCount; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getTweetattach() { - return tweetattach; - } - - public void setTweetattach(String tweetattach) { - this.tweetattach = tweetattach; - } - - public String getTweetimage() { - return tweetimage; - } - - public void setTweetimage(String tweetimage) { - this.tweetimage = tweetimage; - } - - public int getAppClient() { - return appClient; - } - - public void setAppClient(int appClient) { - this.appClient = appClient; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @XStreamAlias("objectreply") - public static class ObjectReply implements Serializable { - @XStreamAlias("objectname") - public String objectName; - - @XStreamAlias("objectbody") - public String objectBody; - - public String getObjectName() { - return objectName; - } - - public void setObjectName(String objectName) { - this.objectName = objectName; - } - - public String getObjectBody() { - return objectBody; - } - - public void setObjectBody(String objectBody) { - this.objectBody = objectBody; - } - } -} diff --git a/app/src/main/java/net/oschina/app/bean/ActiveList.java b/app/src/main/java/net/oschina/app/bean/ActiveList.java deleted file mode 100644 index 6b2219d0c6417335b9eae4e74fe66d821653c28c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/ActiveList.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 动态实体列表 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月22日 下午3:34:21 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class ActiveList extends Entity implements ListEntity { - - public final static int CATALOG_LASTEST = 1;// 最新 - public final static int CATALOG_ATME = 2;// @我 - public final static int CATALOG_COMMENT = 3;// 评论 - public final static int CATALOG_MYSELF = 4;// 我自己 - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("activeCount") - private int activeCount; - - @XStreamAlias("activies") - private List activelist = new ArrayList(); - - @XStreamAlias("result") - private Result result; - - public int getPageSize() { - return pageSize; - } - - public int getActiveCount() { - return activeCount; - } - - public List getActivelist() { - return activelist; - } - - @Override - public List getList() { - return activelist; - } - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Apply.java b/app/src/main/java/net/oschina/app/bean/Apply.java deleted file mode 100644 index 366bbc7e65bf1951c966af29d102520f47082cb8..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Apply.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 活动报名者实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月16日 下午3:27:04 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("apply") -public class Apply extends Entity { - - @XStreamAlias("uid") - private int userid; - - @XStreamAlias("name") - private String name; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("company") - private String company; - - @XStreamAlias("job") - private String job; - - public int getId() { - return userid; - } - public void setId(int userid) { - this.userid = userid; - } - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getPortrait() { - return portrait; - } - public void setPortrait(String portrait) { - this.portrait = portrait; - } - public String getCompany() { - return company; - } - public void setCompany(String company) { - this.company = company; - } - public String getJob() { - return job; - } - public void setJob(String job) { - this.job = job; - } -} - diff --git a/app/src/main/java/net/oschina/app/bean/BarCode.java b/app/src/main/java/net/oschina/app/bean/BarCode.java deleted file mode 100644 index c63e5bbb87d212c1cb34956daa9a99c1de30ac83..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/BarCode.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import net.oschina.app.AppException; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * 二维码扫描实体类 - * @author 火蚁 (http://my.oschina.net/LittleDY) - * @version 1.0 - * @created 2014-3-17 - */ -@SuppressWarnings("serial") -public class BarCode extends Entity implements Serializable{ - - public final static String NODE_REQURE_LOGIN = "require_login"; - public final static String NODE_TYPE = "type"; - public final static String NODE_URL = "url"; - public final static String NODE_TITLE = "title"; - - public final static byte LOGIN_IN = 0x00;// 登录 - public final static byte SIGN_IN = 0x01;// 签到 - - private boolean requireLogin;// 是否需要登录 - private int type;// 类型 - private String url;// url地址 - private String title;// 标题 - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public boolean isRequireLogin() { - return requireLogin; - } - - public void setRequireLogin(boolean requireLogin) { - this.requireLogin = requireLogin; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public static BarCode parse(String barCodeString) throws AppException { - BarCode barCode = new BarCode(); - try { - // 由字符串创建json对象 - JSONObject jsonObject = new JSONObject(barCodeString); - // 取数据操作 - if (!jsonObject.isNull(NODE_REQURE_LOGIN)) { - barCode.setRequireLogin(jsonObject.getBoolean(NODE_REQURE_LOGIN)); - } else { - barCode.setUrl("www.oschina.net"); - } - if (!jsonObject.isNull(NODE_TYPE)) { - barCode.setType(jsonObject.getInt(NODE_TYPE)); - } else { - barCode.setType(1); - } - if (!jsonObject.isNull(NODE_URL)) { - barCode.setUrl(jsonObject.getString(NODE_URL)); - } else { - barCode.setUrl("www.oschina.net"); - } - if (!jsonObject.isNull(NODE_TITLE)) { - barCode.setTitle(jsonObject.getString(NODE_TITLE)); - } else { - barCode.setTitle(""); - } - } catch (JSONException e) { - // 抛出一个json解析错误的异常 - throw AppException.json(e); - } - return barCode; - } - - @Override - public String toString() { - return "Barcode [requireLogin=" + requireLogin + ", type=" + type - + ", url=" + url + "]"; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Base.java b/app/src/main/java/net/oschina/app/bean/Base.java deleted file mode 100644 index d9f64576da1ebfd826a3a8283d3cc63d3628da9d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Base.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 实体基类:实现序列化 - * @author liux (http://my.oschina.net/liux) - * @version 1.0 - * @created 2012-3-21 - */ -@SuppressWarnings("serial") -public abstract class Base implements Serializable { - - @XStreamAlias("notice") - protected Notice notice; - - public Notice getNotice() { - return notice; - } - - public void setNotice(Notice notice) { - this.notice = notice; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Blog.java b/app/src/main/java/net/oschina/app/bean/Blog.java deleted file mode 100644 index 67eb58d00401f690c35246f56d185f4cd69aea69..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Blog.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * @author HuangWenwei - * - * @date 2014年9月29日 - */ -@SuppressWarnings("serial") -@XStreamAlias("blog") -public class Blog extends Entity { - - public final static int DOC_TYPE_REPASTE = 0;//转帖 - public final static int DOC_TYPE_ORIGINAL = 1;//原创 - - @XStreamAlias("title") - private String title; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("where") - private String where; - - @XStreamAlias("commentCount") - private int commentCount; - - @XStreamAlias("body") - private String body; - - @XStreamAlias("author") - private String authorname; - - @XStreamAlias("authorid") - private int authoruid; - - @XStreamAlias("documentType") - private int documentType; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("favorite") - private int favorite; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getWhere() { - return where; - } - - public void setWhere(String where) { - this.where = where; - } - - public int getCommentCount() { - return commentCount; - } - - public void setCommentCount(int commentCount) { - this.commentCount = commentCount; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getAuthor() { - return authorname; - } - - public void setAuthor(String author) { - this.authorname = author; - } - - public int getAuthorId() { - return authoruid; - } - - public void setAuthorId(int authorId) { - this.authoruid = authorId; - } - - public int getDocumenttype() { - return documentType; - } - - public void setDocumenttype(int documenttype) { - this.documentType = documenttype; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public int getFavorite() { - return favorite; - } - - public void setFavorite(int favorite) { - this.favorite = favorite; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/BlogCommentList.java b/app/src/main/java/net/oschina/app/bean/BlogCommentList.java deleted file mode 100644 index c50b632c65526faf220e8d2f5a693f890f440bea..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/BlogCommentList.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 博客评论列表实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月17日 上午10:28:04 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class BlogCommentList extends Entity implements ListEntity { - - @XStreamAlias("pagesize") - private int pageSize; - @XStreamAlias("allCount") - private int allCount; - @XStreamAlias("comments") - private List commentlist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public int getAllCount() { - return allCount; - } - - public List getCommentlist() { - return commentlist; - } - - @Override - public List getList() { - return commentlist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/BlogDetail.java b/app/src/main/java/net/oschina/app/bean/BlogDetail.java deleted file mode 100644 index 97918d7fc6de7bf15262552c727a93d9b633f066..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/BlogDetail.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 博客详情 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月15日 上午10:51:11 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class BlogDetail extends Entity { - - @XStreamAlias("blog") - private Blog blog; - - public Blog getBlog() { - return blog; - } - - public void setBlog(Blog blog) { - this.blog = blog; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/BlogList.java b/app/src/main/java/net/oschina/app/bean/BlogList.java deleted file mode 100644 index 80ded41b5e7ccbc37a3ced6b7954f9868d86ac24..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/BlogList.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * @author HuangWenwei - * - * @date 2014年9月28日 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class BlogList extends Entity implements ListEntity { - - public final static String PREF_READED_BLOG_LIST = "readed_blog_list.pref"; - - public static final String CATALOG_LATEST = "latest"; - public static final String CATALOG_RECOMMEND = "recommend"; - - @XStreamAlias("pagesize") - private int pagesize; - - @XStreamAlias("blogs") - private List bloglist = new ArrayList(); - - @XStreamAlias("blogsCount") - private int blogsCount; - - public int getPageSize() { - return pagesize; - } - - public void setPageSize(int pageSize) { - this.pagesize = pageSize; - } - - public List getBloglist() { - return bloglist; - } - - public void setBloglist(List bloglist) { - this.bloglist = bloglist; - } - - @Override - public List getList() { - return bloglist; - } - - public int getPagesize() { - return pagesize; - } - - public void setPagesize(int pagesize) { - this.pagesize = pagesize; - } - - public int getBlogsCount() { - return blogsCount; - } - - public void setBlogsCount(int blogsCount) { - this.blogsCount = blogsCount; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Comment.java b/app/src/main/java/net/oschina/app/bean/Comment.java deleted file mode 100644 index ff846d07a40955eea894a63cad266e4e3e5fb2fc..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Comment.java +++ /dev/null @@ -1,287 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 评论实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月14日 下午3:29:22 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("comment") -public class Comment extends Entity implements Parcelable { - - public static final String BUNDLE_KEY_COMMENT = "bundle_key_comment"; - public static final String BUNDLE_KEY_ID = "bundle_key_id"; - public static final String BUNDLE_KEY_CATALOG = "bundle_key_catalog"; - public static final String BUNDLE_KEY_BLOG = "bundle_key_blog"; - public static final String BUNDLE_KEY_OPERATION = "bundle_key_operation"; - - public static final int OPT_ADD = 1; - public static final int OPT_REMOVE = 2; - - public final static int CLIENT_MOBILE = 2; - public final static int CLIENT_ANDROID = 3; - public final static int CLIENT_IPHONE = 4; - public final static int CLIENT_WINDOWS_PHONE = 5; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("content") - private String content; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("appclient") - private int appClient; - - @XStreamAlias("replies") - private List replies = new ArrayList(); - - @XStreamAlias("refers") - private List refers = new ArrayList(); - - @SuppressWarnings("unchecked") - public Comment(Parcel source) { - id = source.readInt(); - portrait = source.readString(); - author = source.readString(); - authorId = source.readInt(); - pubDate = source.readString(); - appClient = source.readInt(); - content = source.readString(); - - replies = source.readArrayList(Reply.class.getClassLoader()); - refers = source.readArrayList(Refer.class.getClassLoader()); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(id); - dest.writeString(portrait); - dest.writeString(author); - dest.writeInt(authorId); - dest.writeString(pubDate); - dest.writeInt(appClient); - dest.writeString(content); - - dest.writeList(replies); - dest.writeList(refers); - } - - @Override - public int describeContents() { - return 0; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(int authorId) { - this.authorId = authorId; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public int getAppClient() { - return appClient; - } - - public void setAppClient(int appClient) { - this.appClient = appClient; - } - - public List getReplies() { - return replies; - } - - public void setReplies(List replies) { - this.replies = replies; - } - - public List getRefers() { - return refers; - } - - public void setRefers(List refers) { - this.refers = refers; - } - - @XStreamAlias("reply") - public static class Reply implements Serializable, Parcelable { - @XStreamAlias("rauthor") - public String rauthor; - @XStreamAlias("rpubDate") - public String rpubDate; - @XStreamAlias("rcontent") - public String rcontent; - - public Reply() { - } - - public Reply(Parcel source) { - rauthor = source.readString(); - rpubDate = source.readString(); - rcontent = source.readString(); - } - - public String getRauthor() { - return rauthor; - } - public void setRauthor(String rauthor) { - this.rauthor = rauthor; - } - public String getRpubDate() { - return rpubDate; - } - public void setRpubDate(String rpubDate) { - this.rpubDate = rpubDate; - } - public String getRcontent() { - return rcontent; - } - public void setRcontent(String rcontent) { - this.rcontent = rcontent; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(rauthor); - dest.writeString(rpubDate); - dest.writeString(rcontent); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Parcelable.Creator CREATOR = new Creator() { - - @Override - public Reply[] newArray(int size) { - return new Reply[size]; - } - - @Override - public Reply createFromParcel(Parcel source) { - return new Reply(source); - } - }; - - } - - @XStreamAlias("refer") - public static class Refer implements Serializable, Parcelable { - - @XStreamAlias("refertitle") - public String refertitle; - @XStreamAlias("referbody") - public String referbody; - - public Refer() { - } - - public Refer(Parcel source) { - referbody = source.readString(); - refertitle = source.readString(); - } - - public String getRefertitle() { - return refertitle; - } - public void setRefertitle(String refertitle) { - this.refertitle = refertitle; - } - public String getReferbody() { - return referbody; - } - public void setReferbody(String referbody) { - this.referbody = referbody; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(referbody); - dest.writeString(refertitle); - } - - @Override - public int describeContents() { - return 0; - } - - public static final Parcelable.Creator CREATOR = new Creator() { - - @Override - public Refer[] newArray(int size) { - return new Refer[size]; - } - - @Override - public Refer createFromParcel(Parcel source) { - return new Refer(source); - } - }; - } - - public static final Parcelable.Creator CREATOR = new Creator() { - - @Override - public Comment[] newArray(int size) { - return new Comment[size]; - } - - @Override - public Comment createFromParcel(Parcel source) { - return new Comment(source); - } - }; -} diff --git a/app/src/main/java/net/oschina/app/bean/CommentList.java b/app/src/main/java/net/oschina/app/bean/CommentList.java deleted file mode 100644 index 0b19aa56556782a2253332b40629e1f65d5485a8..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/CommentList.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 评论列表实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月14日 下午3:32:39 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class CommentList extends Entity implements ListEntity { - - public final static int CATALOG_NEWS = 1; - public final static int CATALOG_POST = 2; - public final static int CATALOG_TWEET = 3; - public final static int CATALOG_ACTIVE = 4; - public final static int CATALOG_MESSAGE = 4;// 动态与留言都属于消息中心 - - @XStreamAlias("pagesize") - private int pageSize; - @XStreamAlias("allCount") - private int allCount; - @XStreamAlias("comments") - private final List commentlist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public int getAllCount() { - return allCount; - } - - public List getCommentlist() { - return commentlist; - } - - @Override - public List getList() { - return commentlist; - } - - public void sortList() { - Collections.sort(commentlist, new Comparator() { - - @Override - public int compare(Comment lhs, Comment rhs) { - return lhs.getPubDate().compareTo(rhs.getPubDate()); - } - }); - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Constants.java b/app/src/main/java/net/oschina/app/bean/Constants.java deleted file mode 100644 index edaf5cc4f35c0c42794998771af0e85aa68053ee..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Constants.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.oschina.app.bean; - -/** - * 常量类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月27日 下午12:14:42 - * - */ - -public class Constants { - - public static final String INTENT_ACTION_USER_CHANGE = "net.oschina.action.USER_CHANGE"; - - public static final String INTENT_ACTION_COMMENT_CHANGED = "net.oschina.action.COMMENT_CHANGED"; - - public static final String INTENT_ACTION_NOTICE = "net.oschina.action.APPWIDGET_UPDATE"; - - public static final String INTENT_ACTION_LOGOUT = "net.oschina.action.LOGOUT"; - - public static final String WEICHAT_APPID = "wxa8213dc827399101"; - public static final String WEICHAT_SECRET = "5c716417ce72ff69d8cf0c43572c9284"; - - public static final String QQ_APPID = "100942993"; - public static final String QQ_APPKEY = "8edd3cc7ca8dcc15082d6fe75969601b"; -} diff --git a/app/src/main/java/net/oschina/app/bean/Entity.java b/app/src/main/java/net/oschina/app/bean/Entity.java deleted file mode 100644 index 60fdf96e4cdc0b41d34925615e87a81cd3c7da7f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Entity.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 实体类 - * - * @author liux (http://my.oschina.net/liux) - * @version 1.0 - * @created 2012-3-21 - */ -@SuppressWarnings("serial") -public abstract class Entity extends Base { - - @XStreamAlias("id") - protected int id; - - protected String cacheKey; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCacheKey() { - return cacheKey; - } - - public void setCacheKey(String cacheKey) { - this.cacheKey = cacheKey; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Event.java b/app/src/main/java/net/oschina/app/bean/Event.java deleted file mode 100644 index 25c50e8a348e0d3b031cb6d4748f479f38640326..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Event.java +++ /dev/null @@ -1,186 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 活动实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年12月12日 下午3:18:08 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("event") -public class Event extends Entity { - - public final static int EVNET_STATUS_APPLYING = 0x02; - public final static int EVNET_STATUS_END = 0x01; - - public final static int APPLYSTATUS_CHECKING = 0x00;// 审核中 - public final static int APPLYSTATUS_CHECKED = 0x01;// 已经确认 - public final static int APPLYSTATUS_ATTEND = 0x02;// 已经出席 - public final static int APPLYSTATUS_CANCLE = 0x03;// 已取消 - public final static int APPLYSTATUS_REJECT = 0X04;// 已拒绝 - - @XStreamAlias("cover") - private String cover; - - @XStreamAlias("title") - private String title; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("createTime") - private String createTime; - - @XStreamAlias("startTime") - private String startTime; - - @XStreamAlias("endTime") - private String endTime; - - @XStreamAlias("spot") - private String spot; - - @XStreamAlias("actor_count") - private int actor_count; - - @XStreamAlias("location") - private String location; - - @XStreamAlias("city") - private String city; - - @XStreamAlias("status") - private int status; - - @XStreamAlias("applyStatus") - private int applyStatus; - - @XStreamAlias("category") - private int category;// 活动类型 1源创会 2技术交流 3其他 4站外活动 - - @XStreamAlias("remark") - private EventRemark eventRemark; - - public int getCategory() { - return category; - } - - public void setCategory(int category) { - this.category = category; - } - - public String getCity() { - return city; - } - - public void setCity(String city) { - this.city = city; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getCover() { - return cover; - } - - public void setCover(String cover) { - this.cover = cover; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getSpot() { - return spot; - } - - public void setSpot(String spot) { - this.spot = spot; - } - - public int getActor_count() { - return actor_count; - } - - public void setActor_count(int actor_count) { - this.actor_count = actor_count; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public int getApplyStatus() { - return applyStatus; - } - - public void setApplyStatus(int applyStatus) { - this.applyStatus = applyStatus; - } - - public EventRemark getEventRemark() { - return eventRemark; - } - - public void setEventRemark(EventRemark eventRemark) { - this.eventRemark = eventRemark; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/EventAppliesList.java b/app/src/main/java/net/oschina/app/bean/EventAppliesList.java deleted file mode 100644 index 9ac5dfb07e6f4d1af7bcad55b6a0730c519bf26c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/EventAppliesList.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 活动参与者列表实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月12日 下午8:06:30 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class EventAppliesList extends Entity implements ListEntity { - - public final static int TYPE_FANS = 0x00; - public final static int TYPE_FOLLOWER = 0x01; - - @XStreamAlias("applies") - private List list = new ArrayList(); - - @Override - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/EventApplyData.java b/app/src/main/java/net/oschina/app/bean/EventApplyData.java deleted file mode 100644 index 89a6a5d65384f20f1723ff2d7ae27612679074ea..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/EventApplyData.java +++ /dev/null @@ -1,92 +0,0 @@ -package net.oschina.app.bean; - -/** - * 活动报名实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月17日 下午3:13:07 - * - */ -@SuppressWarnings("serial") -public class EventApplyData extends Entity { - - private int event;// 活动的id - - private int user;// 用户的id - - private String name;// 名字 - - private String gender;// 性别 - - private String mobile;// 电话 - - private String company;// 单位名称 - - private String job;// 职业名称 - - private String remark;// 备注 - - public int getEvent() { - return event; - } - - public void setEvent(int event) { - this.event = event; - } - - public int getUser() { - return user; - } - - public void setUser(int user) { - this.user = user; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getGender() { - return gender; - } - - public void setGender(String gender) { - this.gender = gender; - } - - public String getPhone() { - return mobile; - } - - public void setPhone(String phone) { - this.mobile = phone; - } - - public String getCompany() { - return company; - } - - public void setCompany(String company) { - this.company = company; - } - - public String getJob() { - return job; - } - - public void setJob(String job) { - this.job = job; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/EventList.java b/app/src/main/java/net/oschina/app/bean/EventList.java deleted file mode 100644 index ad2f80a5fb4518b79848169015c4035c034b890f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/EventList.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 活动实体类列表 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月10日 下午2:28:54 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class EventList extends Entity implements ListEntity { - - public final static int EVENT_LIST_TYPE_NEW_EVENT = 0X00;// 近期活动 - - public final static int EVENT_LIST_TYPE_MY_EVENT = 0X01;// 我的活动 - - @XStreamAlias("events") - private List friendlist = new ArrayList(); - - public List getFriendlist() { - return friendlist; - } - - public void setFriendlist(List resultlist) { - this.friendlist = resultlist; - } - - @Override - public List getList() { - return friendlist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/EventRemark.java b/app/src/main/java/net/oschina/app/bean/EventRemark.java deleted file mode 100644 index f0242a22fb48d11155c3795faa1d80e03a5c0fb6..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/EventRemark.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -import java.io.Serializable; -import java.util.List; - -/** - * 活动备注选择 - * Created by zhangdeyi on 15/8/19. - */ -@XStreamAlias("remark") -public class EventRemark implements Serializable { - - @XStreamAlias("remarkTip") - private String remarkTip; - - @XStreamAlias("remarkSelect") - private RemarksSelet select; - - public class RemarksSelet implements Serializable { - @XStreamImplicit(itemFieldName = "select") - private List list; - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - - } - - public String getRemarkTip() { - return remarkTip; - } - - public void setRemarkTip(String remarkTip) { - this.remarkTip = remarkTip; - } - - public RemarksSelet getSelect() { - return select; - } - - public void setSelect(RemarksSelet select) { - this.select = select; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Favorite.java b/app/src/main/java/net/oschina/app/bean/Favorite.java deleted file mode 100644 index d229ffdb478acfdce9b74c49dae37a96fbe3cfb4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Favorite.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 收藏实体类 - * @author hww - * - */ -@SuppressWarnings("serial") -@XStreamAlias("favorite") -public class Favorite extends Entity { - - public static final int CATALOG_ALL = 0; - public static final int CATALOG_SOFTWARE = 1; - public static final int CATALOG_TOPIC = 2; - public static final int CATALOG_BLOGS = 3; - public static final int CATALOG_NEWS = 4; - public static final int CATALOG_CODE = 5; - - @XStreamAlias("objid") - public int id; - @XStreamAlias("type") - public int type; - @XStreamAlias("title") - public String title; - @XStreamAlias("url") - public String url; - public int getId() { - return id; - } - public void setId(int id) { - this.id = id; - } - public int getType() { - return type; - } - public void setType(int type) { - this.type = type; - } - public String getTitle() { - return title; - } - public void setTitle(String title) { - this.title = title; - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/FavoriteList.java b/app/src/main/java/net/oschina/app/bean/FavoriteList.java deleted file mode 100644 index 513eb64a430dd331f2a57b4e2b6c90b2de4f0101..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/FavoriteList.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 收藏实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月14日 下午2:27:39 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class FavoriteList extends Entity implements ListEntity { - - public final static int TYPE_ALL = 0x00; - public final static int TYPE_SOFTWARE = 0x01; - public final static int TYPE_POST = 0x02; - public final static int TYPE_BLOG = 0x03; - public final static int TYPE_NEWS = 0x04; - public final static int TYPE_CODE = 0x05; - - @XStreamAlias("pagesize") - private int pageSize; - @XStreamAlias("favorites") - private List favoritelist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pagesize) { - this.pageSize = pagesize; - } - - public List getFavoritelist() { - return favoritelist; - } - - public void setFavoritelist(List favoritelist) { - this.favoritelist = favoritelist; - } - - @Override - public List getList() { - return favoritelist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/FindUserList.java b/app/src/main/java/net/oschina/app/bean/FindUserList.java deleted file mode 100644 index 165884e018ef145701c596b562db6c377da34b60..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/FindUserList.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 好友实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:17:36 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class FindUserList extends Entity implements ListEntity { - - public final static int TYPE_FANS = 0x00; - public final static int TYPE_FOLLOWER = 0x01; - - @XStreamAlias("users") - private List friendlist = new ArrayList(); - - public List getFriendlist() { - return friendlist; - } - - public void setFriendlist(List resultlist) { - this.friendlist = resultlist; - } - - @Override - public List getList() { - return friendlist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Friend.java b/app/src/main/java/net/oschina/app/bean/Friend.java deleted file mode 100644 index eeaa23adbfeea11100c4ac6534f700c3d2114b30..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Friend.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 好友实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:37:31 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("friend") -public class Friend extends Entity { - - @XStreamAlias("userid") - private int userid; - - @XStreamAlias("name") - private String name; - - @XStreamAlias("from") - private String from; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("expertise") - private String expertise; - - @XStreamAlias("gender") - private int gender; - - public int getUserid() { - return userid; - } - - public void setUserid(int userid) { - this.userid = userid; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getExpertise() { - return expertise; - } - - public void setExpertise(String expertise) { - this.expertise = expertise; - } - - public int getGender() { - return gender; - } - - public void setGender(int gender) { - this.gender = gender; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/FriendsList.java b/app/src/main/java/net/oschina/app/bean/FriendsList.java deleted file mode 100644 index 9c73190f12d51382d58166bf1bf54dec000699e4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/FriendsList.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 好友实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:17:36 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class FriendsList extends Entity implements ListEntity { - - public final static int TYPE_FANS = 0x00; - public final static int TYPE_FOLLOWER = 0x01; - - @XStreamAlias("friends") - private List friendlist = new ArrayList(); - - public List getFriendlist() { - return friendlist; - } - - public void setFriendlist(List resultlist) { - this.friendlist = resultlist; - } - - @Override - public List getList() { - return friendlist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/ListEntity.java b/app/src/main/java/net/oschina/app/bean/ListEntity.java deleted file mode 100644 index 1581e070716d766a49927dbe403943fafe4cd249..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/ListEntity.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; -import java.util.List; - -public interface ListEntity extends Serializable { - - public List getList(); -} diff --git a/app/src/main/java/net/oschina/app/bean/LoginUserBean.java b/app/src/main/java/net/oschina/app/bean/LoginUserBean.java deleted file mode 100644 index a6d7ac9a4b4252b296f2713a60e3491ce6cb4a38..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/LoginUserBean.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年9月27日 下午2:45:57 - * - */ - -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class LoginUserBean extends Entity { - - @XStreamAlias("result") - private Result result; - - @XStreamAlias("user") - private User user; - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/bean/MessageDetail.java b/app/src/main/java/net/oschina/app/bean/MessageDetail.java deleted file mode 100644 index 222440b4dfeb5587085c61cdeaa9064704d60023..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/MessageDetail.java +++ /dev/null @@ -1,115 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 聊天详细信息实体类 - * @author 铂金小鸟(http://my.oschina.net/fants) - * @Created 2015年9月16日 上午4:20:01 - */ -@SuppressWarnings("serial") -@XStreamAlias("message") -public class MessageDetail extends Entity { - - //是否显示时间 - private boolean showDate; - //消息状态 - private MessageStatus status; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("content") - private String content; - - @XStreamAlias("fileName") - private String fileName; - - @XStreamAlias("btype") - private int btype; - - @XStreamAlias("pubDate") - private String pubDate; - - public enum MessageStatus{ - NORMAL,SENDING,ERROR - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(int authorId) { - this.authorId = authorId; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public int getBtype() { - return btype; - } - - public void setBtype(int btype) { - this.btype = btype; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public boolean isShowDate() { - return showDate; - } - - public void setShowDate(boolean showDate) { - this.showDate = showDate; - } - - public MessageStatus getStatus() { - return status; - } - - public void setStatus(MessageStatus status) { - this.status = status; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/MessageDetailList.java b/app/src/main/java/net/oschina/app/bean/MessageDetailList.java deleted file mode 100644 index 7684a8dcbbd88ad051b11955f14f7f1c651a917b..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/MessageDetailList.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import java.util.ArrayList; -import java.util.List; - -/** - * 聊天详细信息实体类 - * @author 铂金小鸟(http://my.oschina.net/fants) - * @Created 2015年9月16日 上午4:20:01 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class MessageDetailList extends Entity implements ListEntity { - - @XStreamAlias("allCount") - private int allCount; - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("messages") - private List messagelist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public int getMessageCount() { - return allCount; - } - - public List getMessagelist() { - return messagelist; - } - - @Override - public List getList() { - return messagelist; - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/MessageList.java b/app/src/main/java/net/oschina/app/bean/MessageList.java deleted file mode 100644 index 63cb67eb4fddc6f98cf61ac0c0d11448cde479c4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/MessageList.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 留言实体类列表 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月22日 下午4:38:49 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class MessageList extends Entity implements ListEntity { - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("messageCount") - private int messageCount; - - @XStreamAlias("messages") - private List messagelist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public int getMessageCount() { - return messageCount; - } - - public List getMessagelist() { - return messagelist; - } - - @Override - public List getList() { - return messagelist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Messages.java b/app/src/main/java/net/oschina/app/bean/Messages.java deleted file mode 100644 index e004f82dc910fc1460c5635eb5ce177fb6fb53b5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Messages.java +++ /dev/null @@ -1,118 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 留言实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月22日 下午4:43:01 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("message") -public class Messages extends Entity { - - public final static int CLIENT_MOBILE = 2; - public final static int CLIENT_ANDROID = 3; - public final static int CLIENT_IPHONE = 4; - public final static int CLIENT_WINDOWS_PHONE = 5; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("friendid") - private int friendId; - - @XStreamAlias("friendname") - private String friendName; - - @XStreamAlias("sender") - private String sender; - - @XStreamAlias("senderid") - private int senderId; - - @XStreamAlias("content") - private String content; - - @XStreamAlias("messageCount") - private int messageCount; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("appClient") - private int appClient; - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public int getFriendId() { - return friendId; - } - - public void setFriendId(int friendId) { - this.friendId = friendId; - } - - public String getFriendName() { - return friendName; - } - - public void setFriendName(String friendName) { - this.friendName = friendName; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public int getSenderId() { - return senderId; - } - - public void setSenderId(int senderId) { - this.senderId = senderId; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public int getMessageCount() { - return messageCount; - } - - public void setMessageCount(int messageCount) { - this.messageCount = messageCount; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public int getAppClient() { - return appClient; - } - - public void setAppClient(int appClient) { - this.appClient = appClient; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/MyInformation.java b/app/src/main/java/net/oschina/app/bean/MyInformation.java deleted file mode 100644 index 91a2bf214ead1ec8eedd2b12918ec9f5ec21091d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/MyInformation.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 我的资料实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月30日 下午4:08:30 - * - */ - -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class MyInformation extends Base { - - @XStreamAlias("user") - private User user; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/News.java b/app/src/main/java/net/oschina/app/bean/News.java deleted file mode 100644 index fb1ab9a00181c2bd2070bb3b406d3f5a146ec6e9..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/News.java +++ /dev/null @@ -1,225 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.util.StringUtils; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 新闻、软件、帖子、博客实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月28日 上午10:16:59 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("news") -public class News extends Entity { - - public final static int NEWSTYPE_NEWS = 0x00;//0 新闻 - public final static int NEWSTYPE_SOFTWARE = 0x01;//1 软件 - public final static int NEWSTYPE_POST = 0x02;//2 帖子 - public final static int NEWSTYPE_BLOG = 0x03;//3 博客 - - @XStreamAlias("title") - private String title; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("body") - private String body; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("commentcount") - private int commentCount; - - @XStreamAlias("pubdate") - private String pubDate; - - @XStreamAlias("softwarelink") - private String softwareLink; - - @XStreamAlias("softwarename") - private String softwareName; - - @XStreamAlias("favorite") - private int favorite; - - @XStreamAlias("newstype") - private NewsType newsType; - - @XStreamAlias("relativies") - private List relatives = new ArrayList(); - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(String authorId) { - this.authorId = StringUtils.toInt(authorId, 0); - } - - public int getCommentCount() { - return commentCount; - } - - public void setCommentCount(int commentCount) { - this.commentCount = commentCount; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getSoftwareLink() { - return softwareLink; - } - - public void setSoftwareLink(String softwareLink) { - this.softwareLink = softwareLink; - } - - public String getSoftwareName() { - return softwareName; - } - - public void setSoftwareName(String softwareName) { - this.softwareName = softwareName; - } - - public int getFavorite() { - return favorite; - } - - public void setFavorite(int favorite) { - this.favorite = favorite; - } - - public NewsType getNewType() { - return newsType; - } - - public void setNewType(NewsType newType) { - this.newsType = newType; - } - - public List getRelatives() { - return relatives; - } - - public void setRelatives(List relatives) { - this.relatives = relatives; - } - - @XStreamAlias("newstype") - public class NewsType implements Serializable{ - @XStreamAlias("type") - private int type; - @XStreamAlias("attachment") - private String attachment; - @XStreamAlias("authoruid2") - private int authoruid2; - @XStreamAlias("eventurl") - private String eventUrl; - - public String getEventUrl() { - return eventUrl; - } - public void setEventUrl(String eventUrl) { - this.eventUrl = eventUrl; - } - public int getType() { - return type; - } - public void setType(int type) { - this.type = type; - } - public String getAttachment() { - return attachment; - } - public void setAttachment(String attachment) { - this.attachment = attachment; - } - public int getAuthoruid2() { - return authoruid2; - } - public void setAuthoruid2(int authoruid2) { - this.authoruid2 = authoruid2; - } - } - - @XStreamAlias("relative") - public class Relative implements Serializable{ - - @XStreamAlias("rtitle") - public String title; - - @XStreamAlias("rurl") - public String url; - - public String getTitle() { - return title; - } - public void setTitle(String title) { - this.title = title; - } - public String getUrl() { - return url; - } - public void setUrl(String url) { - this.url = url; - } - } -} diff --git a/app/src/main/java/net/oschina/app/bean/NewsDetail.java b/app/src/main/java/net/oschina/app/bean/NewsDetail.java deleted file mode 100644 index ce68418a35935ed38ee4ed3b948141ebaf105b83..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/NewsDetail.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 资讯详情 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月11日 下午3:28:33 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class NewsDetail extends Entity { - - @XStreamAlias("news") - private News news; - - public News getNews() { - return news; - } - - public void setNews(News news) { - this.news = news; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/NewsList.java b/app/src/main/java/net/oschina/app/bean/NewsList.java deleted file mode 100644 index c353462a01a375f5b9bd762741659f9ea7e32a40..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/NewsList.java +++ /dev/null @@ -1,71 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 新闻列表实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月27日 下午5:55:58 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class NewsList extends Entity implements ListEntity { - - public final static String PREF_READED_NEWS_LIST = "readed_news_list.pref"; - - public final static int CATALOG_ALL = 1; - public final static int CATALOG_INTEGRATION = 2; - public final static int CATALOG_SOFTWARE = 3; - - public final static int CATALOG_WEEK = 4; - public final static int CATALOG_MONTH = 5; - - @XStreamAlias("catalog") - private int catalog; - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("newscount") - private int newsCount; - - @XStreamAlias("newslist") - private List list = new ArrayList(); - - public int getCatalog() { - return catalog; - } - - public void setCatalog(int catalog) { - this.catalog = catalog; - } - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getNewsCount() { - return newsCount; - } - - public void setNewsCount(int newsCount) { - this.newsCount = newsCount; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/NotebookData.java b/app/src/main/java/net/oschina/app/bean/NotebookData.java deleted file mode 100644 index 1e429ece94fdfa671c7cc4355f1e5eb6d09a679f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/NotebookData.java +++ /dev/null @@ -1,159 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 便签数据bean(有重载equals()方法) - * - * @author kymjs (https://github.com/kymjs) - * - */ -@XStreamAlias("sticky") -public class NotebookData extends Entity implements Serializable, - Comparable { - private static final long serialVersionUID = 1L; - - @XStreamAlias("id") - private int id; - @XStreamAlias("iid") - private int iid; - @XStreamAlias("timestamp") - private String unixTime; - @XStreamAlias("updateTime") - private String date; - @XStreamAlias("content") - private String content; - @XStreamAlias("color") - private String colorText; - - private String serverUpdateTime; // 服务器端需要,客户端无用 - private int color; - - @Override - public boolean equals(Object o) { - if (super.equals(o)) { - return true; - } else { - if (o instanceof NotebookData) { - NotebookData data = (NotebookData) o; - try { - return (this.id == data.getId()) - && (this.iid == data.getIid()) - && (this.unixTime == data.getUnixTime()) - && (this.date.equals(data.getDate())) - && (this.content == data.getContent()) - && (this.color == data.getColor()); - } catch (NullPointerException e) { - return false; - } - } else { - return false; - } - } - } - - @Override - public int getId() { - return id; - } - - @Override - public void setId(int id) { - this.id = id; - } - - public int getIid() { - return iid; - } - - public void setIid(int iid) { - this.iid = iid; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } - - public String getUnixTime() { - return unixTime; - } - - public void setUnixTime(String time) { - this.unixTime = time; - setServerUpdateTime(time); - } - - public String getColorText() { - return colorText; - } - - public void setColorText(String color) { - this.colorText = color; - } - - public int getColor() { - // 客户端始终以当前手机上的颜色为准 - if ("blue".equals(colorText)) { - this.color = 3; - } else if ("red".equals(colorText)) { - this.color = 2; - } else if ("yellow".equals(colorText)) { - this.color = 1; - } else if ("purple".equals(colorText)) { - this.color = 4; - } else if ("green".equals(colorText)) { - this.color = 0; - } - return color; - } - - public String getServerUpdateTime() { - return serverUpdateTime; - } - - public void setServerUpdateTime(String serverUpdateTime) { - this.serverUpdateTime = serverUpdateTime; - } - - public void setColor(int color) { - switch (color) { - case 0: - colorText = "green"; - break; - case 1: - colorText = "yellow"; - break; - case 2: - colorText = "red"; - break; - case 3: - colorText = "blue"; - break; - case 4: - colorText = "purple"; - break; - default: - this.color = color; - break; - } - } - - @Override - public int compareTo(NotebookData another) { - return this.iid - another.getIid(); - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/bean/NotebookDataList.java b/app/src/main/java/net/oschina/app/bean/NotebookDataList.java deleted file mode 100644 index 5a9c5a790b5f8534146b98831f9570b18b3cb8da..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/NotebookDataList.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@XStreamAlias("oschina") -public class NotebookDataList extends Entity implements - ListEntity { - - private static final long serialVersionUID = 1L; - @XStreamAlias("stickies") - private List list = new ArrayList(); - - @Override - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/bean/Notice.java b/app/src/main/java/net/oschina/app/bean/Notice.java deleted file mode 100644 index 8d5717bbc4489c3024f050100677077af02e3665..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Notice.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 通知信息实体类 - * - * @author liux (http://my.oschina.net/liux) - * @version 1.0 - * @created 2012-3-21 - */ -@SuppressWarnings("serial") -@XStreamAlias("notice") -public class Notice implements Serializable { - - public final static String UTF8 = "UTF-8"; - public final static String NODE_ROOT = "oschina"; - - public final static int TYPE_ATME = 1; - public final static int TYPE_MESSAGE = 2; - public final static int TYPE_COMMENT = 3; - public final static int TYPE_NEWFAN = 4; - public final static int TYPE_NEWLIKE = 5; - - @XStreamAlias("atmeCount") - private int atmeCount; - - @XStreamAlias("msgCount") - private int msgCount; - - @XStreamAlias("reviewCount") - private int reviewCount; - - @XStreamAlias("newFansCount") - private int newFansCount; - - @XStreamAlias("newLikeCount") - private int newLikeCount; - - public int getAtmeCount() { - return atmeCount; - } - - public void setAtmeCount(int atmeCount) { - this.atmeCount = atmeCount; - } - - public int getMsgCount() { - return msgCount; - } - - public void setMsgCount(int msgCount) { - this.msgCount = msgCount; - } - - public int getReviewCount() { - return reviewCount; - } - - public void setReviewCount(int reviewCount) { - this.reviewCount = reviewCount; - } - - public int getNewFansCount() { - return newFansCount; - } - - public void setNewFansCount(int newFansCount) { - this.newFansCount = newFansCount; - } - - public int getNewLikeCount() { - return newLikeCount; - } - - public void setNewLikeCount(int newLikeCount) { - this.newLikeCount = newLikeCount; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/NoticeDetail.java b/app/src/main/java/net/oschina/app/bean/NoticeDetail.java deleted file mode 100644 index 776fe5fb7128e90447a7e54d5f9956443c84f14f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/NoticeDetail.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 通知实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月27日 下午2:28:42 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class NoticeDetail extends Base { - - @XStreamAlias("result") - private Result result; - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } - - -} diff --git a/app/src/main/java/net/oschina/app/bean/OpenIdCatalog.java b/app/src/main/java/net/oschina/app/bean/OpenIdCatalog.java deleted file mode 100644 index 7d6efe9cb4cb32b2e269c7180ee46dda6bedd8de..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/OpenIdCatalog.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.oschina.app.bean; - -/** - * Created by zhangdeyi on 15/7/22. - */ -public class OpenIdCatalog { - - public static final String QQ = "qq"; - public static final String WEIBO = "weibo"; - public static final String WECHAT = "wechat"; - public static final String GITHUB = "github"; -} diff --git a/app/src/main/java/net/oschina/app/bean/Post.java b/app/src/main/java/net/oschina/app/bean/Post.java deleted file mode 100644 index b6441f74aa2cc1e892bb23e96524139d674434d5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Post.java +++ /dev/null @@ -1,229 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -/** - * 帖子实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月9日 下午6:02:47 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("post") -public class Post extends Entity { - - public final static int CATALOG_ASK = 1; - public final static int CATALOG_SHARE = 2; - public final static int CATALOG_OTHER = 3; - public final static int CATALOG_JOB = 4; - public final static int CATALOG_SITE = 5; - - @XStreamAlias("title") - private String title; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("body") - private String body; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("answerCount") - private int answerCount; - - @XStreamAlias("viewCount") - private int viewCount; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("catalog") - private int catalog; - - @XStreamAlias("isnoticeme") - private int isNoticeMe; - - @XStreamAlias("favorite") - private int favorite; - - @XStreamAlias("tags") - private Tags tags; - - @XStreamAlias("answer") - private Answer answer; - - @XStreamAlias("event") - private Event event; - - public Event getEvent() { - return event; - } - - public void setEvent(Event event) { - this.event = event; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(int authorId) { - this.authorId = authorId; - } - - public int getAnswerCount() { - return answerCount; - } - - public void setAnswerCount(int answerCount) { - this.answerCount = answerCount; - } - - public int getViewCount() { - return viewCount; - } - - public void setViewCount(int viewCount) { - this.viewCount = viewCount; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public int getCatalog() { - return catalog; - } - - public void setCatalog(int catalog) { - this.catalog = catalog; - } - - public int getIsNoticeMe() { - return isNoticeMe; - } - - public void setIsNoticeMe(int isNoticeMe) { - this.isNoticeMe = isNoticeMe; - } - - public int getFavorite() { - return favorite; - } - - public void setFavorite(int favorite) { - this.favorite = favorite; - } - - public Post.Tags getTags() { - return tags; - } - - public void setTags(Tags tags) { - this.tags = tags; - } - - public Answer getAnswer() { - return answer; - } - - public void setAnswer(Answer answer) { - this.answer = answer; - } - - @XStreamAlias("answer") - public class Answer implements Serializable { - - @XStreamAlias("name") - private String name; - - @XStreamAlias("time") - private String time; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - } - - public class Tags implements Serializable { - @XStreamImplicit(itemFieldName="tag") - private List tags; - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - } -} diff --git a/app/src/main/java/net/oschina/app/bean/PostDetail.java b/app/src/main/java/net/oschina/app/bean/PostDetail.java deleted file mode 100644 index 017c5bf86dd52ef899f320dd245bcd02a9638195..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/PostDetail.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 帖子详情 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月11日 下午3:28:33 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class PostDetail extends Entity { - - @XStreamAlias("post") - private Post post; - - public Post getPost() { - return post; - } - - public void setPost(Post post) { - this.post = post; - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/PostList.java b/app/src/main/java/net/oschina/app/bean/PostList.java deleted file mode 100644 index 06c848db8b669fc67569401d1bce681ab00973af..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/PostList.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 帖子实体类列表 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月9日 下午6:10:11 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class PostList extends Entity implements ListEntity { - - public final static String PREF_READED_POST_LIST = "readed_post_list.pref"; - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("postCount") - private int postCount; - - @XStreamAlias("posts") - private List postlist = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - public int getPostCount() { - return postCount; - } - public List getPostlist() { - return postlist; - } - @Override - public List getList() { - return postlist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Report.java b/app/src/main/java/net/oschina/app/bean/Report.java deleted file mode 100644 index 02c7e9ccaeb6fb31008d8793c32f0b66168f6069..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Report.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.oschina.app.bean; - -/** - * 举报实体类 - * - * @author 火蚁(http://my.oschina.net/LittleDY) - * @version 1.0 - * @created 2014-02-13 - */ -public class Report extends Entity { - private static final long serialVersionUID = 1L; - - public static final byte TYPE_QUESTION = 0x02;// 问题 - - private int objId;//需要举报的id - private String url;// 举报的链接地址 - private byte objType;// 举报的类型 - private int reason;// 原因 - private String otherReason;// 其他原因 - - public int getObjId() { - return objId; - } - - public void setObjId(int objId) { - this.objId = objId; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public byte getObjType() { - return objType; - } - - public void setObjType(byte objType) { - this.objType = objType; - } - - public int getReason() { - return reason; - } - - public void setReason(int reason) { - this.reason = reason; - } - - public String getOtherReason() { - return otherReason; - } - - public void setOtherReason(String otherReason) { - this.otherReason = otherReason; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Result.java b/app/src/main/java/net/oschina/app/bean/Result.java deleted file mode 100644 index 3f0a4eeab2d944dd36d23bb77f675ec6f11361f7..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Result.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 数据操作结果实体类 - * - * @author liux (http://my.oschina.net/liux) - * @version 1.0 - * @created 2012-3-21 - */ -@SuppressWarnings("serial") -@XStreamAlias("result") -public class Result implements Serializable { - - @XStreamAlias("errorCode") - private int errorCode; - - @XStreamAlias("errorMessage") - private String errorMessage; - - public boolean OK() { - return errorCode == 1; - } - - public int getErrorCode() { - return errorCode; - } - - public void setErrorCode(int errorCode) { - this.errorCode = errorCode; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/ResultBean.java b/app/src/main/java/net/oschina/app/bean/ResultBean.java deleted file mode 100644 index 687c82a5a197ea4e11d2cb6ddd43e0aa0e702d48..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/ResultBean.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 操作结果实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月14日 下午2:59:27 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class ResultBean extends Base { - - @XStreamAlias("result") - private Result result; - - @XStreamAlias("notice") - private Notice notice; - - @XStreamAlias("comment") - private Comment comment; - - //现在pub_message接口返回的是comment对象。 - //@XStreamAlias("message") - private MessageDetail message; - - @XStreamAlias("relation") - private int relation; - - public Result getResult() { - return result; - } - - public void setResult(Result result) { - this.result = result; - } - - public int getRelation() { - return relation; - } - - public void setRelation(int relation) { - this.relation = relation; - } - - public Notice getNotice() { - return notice; - } - - public void setNotice(Notice notice) { - this.notice = notice; - } - - public Comment getComment() { - return comment; - } - - public void setComment(Comment comment) { - this.comment = comment; - } - - public MessageDetail getMessage() { - //现在pub_message接口返回的是comment对象。所以要转成message - message = new MessageDetail(); - if(comment!=null) { - message.setId(comment.getId()); - message.setPortrait(comment.getPortrait()); - message.setAuthor(comment.getAuthor()); - message.setAuthorId(comment.getId()); - message.setContent(comment.getContent()); - message.setPubDate(comment.getPubDate()); - } - return message; - } - - public void setMessage(MessageDetail message) { - this.message = message; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SearchList.java b/app/src/main/java/net/oschina/app/bean/SearchList.java deleted file mode 100644 index 4e212dd92d8dd5be3a5b38b074c64d9e9005b3fd..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SearchList.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 搜索实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月5日 上午11:19:44 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class SearchList extends Entity implements ListEntity { - - public final static String CATALOG_ALL = "all"; - public final static String CATALOG_NEWS = "news"; - public final static String CATALOG_POST = "post"; - public final static String CATALOG_SOFTWARE = "software"; - public final static String CATALOG_BLOG = "blog"; - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("results") - private List list = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - @Override - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SearchResult.java b/app/src/main/java/net/oschina/app/bean/SearchResult.java deleted file mode 100644 index e414f412cc8bd3dceeaa9ea77eac6b22204b71cb..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SearchResult.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 搜索结果实体类 - */ -@SuppressWarnings("serial") -@XStreamAlias("result") -public class SearchResult extends Entity { - - @XStreamAlias("objid") - private int id; - - @XStreamAlias("type") - private String type; - - @XStreamAlias("title") - private String title; - - @XStreamAlias("description") - private String description; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("pubDate") - private String pubDate; - - @XStreamAlias("author") - private String author; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/ShakeObject.java b/app/src/main/java/net/oschina/app/bean/ShakeObject.java deleted file mode 100644 index 865de1269247c1c048daf715320416613c1721da..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/ShakeObject.java +++ /dev/null @@ -1,113 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@XStreamAlias("oschina") -public class ShakeObject { - - @XStreamAlias("randomtype") - private String randomtype; // 数据类型 - @XStreamAlias("id") - private String id; // 数据id - @XStreamAlias("title") - private String title; // 帖子标题 - @XStreamAlias("detail") - private String detail; // 内容 - @XStreamAlias("author") - private String author; // 作者 - @XStreamAlias("authorid") - private String authorid; // 作者id - @XStreamAlias("image") - private String image; // 头像地址 - @XStreamAlias("pubDate") - private String pubDate; // 收录日期 - @XStreamAlias("commentCount") - private String commentCount; - @XStreamAlias("url") - private String url; - - public static final String RANDOMTYPE_NEWS = "1"; - public static final String RANDOMTYPE_BLOG = "2"; - public static final String RANDOMTYPE_SOFTWARE = "3"; - - public String getRandomtype() { - return randomtype; - } - - public void setRandomtype(String randomtype) { - this.randomtype = randomtype; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getAuthorid() { - return authorid; - } - - public void setAuthorid(String authorid) { - this.authorid = authorid; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - this.image = image; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getCommentCount() { - return commentCount; - } - - public void setCommentCount(String commentCount) { - this.commentCount = commentCount; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/SimpleBackPage.java b/app/src/main/java/net/oschina/app/bean/SimpleBackPage.java deleted file mode 100644 index 7e40b7f95860bac0148e44ddb1cd0b141f4ac102..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SimpleBackPage.java +++ /dev/null @@ -1,185 +0,0 @@ -package net.oschina.app.bean; - -import net.oschina.app.R; -import net.oschina.app.fragment.AboutOSCFragment; -import net.oschina.app.fragment.ActiveFragment; -import net.oschina.app.fragment.BrowserFragment; -import net.oschina.app.fragment.CommentFrament; -import net.oschina.app.fragment.EventAppliesFragment; -import net.oschina.app.fragment.EventFragment; -import net.oschina.app.fragment.FeedBackFragment; -import net.oschina.app.fragment.MessageDetailFragment; -import net.oschina.app.fragment.MyInformationFragment; -import net.oschina.app.fragment.MyInformationFragmentDetail; -import net.oschina.app.fragment.QuestionTagFragment; -import net.oschina.app.fragment.SettingsFragment; -import net.oschina.app.fragment.SettingsNotificationFragment; -import net.oschina.app.fragment.SoftWareTweetsFrament; -import net.oschina.app.fragment.TweetLikeUsersFragment; -import net.oschina.app.fragment.TweetPubFragment; -import net.oschina.app.fragment.TweetRecordFragment; -import net.oschina.app.fragment.TweetsFragment; -import net.oschina.app.fragment.UserBlogFragment; -import net.oschina.app.fragment.UserCenterFragment; -import net.oschina.app.team.fragment.NoteBookFragment; -import net.oschina.app.team.fragment.NoteEditFragment; -import net.oschina.app.team.fragment.TeamActiveFragment; -import net.oschina.app.team.fragment.TeamDiaryDetailFragment; -import net.oschina.app.team.fragment.TeamDiscussFragment; -import net.oschina.app.team.fragment.TeamIssueFragment; -import net.oschina.app.team.fragment.TeamMemberInformationFragment; -import net.oschina.app.team.fragment.TeamProjectFragment; -import net.oschina.app.team.fragment.TeamProjectMemberSelectFragment; -import net.oschina.app.team.viewpagefragment.MyIssuePagerfragment; -import net.oschina.app.team.viewpagefragment.TeamDiaryFragment; -import net.oschina.app.team.viewpagefragment.TeamIssueViewPageFragment; -import net.oschina.app.team.viewpagefragment.TeamProjectViewPagerFragment; -import net.oschina.app.viewpagerfragment.BlogViewPagerFragment; -import net.oschina.app.viewpagerfragment.EventViewPagerFragment; -import net.oschina.app.viewpagerfragment.FriendsViewPagerFragment; -import net.oschina.app.viewpagerfragment.NoticeViewPagerFragment; -import net.oschina.app.viewpagerfragment.OpensourceSoftwareFragment; -import net.oschina.app.viewpagerfragment.QuestViewPagerFragment; -import net.oschina.app.viewpagerfragment.SearchViewPageFragment; -import net.oschina.app.viewpagerfragment.UserFavoriteViewPagerFragment; - -public enum SimpleBackPage { - - COMMENT(1, R.string.actionbar_title_comment, CommentFrament.class), - - QUEST(2, R.string.actionbar_title_questions, QuestViewPagerFragment.class), - - TWEET_PUB(3, R.string.actionbar_title_tweetpub, TweetPubFragment.class), - - SOFTWARE_TWEETS(4, R.string.actionbar_title_softtweet, - SoftWareTweetsFrament.class), - - USER_CENTER(5, R.string.actionbar_title_user_center, - UserCenterFragment.class), - - USER_BLOG(6, R.string.actionbar_title_user_blog, UserBlogFragment.class), - - MY_INFORMATION(7, R.string.actionbar_title_my_information, - MyInformationFragment.class), - - MY_ACTIVE(8, R.string.actionbar_title_active, ActiveFragment.class), - - MY_MES(9, R.string.actionbar_title_mes, NoticeViewPagerFragment.class), - - OPENSOURCE_SOFTWARE(10, R.string.actionbar_title_softwarelist, - OpensourceSoftwareFragment.class), - - MY_FRIENDS(11, R.string.actionbar_title_my_friends, - FriendsViewPagerFragment.class), - - QUESTION_TAG(12, R.string.actionbar_title_question, - QuestionTagFragment.class), - - MESSAGE_DETAIL(13, R.string.actionbar_title_message_detail, - MessageDetailFragment.class), - - USER_FAVORITE(14, R.string.actionbar_title_user_favorite, - UserFavoriteViewPagerFragment.class), - - SETTING(15, R.string.actionbar_title_setting, SettingsFragment.class), - - SETTING_NOTIFICATION(16, R.string.actionbar_title_setting_notification, - SettingsNotificationFragment.class), - - ABOUT_OSC(17, R.string.actionbar_title_about_osc, AboutOSCFragment.class), - - BLOG(18, R.string.actionbar_title_blog_area, BlogViewPagerFragment.class), - - RECORD(19, R.string.actionbar_title_tweetpub, TweetRecordFragment.class), - - SEARCH(20, R.string.actionbar_title_search, SearchViewPageFragment.class), - - EVENT_LIST(21, R.string.actionbar_title_event, EventViewPagerFragment.class), - - EVENT_APPLY(22, R.string.actionbar_title_event_apply, - EventAppliesFragment.class), - - SAME_CITY(23, R.string.actionbar_title_same_city, EventFragment.class), - - NOTE(24, R.string.actionbar_title_note, NoteBookFragment.class), - - NOTE_EDIT(25, R.string.actionbar_title_noteedit, NoteEditFragment.class), - - BROWSER(26, R.string.app_name, BrowserFragment.class), - - DYNAMIC(27, R.string.team_dynamic, TeamActiveFragment.class), - - MY_INFORMATION_DETAIL(28, R.string.actionbar_title_my_information, - MyInformationFragmentDetail.class), - - FEED_BACK(29, R.string.str_feedback_title, FeedBackFragment.class), - - TEAM_USER_INFO(30, R.string.str_team_userinfo, - TeamMemberInformationFragment.class), - - MY_ISSUE_PAGER(31, R.string.str_team_my_issue, MyIssuePagerfragment.class), - - TEAM_PROJECT_MAIN(32, 0, TeamProjectViewPagerFragment.class), - - TEAM_ISSUECATALOG_ISSUE_LIST(33, 0, TeamIssueFragment.class), - - TEAM_ACTIVE(34, R.string.team_actvie, TeamActiveFragment.class), - - TEAM_ISSUE(35, R.string.team_issue, TeamIssueViewPageFragment.class), - - TEAM_DISCUSS(36, R.string.team_discuss, TeamDiscussFragment.class), - - TEAM_DIRAY(37, R.string.team_diary, TeamDiaryFragment.class), - - TEAM_DIRAY_DETAIL(38, R.string.team_diary_detail, TeamDiaryDetailFragment.class), - - TEAM_PROJECT_MEMBER_SELECT(39, 0, TeamProjectMemberSelectFragment.class), - - TEAM_PROJECT(40, R.string.team_project, TeamProjectFragment.class), - - TWEET_LIKE_USER_LIST(41, 0, TweetLikeUsersFragment.class), - - TWEET_TOPIC_LIST(42, 0, TweetsFragment.class); - - private int title; - private Class clz; - private int value; - - private SimpleBackPage(int value, int title, Class clz) { - this.value = value; - this.title = title; - this.clz = clz; - } - - public int getTitle() { - return title; - } - - public void setTitle(int title) { - this.title = title; - } - - public Class getClz() { - return clz; - } - - public void setClz(Class clz) { - this.clz = clz; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - - public static SimpleBackPage getPageByValue(int val) { - for (SimpleBackPage p : values()) { - if (p.getValue() == val) - return p; - } - return null; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SingInResult.java b/app/src/main/java/net/oschina/app/bean/SingInResult.java deleted file mode 100644 index b4396268dde021d4043174c15b0599877d84450e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SingInResult.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.oschina.app.bean; - -import net.oschina.app.AppException; - -import org.json.JSONException; -import org.json.JSONObject; - -/** - * 签到返回结果实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月22日 下午1:43:13 - * - */ -public class SingInResult { - - public final static String NODE_MES = "msg"; - public final static String NODE_ERROR = "error"; - - private String message;// 成功消息 - private String errorMes;// 错误消息 - private boolean ok;// 是否成功 - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getErrorMes() { - return errorMes; - } - - public void setErrorMes(String errorMes) { - this.errorMes = errorMes; - } - - public boolean isOk() { - return ok; - } - - public void setOk(boolean ok) { - this.ok = ok; - } - - public static SingInResult parse(String jsonStr) throws AppException { - SingInResult jsonResult = new SingInResult(); - try { - JSONObject jsonObject = new JSONObject(jsonStr); - // 如果有错误信息则表示不成功 - if (jsonObject.isNull(NODE_ERROR)) { - jsonResult.setOk(true); - } - if (!jsonObject.isNull(NODE_ERROR)) { - jsonResult.setErrorMes(jsonObject.getString(NODE_ERROR)); - } - if (!jsonObject.isNull(NODE_MES)) { - jsonResult.setMessage(jsonObject.getString(NODE_MES)); - } - } catch (JSONException e) { - // 抛出一个json解析错误的异常 - throw AppException.json(e); - } - return jsonResult; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Software.java b/app/src/main/java/net/oschina/app/bean/Software.java deleted file mode 100644 index 3564a489fba6e43917d25b4b4be13b8aea0f79a0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Software.java +++ /dev/null @@ -1,202 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 软件实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月23日 下午3:03:25 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("software") -public class Software extends Entity { - - @XStreamAlias("title") - private String title; - - @XStreamAlias("author") - private String author; - - @XStreamAlias("authorid") - private int authorId; - - @XStreamAlias("recommended") - private int recommended; - - @XStreamAlias("extensiontitle") - private String extensionTitle; - - @XStreamAlias("license") - private String license; - - @XStreamAlias("body") - private String body; - - @XStreamAlias("homepage") - private String homepage; - - @XStreamAlias("document") - private String document; - - @XStreamAlias("download") - private String download; - - @XStreamAlias("logo") - private String logo; - - @XStreamAlias("language") - private String language; - - @XStreamAlias("os") - private String os; - - @XStreamAlias("recordtime") - private String recordtime; - - @XStreamAlias("url") - private String url; - - @XStreamAlias("favorite") - private int favorite; - - @XStreamAlias("tweetCount") - private int tweetCount; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorId() { - return authorId; - } - - public void setAuthorId(int authorId) { - this.authorId = authorId; - } - - public int getRecommended() { - return recommended; - } - - public void setRecommended(int recommended) { - this.recommended = recommended; - } - - public String getExtensionTitle() { - return extensionTitle; - } - - public void setExtensionTitle(String extensionTitle) { - this.extensionTitle = extensionTitle; - } - - public String getLicense() { - return license; - } - - public void setLicense(String license) { - this.license = license; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getHomepage() { - return homepage; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public String getDocument() { - return document; - } - - public void setDocument(String document) { - this.document = document; - } - - public String getDownload() { - return download; - } - - public void setDownload(String download) { - this.download = download; - } - - public String getLogo() { - return logo; - } - - public void setLogo(String logo) { - this.logo = logo; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public String getOs() { - return os; - } - - public void setOs(String os) { - this.os = os; - } - - public String getRecordtime() { - return recordtime; - } - - public void setRecordtime(String recordtime) { - this.recordtime = recordtime; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public int getFavorite() { - return favorite; - } - - public void setFavorite(int favorite) { - this.favorite = favorite; - } - - public int getTweetCount() { - return tweetCount; - } - - public void setTweetCount(int tweetCount) { - this.tweetCount = tweetCount; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SoftwareCatalogList.java b/app/src/main/java/net/oschina/app/bean/SoftwareCatalogList.java deleted file mode 100644 index c14e52a514a43f7e12b26a5bd5931239a556bad0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SoftwareCatalogList.java +++ /dev/null @@ -1,67 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 开源软件分类列表实体 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月2日 上午10:54:10 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class SoftwareCatalogList extends Entity implements ListEntity { - - @XStreamAlias("softwarecount") - private int softwarecount; - @XStreamAlias("softwareTypes") - private List softwarecataloglist = new ArrayList(); - - public int getSoftwarecount() { - return softwarecount; - } - - public void setSoftwarecount(int softwarecount) { - this.softwarecount = softwarecount; - } - - public List getSoftwarecataloglist() { - return softwarecataloglist; - } - - public void setSoftwarecataloglist(List softwarecataloglist) { - this.softwarecataloglist = softwarecataloglist; - } - - @Override - public List getList() { - return softwarecataloglist; - } - - @XStreamAlias("softwareType") - public class SoftwareType extends Entity { - - @XStreamAlias("name") - private String name; - @XStreamAlias("tag") - private int tag; - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public int getTag() { - return tag; - } - public void setTag(int tag) { - this.tag = tag; - } - - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/SoftwareDec.java b/app/src/main/java/net/oschina/app/bean/SoftwareDec.java deleted file mode 100644 index 74db5284a39633901ba3996ecff7238bbfd44a7d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SoftwareDec.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 软件列表 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2015年1月20日 下午3:34:52 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("software") -public class SoftwareDec extends Entity { - @XStreamAlias("name") - private String name; - @XStreamAlias("description") - private String description; - @XStreamAlias("url") - private String url; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SoftwareDetail.java b/app/src/main/java/net/oschina/app/bean/SoftwareDetail.java deleted file mode 100644 index b4d7689a18a78b6f71c6bc7b391b09efa65425b5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SoftwareDetail.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 软件详情实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月23日 下午3:10:54 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class SoftwareDetail extends Entity { - - @XStreamAlias("software") - private Software software; - - public Software getSoftware() { - return software; - } - - public void setSoftware(Software software) { - this.software = software; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/SoftwareList.java b/app/src/main/java/net/oschina/app/bean/SoftwareList.java deleted file mode 100644 index bc5bd6e21e20510986b2ec668315dc154edcdd16..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/SoftwareList.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class SoftwareList extends Entity implements ListEntity { - - public final static String PREF_READED_SOFTWARE_LIST = "readed_software_list.pref"; - - public final static String CATALOG_RECOMMEND = "recommend"; - public final static String CATALOG_TIME = "time"; - public final static String CATALOG_VIEW = "view"; - public final static String CATALOG_LIST_CN = "list_cn"; - - @XStreamAlias("softwarecount") - private int softwarecount; - @XStreamAlias("pagesize") - private int pagesize; - @XStreamAlias("softwares") - private List softwarelist = new ArrayList(); - - public int getSoftwarecount() { - return softwarecount; - } - - public void setSoftwarecount(int softwarecount) { - this.softwarecount = softwarecount; - } - - public int getPagesize() { - return pagesize; - } - - public void setPagesize(int pagesize) { - this.pagesize = pagesize; - } - - public List getSoftwarelist() { - return softwarelist; - } - - public void setSoftwarelist(List softwarelist) { - this.softwarelist = softwarelist; - } - - @Override - public List getList() { - return softwarelist; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/Tweet.java b/app/src/main/java/net/oschina/app/bean/Tweet.java deleted file mode 100644 index 38de54d17f46ea5408247b537d4693e7888a253e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Tweet.java +++ /dev/null @@ -1,355 +0,0 @@ -package net.oschina.app.bean; - -import android.content.Context; -import android.os.Bundle; -import android.os.Parcel; -import android.os.Parcelable; -import android.text.SpannableString; -import android.text.SpannableStringBuilder; -import android.text.TextPaint; -import android.text.method.LinkMovementMethod; -import android.text.style.ClickableSpan; -import android.view.View; -import android.widget.TextView; -import android.widget.TextView.BufferType; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.AppContext; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.util.UIHelper; - -import java.util.ArrayList; -import java.util.List; - -/** - * 动弹实体类 - * - * @author liux (http://my.oschina.net/liux),kymjs(kymjs123@gmail.com) - * @version 1.1 添加语音动弹功能 - * @created 2012-3-21 - * @changed 2014-12-1 - */ -@SuppressWarnings("serial") -@XStreamAlias("tweet") -public class Tweet extends Entity implements Parcelable { - - @XStreamAlias("portrait") - private String portrait; - @XStreamAlias("author") - private String author; - @XStreamAlias("authorid") - private int authorid; - @XStreamAlias("body") - private String body; - @XStreamAlias("appclient") - private int appclient; - @XStreamAlias("commentCount") - private String commentCount; - @XStreamAlias("pubDate") - private String pubDate; - @XStreamAlias("imgSmall") - private String imgSmall; - @XStreamAlias("imgBig") - private String imgBig; - @XStreamAlias("attach") - private String attach; - - @XStreamAlias("likeCount") - private int likeCount; - - @XStreamAlias("isLike") - private int isLike; - - @XStreamAlias("likeList") - private List likeUser = new ArrayList(); - - private String imageFilePath; - private String audioPath; - - public Tweet() { - } - - public Tweet(Parcel dest) { - id = dest.readInt(); - portrait = dest.readString(); - author = dest.readString(); - authorid = dest.readInt(); - body = dest.readString(); - appclient = dest.readInt(); - commentCount = dest.readString(); - pubDate = dest.readString(); - imgSmall = dest.readString(); - imgBig = dest.readString(); - attach = dest.readString(); - imageFilePath = dest.readString(); - audioPath = dest.readString(); - isLike = dest.readInt(); - } - - public String getAttach() { - return attach; - } - - public void setAttach(String attach) { - this.attach = attach; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public int getAuthorid() { - return authorid; - } - - public void setAuthorid(int authorid) { - this.authorid = authorid; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public int getAppclient() { - return appclient; - } - - public void setAppclient(int appclient) { - this.appclient = appclient; - } - - public String getCommentCount() { - return commentCount; - } - - public void setCommentCount(String commentCount) { - this.commentCount = commentCount; - } - - public String getPubDate() { - return pubDate; - } - - public void setPubDate(String pubDate) { - this.pubDate = pubDate; - } - - public String getImgSmall() { - return imgSmall; - } - - public void setImgSmall(String imgSmall) { - this.imgSmall = imgSmall; - } - - public String getImgBig() { - return imgBig; - } - - public void setImgBig(String imgBig) { - this.imgBig = imgBig; - } - - public String getImageFilePath() { - return imageFilePath; - } - - public void setImageFilePath(String imageFilePath) { - this.imageFilePath = imageFilePath; - } - - public String getAudioPath() { - return audioPath; - } - - public void setAudioPath(String audioPath) { - this.audioPath = audioPath; - } - - public List getLikeUser() { - return likeUser; - } - - public void setLikeUser(List likeUser) { - this.likeUser = likeUser; - } - - public int getLikeCount() { - return likeCount; - } - - public void setLikeCount(int likeCount) { - this.likeCount = likeCount; - } - - public int getIsLike() { - return isLike; - } - - public void setIsLike(int isLike) { - this.isLike = isLike; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(id); - dest.writeString(portrait); - dest.writeString(author); - dest.writeInt(authorid); - dest.writeString(body); - dest.writeInt(appclient); - dest.writeString(commentCount); - dest.writeString(pubDate); - dest.writeString(imgSmall); - dest.writeString(imgBig); - dest.writeString(attach); - dest.writeString(imageFilePath); - dest.writeString(audioPath); - dest.writeInt(isLike); - } - - public static final Parcelable.Creator CREATOR = new Creator() { - - @Override - public Tweet[] newArray(int size) { - return new Tweet[size]; - } - - @Override - public Tweet createFromParcel(Parcel source) { - return new Tweet(source); - } - }; - - public void setLikeUsers(Context contet, TextView likeUser, boolean limit) { - // 构造多个超链接的html, 通过选中的位置来获取用户名 - if (getLikeCount() > 0 && getLikeUser() != null - && !getLikeUser().isEmpty()) { - likeUser.setVisibility(View.VISIBLE); - likeUser.setMovementMethod(LinkMovementMethod.getInstance()); - likeUser.setFocusable(false); - likeUser.setLongClickable(false); - likeUser.setText(addClickablePart(contet, limit), BufferType.SPANNABLE); - } else { - likeUser.setVisibility(View.GONE); - likeUser.setText(""); - } - } - - /** - * @return - */ - private SpannableStringBuilder addClickablePart(final Context context, - boolean limit) { - - StringBuilder sbBuilder = new StringBuilder(); - int showCunt = getLikeUser().size(); - if (limit && showCunt > 4) { - showCunt = 4; - } - - // 如果已经点赞,始终让该用户在首位 - if (getIsLike() == 1) { - - for (int i = 0; i < getLikeUser().size(); i++) { - if (getLikeUser().get(i).getId() == AppContext.getInstance() - .getLoginUid()) { - getLikeUser().remove(i); - } - } - getLikeUser().add(0, AppContext.getInstance().getLoginUser()); - } - - for (int i = 0; i < showCunt; i++) { - sbBuilder.append(getLikeUser().get(i).getName()).append("、"); - } - - String likeUsersStr = sbBuilder.substring(0, sbBuilder.lastIndexOf("、")); - - // 第一个赞图标 - // ImageSpan span = new ImageSpan(AppContext.getInstance(), - // R.drawable.ic_unlike_small); - SpannableString spanStr = new SpannableString(""); - // spanStr.setSpan(span, 0, 1, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - - SpannableStringBuilder ssb = new SpannableStringBuilder(spanStr); - ssb.append(likeUsersStr); - - String[] likeUsers = likeUsersStr.split("、"); - - if (likeUsers.length > 0) { - // 最后一个 - for (int i = 0; i < likeUsers.length; i++) { - final String name = likeUsers[i]; - final int start = likeUsersStr.indexOf(name) + spanStr.length(); - final int index = i; - ssb.setSpan(new ClickableSpan() { - @Override - public void onClick(View widget) { - User user = getLikeUser().get(index); - UIHelper.showUserCenter(context, user.getId(), - user.getName()); - } - - @Override - public void updateDrawState(TextPaint ds) { - super.updateDrawState(ds); - // ds.setColor(R.color.link_color); // 设置文本颜色 - // 去掉下划线 - ds.setUnderlineText(false); - } - }, start, start + name.length(), 0); - } - } - if (likeUsers.length < getLikeCount()) { - ssb.append("等"); - int start = ssb.length(); - String more = getLikeCount() + "人"; - ssb.append(more); - ssb.setSpan(new ClickableSpan() { - - @Override - public void onClick(View widget) { - Bundle bundle = new Bundle(); - bundle.putInt(BaseListFragment.BUNDLE_KEY_CATALOG, getId()); - UIHelper.showSimpleBack(context, - SimpleBackPage.TWEET_LIKE_USER_LIST, bundle); - } - - @Override - public void updateDrawState(TextPaint ds) { - super.updateDrawState(ds); - // ds.setColor(R.color.link_color); // 设置文本颜色 - // 去掉下划线 - ds.setUnderlineText(false); - } - - }, start, start + more.length(), 0); - return ssb.append("觉得很赞"); - } else { - return ssb.append("觉得很赞"); - } - } -} diff --git a/app/src/main/java/net/oschina/app/bean/TweetDetail.java b/app/src/main/java/net/oschina/app/bean/TweetDetail.java deleted file mode 100644 index fbb850a4bc5dbfa486da4645f16fbfa1ac27afc4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/TweetDetail.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * @author HuangWenwei - * - * @date 2014年10月16日 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TweetDetail extends Entity { - - @XStreamAlias("tweet") - private Tweet tweet; - - public Tweet getTweet() { - return tweet; - } - public void setTweet(Tweet tweet) { - this.tweet = tweet; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/TweetLike.java b/app/src/main/java/net/oschina/app/bean/TweetLike.java deleted file mode 100644 index 2faf97d670d7374ad145ad36e7a0b37e1a70ba1b..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/TweetLike.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 点赞消息实体类 - * LikeTweet.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-4-10 上午10:09:15 - */ -@SuppressWarnings("serial") -@XStreamAlias("mytweet") -public class TweetLike extends Entity { - - @XStreamAlias("user") - private User user; - - @XStreamAlias("tweet") - private Tweet tweet; - - @XStreamAlias("datatime") - private String datatime; - - @XStreamAlias("appclient") - private int appClient; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Tweet getTweet() { - return tweet; - } - - public void setTweet(Tweet tweet) { - this.tweet = tweet; - } - - public String getDatatime() { - return datatime; - } - - public void setDatatime(String datatime) { - this.datatime = datatime; - } - - public int getAppClient() { - return appClient; - } - - public void setAppClient(int appClient) { - this.appClient = appClient; - } -} - diff --git a/app/src/main/java/net/oschina/app/bean/TweetLikeList.java b/app/src/main/java/net/oschina/app/bean/TweetLikeList.java deleted file mode 100644 index aa22120703357cbf9547feb62aa368730d89ee55..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/TweetLikeList.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.oschina.app.bean; - -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * LikeTweetList.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-4-10 上午10:11:48 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TweetLikeList implements ListEntity { - - @XStreamAlias("likeList") - private List list; - - @Override - public List getList() { - // TODO Auto-generated method stub - return list; - } - - public void setList(List list) { - this.list = list; - } - -} - diff --git a/app/src/main/java/net/oschina/app/bean/TweetLikeUserList.java b/app/src/main/java/net/oschina/app/bean/TweetLikeUserList.java deleted file mode 100644 index df3ee1c359d03d14f828f027f31173bda91ff213..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/TweetLikeUserList.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * TweetLikeUserList.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-3-26 下午4:23:32 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TweetLikeUserList implements ListEntity { - - @XStreamAlias("likeList") - private List list = new ArrayList(); - - public List getList() { - return list; - } - - public void getList(List list) { - this.list = list; - } -} - diff --git a/app/src/main/java/net/oschina/app/bean/TweetsList.java b/app/src/main/java/net/oschina/app/bean/TweetsList.java deleted file mode 100644 index 5e633868cd38a17e4559450c1c90798a773ecb71..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/TweetsList.java +++ /dev/null @@ -1,57 +0,0 @@ -package net.oschina.app.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * @author HuangWenwei - * - * @date 2014年10月10日 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TweetsList extends Entity implements ListEntity { - - public final static int CATALOG_LATEST = 0; - public final static int CATALOG_HOT = -1; - public final static int CATALOG_ME = 1; - - @XStreamAlias("tweetcount") - private int tweetCount; - @XStreamAlias("pagesize") - private int pagesize; - @XStreamAlias("tweets") - private List tweetslist = new ArrayList(); - - public int getTweetCount() { - return tweetCount; - } - - public void setTweetCount(int tweetCount) { - this.tweetCount = tweetCount; - } - - public int getPagesize() { - return pagesize; - } - - public void setPagesize(int pagesize) { - this.pagesize = pagesize; - } - - public List getTweetslist() { - return tweetslist; - } - - public void setTweetslist(List tweetslist) { - this.tweetslist = tweetslist; - } - - @Override - public List getList() { - return tweetslist; - } - -} diff --git a/app/src/main/java/net/oschina/app/bean/Update.java b/app/src/main/java/net/oschina/app/bean/Update.java deleted file mode 100644 index bbc0d8d9fb197a3fb8eeb413decf79e46f323e9e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/Update.java +++ /dev/null @@ -1,146 +0,0 @@ -package net.oschina.app.bean; - -import java.io.Serializable; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 更新实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年11月10日 下午12:56:27 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class Update implements Serializable { - - @XStreamAlias("update") - private UpdateBean update; - - public UpdateBean getUpdate() { - return update; - } - - public void setUpdate(UpdateBean update) { - this.update = update; - } - - @XStreamAlias("update") - public class UpdateBean implements Serializable { - @XStreamAlias("wp7") - private String wp7; - @XStreamAlias("ios") - private String ios; - @XStreamAlias("android") - private AndroidBean android; - - public String getWp7() { - return wp7; - } - - public void setWp7(String wp7) { - this.wp7 = wp7; - } - - public String getIos() { - return ios; - } - - public void setIos(String ios) { - this.ios = ios; - } - - public AndroidBean getAndroid() { - return android; - } - - public void setAndroid(AndroidBean android) { - this.android = android; - } - - } - - @XStreamAlias("android") - public class AndroidBean implements Serializable { - @XStreamAlias("versionCode") - private int versionCode; - @XStreamAlias("versionName") - private String versionName; - @XStreamAlias("downloadUrl") - private String downloadUrl; - @XStreamAlias("updateLog") - private String updateLog; - @XStreamAlias("coverUpdate") - private String coverUpdate; - @XStreamAlias("coverStartDate") - private String coverStartDate; - @XStreamAlias("coverEndDate") - private String coverEndDate; - @XStreamAlias("coverURL") - private String coverURL; - - public int getVersionCode() { - return versionCode; - } - - public void setVersionCode(int versionCode) { - this.versionCode = versionCode; - } - - public String getVersionName() { - return versionName; - } - - public void setVersionName(String versionName) { - this.versionName = versionName; - } - - public String getDownloadUrl() { - return downloadUrl; - } - - public void setDownloadUrl(String downloadUrl) { - this.downloadUrl = downloadUrl; - } - - public String getUpdateLog() { - return updateLog; - } - - public void setUpdateLog(String updateLog) { - this.updateLog = updateLog; - } - - public String getCoverUpdate() { - return coverUpdate; - } - - public void setCoverUpdate(String coverUpdate) { - this.coverUpdate = coverUpdate; - } - - public String getCoverStartDate() { - return coverStartDate; - } - - public void setCoverStartDate(String coverStartDate) { - this.coverStartDate = coverStartDate; - } - - public String getCoverEndDate() { - return coverEndDate; - } - - public void setCoverEndDate(String coverEndDate) { - this.coverEndDate = coverEndDate; - } - - public String getCoverURL() { - return coverURL; - } - - public void setCoverURL(String coverURL) { - this.coverURL = coverURL; - } - } -} diff --git a/app/src/main/java/net/oschina/app/bean/User.java b/app/src/main/java/net/oschina/app/bean/User.java deleted file mode 100644 index 4df29db296301f93791626a75143787722709994..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/User.java +++ /dev/null @@ -1,230 +0,0 @@ -package net.oschina.app.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 登录用户实体类 - * - * @author liux (http://my.oschina.net/liux) - * @version 1.0 - * @created 2012-3-21 - */ -@SuppressWarnings("serial") -@XStreamAlias("user") -public class User extends Entity { - - public final static int RELATION_ACTION_DELETE = 0x00;// 取消关注 - public final static int RELATION_ACTION_ADD = 0x01;// 加关注 - - public final static int RELATION_TYPE_BOTH = 0x01;// 双方互为粉丝 - public final static int RELATION_TYPE_FANS_HIM = 0x02;// 你单方面关注他 - public final static int RELATION_TYPE_NULL = 0x03;// 互不关注 - public final static int RELATION_TYPE_FANS_ME = 0x04;// 只有他关注我 - - @XStreamAlias("uid") - private int id; - - @XStreamAlias("location") - private String location; - - @XStreamAlias("name") - private String name; - - @XStreamAlias("followers") - private int followers; - - @XStreamAlias("fans") - private int fans; - - @XStreamAlias("score") - private int score; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("jointime") - private String jointime; - - @XStreamAlias("gender") - private String gender; - - @XStreamAlias("devplatform") - private String devplatform; - - @XStreamAlias("expertise") - private String expertise; - - @XStreamAlias("relation") - private int relation; - - @XStreamAlias("latestonline") - private String latestonline; - - @XStreamAlias("from") - private String from; - - @XStreamAlias("favoritecount") - private int favoritecount; - - private String account; - - private String pwd; - - private boolean isRememberMe; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getFollowers() { - return followers; - } - - public void setFollowers(int followers) { - this.followers = followers; - } - - public int getFans() { - return fans; - } - - public void setFans(int fans) { - this.fans = fans; - } - - public int getScore() { - return score; - } - - public void setScore(int score) { - this.score = score; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - - public String getJointime() { - return jointime; - } - - public void setJointime(String jointime) { - this.jointime = jointime; - } - - public String getGender() { - return gender; - } - - public void setGender(String gender) { - this.gender = gender; - } - - public String getDevplatform() { - return devplatform; - } - - public void setDevplatform(String devplatform) { - this.devplatform = devplatform; - } - - public String getExpertise() { - return expertise; - } - - public void setExpertise(String expertise) { - this.expertise = expertise; - } - - public int getRelation() { - return relation; - } - - public void setRelation(int relation) { - this.relation = relation; - } - - public String getLatestonline() { - return latestonline; - } - - public void setLatestonline(String latestonline) { - this.latestonline = latestonline; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public int getFavoritecount() { - return favoritecount; - } - - public void setFavoritecount(int favoritecount) { - this.favoritecount = favoritecount; - } - - public String getAccount() { - return account; - } - - public void setAccount(String account) { - this.account = account; - } - - public String getPwd() { - return pwd; - } - - public void setPwd(String pwd) { - this.pwd = pwd; - } - - public boolean isRememberMe() { - return isRememberMe; - } - - public void setRememberMe(boolean isRememberMe) { - this.isRememberMe = isRememberMe; - } - - @Override - public String toString() { - return "User [uid=" + id + ", location=" + location + ", name=" + name - + ", followers=" + followers + ", fans=" + fans + ", score=" - + score + ", portrait=" + portrait + ", jointime=" + jointime - + ", gender=" + gender + ", devplatform=" + devplatform - + ", expertise=" + expertise + ", relation=" + relation - + ", latestonline=" + latestonline + ", from=" + from - + ", favoritecount=" + favoritecount + ", account=" + account - + ", pwd=" + pwd + ", isRememberMe=" + isRememberMe + "]"; - } -} diff --git a/app/src/main/java/net/oschina/app/bean/UserInformation.java b/app/src/main/java/net/oschina/app/bean/UserInformation.java deleted file mode 100644 index a23f53ef95afafa1fc62b3c7250c8ef54a6d34cf..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/bean/UserInformation.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.oschina.app.bean; - -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 个人信息专用实体类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月29日 上午10:53:54 - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class UserInformation extends Base { - - @XStreamAlias("user") - private User user; - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("activies") - private List activeList; - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public List getActiveList() { - return activeList; - } - - public void setActiveList(List activeList) { - this.activeList = activeList; - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/broadcast/AlarmReceiver.java b/app/src/main/java/net/oschina/app/broadcast/AlarmReceiver.java deleted file mode 100644 index edc1a16e79a2220379846c0b830093949f685019..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/broadcast/AlarmReceiver.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.oschina.app.broadcast; - -import net.oschina.app.service.NoticeUtils; -import net.oschina.app.util.TLog; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; - -public class AlarmReceiver extends BroadcastReceiver { - - @Override - public void onReceive(Context context, Intent intent) { - TLog.log("onReceive ->net.oschina.app收到定时获取消息"); - NoticeUtils.requestNotice(context); - } -} diff --git a/app/src/main/java/net/oschina/app/cache/CacheManager.java b/app/src/main/java/net/oschina/app/cache/CacheManager.java deleted file mode 100644 index 1b9ebec7c7b8a147edfe2e1a4f687b67cf327ba2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/cache/CacheManager.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.oschina.app.cache; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InvalidClassException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; - -import net.oschina.app.util.TDevice; -import android.content.Context; - -public class CacheManager { - - // wifi缓存时间为5分钟 - private static long wifi_cache_time = 5 * 60 * 1000; - // 其他网络环境为1小时 - private static long other_cache_time = 60 * 60 * 1000; - - /** - * 保存对象 - * - * @param ser - * @param file - * @throws IOException - */ - public static boolean saveObject(Context context, Serializable ser, - String file) { - FileOutputStream fos = null; - ObjectOutputStream oos = null; - try { - fos = context.openFileOutput(file, Context.MODE_PRIVATE); - oos = new ObjectOutputStream(fos); - oos.writeObject(ser); - oos.flush(); - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } finally { - try { - oos.close(); - } catch (Exception e) { - } - try { - fos.close(); - } catch (Exception e) { - } - } - } - - /** - * 读取对象 - * - * @param file - * @return - * @throws IOException - */ - public static Serializable readObject(Context context, String file) { - if (!isExistDataCache(context, file)) - return null; - FileInputStream fis = null; - ObjectInputStream ois = null; - try { - fis = context.openFileInput(file); - ois = new ObjectInputStream(fis); - return (Serializable) ois.readObject(); - } catch (FileNotFoundException e) { - } catch (Exception e) { - e.printStackTrace(); - // 反序列化失败 - 删除缓存文件 - if (e instanceof InvalidClassException) { - File data = context.getFileStreamPath(file); - data.delete(); - } - } finally { - try { - ois.close(); - } catch (Exception e) { - } - try { - fis.close(); - } catch (Exception e) { - } - } - return null; - } - - /** - * 判断缓存是否存在 - * - * @param cachefile - * @return - */ - public static boolean isExistDataCache(Context context, String cachefile) { - if (context == null) - return false; - boolean exist = false; - File data = context.getFileStreamPath(cachefile); - if (data.exists()) - exist = true; - return exist; - } - - /** - * 判断缓存是否已经失效 - */ - public static boolean isCacheDataFailure(Context context, String cachefile) { - File data = context.getFileStreamPath(cachefile); - if (!data.exists()) { - - return false; - } - long existTime = System.currentTimeMillis() - data.lastModified(); - boolean failure = false; - if (TDevice.getNetworkType() == TDevice.NETTYPE_WIFI) { - failure = existTime > wifi_cache_time ? true : false; - } else { - failure = existTime > other_cache_time ? true : false; - } - return failure; - } -} diff --git a/app/src/main/java/net/oschina/app/cache/DataCleanManager.java b/app/src/main/java/net/oschina/app/cache/DataCleanManager.java deleted file mode 100644 index 4c200a976ee5b1322ce2a63f75dfc7be8a89404c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/cache/DataCleanManager.java +++ /dev/null @@ -1,120 +0,0 @@ -package net.oschina.app.cache; - -import java.io.File; - -import android.content.Context; -import android.os.Environment; - -/** - * 数据删除工具类 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月27日 上午10:18:22 - * - */ -public class DataCleanManager { - - /** - * 清除本应用内部缓存 - * (/data/data/com.xxx.xxx/cache) - * @param context - */ - public static void cleanInternalCache(Context context) { - deleteFilesByDirectory(context.getCacheDir()); - deleteFilesByDirectory(context.getFilesDir()); - } - - /** - * 清楚本应用所有数据库 - * (/data/data/com.xxx.xxx/databases) - * @param context - */ - public static void cleanDatabases(Context context) { - deleteFilesByDirectory(new File("/data/data/" - + context.getPackageName() + "/databases")); - } - - /** - * 清除本应用SharedPreference - * (/data/data/com.xxx.xxx/shared_prefs) - * @param context - */ - public static void cleanSharedPreference(Context context) { - deleteFilesByDirectory(new File("/data/data/" - + context.getPackageName() + "/shared_prefs")); - } - - /** - * 按名字清除本应用数据库 - * @param context - * @param dbName - */ - public static void cleanDatabaseByName(Context context, String dbName) { - context.deleteDatabase(dbName); - } - - /** - * 清除/data/data/com.xxx.xxx/files下的内容 - * @param context - */ - public static void cleanFiles(Context context) { - deleteFilesByDirectory(context.getFilesDir()); - } - - /** - * 清除外部cache下的内容(/mnt/sdcard/android/data/com.xxx.xxx/cache) - * @param context - */ - public static void cleanExternalCache(Context context) { - if (Environment.getExternalStorageState().equals( - Environment.MEDIA_MOUNTED)) { - deleteFilesByDirectory(context.getExternalCacheDir()); - } - } - - /** - * 清除自定义路径下的文件,使用需小心,请不要误删。而且只支持目录下的文件删除 - * @param filePath - */ - public static void cleanCustomCache(String filePath) { - deleteFilesByDirectory(new File(filePath)); - } - - /** - * 清除自定义路径下的文件,使用需小心,请不要误删。而且只支持目录下的文件删除 - * @param filePath - */ - public static void cleanCustomCache(File file) { - deleteFilesByDirectory(file); - } - - /** - * 清除本应用所有的数据 - * @param context - * @param filepath - */ - public static void cleanApplicationData(Context context, String... filepath) { - cleanInternalCache(context); - cleanExternalCache(context); - cleanDatabases(context); - cleanSharedPreference(context); - cleanFiles(context); - for (String filePath : filepath) { - cleanCustomCache(filePath); - } - } - - /** - * 删除方法 这里只会删除某个文件夹下的文件,如果传入的directory是个文件,将不做处理 - * @param directory - */ - private static void deleteFilesByDirectory(File directory) { - if (directory != null && directory.exists() && directory.isDirectory()) { - for (File child : directory.listFiles()) { - if (child.isDirectory()) { - deleteFilesByDirectory(child); - } - child.delete(); - } - } - } -} diff --git a/app/src/main/java/net/oschina/app/cache/DiskLruCache.java b/app/src/main/java/net/oschina/app/cache/DiskLruCache.java deleted file mode 100644 index e36f68359cc90007a4a7e5de0c9abc978f0f925d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/cache/DiskLruCache.java +++ /dev/null @@ -1,953 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.oschina.app.cache; - -import java.io.BufferedInputStream; -import java.io.BufferedWriter; -import java.io.Closeable; -import java.io.EOFException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.StringWriter; -import java.io.Writer; -import java.lang.reflect.Array; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -/** - ****************************************************************************** - * Taken from the JB source code, can be found in: - * libcore/luni/src/main/java/libcore/io/DiskLruCache.java - * or direct link: - * https://android.googlesource.com/platform/libcore/+/android-4.1.1_r1/luni/src/main/java/libcore/io/DiskLruCache.java - ****************************************************************************** - * - * A cache that uses a bounded amount of space on a filesystem. Each cache - * entry has a string key and a fixed number of values. Values are byte - * sequences, accessible as streams or files. Each value must be between {@code - * 0} and {@code Integer.MAX_VALUE} bytes in length. - * - *

The cache stores its data in a directory on the filesystem. This - * directory must be exclusive to the cache; the cache may delete or overwrite - * files from its directory. It is an error for multiple processes to use the - * same cache directory at the same time. - * - *

This cache limits the number of bytes that it will store on the - * filesystem. When the number of stored bytes exceeds the limit, the cache will - * remove entries in the background until the limit is satisfied. The limit is - * not strict: the cache may temporarily exceed it while waiting for files to be - * deleted. The limit does not include filesystem overhead or the cache - * journal so space-sensitive applications should set a conservative limit. - * - *

Clients call {@link #edit} to create or update the values of an entry. An - * entry may have only one editor at one time; if a value is not available to be - * edited then {@link #edit} will return null. - *

    - *
  • When an entry is being created it is necessary to - * supply a full set of values; the empty value should be used as a - * placeholder if necessary. - *
  • When an entry is being edited, it is not necessary - * to supply data for every value; values default to their previous - * value. - *
- * Every {@link #edit} call must be matched by a call to {@link Editor#commit} - * or {@link Editor#abort}. Committing is atomic: a read observes the full set - * of values as they were before or after the commit, but never a mix of values. - * - *

Clients call {@link #get} to read a snapshot of an entry. The read will - * observe the value at the time that {@link #get} was called. Updates and - * removals after the call do not impact ongoing reads. - * - *

This class is tolerant of some I/O errors. If files are missing from the - * filesystem, the corresponding entries will be dropped from the cache. If - * an error occurs while writing a cache value, the edit will fail silently. - * Callers should handle other problems by catching {@code IOException} and - * responding appropriately. - */ -public final class DiskLruCache implements Closeable { - static final String JOURNAL_FILE = "journal"; - static final String JOURNAL_FILE_TMP = "journal.tmp"; - static final String MAGIC = "libcore.io.DiskLruCache"; - static final String VERSION_1 = "1"; - static final long ANY_SEQUENCE_NUMBER = -1; - private static final String CLEAN = "CLEAN"; - private static final String DIRTY = "DIRTY"; - private static final String REMOVE = "REMOVE"; - private static final String READ = "READ"; - - private static final Charset UTF_8 = Charset.forName("UTF-8"); - private static final int IO_BUFFER_SIZE = 8 * 1024; - - /* - * This cache uses a journal file named "journal". A typical journal file - * looks like this: - * libcore.io.DiskLruCache - * 1 - * 100 - * 2 - * - * CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054 - * DIRTY 335c4c6028171cfddfbaae1a9c313c52 - * CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342 - * REMOVE 335c4c6028171cfddfbaae1a9c313c52 - * DIRTY 1ab96a171faeeee38496d8b330771a7a - * CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234 - * READ 335c4c6028171cfddfbaae1a9c313c52 - * READ 3400330d1dfc7f3f7f4b8d4d803dfcf6 - * - * The first five lines of the journal form its header. They are the - * constant string "libcore.io.DiskLruCache", the disk cache's version, - * the application's version, the value count, and a blank line. - * - * Each of the subsequent lines in the file is a record of the state of a - * cache entry. Each line contains space-separated values: a state, a key, - * and optional state-specific values. - * o DIRTY lines track that an entry is actively being created or updated. - * Every successful DIRTY action should be followed by a CLEAN or REMOVE - * action. DIRTY lines without a matching CLEAN or REMOVE indicate that - * temporary files may need to be deleted. - * o CLEAN lines track a cache entry that has been successfully published - * and may be read. A publish line is followed by the lengths of each of - * its values. - * o READ lines track accesses for LRU. - * o REMOVE lines track entries that have been deleted. - * - * The journal file is appended to as cache operations occur. The journal may - * occasionally be compacted by dropping redundant lines. A temporary file named - * "journal.tmp" will be used during compaction; that file should be deleted if - * it exists when the cache is opened. - */ - - private final File directory; - private final File journalFile; - private final File journalFileTmp; - private final int appVersion; - private final long maxSize; - private final int valueCount; - private long size = 0; - private Writer journalWriter; - private final LinkedHashMap lruEntries - = new LinkedHashMap(0, 0.75f, true); - private int redundantOpCount; - - /** - * To differentiate between old and current snapshots, each entry is given - * a sequence number each time an edit is committed. A snapshot is stale if - * its sequence number is not equal to its entry's sequence number. - */ - private long nextSequenceNumber = 0; - - /* From java.util.Arrays */ - @SuppressWarnings("unchecked") - private static T[] copyOfRange(T[] original, int start, int end) { - final int originalLength = original.length; // For exception priority compatibility. - if (start > end) { - throw new IllegalArgumentException(); - } - if (start < 0 || start > originalLength) { - throw new ArrayIndexOutOfBoundsException(); - } - final int resultLength = end - start; - final int copyLength = Math.min(resultLength, originalLength - start); - final T[] result = (T[]) Array - .newInstance(original.getClass().getComponentType(), resultLength); - System.arraycopy(original, start, result, 0, copyLength); - return result; - } - - /** - * Returns the remainder of 'reader' as a string, closing it when done. - */ - public static String readFully(Reader reader) throws IOException { - try { - StringWriter writer = new StringWriter(); - char[] buffer = new char[1024]; - int count; - while ((count = reader.read(buffer)) != -1) { - writer.write(buffer, 0, count); - } - return writer.toString(); - } finally { - reader.close(); - } - } - - /** - * Returns the ASCII characters up to but not including the next "\r\n", or - * "\n". - * - * @throws java.io.EOFException if the stream is exhausted before the next newline - * character. - */ - public static String readAsciiLine(InputStream in) throws IOException { - // TODO: support UTF-8 here instead - - StringBuilder result = new StringBuilder(80); - while (true) { - int c = in.read(); - if (c == -1) { - throw new EOFException(); - } else if (c == '\n') { - break; - } - - result.append((char) c); - } - int length = result.length(); - if (length > 0 && result.charAt(length - 1) == '\r') { - result.setLength(length - 1); - } - return result.toString(); - } - - /** - * Closes 'closeable', ignoring any checked exceptions. Does nothing if 'closeable' is null. - */ - public static void closeQuietly(Closeable closeable) { - if (closeable != null) { - try { - closeable.close(); - } catch (RuntimeException rethrown) { - throw rethrown; - } catch (Exception ignored) { - } - } - } - - /** - * Recursively delete everything in {@code dir}. - */ - // TODO: this should specify paths as Strings rather than as Files - public static void deleteContents(File dir) throws IOException { - File[] files = dir.listFiles(); - if (files == null) { - throw new IllegalArgumentException("not a directory: " + dir); - } - for (File file : files) { - if (file.isDirectory()) { - deleteContents(file); - } - if (!file.delete()) { - throw new IOException("failed to delete file: " + file); - } - } - } - - /** This cache uses a single background thread to evict entries. */ - private final ExecutorService executorService = new ThreadPoolExecutor(0, 1, - 60L, TimeUnit.SECONDS, new LinkedBlockingQueue()); - private final Callable cleanupCallable = new Callable() { - @Override public Void call() throws Exception { - synchronized (DiskLruCache.this) { - if (journalWriter == null) { - return null; // closed - } - trimToSize(); - if (journalRebuildRequired()) { - rebuildJournal(); - redundantOpCount = 0; - } - } - return null; - } - }; - - private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize) { - this.directory = directory; - this.appVersion = appVersion; - this.journalFile = new File(directory, JOURNAL_FILE); - this.journalFileTmp = new File(directory, JOURNAL_FILE_TMP); - this.valueCount = valueCount; - this.maxSize = maxSize; - } - - /** - * Opens the cache in {@code directory}, creating a cache if none exists - * there. - * - * @param directory a writable directory - * @param appVersion - * @param valueCount the number of values per cache entry. Must be positive. - * @param maxSize the maximum number of bytes this cache should use to store - * @throws java.io.IOException if reading or writing the cache directory fails - */ - public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize) - throws IOException { - if (maxSize <= 0) { - throw new IllegalArgumentException("maxSize <= 0"); - } - if (valueCount <= 0) { - throw new IllegalArgumentException("valueCount <= 0"); - } - - // prefer to pick up where we left off - DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); - if (cache.journalFile.exists()) { - try { - cache.readJournal(); - cache.processJournal(); - cache.journalWriter = new BufferedWriter(new FileWriter(cache.journalFile, true), - IO_BUFFER_SIZE); - return cache; - } catch (IOException journalIsCorrupt) { -// System.logW("DiskLruCache " + directory + " is corrupt: " -// + journalIsCorrupt.getMessage() + ", removing"); - cache.delete(); - } - } - - // create a new empty cache - directory.mkdirs(); - cache = new DiskLruCache(directory, appVersion, valueCount, maxSize); - cache.rebuildJournal(); - return cache; - } - - private void readJournal() throws IOException { - InputStream in = new BufferedInputStream(new FileInputStream(journalFile), IO_BUFFER_SIZE); - try { - String magic = readAsciiLine(in); - String version = readAsciiLine(in); - String appVersionString = readAsciiLine(in); - String valueCountString = readAsciiLine(in); - String blank = readAsciiLine(in); - if (!MAGIC.equals(magic) - || !VERSION_1.equals(version) - || !Integer.toString(appVersion).equals(appVersionString) - || !Integer.toString(valueCount).equals(valueCountString) - || !"".equals(blank)) { - throw new IOException("unexpected journal header: [" - + magic + ", " + version + ", " + valueCountString + ", " + blank + "]"); - } - - while (true) { - try { - readJournalLine(readAsciiLine(in)); - } catch (EOFException endOfJournal) { - break; - } - } - } finally { - closeQuietly(in); - } - } - - private void readJournalLine(String line) throws IOException { - String[] parts = line.split(" "); - if (parts.length < 2) { - throw new IOException("unexpected journal line: " + line); - } - - String key = parts[1]; - if (parts[0].equals(REMOVE) && parts.length == 2) { - lruEntries.remove(key); - return; - } - - Entry entry = lruEntries.get(key); - if (entry == null) { - entry = new Entry(key); - lruEntries.put(key, entry); - } - - if (parts[0].equals(CLEAN) && parts.length == 2 + valueCount) { - entry.readable = true; - entry.currentEditor = null; - entry.setLengths(copyOfRange(parts, 2, parts.length)); - } else if (parts[0].equals(DIRTY) && parts.length == 2) { - entry.currentEditor = new Editor(entry); - } else if (parts[0].equals(READ) && parts.length == 2) { - // this work was already done by calling lruEntries.get() - } else { - throw new IOException("unexpected journal line: " + line); - } - } - - /** - * Computes the initial size and collects garbage as a part of opening the - * cache. Dirty entries are assumed to be inconsistent and will be deleted. - */ - private void processJournal() throws IOException { - deleteIfExists(journalFileTmp); - for (Iterator i = lruEntries.values().iterator(); i.hasNext(); ) { - Entry entry = i.next(); - if (entry.currentEditor == null) { - for (int t = 0; t < valueCount; t++) { - size += entry.lengths[t]; - } - } else { - entry.currentEditor = null; - for (int t = 0; t < valueCount; t++) { - deleteIfExists(entry.getCleanFile(t)); - deleteIfExists(entry.getDirtyFile(t)); - } - i.remove(); - } - } - } - - /** - * Creates a new journal that omits redundant information. This replaces the - * current journal if it exists. - */ - private synchronized void rebuildJournal() throws IOException { - if (journalWriter != null) { - journalWriter.close(); - } - - Writer writer = new BufferedWriter(new FileWriter(journalFileTmp), IO_BUFFER_SIZE); - writer.write(MAGIC); - writer.write("\n"); - writer.write(VERSION_1); - writer.write("\n"); - writer.write(Integer.toString(appVersion)); - writer.write("\n"); - writer.write(Integer.toString(valueCount)); - writer.write("\n"); - writer.write("\n"); - - for (Entry entry : lruEntries.values()) { - if (entry.currentEditor != null) { - writer.write(DIRTY + ' ' + entry.key + '\n'); - } else { - writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n'); - } - } - - writer.close(); - journalFileTmp.renameTo(journalFile); - journalWriter = new BufferedWriter(new FileWriter(journalFile, true), IO_BUFFER_SIZE); - } - - private static void deleteIfExists(File file) throws IOException { -// try { -// Libcore.os.remove(file.getPath()); -// } catch (ErrnoException errnoException) { -// if (errnoException.errno != OsConstants.ENOENT) { -// throw errnoException.rethrowAsIOException(); -// } -// } - if (file.exists() && !file.delete()) { - throw new IOException(); - } - } - - /** - * Returns a snapshot of the entry named {@code key}, or null if it doesn't - * exist is not currently readable. If a value is returned, it is moved to - * the head of the LRU queue. - */ - public synchronized Snapshot get(String key) throws IOException { - checkNotClosed(); - validateKey(key); - Entry entry = lruEntries.get(key); - if (entry == null) { - return null; - } - - if (!entry.readable) { - return null; - } - - /* - * Open all streams eagerly to guarantee that we see a single published - * snapshot. If we opened streams lazily then the streams could come - * from different edits. - */ - InputStream[] ins = new InputStream[valueCount]; - try { - for (int i = 0; i < valueCount; i++) { - ins[i] = new FileInputStream(entry.getCleanFile(i)); - } - } catch (FileNotFoundException e) { - // a file must have been deleted manually! - return null; - } - - redundantOpCount++; - journalWriter.append(READ + ' ' + key + '\n'); - if (journalRebuildRequired()) { - executorService.submit(cleanupCallable); - } - - return new Snapshot(key, entry.sequenceNumber, ins); - } - - /** - * Returns an editor for the entry named {@code key}, or null if another - * edit is in progress. - */ - public Editor edit(String key) throws IOException { - return edit(key, ANY_SEQUENCE_NUMBER); - } - - private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException { - checkNotClosed(); - validateKey(key); - Entry entry = lruEntries.get(key); - if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER - && (entry == null || entry.sequenceNumber != expectedSequenceNumber)) { - return null; // snapshot is stale - } - if (entry == null) { - entry = new Entry(key); - lruEntries.put(key, entry); - } else if (entry.currentEditor != null) { - return null; // another edit is in progress - } - - Editor editor = new Editor(entry); - entry.currentEditor = editor; - - // flush the journal before creating files to prevent file leaks - journalWriter.write(DIRTY + ' ' + key + '\n'); - journalWriter.flush(); - return editor; - } - - /** - * Returns the directory where this cache stores its data. - */ - public File getDirectory() { - return directory; - } - - /** - * Returns the maximum number of bytes that this cache should use to store - * its data. - */ - public long maxSize() { - return maxSize; - } - - /** - * Returns the number of bytes currently being used to store the values in - * this cache. This may be greater than the max size if a background - * deletion is pending. - */ - public synchronized long size() { - return size; - } - - private synchronized void completeEdit(Editor editor, boolean success) throws IOException { - Entry entry = editor.entry; - if (entry.currentEditor != editor) { - throw new IllegalStateException(); - } - - // if this edit is creating the entry for the first time, every index must have a value - if (success && !entry.readable) { - for (int i = 0; i < valueCount; i++) { - if (!entry.getDirtyFile(i).exists()) { - editor.abort(); - throw new IllegalStateException("edit didn't create file " + i); - } - } - } - - for (int i = 0; i < valueCount; i++) { - File dirty = entry.getDirtyFile(i); - if (success) { - if (dirty.exists()) { - File clean = entry.getCleanFile(i); - dirty.renameTo(clean); - long oldLength = entry.lengths[i]; - long newLength = clean.length(); - entry.lengths[i] = newLength; - size = size - oldLength + newLength; - } - } else { - deleteIfExists(dirty); - } - } - - redundantOpCount++; - entry.currentEditor = null; - if (entry.readable | success) { - entry.readable = true; - journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n'); - if (success) { - entry.sequenceNumber = nextSequenceNumber++; - } - } else { - lruEntries.remove(entry.key); - journalWriter.write(REMOVE + ' ' + entry.key + '\n'); - } - - if (size > maxSize || journalRebuildRequired()) { - executorService.submit(cleanupCallable); - } - } - - /** - * We only rebuild the journal when it will halve the size of the journal - * and eliminate at least 2000 ops. - */ - private boolean journalRebuildRequired() { - final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000; - return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD - && redundantOpCount >= lruEntries.size(); - } - - /** - * Drops the entry for {@code key} if it exists and can be removed. Entries - * actively being edited cannot be removed. - * - * @return true if an entry was removed. - */ - public synchronized boolean remove(String key) throws IOException { - checkNotClosed(); - validateKey(key); - Entry entry = lruEntries.get(key); - if (entry == null || entry.currentEditor != null) { - return false; - } - - for (int i = 0; i < valueCount; i++) { - File file = entry.getCleanFile(i); - if (!file.delete()) { - throw new IOException("failed to delete " + file); - } - size -= entry.lengths[i]; - entry.lengths[i] = 0; - } - - redundantOpCount++; - journalWriter.append(REMOVE + ' ' + key + '\n'); - lruEntries.remove(key); - - if (journalRebuildRequired()) { - executorService.submit(cleanupCallable); - } - - return true; - } - - /** - * Returns true if this cache has been closed. - */ - public boolean isClosed() { - return journalWriter == null; - } - - private void checkNotClosed() { - if (journalWriter == null) { - throw new IllegalStateException("cache is closed"); - } - } - - /** - * Force buffered operations to the filesystem. - */ - public synchronized void flush() throws IOException { - checkNotClosed(); - trimToSize(); - journalWriter.flush(); - } - - /** - * Closes this cache. Stored values will remain on the filesystem. - */ - public synchronized void close() throws IOException { - if (journalWriter == null) { - return; // already closed - } - for (Entry entry : new ArrayList(lruEntries.values())) { - if (entry.currentEditor != null) { - entry.currentEditor.abort(); - } - } - trimToSize(); - journalWriter.close(); - journalWriter = null; - } - - private void trimToSize() throws IOException { - while (size > maxSize) { -// Map.Entry toEvict = lruEntries.eldest(); - final Map.Entry toEvict = lruEntries.entrySet().iterator().next(); - remove(toEvict.getKey()); - } - } - - /** - * Closes the cache and deletes all of its stored values. This will delete - * all files in the cache directory including files that weren't created by - * the cache. - */ - public void delete() throws IOException { - close(); - deleteContents(directory); - } - - private void validateKey(String key) { - if (key.contains(" ") || key.contains("\n") || key.contains("\r")) { - throw new IllegalArgumentException( - "keys must not contain spaces or newlines: \"" + key + "\""); - } - } - - private static String inputStreamToString(InputStream in) throws IOException { - return readFully(new InputStreamReader(in, UTF_8)); - } - - /** - * A snapshot of the values for an entry. - */ - public final class Snapshot implements Closeable { - private final String key; - private final long sequenceNumber; - private final InputStream[] ins; - - private Snapshot(String key, long sequenceNumber, InputStream[] ins) { - this.key = key; - this.sequenceNumber = sequenceNumber; - this.ins = ins; - } - - /** - * Returns an editor for this snapshot's entry, or null if either the - * entry has changed since this snapshot was created or if another edit - * is in progress. - */ - public Editor edit() throws IOException { - return DiskLruCache.this.edit(key, sequenceNumber); - } - - /** - * Returns the unbuffered stream with the value for {@code index}. - */ - public InputStream getInputStream(int index) { - return ins[index]; - } - - /** - * Returns the string value for {@code index}. - */ - public String getString(int index) throws IOException { - return inputStreamToString(getInputStream(index)); - } - - @Override public void close() { - for (InputStream in : ins) { - closeQuietly(in); - } - } - } - - /** - * Edits the values for an entry. - */ - public final class Editor { - private final Entry entry; - private boolean hasErrors; - - private Editor(Entry entry) { - this.entry = entry; - } - - /** - * Returns an unbuffered input stream to read the last committed value, - * or null if no value has been committed. - */ - public InputStream newInputStream(int index) throws IOException { - synchronized (DiskLruCache.this) { - if (entry.currentEditor != this) { - throw new IllegalStateException(); - } - if (!entry.readable) { - return null; - } - return new FileInputStream(entry.getCleanFile(index)); - } - } - - /** - * Returns the last committed value as a string, or null if no value - * has been committed. - */ - public String getString(int index) throws IOException { - InputStream in = newInputStream(index); - return in != null ? inputStreamToString(in) : null; - } - - /** - * Returns a new unbuffered output stream to write the value at - * {@code index}. If the underlying output stream encounters errors - * when writing to the filesystem, this edit will be aborted when - * {@link #commit} is called. The returned output stream does not throw - * IOExceptions. - */ - public OutputStream newOutputStream(int index) throws IOException { - synchronized (DiskLruCache.this) { - if (entry.currentEditor != this) { - throw new IllegalStateException(); - } - return new FaultHidingOutputStream(new FileOutputStream(entry.getDirtyFile(index))); - } - } - - /** - * Sets the value at {@code index} to {@code value}. - */ - public void set(int index, String value) throws IOException { - Writer writer = null; - try { - writer = new OutputStreamWriter(newOutputStream(index), UTF_8); - writer.write(value); - } finally { - closeQuietly(writer); - } - } - - /** - * Commits this edit so it is visible to readers. This releases the - * edit lock so another edit may be started on the same key. - */ - public void commit() throws IOException { - if (hasErrors) { - completeEdit(this, false); - remove(entry.key); // the previous entry is stale - } else { - completeEdit(this, true); - } - } - - /** - * Aborts this edit. This releases the edit lock so another edit may be - * started on the same key. - */ - public void abort() throws IOException { - completeEdit(this, false); - } - - private class FaultHidingOutputStream extends FilterOutputStream { - private FaultHidingOutputStream(OutputStream out) { - super(out); - } - - @Override public void write(int oneByte) { - try { - out.write(oneByte); - } catch (IOException e) { - hasErrors = true; - } - } - - @Override public void write(byte[] buffer, int offset, int length) { - try { - out.write(buffer, offset, length); - } catch (IOException e) { - hasErrors = true; - } - } - - @Override public void close() { - try { - out.close(); - } catch (IOException e) { - hasErrors = true; - } - } - - @Override public void flush() { - try { - out.flush(); - } catch (IOException e) { - hasErrors = true; - } - } - } - } - - private final class Entry { - private final String key; - - /** Lengths of this entry's files. */ - private final long[] lengths; - - /** True if this entry has ever been published */ - private boolean readable; - - /** The ongoing edit or null if this entry is not being edited. */ - private Editor currentEditor; - - /** The sequence number of the most recently committed edit to this entry. */ - private long sequenceNumber; - - private Entry(String key) { - this.key = key; - this.lengths = new long[valueCount]; - } - - public String getLengths() throws IOException { - StringBuilder result = new StringBuilder(); - for (long size : lengths) { - result.append(' ').append(size); - } - return result.toString(); - } - - /** - * Set lengths using decimal numbers like "10123". - */ - private void setLengths(String[] strings) throws IOException { - if (strings.length != valueCount) { - throw invalidLengths(strings); - } - - try { - for (int i = 0; i < strings.length; i++) { - lengths[i] = Long.parseLong(strings[i]); - } - } catch (NumberFormatException e) { - throw invalidLengths(strings); - } - } - - private IOException invalidLengths(String[] strings) throws IOException { - throw new IOException("unexpected journal line: " + Arrays.toString(strings)); - } - - public File getCleanFile(int i) { - return new File(directory, key + "." + i); - } - - public File getDirtyFile(int i) { - return new File(directory, key + "." + i + ".tmp"); - } - } -} diff --git a/app/src/main/java/net/oschina/app/cache/DiskLruCacheUtil.java b/app/src/main/java/net/oschina/app/cache/DiskLruCacheUtil.java deleted file mode 100644 index a02acff76303b5919dc1ced54f46fdf4763107ec..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/cache/DiskLruCacheUtil.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.oschina.app.cache; - -import java.io.File; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import net.oschina.app.util.TDevice; - -import org.kymjs.kjframe.utils.FileUtils; - -import android.content.Context; -import android.os.Environment; - -/** - * 缓存工具类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年12月26日 下午4:53:13 - * - */ - -public class DiskLruCacheUtil { - - private static int appVersion = TDevice.getVersionCode(); - - private static int valueCount = 1;// 同一个key可以对应多少个缓存文件 - - private static int maxSize = 10 * 1024 * 1024;// 一个缓存文件最大可以缓存10M - - public static final String CACHE_OBJECT = "object";// 对象缓存目录 - - /** - * 保存对象缓存 - * - * @param context - * @param ser - * @param key - */ - public static void saveObject(Context context, Serializable ser, String key) { - ObjectOutputStream oos = null; - try { - DiskLruCache.Editor editor = getDiskLruCacheOutputStream(context, - CACHE_OBJECT, key); - if (editor != null) { - oos = new ObjectOutputStream(editor.newOutputStream(0)); - oos.writeObject(ser); - oos.flush(); - editor.commit(); - } - } catch (IOException e) { - - e.printStackTrace(); - } finally { - FileUtils.closeIO(oos); - } - } - - /** - * 读取对象缓存 - * - * @param context - * @param key - * @return - */ - public static Serializable readObject(Context context, String key) { - ObjectInputStream ois = null; - try { - DiskLruCache.Editor editor = getDiskLruCacheOutputStream(context, - CACHE_OBJECT, key); - ois = new ObjectInputStream(editor.newInputStream(0)); - return (Serializable) ois.readObject(); - } catch (IOException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } finally { - FileUtils.closeIO(ois); - } - return null; - } - - /** - * 获取DiskLruCache的editor - * - * @param context - * @param key - * @return - * @throws IOException - */ - public static DiskLruCache.Editor getDiskLruCacheOutputStream( - Context context, String uniqueName, String key) throws IOException { - DiskLruCache mDiskLruCache = DiskLruCache.open( - getDiskCacheDir(context, uniqueName), appVersion, valueCount, - maxSize); - DiskLruCache.Editor editor = mDiskLruCache.edit(hashKeyForDisk(key)); - return editor; - } - - /** - * 获取相应的缓存目录 - * - * @param context - * @param uniqueName - * @return - */ - public static File getDiskCacheDir(Context context, String uniqueName) { - String cachePath; - if (Environment.MEDIA_MOUNTED.equals(Environment - .getExternalStorageState()) - || !Environment.isExternalStorageRemovable()) { - cachePath = context.getExternalCacheDir().getPath(); - } else { - cachePath = context.getCacheDir().getPath(); - } - return new File(cachePath + File.separator + uniqueName); - } - - /** - * 传入缓存的key值,以得到相应的MD5值 - * - * @param key - * @return - */ - public static String hashKeyForDisk(String key) { - String cacheKey; - try { - final MessageDigest mDigest = MessageDigest.getInstance("MD5"); - mDigest.update(key.getBytes()); - cacheKey = bytesToHexString(mDigest.digest()); - } catch (NoSuchAlgorithmException e) { - cacheKey = String.valueOf(key.hashCode()); - } - return cacheKey; - } - - private static String bytesToHexString(byte[] bytes) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - String hex = Integer.toHexString(0xFF & bytes[i]); - if (hex.length() == 1) { - sb.append('0'); - } - sb.append(hex); - } - return sb.toString(); - } -} diff --git a/app/src/main/java/net/oschina/app/db/DatabaseHelper.java b/app/src/main/java/net/oschina/app/db/DatabaseHelper.java deleted file mode 100644 index 469cb0340926c3b4f8f9afe6084de936f81923e7..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/db/DatabaseHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -package net.oschina.app.db; - -import android.content.Context; -import android.database.sqlite.SQLiteDatabase; -import android.database.sqlite.SQLiteOpenHelper; - -/** - * 创建便签的数据库 - * - * @author kymjs - * - * update:2014-01-12 updateor: fireant 内容:修改为全应用数据库 - * - */ -public class DatabaseHelper extends SQLiteOpenHelper { - - public static final String OSC_DATABASE_NAME = "oschina"; - - public static final String NOTE_TABLE_NAME = "osc_Notebook"; - - public static final String CREATE_NOTE_TABLE = "create table " - + NOTE_TABLE_NAME - + " (_id integer primary key autoincrement, iid integer," - + " time varchar(10), date varchar(10), content text, color integer)"; - - public static final String NEWS_LIST = "osc_news_list"; - - public static final String CREATE_NEWS_LIST_TABLE = "create table " - + NOTE_TABLE_NAME + "(" + "_id integer primary key autoincrement, " - + "news_id interger, title varchar(10), " + ")"; - - public DatabaseHelper(Context context) { - super(context, OSC_DATABASE_NAME, null, 1); - } - - @Override - public void onCreate(SQLiteDatabase db) { - db.execSQL(CREATE_NOTE_TABLE); - // db.execSQL(CREATE_NEWS_LIST_TABLE); - } - - @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {} - -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/db/NoteDatabase.java b/app/src/main/java/net/oschina/app/db/NoteDatabase.java deleted file mode 100644 index d7f957283efa96e3a8681beb6ddbe42e752fb216..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/db/NoteDatabase.java +++ /dev/null @@ -1,161 +0,0 @@ -package net.oschina.app.db; - -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.bean.NotebookData; -import android.content.Context; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; - -public class NoteDatabase { - private final DatabaseHelper dbHelper; - - public NoteDatabase(Context context) { - super(); - dbHelper = new DatabaseHelper(context); - } - - /** - * 增 - * - * @param data - */ - public void insert(NotebookData data) { - String sql = "insert into " + DatabaseHelper.NOTE_TABLE_NAME; - - sql += "(_id, iid, time, date, content, color) values(?, ?, ?, ?, ?, ?)"; - - SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); - sqlite.execSQL(sql, new String[] { data.getId() + "", - data.getIid() + "", data.getUnixTime() + "", data.getDate(), - data.getContent(), data.getColor() + "" }); - sqlite.close(); - } - - /** - * 删 - * - * @param id - */ - public void delete(int id) { - SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); - String sql = ("delete from " + DatabaseHelper.NOTE_TABLE_NAME + " where _id=?"); - sqlite.execSQL(sql, new Integer[] { id }); - sqlite.close(); - } - - /** - * 改 - * - * @param data - */ - public void update(NotebookData data) { - SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); - String sql = ("update " + DatabaseHelper.NOTE_TABLE_NAME + " set iid=?, time=?, date=?, content=?, color=? where _id=?"); - sqlite.execSQL(sql, - new String[] { data.getIid() + "", data.getUnixTime() + "", - data.getDate(), data.getContent(), - data.getColor() + "", data.getId() + "" }); - sqlite.close(); - } - - public List query() { - return query(" "); - } - - /** - * 查 - * - * @param where - * @return - */ - public List query(String where) { - SQLiteDatabase sqlite = dbHelper.getReadableDatabase(); - ArrayList data = null; - data = new ArrayList(); - Cursor cursor = sqlite.rawQuery("select * from " - + DatabaseHelper.NOTE_TABLE_NAME + where, null); - for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { - NotebookData notebookData = new NotebookData(); - notebookData.setId(cursor.getInt(0)); - notebookData.setIid(cursor.getInt(1)); - notebookData.setUnixTime(cursor.getString(2)); - notebookData.setDate(cursor.getString(3)); - notebookData.setContent(cursor.getString(4)); - notebookData.setColor(cursor.getInt(5)); - data.add(notebookData); - } - if (!cursor.isClosed()) { - cursor.close(); - } - sqlite.close(); - - return data; - } - - /** - * 重置 - * - * @param datas - */ - public void reset(List datas) { - if (datas != null) { - SQLiteDatabase sqlite = dbHelper.getWritableDatabase(); - // 删除全部 - sqlite.execSQL("delete from " + DatabaseHelper.NOTE_TABLE_NAME); - // 重新添加 - for (NotebookData data : datas) { - insert(data); - } - sqlite.close(); - } - } - - /** - * 保存一条数据到本地(若已存在则直接覆盖) - * - * @param data - */ - public void save(NotebookData data) { - List datas = query(" where _id=" + data.getId()); - if (datas != null && !datas.isEmpty()) { - update(data); - } else { - insert(data); - } - } - - // - // /** - // * 合并一条数据到本地(通过更新时间判断仅保留最新) - // * - // * @param data - // * @return 数据是否被合并了 - // */ - // public boolean merge(NotebookData data) { - // Cursor cursor = sqlite.rawQuery( - // "select * from " + DatabaseHelper.NOTE_TABLE_NAME - // + " where _id=" + data.getId(), null); - // NotebookData localData = new NotebookData(); - // // 本循环其实只执行一次 - // for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { - // localData.setId(cursor.getInt(0)); - // localData.setIid(cursor.getInt(1)); - // localData.setUnixTime(cursor.getString(2)); - // localData.setDate(cursor.getString(3)); - // localData.setContent(cursor.getString(4)); - // localData.setColor(cursor.getInt(5)); - // } - // // 是否需要合这条数据 - // boolean isMerge = localData.getUnixTime() < data.getUnixTime(); - // if (isMerge) { - // save(data); - // } - // return isMerge; - // } - - public void destroy() { - dbHelper.close(); - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/emoji/DisplayRules.java b/app/src/main/java/net/oschina/app/emoji/DisplayRules.java deleted file mode 100644 index 90440197b613407cba0184d9483507c2febdd5f1..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/DisplayRules.java +++ /dev/null @@ -1,907 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.oschina.app.R; - -/** - * Emoji在手机上的显示规则 - * - * @author kymjs (http://www.kymjs.com) - */ -public enum DisplayRules { - // 注意:value不能从0开始,因为0会被库自动设置为删除按钮 - // int type, int value, int resId, String cls - KJEMOJI0(0, 1, R.drawable.smiley_0, "[微笑]", "[0]"), KJEMOJI1(0, 1, - R.drawable.smiley_1, "[撇嘴]", "[1]"), KJEMOJI2(0, 1, - R.drawable.smiley_2, "[色]", "[2]"), KJEMOJI3(0, 1, - R.drawable.smiley_3, "[发呆]", "[3]"), KJEMOJI4(0, 1, - R.drawable.smiley_4, "[得意]", "[4]"), KJEMOJI5(0, 1, - R.drawable.smiley_5, "[流泪]", "[5]"), KJEMOJI6(0, 1, - R.drawable.smiley_6, "[害羞]", "[6]"), KJEMOJI7(0, 1, - R.drawable.smiley_7, "[闭嘴]", "[7]"), KJEMOJI8(0, 1, - R.drawable.smiley_8, "[睡]", "[8]"), KJEMOJI9(0, 1, - R.drawable.smiley_9, "[大哭]", "[9]"), KJEMOJI10(0, 1, - R.drawable.smiley_10, "[尴尬]", "[10]"), KJEMOJI11(0, 1, - R.drawable.smiley_11, "[发怒]", "[11]"), KJEMOJI12(0, 1, - R.drawable.smiley_12, "调皮", "[12]"), KJEMOJI13(0, 1, - R.drawable.smiley_13, "[呲牙]", "[13]"), KJEMOJI14(0, 1, - R.drawable.smiley_14, "[惊讶]", "[14]"), KJEMOJI15(0, 1, - R.drawable.smiley_15, "[难过]", "[15]"), KJEMOJI16(0, 1, - R.drawable.smiley_16, "[酷]", "[16]"), KJEMOJI17(0, 1, - R.drawable.smiley_17, "[冷汗]", "[17]"), KJEMOJI18(0, 1, - R.drawable.smiley_18, "[抓狂]", "[18]"), KJEMOJI19(0, 1, - R.drawable.smiley_19, "[吐]", "[19]"), KJEMOJI20(0, 1, - R.drawable.smiley_20, "[偷笑]", "[20]"), KJEMOJI21(0, 1, - R.drawable.smiley_21, "[可爱]", "[21]"), KJEMOJI22(0, 1, - R.drawable.smiley_22, "[白眼]", "[22]"), KJEMOJI23(0, 1, - R.drawable.smiley_23, "[傲慢]", "[23]"), KJEMOJI24(0, 1, - R.drawable.smiley_24, "[饥饿]", "[24]"), KJEMOJI25(0, 1, - R.drawable.smiley_25, "[困]", "[25]"), KJEMOJI26(0, 1, - R.drawable.smiley_26, "[惊恐]", "[26]"), KJEMOJI27(0, 1, - R.drawable.smiley_27, "[流汗]", "[27]"), KJEMOJI28(0, 1, - R.drawable.smiley_28, "[憨笑]", "[28]"), KJEMOJI29(0, 1, - R.drawable.smiley_29, "[大兵]", "[29]"), KJEMOJI30(0, 1, - R.drawable.smiley_30, "[奋斗]", "[30]"), KJEMOJI31(0, 1, - R.drawable.smiley_31, "[咒骂]", "[31]"), KJEMOJI32(0, 1, - R.drawable.smiley_32, "[疑问]", "[32]"), KJEMOJI33(0, 1, - R.drawable.smiley_33, "[嘘]", "[33]"), KJEMOJI34(0, 1, - R.drawable.smiley_34, "[晕]", "[34]"), KJEMOJI35(0, 1, - R.drawable.smiley_35, "折磨", "[35]"), KJEMOJI36(0, 1, - R.drawable.smiley_36, "衰", "[36]"), KJEMOJI37(0, 1, - R.drawable.smiley_37, "骷髅", "[37]"), KJEMOJI38(0, 1, - R.drawable.smiley_38, "敲打", "[38]"), KJEMOJI39(0, 1, - R.drawable.smiley_39, "再见", "[39]"), KJEMOJI40(0, 1, - R.drawable.smiley_40, "擦汗", "[40]"), KJEMOJI41(0, 1, - R.drawable.smiley_41, "抠鼻", "[41]"), KJEMOJI42(0, 1, - R.drawable.smiley_42, "鼓掌", "[42]"), KJEMOJI43(0, 1, - R.drawable.smiley_43, "糗大了", "[43]"), KJEMOJI44(0, 1, - R.drawable.smiley_44, "坏笑", "[44]"), KJEMOJI45(0, 1, - R.drawable.smiley_45, "[左哼哼]", "[45]"), KJEMOJI46(0, 1, - R.drawable.smiley_46, "[右哼哼]", "[46]"), KJEMOJI47(0, 1, - R.drawable.smiley_47, "[哈欠]", "[47]"), KJEMOJI48(0, 1, - R.drawable.smiley_48, "[鄙视]", "[48]"), KJEMOJI49(0, 1, - R.drawable.smiley_49, "[委屈]", "[49]"), KJEMOJI50(0, 1, - R.drawable.smiley_50, "[快哭了]", "[50]"), KJEMOJI51(0, 1, - R.drawable.smiley_51, "[阴险]", "[51]"), KJEMOJI52(0, 1, - R.drawable.smiley_52, "[亲亲]", "[52]"), KJEMOJI53(0, 1, - R.drawable.smiley_53, "[吓]", "[53]"), KJEMOJI54(0, 1, - R.drawable.smiley_54, "[可怜]", "[54]"), KJEMOJI55(0, 1, - R.drawable.smiley_55, "[菜刀]", "[55]"), KJEMOJI56(0, 1, - R.drawable.smiley_56, "[西瓜]", "[56]"), KJEMOJI57(0, 1, - R.drawable.smiley_57, "[啤酒]", "[57]"), KJEMOJI58(0, 1, - R.drawable.smiley_58, "[篮球]", "[58]"), KJEMOJI59(0, 1, - R.drawable.smiley_59, "[乒乓]", "[59]"), KJEMOJI60(0, 1, - R.drawable.smiley_60, "[咖啡]", "[60]"), KJEMOJI61(0, 1, - R.drawable.smiley_61, "[饭]", "[61]"), KJEMOJI62(0, 1, - R.drawable.smiley_62, "[猪头]", "[62]"), KJEMOJI63(0, 1, - R.drawable.smiley_63, "[玫瑰]", "[63]"), KJEMOJI64(0, 1, - R.drawable.smiley_64, "[凋谢]", "[64]"), KJEMOJI65(0, 1, - R.drawable.smiley_65, "[嘴唇]", "[65]"), KJEMOJI66(0, 1, - R.drawable.smiley_66, "[爱心]", "[66]"), KJEMOJI67(0, 1, - R.drawable.smiley_67, "[心碎]", "[67]"), KJEMOJI68(0, 1, - R.drawable.smiley_68, "[蛋糕]", "[68]"), KJEMOJI69(0, 1, - R.drawable.smiley_69, "[闪电]", "[69]"), KJEMOJI70(0, 1, - R.drawable.smiley_70, "[炸弹]", "[70]"), KJEMOJI71(0, 1, - R.drawable.smiley_71, "[刀]", "[71]"), KJEMOJI72(0, 1, - R.drawable.smiley_72, "[足球]", "[72]"), KJEMOJI73(0, 1, - R.drawable.smiley_73, "[瓢虫]", "[73]"), KJEMOJI74(0, 1, - R.drawable.smiley_74, "[便便]", "[74]"), KJEMOJI75(0, 1, - R.drawable.smiley_75, "[月亮]", "[75]"), KJEMOJI76(0, 1, - R.drawable.smiley_76, "[太阳]", "[76]"), KJEMOJI77(0, 1, - R.drawable.smiley_77, "[礼物]", "[77]"), KJEMOJI78(0, 1, - R.drawable.smiley_78, "[拥抱]", "[78]"), KJEMOJI79(0, 1, - R.drawable.smiley_79, "[强]", "[79]"), KJEMOJI80(0, 1, - R.drawable.smiley_80, "[弱]", "[80]"), KJEMOJI81(0, 1, - R.drawable.smiley_81, "[握手]", "[81]"), KJEMOJI82(0, 1, - R.drawable.smiley_82, "[胜利]", "[82]"), KJEMOJI83(0, 1, - R.drawable.smiley_83, "[抱拳]", "[83]"), KJEMOJI84(0, 1, - R.drawable.smiley_84, "[勾引]", "[84]"), KJEMOJI85(0, 1, - R.drawable.smiley_85, "[拳头]", "[85]"), KJEMOJI86(0, 1, - R.drawable.smiley_86, "[差劲]", "[86]"), KJEMOJI87(0, 1, - R.drawable.smiley_87, "[爱你]", "[87]"), KJEMOJI88(0, 1, - R.drawable.smiley_88, "[NO]", "[88]"), KJEMOJI89(0, 1, - R.drawable.smiley_89, "[OK]", "[89]"), KJEMOJI90(0, 1, - R.drawable.smiley_90, "[爱情]", "[90]"), KJEMOJI91(0, 1, - R.drawable.smiley_91, "[飞吻]", "[91]"), KJEMOJI92(0, 1, - R.drawable.smiley_92, "[跳跳]", "[92]"), KJEMOJI93(0, 1, - R.drawable.smiley_93, "[发抖]", "[93]"), KJEMOJI94(0, 1, - R.drawable.smiley_94, "[怄火]", "[94]"), KJEMOJI95(0, 1, - R.drawable.smiley_95, "[转圈]", "[95]"), KJEMOJI96(0, 1, - R.drawable.smiley_96, "[磕头]", "[96]"), KJEMOJI97(0, 1, - R.drawable.smiley_97, "[回头]", "[97]"), KJEMOJI98(0, 1, - R.drawable.smiley_98, "[跳绳]", "[98]"), KJEMOJI99(0, 1, - R.drawable.smiley_99, "[投降]", "[99]"), KJEMOJI100(0, 1, - R.drawable.smiley_100, "[激动]", "[100]"), KJEMOJI101(0, 1, - R.drawable.smiley_101, "[乱舞]", "[101]"), KJEMOJI102(0, 1, - R.drawable.smiley_102, "[献吻]", "[102]"), KJEMOJI103(0, 1, - R.drawable.smiley_103, "[左太极]", "[103]"), KJEMOJI104(0, 1, - R.drawable.smiley_104, "[右太极]", "[104]"), - - GITHUB0(1, 1, R.drawable.bowtie, ":bowtie:", ":bowtie:"), - - GITHUB1(1, 1, R.drawable.smile, ":smile:", ":smile:"), - - GITHUB2(1, 1, R.drawable.laughing, ":laughing:", ":laughing:"), - - GITHUB3(1, 1, R.drawable.blush, ":blush:", ":blush:"), - - GITHUB4(1, 1, R.drawable.smiley, ":smiley:", ":smiley:"), - - GITHUB5(1, 1, R.drawable.relaxed, ":relaxed:", ":relaxed:"), - - GITHUB6(1, 1, R.drawable.smirk, ":smirk:", ":smirk:"), - - GITHUB7(1, 1, R.drawable.heart_eyes, ":heart_eyes:", ":heart_eyes:"), - - GITHUB8(1, 1, R.drawable.kissing_heart, ":kissing_heart:", - ":kissing_heart:"), - - GITHUB9(1, 1, R.drawable.kissing_closed_eyes, ":kissing_closed_eyes:", - ":kissing_closed_eyes:"), - - GITHUB10(1, 1, R.drawable.flushed, ":flushed:", ":flushed:"), - - GITHUB11(1, 1, R.drawable.relieved, ":relieved:", ":relieved:"), - - GITHUB12(1, 1, R.drawable.satisfied, ":satisfied:", ":satisfied:"), - - GITHUB13(1, 1, R.drawable.grin, ":grin:", ":grin:"), - - GITHUB14(1, 1, R.drawable.wink, ":wink:", ":wink:"), - - GITHUB15(1, 1, R.drawable.stuck_out_tongue_winking_eye, - ":stuck_out_tongue_winking_eye:", ":stuck_out_tongue_winking_eye:"), - - GITHUB16(1, 1, R.drawable.stuck_out_tongue_closed_eyes, - ":stuck_out_tongue_closed_eyes:", ":stuck_out_tongue_closed_eyes:"), - - GITHUB17(1, 1, R.drawable.grinning, ":grinning:", ":grinning:"), - - GITHUB18(1, 1, R.drawable.kissing, ":kissing:", ":kissing:"), - - GITHUB19(1, 1, R.drawable.kissing_smiling_eyes, ":kissing_smiling_eyes:", - ":kissing_smiling_eyes:"), - - GITHUB20(1, 1, R.drawable.stuck_out_tongue, ":stuck_out_tongue:", - ":stuck_out_tongue:"), - - GITHUB21(1, 1, R.drawable.sleeping, ":sleeping:", ":sleeping:"), - - GITHUB22(1, 1, R.drawable.worried, ":worried:", ":worried:"), - - GITHUB23(1, 1, R.drawable.frowning, ":frowning:", ":frowning:"), - - GITHUB24(1, 1, R.drawable.anguished, ":anguished:", ":anguished:"), - - GITHUB25(1, 1, R.drawable.open_mouth, ":open_mouth:", ":open_mouth:"), - - GITHUB26(1, 1, R.drawable.grimacing, ":grimacing:", ":grimacing:"), - - GITHUB27(1, 1, R.drawable.confused, ":confused:", ":confused:"), - - GITHUB28(1, 1, R.drawable.hushed, ":hushed:", ":hushed:"), - - GITHUB29(1, 1, R.drawable.expressionless, ":expressionless:", - ":expressionless:"), - - GITHUB30(1, 1, R.drawable.unamused, ":unamused:", ":unamused:"), - - GITHUB31(1, 1, R.drawable.sweat_smile, ":sweat_smile:", ":sweat_smile:"), - - GITHUB32(1, 1, R.drawable.sweat, ":sweat:", ":sweat:"), - - GITHUB33(1, 1, R.drawable.disappointed_relieved, ":disappointed_relieved:", - ":disappointed_relieved:"), - - GITHUB34(1, 1, R.drawable.weary, ":weary:", ":weary:"), - - GITHUB35(1, 1, R.drawable.pensive, ":pensive:", ":pensive:"), - - GITHUB36(1, 1, R.drawable.disappointed, ":disappointed:", ":disappointed:"), - - GITHUB37(1, 1, R.drawable.confounded, ":confounded:", ":confounded:"), - - GITHUB38(1, 1, R.drawable.fearful, ":fearful:", ":fearful:"), - - GITHUB39(1, 1, R.drawable.cold_sweat, ":cold_sweat:", ":cold_sweat:"), - - GITHUB40(1, 1, R.drawable.persevere, ":persevere:", ":persevere:"), - - GITHUB41(1, 1, R.drawable.cry, ":cry:", ":cry:"), - - GITHUB42(1, 1, R.drawable.sob, ":sob:", ":sob:"), - - GITHUB43(1, 1, R.drawable.joy, ":joy:", ":joy:"), - - GITHUB44(1, 1, R.drawable.astonished, ":astonished:", ":astonished:"), - - GITHUB45(1, 1, R.drawable.scream, ":scream:", ":scream:"), - - GITHUB46(1, 1, R.drawable.neckbeard, ":neckbeard:", ":neckbeard:"), - - GITHUB47(1, 1, R.drawable.tired_face, ":tired_face:", ":tired_face:"), - - GITHUB48(1, 1, R.drawable.angry, ":angry:", ":angry:"), - - GITHUB49(1, 1, R.drawable.rage, ":rage:", ":rage:"), - - GITHUB50(1, 1, R.drawable.triumph, ":triumph:", ":triumph:"), - - GITHUB51(1, 1, R.drawable.sleepy, ":sleepy:", ":sleepy:"), - - GITHUB52(1, 1, R.drawable.yum, ":yum:", ":yum:"), - - GITHUB53(1, 1, R.drawable.mask, ":mask:", ":mask:"), - - GITHUB54(1, 1, R.drawable.sunglasses, ":sunglasses:", ":sunglasses:"), - - GITHUB55(1, 1, R.drawable.dizzy_face, ":dizzy_face:", ":dizzy_face:"), - - GITHUB56(1, 1, R.drawable.imp, ":imp:", ":imp:"), - - GITHUB57(1, 1, R.drawable.smiling_imp, ":smiling_imp:", ":smiling_imp:"), - - GITHUB58(1, 1, R.drawable.neutral_face, ":neutral_face:", ":neutral_face:"), - - GITHUB59(1, 1, R.drawable.no_mouth, ":no_mouth:", ":no_mouth:"), - - GITHUB60(1, 1, R.drawable.innocent, ":innocent:", ":innocent:"), - - GITHUB61(1, 1, R.drawable.alien, ":alien:", ":alien:"), - - GITHUB62(1, 1, R.drawable.yellow_heart, ":yellow_heart:", ":yellow_heart:"), - - GITHUB63(1, 1, R.drawable.blue_heart, ":blue_heart:", ":blue_heart:"), - - GITHUB64(1, 1, R.drawable.purple_heart, ":purple_heart:", ":purple_heart:"), - - GITHUB65(1, 1, R.drawable.heart, ":heart:", ":heart:"), - - GITHUB66(1, 1, R.drawable.green_heart, ":green_heart:", ":green_heart:"), - - GITHUB67(1, 1, R.drawable.broken_heart, ":broken_heart:", ":broken_heart:"), - - GITHUB68(1, 1, R.drawable.heartbeat, ":heartbeat:", ":heartbeat:"), - - GITHUB69(1, 1, R.drawable.heartpulse, ":heartpulse:", ":heartpulse:"), - - GITHUB70(1, 1, R.drawable.two_hearts, ":two_hearts:", ":two_hearts:"), - - GITHUB71(1, 1, R.drawable.revolving_hearts, ":revolving_hearts:", - ":revolving_hearts:"), - - GITHUB72(1, 1, R.drawable.cupid, ":cupid:", ":cupid:"), - - GITHUB73(1, 1, R.drawable.sparkling_heart, ":sparkling_heart:", - ":sparkling_heart:"), - - GITHUB74(1, 1, R.drawable.sparkles, ":sparkles:", ":sparkles:"), - - GITHUB75(1, 1, R.drawable.star, ":star:", ":star:"), - - GITHUB76(1, 1, R.drawable.star2, ":star2:", ":star2:"), - - GITHUB77(1, 1, R.drawable.dizzy, ":dizzy:", ":dizzy:"), - - GITHUB78(1, 1, R.drawable.boom, ":boom:", ":boom:"), - - GITHUB79(1, 1, R.drawable.collision, ":collision:", ":collision:"), - - GITHUB80(1, 1, R.drawable.anger, ":anger:", ":anger:"), - - GITHUB81(1, 1, R.drawable.exclamation, ":exclamation:", ":exclamation:"), - - GITHUB82(1, 1, R.drawable.question, ":question:", ":question:"), - - GITHUB83(1, 1, R.drawable.grey_exclamation, ":grey_exclamation:", - ":grey_exclamation:"), - - GITHUB84(1, 1, R.drawable.grey_question, ":grey_question:", - ":grey_question:"), - - GITHUB85(1, 1, R.drawable.zzz, ":zzz:", ":zzz:"), - - GITHUB86(1, 1, R.drawable.dash, ":dash:", ":dash:"), - - GITHUB87(1, 1, R.drawable.sweat_drops, ":sweat_drops:", ":sweat_drops:"), - - GITHUB88(1, 1, R.drawable.notes, ":notes:", ":notes:"), - - GITHUB89(1, 1, R.drawable.musical_note, ":musical_note:", ":musical_note:"), - - GITHUB90(1, 1, R.drawable.fire, ":fire:", ":fire:"), - - GITHUB91(1, 1, R.drawable.hankey, ":hankey:", ":hankey:"), - - GITHUB92(1, 1, R.drawable.poop, ":poop:", ":poop:"), - - GITHUB93(1, 1, R.drawable.shit, ":shit:", ":shit:"), - - GITHUB94(1, 1, R.drawable.thumbsup, ":+1:", ":+1:"), - - GITHUB95(1, 1, R.drawable.thumbsup, ":thumbsup:", ":thumbsup:"), - - GITHUB96(1, 1, R.drawable.the_1, ":-1:", ":-1:"), - - GITHUB97(1, 1, R.drawable.thumbsdown, ":thumbsdown:", ":thumbsdown:"), - - GITHUB98(1, 1, R.drawable.ok_hand, ":ok_hand:", ":ok_hand:"), - - GITHUB99(1, 1, R.drawable.punch, ":punch:", ":punch:"), - - GITHUB100(1, 1, R.drawable.facepunch, ":facepunch:", ":facepunch:"), - - GITHUB101(1, 1, R.drawable.fist, ":fist:", ":fist:"), - - GITHUB102(1, 1, R.drawable.v, ":v:", ":v:"), - - GITHUB103(1, 1, R.drawable.wave, ":wave:", ":wave:"), - - GITHUB104(1, 1, R.drawable.hand, ":hand:", ":hand:"), - - GITHUB105(1, 1, R.drawable.raised_hand, ":raised_hand:", ":raised_hand:"), - - GITHUB106(1, 1, R.drawable.open_hands, ":open_hands:", ":open_hands:"), - - GITHUB107(1, 1, R.drawable.point_up, ":point_up:", ":point_up:"), - - GITHUB108(1, 1, R.drawable.point_down, ":point_down:", ":point_down:"), - - GITHUB109(1, 1, R.drawable.point_left, ":point_left:", ":point_left:"), - - GITHUB110(1, 1, R.drawable.point_right, ":point_right:", ":point_right:"), - - GITHUB111(1, 1, R.drawable.raised_hands, ":raised_hands:", ":raised_hands:"), - - GITHUB112(1, 1, R.drawable.pray, ":pray:", ":pray:"), - - GITHUB113(1, 1, R.drawable.point_up_2, ":point_up_2:", ":point_up_2:"), - - GITHUB114(1, 1, R.drawable.clap, ":clap:", ":clap:"), - - GITHUB115(1, 1, R.drawable.muscle, ":muscle:", ":muscle:"), - - GITHUB116(1, 1, R.drawable.metal, ":metal:", ":metal:"), - - GITHUB117(1, 1, R.drawable.fu, ":fu:", ":fu:"), - - GITHUB118(1, 1, R.drawable.walking, ":walking:", ":walking:"), - - GITHUB119(1, 1, R.drawable.runner, ":runner:", ":runner:"), - - GITHUB120(1, 1, R.drawable.running, ":running:", ":running:"), - - GITHUB121(1, 1, R.drawable.couple, ":couple:", ":couple:"), - - GITHUB122(1, 1, R.drawable.family, ":family:", ":family:"), - - GITHUB123(1, 1, R.drawable.two_men_holding_hands, - ":two_men_holding_hands:", ":two_men_holding_hands:"), - - GITHUB124(1, 1, R.drawable.two_women_holding_hands, - ":two_women_holding_hands:", ":two_women_holding_hands:"), - - GITHUB125(1, 1, R.drawable.dancer, ":dancer:", ":dancer:"), - - GITHUB126(1, 1, R.drawable.dancers, ":dancers:", ":dancers:"), - - GITHUB127(1, 1, R.drawable.ok_woman, ":ok_woman:", ":ok_woman:"), - - GITHUB128(1, 1, R.drawable.no_good, ":no_good:", ":no_good:"), - - GITHUB129(1, 1, R.drawable.information_desk_person, - ":information_desk_person:", ":information_desk_person:"), - - GITHUB130(1, 1, R.drawable.raising_hand, ":raising_hand:", ":raising_hand:"), - - GITHUB131(1, 1, R.drawable.bride_with_veil, ":bride_with_veil:", - ":bride_with_veil:"), - - GITHUB132(1, 1, R.drawable.person_with_pouting_face, - ":person_with_pouting_face:", ":person_with_pouting_face:"), - - GITHUB133(1, 1, R.drawable.person_frowning, ":person_frowning:", - ":person_frowning:"), - - GITHUB134(1, 1, R.drawable.bow, ":bow:", ":bow:"), - - GITHUB135(1, 1, R.drawable.couplekiss, ":couplekiss:", ":couplekiss:"), - - GITHUB136(1, 1, R.drawable.couple_with_heart, ":couple_with_heart:", - ":couple_with_heart:"), - - GITHUB137(1, 1, R.drawable.massage, ":massage:", ":massage:"), - - GITHUB138(1, 1, R.drawable.haircut, ":haircut:", ":haircut:"), - - GITHUB139(1, 1, R.drawable.nail_care, ":nail_care:", ":nail_care:"), - - GITHUB140(1, 1, R.drawable.boy, ":boy:", ":boy:"), - - GITHUB141(1, 1, R.drawable.girl, ":girl:", ":girl:"), - - GITHUB142(1, 1, R.drawable.woman, ":woman:", ":woman:"), - - GITHUB143(1, 1, R.drawable.man, ":man:", ":man:"), - - GITHUB144(1, 1, R.drawable.baby, ":baby:", ":baby:"), - - GITHUB145(1, 1, R.drawable.older_woman, ":older_woman:", ":older_woman:"), - - GITHUB146(1, 1, R.drawable.older_man, ":older_man:", ":older_man:"), - - GITHUB147(1, 1, R.drawable.person_with_blond_hair, - ":person_with_blond_hair:", ":person_with_blond_hair:"), - - GITHUB148(1, 1, R.drawable.man_with_gua_pi_mao, ":man_with_gua_pi_mao:", - ":man_with_gua_pi_mao:"), - - GITHUB149(1, 1, R.drawable.man_with_turban, ":man_with_turban:", - ":man_with_turban:"), - - GITHUB150(1, 1, R.drawable.construction_worker, ":construction_worker:", - ":construction_worker:"), - - GITHUB151(1, 1, R.drawable.cop, ":cop:", ":cop:"), - - GITHUB152(1, 1, R.drawable.angel, ":angel:", ":angel:"), - - GITHUB153(1, 1, R.drawable.princess, ":princess:", ":princess:"), - - GITHUB154(1, 1, R.drawable.smiley_cat, ":smiley_cat:", ":smiley_cat:"), - - GITHUB155(1, 1, R.drawable.smile_cat, ":smile_cat:", ":smile_cat:"), - - GITHUB156(1, 1, R.drawable.heart_eyes_cat, ":heart_eyes_cat:", - ":heart_eyes_cat:"), - - GITHUB157(1, 1, R.drawable.kissing_cat, ":kissing_cat:", ":kissing_cat:"), - - GITHUB158(1, 1, R.drawable.smirk_cat, ":smirk_cat:", ":smirk_cat:"), - - GITHUB159(1, 1, R.drawable.scream_cat, ":scream_cat:", ":scream_cat:"), - - GITHUB160(1, 1, R.drawable.crying_cat_face, ":crying_cat_face:", - ":crying_cat_face:"), - - GITHUB161(1, 1, R.drawable.joy_cat, ":joy_cat:", ":joy_cat:"), - - GITHUB162(1, 1, R.drawable.pouting_cat, ":pouting_cat:", ":pouting_cat:"), - - GITHUB163(1, 1, R.drawable.japanese_ogre, ":japanese_ogre:", - ":japanese_ogre:"), - - GITHUB164(1, 1, R.drawable.japanese_goblin, ":japanese_goblin:", - ":japanese_goblin:"), - - GITHUB165(1, 1, R.drawable.see_no_evil, ":see_no_evil:", ":see_no_evil:"), - - GITHUB166(1, 1, R.drawable.hear_no_evil, ":hear_no_evil:", ":hear_no_evil:"), - - GITHUB167(1, 1, R.drawable.speak_no_evil, ":speak_no_evil:", - ":speak_no_evil:"), - - GITHUB168(1, 1, R.drawable.guardsman, ":guardsman:", ":guardsman:"), - - GITHUB169(1, 1, R.drawable.skull, ":skull:", ":skull:"), - - GITHUB170(1, 1, R.drawable.feet, ":feet:", ":feet:"), - - GITHUB171(1, 1, R.drawable.lips, ":lips:", ":lips:"), - - GITHUB172(1, 1, R.drawable.kiss, ":kiss:", ":kiss:"), - - GITHUB173(1, 1, R.drawable.droplet, ":droplet:", ":droplet:"), - - GITHUB174(1, 1, R.drawable.ear, ":ear:", ":ear:"), - - GITHUB175(1, 1, R.drawable.eyes, ":eyes:", ":eyes:"), - - GITHUB176(1, 1, R.drawable.nose, ":nose:", ":nose:"), - - GITHUB177(1, 1, R.drawable.tongue, ":tongue:", ":tongue:"), - - GITHUB178(1, 1, R.drawable.love_letter, ":love_letter:", ":love_letter:"), - - GITHUB179(1, 1, R.drawable.bust_in_silhouette, ":bust_in_silhouette:", - ":bust_in_silhouette:"), - - GITHUB180(1, 1, R.drawable.busts_in_silhouette, ":busts_in_silhouette:", - ":busts_in_silhouette:"), - - GITHUB181(1, 1, R.drawable.speech_balloon, ":speech_balloon:", - ":speech_balloon:"), - - GITHUB182(1, 1, R.drawable.thought_balloon, ":thought_balloon:", - ":thought_balloon:"), - - GITHUB183(1, 1, R.drawable.feelsgood, ":feelsgood:", ":feelsgood:"), - - GITHUB184(1, 1, R.drawable.finnadie, ":finnadie:", ":finnadie:"), - - GITHUB185(1, 1, R.drawable.goberserk, ":goberserk:", ":goberserk:"), - - GITHUB186(1, 1, R.drawable.godmode, ":godmode:", ":godmode:"), - - GITHUB187(1, 1, R.drawable.hurtrealbad, ":hurtrealbad:", ":hurtrealbad:"), - - GITHUB188(1, 1, R.drawable.rage1, ":rage1:", ":rage1:"), - - GITHUB189(1, 1, R.drawable.rage2, ":rage2:", ":rage2:"), - - GITHUB190(1, 1, R.drawable.rage3, ":rage3:", ":rage3:"), - - GITHUB191(1, 1, R.drawable.rage4, ":rage4:", ":rage4:"), - - GITHUB192(1, 1, R.drawable.suspect, ":suspect:", ":suspect:"), - - GITHUB193(1, 1, R.drawable.trollface, ":trollface:", ":trollface:"), - - Nature0(2, 1, R.drawable.sunny, ":sunny:", ":sunny:"), - - Nature1(2, 1, R.drawable.umbrella, ":umbrella:", ":umbrella:"), - - Nature2(2, 1, R.drawable.cloud, ":cloud:", ":cloud:"), - - Nature3(2, 1, R.drawable.snowflake, ":snowflake:", ":snowflake:"), - - Nature4(2, 1, R.drawable.snowman, ":snowman:", ":snowman:"), - - Nature5(2, 1, R.drawable.zap, ":zap:", ":zap:"), - - Nature6(2, 1, R.drawable.cyclone, ":cyclone:", ":cyclone:"), - - Nature7(2, 1, R.drawable.foggy, ":foggy:", ":foggy:"), - - Nature8(2, 1, R.drawable.ocean, ":ocean:", ":ocean:"), - - Nature9(2, 1, R.drawable.cat, ":cat:", ":cat:"), - - Nature10(2, 1, R.drawable.dog, ":dog:", ":dog:"), - - Nature11(2, 1, R.drawable.mouse, ":mouse:", ":mouse:"), - - Nature12(2, 1, R.drawable.hamster, ":hamster:", ":hamster:"), - - Nature13(2, 1, R.drawable.rabbit, ":rabbit:", ":rabbit:"), - - Nature14(2, 1, R.drawable.wolf, ":wolf:", ":wolf:"), - - Nature15(2, 1, R.drawable.frog, ":frog:", ":frog:"), - - Nature16(2, 1, R.drawable.tiger, ":tiger:", ":tiger:"), - - Nature17(2, 1, R.drawable.koala, ":koala:", ":koala:"), - - Nature18(2, 1, R.drawable.bear, ":bear:", ":bear:"), - - Nature19(2, 1, R.drawable.pig, ":pig:", ":pig:"), - - Nature20(2, 1, R.drawable.pig_nose, ":pig_nose:", ":pig_nose:"), - - Nature21(2, 1, R.drawable.cow, ":cow:", ":cow:"), - - Nature22(2, 1, R.drawable.boar, ":boar:", ":boar:"), - - Nature23(2, 1, R.drawable.monkey_face, ":monkey_face:", ":monkey_face:"), - - Nature24(2, 1, R.drawable.monkey, ":monkey:", ":monkey:"), - - Nature25(2, 1, R.drawable.horse, ":horse:", ":horse:"), - - Nature26(2, 1, R.drawable.racehorse, ":racehorse:", ":racehorse:"), - - Nature27(2, 1, R.drawable.camel, ":camel:", ":camel:"), - - Nature28(2, 1, R.drawable.sheep, ":sheep:", ":sheep:"), - - Nature29(2, 1, R.drawable.elephant, ":elephant:", ":elephant:"), - - Nature30(2, 1, R.drawable.panda_face, ":panda_face:", ":panda_face:"), - - Nature31(2, 1, R.drawable.snake, ":snake:", ":snake:"), - - Nature32(2, 1, R.drawable.bird, ":bird:", ":bird:"), - - Nature33(2, 1, R.drawable.baby_chick, ":baby_chick:", ":baby_chick:"), - - Nature34(2, 1, R.drawable.hatched_chick, ":hatched_chick:", - ":hatched_chick:"), - - Nature35(2, 1, R.drawable.hatching_chick, ":hatching_chick:", - ":hatching_chick:"), - - Nature36(2, 1, R.drawable.chicken, ":chicken:", ":chicken:"), - - Nature37(2, 1, R.drawable.penguin, ":penguin:", ":penguin:"), - - Nature38(2, 1, R.drawable.turtle, ":turtle:", ":turtle:"), - - Nature39(2, 1, R.drawable.bug, ":bug:", ":bug:"), - - Nature40(2, 1, R.drawable.honeybee, ":honeybee:", ":honeybee:"), - - Nature41(2, 1, R.drawable.ant, ":ant:", ":ant:"), - - Nature42(2, 1, R.drawable.beetle, ":beetle:", ":beetle:"), - - Nature43(2, 1, R.drawable.snail, ":snail:", ":snail:"), - - Nature44(2, 1, R.drawable.octopus, ":octopus:", ":octopus:"), - - Nature45(2, 1, R.drawable.tropical_fish, ":tropical_fish:", - ":tropical_fish:"), - - Nature46(2, 1, R.drawable.fish, ":fish:", ":fish:"), - - Nature47(2, 1, R.drawable.whale, ":whale:", ":whale:"), - - Nature48(2, 1, R.drawable.whale2, ":whale2:", ":whale2:"), - - Nature49(2, 1, R.drawable.dolphin, ":dolphin:", ":dolphin:"), - - Nature50(2, 1, R.drawable.cow2, ":cow2:", ":cow2:"), - - Nature51(2, 1, R.drawable.ram, ":ram:", ":ram:"), - - Nature52(2, 1, R.drawable.rat, ":rat:", ":rat:"), - - Nature53(2, 1, R.drawable.water_buffalo, ":water_buffalo:", - ":water_buffalo:"), - - Nature54(2, 1, R.drawable.tiger2, ":tiger2:", ":tiger2:"), - - Nature55(2, 1, R.drawable.rabbit2, ":rabbit2:", ":rabbit2:"), - - Nature56(2, 1, R.drawable.dragon, ":dragon:", ":dragon:"), - - Nature57(2, 1, R.drawable.goat, ":goat:", ":goat:"), - - Nature58(2, 1, R.drawable.rooster, ":rooster:", ":rooster:"), - - Nature59(2, 1, R.drawable.dog2, ":dog2:", ":dog2:"), - - Nature60(2, 1, R.drawable.pig2, ":pig2:", ":pig2:"), - - Nature61(2, 1, R.drawable.mouse2, ":mouse2:", ":mouse2:"), - - Nature62(2, 1, R.drawable.ox, ":ox:", ":ox:"), - - Nature63(2, 1, R.drawable.dragon_face, ":dragon_face:", ":dragon_face:"), - - Nature64(2, 1, R.drawable.blowfish, ":blowfish:", ":blowfish:"), - - Nature65(2, 1, R.drawable.crocodile, ":crocodile:", ":crocodile:"), - - Nature66(2, 1, R.drawable.dromedary_camel, ":dromedary_camel:", - ":dromedary_camel:"), - - Nature67(2, 1, R.drawable.leopard, ":leopard:", ":leopard:"), - - Nature68(2, 1, R.drawable.cat2, ":cat2:", ":cat2:"), - - Nature69(2, 1, R.drawable.poodle, ":poodle:", ":poodle:"), - - Nature70(2, 1, R.drawable.paw_prints, ":paw_prints:", ":paw_prints:"), - - Nature71(2, 1, R.drawable.bouquet, ":bouquet:", ":bouquet:"), - - Nature72(2, 1, R.drawable.cherry_blossom, ":cherry_blossom:", - ":cherry_blossom:"), - - Nature73(2, 1, R.drawable.tulip, ":tulip:", ":tulip:"), - - Nature74(2, 1, R.drawable.four_leaf_clover, ":four_leaf_clover:", - ":four_leaf_clover:"), - - Nature75(2, 1, R.drawable.rose, ":rose:", ":rose:"), - - Nature76(2, 1, R.drawable.sunflower, ":sunflower:", ":sunflower:"), - - Nature77(2, 1, R.drawable.hibiscus, ":hibiscus:", ":hibiscus:"), - - Nature78(2, 1, R.drawable.maple_leaf, ":maple_leaf:", ":maple_leaf:"), - - Nature79(2, 1, R.drawable.leaves, ":leaves:", ":leaves:"), - - Nature80(2, 1, R.drawable.fallen_leaf, ":fallen_leaf:", ":fallen_leaf:"), - - Nature81(2, 1, R.drawable.herb, ":herb:", ":herb:"), - - Nature82(2, 1, R.drawable.mushroom, ":mushroom:", ":mushroom:"), - - Nature83(2, 1, R.drawable.cactus, ":cactus:", ":cactus:"), - - Nature84(2, 1, R.drawable.palm_tree, ":palm_tree:", ":palm_tree:"), - - Nature85(2, 1, R.drawable.evergreen_tree, ":evergreen_tree:", - ":evergreen_tree:"), - - Nature86(2, 1, R.drawable.deciduous_tree, ":deciduous_tree:", - ":deciduous_tree:"), - - Nature87(2, 1, R.drawable.chestnut, ":chestnut:", ":chestnut:"), - - Nature88(2, 1, R.drawable.seedling, ":seedling:", ":seedling:"), - - Nature89(2, 1, R.drawable.blossom, ":blossom:", ":blossom:"), - - Nature90(2, 1, R.drawable.ear_of_rice, ":ear_of_rice:", ":ear_of_rice:"), - - Nature91(2, 1, R.drawable.shell, ":shell:", ":shell:"), - - Nature92(2, 1, R.drawable.globe_with_meridians, ":globe_with_meridians:", - ":globe_with_meridians:"), - - Nature93(2, 1, R.drawable.sun_with_face, ":sun_with_face:", - ":sun_with_face:"), - - Nature94(2, 1, R.drawable.full_moon_with_face, ":full_moon_with_face:", - ":full_moon_with_face:"), - - Nature95(2, 1, R.drawable.new_moon_with_face, ":new_moon_with_face:", - ":new_moon_with_face:"), - - Nature96(2, 1, R.drawable.new_moon, ":new_moon:", ":new_moon:"), - - Nature97(2, 1, R.drawable.waxing_crescent_moon, ":waxing_crescent_moon:", - ":waxing_crescent_moon:"), - - Nature98(2, 1, R.drawable.first_quarter_moon, ":first_quarter_moon:", - ":first_quarter_moon:"), - - Nature99(2, 1, R.drawable.waxing_gibbous_moon, ":waxing_gibbous_moon:", - ":waxing_gibbous_moon:"), - - Nature100(2, 1, R.drawable.full_moon, ":full_moon:", ":full_moon:"), - - Nature101(2, 1, R.drawable.waning_gibbous_moon, ":waning_gibbous_moon:", - ":waning_gibbous_moon:"), - - Nature102(2, 1, R.drawable.last_quarter_moon, ":last_quarter_moon:", - ":last_quarter_moon:"), - - Nature103(2, 1, R.drawable.waning_crescent_moon, ":waning_crescent_moon:", - ":waning_crescent_moon:"), - - Nature104(2, 1, R.drawable.last_quarter_moon_with_face, - ":last_quarter_moon_with_face:", ":last_quarter_moon_with_face:"), - - Nature105(2, 1, R.drawable.first_quarter_moon_with_face, - ":first_quarter_moon_with_face:", ":first_quarter_moon_with_face:"), - - Nature106(2, 1, R.drawable.moon, ":moon:", ":moon:"), - - Nature107(2, 1, R.drawable.earth_africa, ":earth_africa:", ":earth_africa:"), - - Nature108(2, 1, R.drawable.earth_americas, ":earth_americas:", - ":earth_americas:"), - - Nature109(2, 1, R.drawable.earth_asia, ":earth_asia:", ":earth_asia:"), - - Nature110(2, 1, R.drawable.volcano, ":volcano:", ":volcano:"), - - Nature111(2, 1, R.drawable.milky_way, ":milky_way:", ":milky_way:"), - - Nature112(2, 1, R.drawable.partly_sunny, ":partly_sunny:", ":partly_sunny:"), - - Nature113(2, 1, R.drawable.octocat, ":octocat:", ":octocat:"), - - Nature114(2, 1, R.drawable.squirrel, ":squirrel:", ":squirrel:"); - - /********************************* 操作 **************************************/ - private String emojiStr; - private String remote; - private int value; - private int resId; - private int type; - private static Map sEmojiMap; - - private DisplayRules(int type, int value, int resId, String cls, - String remote) { - this.type = type; - this.emojiStr = cls; - this.value = value; - this.resId = resId; - this.remote = remote; - } - - public String getRemote() { - return remote; - } - - public void setRemote(String remote) { - this.remote = remote; - } - - public String getEmojiStr() { - return emojiStr; - } - - public int getValue() { - return value; - } - - public int getResId() { - return resId; - } - - public int getType() { - return type; - } - - private static Emojicon getEmojiFromEnum(DisplayRules data) { - return new Emojicon(data.getResId(), data.getValue(), - data.getEmojiStr(), data.getRemote()); - } - - public static Emojicon getEmojiFromRes(int resId) { - for (DisplayRules data : values()) { - if (data.getResId() == resId) { - return getEmojiFromEnum(data); - } - } - return null; - } - - public static Emojicon getEmojiFromValue(int value) { - for (DisplayRules data : values()) { - if (data.getValue() == value) { - return getEmojiFromEnum(data); - } - } - return null; - } - - public static Emojicon getEmojiFromName(String emojiStr) { - for (DisplayRules data : values()) { - if (data.getEmojiStr().equals(emojiStr)) { - return getEmojiFromEnum(data); - } - } - return null; - } - - /** - * 提高效率,忽略线程安全 - */ - public static Map getMapAll() { - if (sEmojiMap == null) { - sEmojiMap = new HashMap(); - for (DisplayRules data : values()) { - sEmojiMap.put(data.getEmojiStr(), data.getResId()); - sEmojiMap.put(data.getRemote(), data.getResId()); - } - } - return sEmojiMap; - } - - public static List getAllByType(int type) { - List datas = new ArrayList(values().length); - for (DisplayRules data : values()) { - if (data.getType() == type) { - datas.add(getEmojiFromEnum(data)); - } - } - return datas; - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/EmojiGridAdapter.java b/app/src/main/java/net/oschina/app/emoji/EmojiGridAdapter.java deleted file mode 100644 index eadf9717f00084489375ee986182d68f6a8a2226..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/EmojiGridAdapter.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.R; -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView.LayoutParams; -import android.widget.BaseAdapter; -import android.widget.ImageView; - -/** - * 表情适配器 - * - * @author kymjs (http://www.kymjs.com) - * - */ -public class EmojiGridAdapter extends BaseAdapter { - - private List datas; - private final Context cxt; - - public EmojiGridAdapter(Context cxt, List datas) { - this.cxt = cxt; - if (datas == null) { - datas = new ArrayList(0); - } - this.datas = datas; - } - - public void refresh(List datas) { - if (datas == null) { - datas = new ArrayList(0); - } - this.datas = datas; - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return datas.size(); - } - - @Override - public Object getItem(int position) { - return datas.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - private static class ViewHolder { - ImageView image; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder = null; - if (convertView == null) { - holder = new ViewHolder(); - convertView = new ImageView(cxt); - int bound = (int) cxt.getResources().getDimension(R.dimen.space_49); - LayoutParams params = new LayoutParams(bound, bound); - convertView.setLayoutParams(params); - int padding = (int) cxt.getResources().getDimension( - R.dimen.space_10); - convertView.setPadding(padding, padding, padding, padding); - holder.image = (ImageView) convertView; - convertView.setTag(holder); - } else { - holder = (ViewHolder) convertView.getTag(); - } - holder.image.setImageResource(datas.get(position).getResId()); - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/EmojiKeyboardFragment.java b/app/src/main/java/net/oschina/app/emoji/EmojiKeyboardFragment.java deleted file mode 100644 index 00154dc16ceaf3f6d75cf23d1fd72501dc6314ba..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/EmojiKeyboardFragment.java +++ /dev/null @@ -1,163 +0,0 @@ -package net.oschina.app.emoji; - -import net.oschina.app.R; -import net.oschina.app.emoji.SoftKeyboardStateHelper.SoftKeyboardStateListener; -import android.content.Context; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.view.ViewPager; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.RadioGroup; - -public class EmojiKeyboardFragment extends Fragment implements - SoftKeyboardStateListener { - - private LinearLayout mEmojiContent; - private RadioGroup mEmojiBottom; - private View[] mEmojiTabs; - private ViewPager mEmojiPager; - - private EmojiPagerAdapter adapter; - - private LinearLayout mRootView; - private OnEmojiClickListener listener; - public static int EMOJI_TAB_CONTENT; - - private SoftKeyboardStateHelper mKeyboardHelper; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - mRootView = (LinearLayout) inflater.inflate(R.layout.frag_keyboard, - container, false); - initWidget(mRootView); - return mRootView; - } - - private void initWidget(View rootView) { - // bottom - mEmojiBottom = (RadioGroup) rootView.findViewById(R.id.emoji_bottom); - mEmojiBottom.setVisibility(View.VISIBLE); - EMOJI_TAB_CONTENT = mEmojiBottom.getChildCount() - 1; // 减一是因为有一个删除按钮 - mEmojiTabs = new View[EMOJI_TAB_CONTENT]; - if (EMOJI_TAB_CONTENT <= 1) { // 只有一个分类的时候就不显示了 - mEmojiBottom.setVisibility(View.GONE); - } - for (int i = 0; i < EMOJI_TAB_CONTENT; i++) { - mEmojiTabs[i] = mEmojiBottom.getChildAt(i); - mEmojiTabs[i].setOnClickListener(getBottomBarClickListener(i)); - } - mEmojiBottom.findViewById(R.id.emoji_bottom_del).setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View v) { - if (listener != null) { - listener.onDeleteButtonClick(v); - } - } - }); - - // content必须放在bottom下面初始化 - mEmojiContent = (LinearLayout) rootView - .findViewById(R.id.emoji_content); - mEmojiPager = (ViewPager) mEmojiContent.findViewById(R.id.emoji_pager); - adapter = new EmojiPagerAdapter(getFragmentManager(), - EMOJI_TAB_CONTENT, listener); - mEmojiPager.setAdapter(adapter); - mEmojiContent.setVisibility(View.VISIBLE); - - mKeyboardHelper = new SoftKeyboardStateHelper(getActivity().getWindow() - .getDecorView()); - mKeyboardHelper.addSoftKeyboardStateListener(this); - } - - /** - * 底部栏点击事件监听器 - * - * @param indexfff - * @return - */ - private OnClickListener getBottomBarClickListener(final int index) { - return new OnClickListener() { - @Override - public void onClick(View v) { - mEmojiPager.setCurrentItem(index); - } - }; - } - - public void setOnEmojiClickListener(OnEmojiClickListener l) { - this.listener = l; - } - - public void hideAllKeyBoard() { - hideEmojiKeyBoard(); - hideSoftKeyboard(); - } - - public boolean isShow() { - return mEmojiContent.getVisibility() == View.VISIBLE; - } - - /** - * 隐藏Emoji并显示软键盘 - */ - public void hideEmojiKeyBoard() { - mEmojiBottom.setVisibility(View.GONE); - mEmojiContent.setVisibility(View.GONE); - } - - /** - * 显示Emoji并隐藏软键盘 - */ - public void showEmojiKeyBoard() { - mEmojiContent.setVisibility(View.VISIBLE); - if (EMOJI_TAB_CONTENT > 1) { - mEmojiBottom.setVisibility(View.VISIBLE); - } - } - - /** - * 隐藏软键盘 - */ - public void hideSoftKeyboard() { - ((InputMethodManager) getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( - mEmojiBottom.getWindowToken(), 0); - } - - /** - * 显示软键盘 - */ - public void showSoftKeyboard(EditText et) { - ((InputMethodManager) getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE)).showSoftInput(et, - InputMethodManager.SHOW_FORCED); - } - - /** - * 当软键盘显示时回调 - */ - @Override - public void onSoftKeyboardOpened(int keyboardHeightInPx) { - mEmojiBottom.setVisibility(View.GONE); - mEmojiContent.setVisibility(View.GONE); - } - - @Override - public void onSoftKeyboardClosed() {} - - @Override - public void onStop() { - super.onStop(); - hideSoftKeyboard(); - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/EmojiPageFragment.java b/app/src/main/java/net/oschina/app/emoji/EmojiPageFragment.java deleted file mode 100644 index c15a2be694d40596853246487f3ba6e38a963dbc..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/EmojiPageFragment.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.annotation.SuppressLint; -import android.graphics.drawable.ColorDrawable; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.EditText; -import android.widget.GridView; - -import net.oschina.app.R; - -import java.util.ArrayList; -import java.util.List; - -/** - * 表情页,每页的显示 - * - * @author kymjs (http://www.kymjs.com) - * - */ -@SuppressLint("ValidFragment") -public class EmojiPageFragment extends Fragment { - private List datas; - private GridView sGrid; - private EmojiGridAdapter adapter; - private OnEmojiClickListener listener; - - public EmojiPageFragment(int index, int type, OnEmojiClickListener l) { - initData(index, type); - this.listener = l; - } - - private void initData(int index, int type) { - datas = new ArrayList(); - if (KJEmojiFragment.EMOJI_TAB_CONTENT > 1) { - datas = DisplayRules.getAllByType(type); - } else { - List dataAll = DisplayRules.getAllByType(type); - int max = Math.min((index + 1) * KJEmojiConfig.COUNT_IN_PAGE, - dataAll.size()); - for (int i = index * KJEmojiConfig.COUNT_IN_PAGE; i < max; i++) { - datas.add(dataAll.get(i)); - } - datas.add(new Emojicon(KJEmojiConfig.DELETE_EMOJI_ID, 1, "delete:", - "delete:")); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - sGrid = new GridView(getActivity()); - sGrid.setNumColumns(KJEmojiConfig.COLUMNS); - adapter = new EmojiGridAdapter(getActivity(), datas); - sGrid.setAdapter(adapter); - sGrid.setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, - int position, long id) { - EditText editText = (EditText) getActivity().findViewById( - R.id.emoji_titile_input); - if (listener != null) { - listener.onEmojiClick((Emojicon) parent.getAdapter() - .getItem(position)); - } - InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter() - .getItem(position)); - } - }); - sGrid.setSelector(new ColorDrawable(android.R.color.transparent)); - return sGrid; - } - - public GridView getRootView() { - return sGrid; - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/EmojiPagerAdapter.java b/app/src/main/java/net/oschina/app/emoji/EmojiPagerAdapter.java deleted file mode 100644 index 636a012498f4d788cdac497203415e6deac655f6..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/EmojiPagerAdapter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; - -/** - * 表情页适配器(FragmentPagerAdapter的好处是fragment常驻内存,对于要求效率而页卡很少的表情控件最合适) - * - * @author kymjs (http://www.kymjs.com) - * - */ -public class EmojiPagerAdapter extends FragmentPagerAdapter { - - private OnEmojiClickListener listener; - - public EmojiPagerAdapter(FragmentManager fm, int tabCount, - OnEmojiClickListener l) { - super(fm); - KJEmojiFragment.EMOJI_TAB_CONTENT = tabCount; - listener = l; - } - - public EmojiPagerAdapter(FragmentManager fm) { - super(fm); - } - - @Override - public EmojiPageFragment getItem(int index) { - if (KJEmojiFragment.EMOJI_TAB_CONTENT > 1) { - return new EmojiPageFragment(index, index, listener); - } else { - return new EmojiPageFragment(index, 0, listener); - } - } - - /** - * 显示模式:如果只有一种Emoji表情,则像QQ表情一样左右滑动分页显示
- * 如果有多种Emoji表情,每页显示一种,Emoji筛选时上下滑动筛选。 - */ - @Override - public int getCount() { - if (KJEmojiFragment.EMOJI_TAB_CONTENT > 1) { - return KJEmojiFragment.EMOJI_TAB_CONTENT; - } else { - // 采用进一法取小数 - return (DisplayRules.getAllByType(0).size() - 1 + KJEmojiConfig.COUNT_IN_PAGE) - / KJEmojiConfig.COUNT_IN_PAGE; - } - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/Emojicon.java b/app/src/main/java/net/oschina/app/emoji/Emojicon.java deleted file mode 100644 index c82520ffac272f8570f86d4b9178c2da660ec415..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/Emojicon.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -/** - * - * @author kymjs (http://www.kymjs.com) - */ -public class Emojicon { - private final int resId; // 图片资源地址 - private final int value; // 一个emoji对应唯一一个value - private final String emojiStr; // emoji在互联网传递的字符串 - private final String remote; - - public Emojicon(int id, int value, String name, String remote) { - this.resId = id; - this.value = value; - this.emojiStr = name; - this.remote = remote; - } - - public int getResId() { - return resId; - } - - public String getRemote() { - return remote; - } - - public int getValue() { - return value; - } - - public String getEmojiStr() { - return emojiStr; - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/InputHelper.java b/app/src/main/java/net/oschina/app/emoji/InputHelper.java deleted file mode 100644 index 786c6fe24115606292d56df763186b03aadc9881..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/InputHelper.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.content.res.Resources; -import android.graphics.drawable.Drawable; -import android.text.Spannable; -import android.text.SpannableString; -import android.text.style.ImageSpan; -import android.view.KeyEvent; -import android.widget.EditText; - -import net.oschina.app.R; - -/** - * @author kymjs (http://www.kymjs.com) - */ -public class InputHelper { - public static void backspace(EditText editText) { - if (editText == null) { - return; - } - KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, - 0, KeyEvent.KEYCODE_ENDCALL); - editText.dispatchKeyEvent(event); - } - - /** - * 获取name对应的资源 - */ - public static int getEmojiResId(String name) { - Integer res = DisplayRules.getMapAll().get(name); - if (res != null) { - return res; - } else { - return -1; - } - } - - /** - * Support OSChina Client,due to the need to support both 2 Format
- * (I'm drunk, I go home) - */ - public static Spannable displayEmoji(Resources res, CharSequence s) { - String str = s.toString(); - Spannable spannable; - if (s instanceof Spannable) { - spannable = (Spannable) s; - } else { - // 构建文字span - spannable = new SpannableString(str); - } - if (!str.contains(":") && !str.contains("[")) { - return spannable; - } - - for (int i = 0; i < str.length(); i++) { - int index1 = str.indexOf("[", i); - int length1 = str.indexOf("]", index1 + 1); - int index2 = str.indexOf(":", i); - int length2 = str.indexOf(":", index2 + 1); - int bound = (int) res.getDimension(R.dimen.space_20); - - try { - if (index1 > 0) { - String emojiStr = str.substring(index1, length1 + "]".length()); - int resId = getEmojiResId(emojiStr); - if (resId > 0) { - // 构建图片span - Drawable drawable = res.getDrawable(resId); - - drawable.setBounds(0, 20, bound, bound + 20); - ImageSpan span = new ImageSpan(drawable, - ImageSpan.ALIGN_BASELINE); - spannable.setSpan(span, index1, length1 + "]".length(), - Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - } - } - if (index2 > 0) { - String emojiStr2 = str - .substring(index2, length2 + ":".length()); - int resId2 = getEmojiResId(emojiStr2); - if (resId2 > 0) { - Drawable emojiDrawable = res.getDrawable(resId2); - emojiDrawable.setBounds(0, 0, bound, bound); - // 构建图片span - ImageSpan imageSpan = new ImageSpan(emojiDrawable, str); - spannable.setSpan(imageSpan, index2, - length2 + ":".length(), - Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - } - } - } catch (Exception e) { - } - } - return spannable; - } - - public static void input2OSC(EditText editText, Emojicon emojicon) { - if (editText == null || emojicon == null) { - return; - } - int start = editText.getSelectionStart(); - int end = editText.getSelectionEnd(); - if (start < 0) { - // 没有多选时,直接在当前光标处添加 - editText.append(displayEmoji(editText.getResources(), - emojicon.getRemote())); - } else { - // 将已选中的部分替换为表情(当长按文字时会多选刷中很多文字) - Spannable str = displayEmoji(editText.getResources(), - emojicon.getRemote()); - editText.getText().replace(Math.min(start, end), - Math.max(start, end), str, 0, str.length()); - } - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/JSViewPager.java b/app/src/main/java/net/oschina/app/emoji/JSViewPager.java deleted file mode 100644 index b394e137c4a6b50638122ef8fc9162799e5c2a14..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/JSViewPager.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.content.Context; -import android.support.v4.view.ViewPager; -import android.util.AttributeSet; -import android.view.MotionEvent; - -/** - * 重写ViewPager触屏操作,修正了系统ViewPager与Activity触摸屏事件冲突 - * - * @author kymjs (http://www.kymjs.com) - * - */ -public class JSViewPager extends ViewPager { - - public JSViewPager(Context context) { - super(context); - } - - public JSViewPager(Context context, AttributeSet attrs) { - super(context, attrs); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - super.onTouchEvent(ev); - return false; - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/KJEmojiConfig.java b/app/src/main/java/net/oschina/app/emoji/KJEmojiConfig.java deleted file mode 100644 index 76b2abb4297619539500c9bf393f860b629b959c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/KJEmojiConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import net.oschina.app.R; - -/** - * - * @author kymjs (http://www.kymjs.com) - */ -public class KJEmojiConfig { - public static final String flag_Start = "["; - public static final String flag_End = "]"; - - public static final int COUNT_IN_PAGE = 20; // 每页显示多少个表情(要减去一个删除符号:例如这里是三行七列) - public static final int COLUMNS = 7; // 每页显示多少列 - - public static final int DELETE_EMOJI_ID = R.drawable.btn_del; -} diff --git a/app/src/main/java/net/oschina/app/emoji/KJEmojiFragment.java b/app/src/main/java/net/oschina/app/emoji/KJEmojiFragment.java deleted file mode 100644 index edfd264145a6ab8021d81bd895dc867a258c58fd..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/KJEmojiFragment.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.content.Context; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.view.ViewPager; -import android.text.Editable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.view.inputmethod.InputMethodManager; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.CompoundButton.OnCheckedChangeListener; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.RadioGroup; - -import net.oschina.app.R; -import net.oschina.app.emoji.SoftKeyboardStateHelper.SoftKeyboardStateListener; - -/** - * - * @author kymjs (http://www.kymjs.com) - * - */ -public class KJEmojiFragment extends Fragment implements - SoftKeyboardStateListener { - private LinearLayout mRootView; - - private View mEmojiTitle; - private LinearLayout mEmojiContent; - private RadioGroup mEmojiBottom; - private View[] mEmojiTabs; - - private EditText mEt; - private CheckBox mCBox; - private ViewPager mEmojiPager; - - private EmojiPagerAdapter adapter; - private OnSendClickListener listener; - public static int EMOJI_TAB_CONTENT; - - private SoftKeyboardStateHelper mKeyboardHelper; - - private CheckBox mCboxFlag; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - mRootView = (LinearLayout) inflater.inflate(R.layout.frag_main, - container, false); - initWidget(mRootView); - return mRootView; - } - - public LinearLayout getRootView() { - return mRootView; - } - - private void initWidget(View rootView) { - // title - mEmojiTitle = rootView.findViewById(R.id.emoji_title); - mCboxFlag = (CheckBox) mEmojiTitle.findViewById(R.id.emoji_title_flag); - mCboxFlag.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (listener != null) { - listener.onClickFlagButton(); - } - } - }); - - mEt = (EditText) mEmojiTitle.findViewById(R.id.emoji_titile_input); - mCBox = (CheckBox) mEmojiTitle.findViewById(R.id.emoji_title_menu); - mCBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, - boolean isChecked) { - if (isChecked) { - showEmojiKeyBoard(); - hideSoftKeyboard(); - } else { - showSoftKeyboard(); - } - } - }); - // bottom - mEmojiBottom = (RadioGroup) rootView.findViewById(R.id.emoji_bottom); - EMOJI_TAB_CONTENT = mEmojiBottom.getChildCount() - 1; // 减一是因为有一个删除按钮 - mEmojiTabs = new View[EMOJI_TAB_CONTENT]; - if (EMOJI_TAB_CONTENT <= 1) { // 只有一个分类的时候就不显示了 - mEmojiBottom.setVisibility(View.GONE); - } - for (int i = 0; i < EMOJI_TAB_CONTENT; i++) { - mEmojiTabs[i] = mEmojiBottom.getChildAt(i); - mEmojiTabs[i].setOnClickListener(getBottomBarClickListener(i)); - } - mEmojiBottom.findViewById(R.id.emoji_bottom_del).setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View v) { - InputHelper.backspace(mEt); - } - }); - - // content必须放在bottom下面初始化 - mEmojiContent = (LinearLayout) rootView - .findViewById(R.id.emoji_content); - mEmojiPager = (ViewPager) mEmojiContent.findViewById(R.id.emoji_pager); - adapter = new EmojiPagerAdapter(getFragmentManager()); - mEmojiPager.setAdapter(adapter); - - mKeyboardHelper = new SoftKeyboardStateHelper(getActivity().getWindow() - .getDecorView()); - mKeyboardHelper.addSoftKeyboardStateListener(this); - if (getActivity() instanceof OnSendClickListener) { - listener = (OnSendClickListener) getActivity(); - } - if (listener != null) { - mEmojiTitle.findViewById(R.id.emoji_title_send).setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View v) { - listener.onClickSendButton(mEt.getText()); - mEt.setHint("说点什么吧"); - hideAllKeyBoard(); - } - }); - } - } - - /** - * 底部栏点击事件监听器 - * - * @param index - * @return - */ - private OnClickListener getBottomBarClickListener(final int index) { - return new OnClickListener() { - @Override - public void onClick(View v) { - mEmojiPager.setCurrentItem(index); - } - }; - } - - public void setOnSendClickListener(OnSendClickListener l) { - this.listener = l; - } - - /******************************* preference *************************************/ - - public void clean() { - mEt.setText(null); - mEt.setTag(null); - } - - public void hideAllKeyBoard() { - hideEmojiKeyBoard(); - hideSoftKeyboard(); - } - - /** - * 隐藏Emoji并显示软键盘 - */ - public void hideEmojiKeyBoard() { - mEmojiBottom.setVisibility(View.GONE); - mEmojiContent.setVisibility(View.GONE); - mCBox.setChecked(false); - } - - /** - * 显示Emoji并隐藏软键盘 - */ - public void showEmojiKeyBoard() { - mEmojiContent.setVisibility(View.VISIBLE); - if (EMOJI_TAB_CONTENT > 1) { - mEmojiBottom.setVisibility(View.VISIBLE); - } - mCBox.setChecked(true); - } - - /** - * 隐藏软键盘 - */ - public void hideSoftKeyboard() { - ((InputMethodManager) getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow( - mEt.getWindowToken(), 0); - } - - /** - * 显示软键盘 - */ - public void showSoftKeyboard() { - mEt.requestFocus(); - ((InputMethodManager) getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE)).showSoftInput(mEt, - InputMethodManager.SHOW_FORCED); - } - - public View getEmojiTitle() { - return mEmojiTitle; - } - - public Editable getTextString() { - return mEt.getText(); - } - - public EditText getEditText() { - return mEt; - } - - public boolean isShowEmojiKeyBoard() { - if (mCBox == null) { - return false; - } else { - return mCBox.isChecked(); - } - } - - /** - * 当软键盘显示时回调 - */ - @Override - public void onSoftKeyboardOpened(int keyboardHeightInPx) { - if (mEmojiBottom != null && mEmojiContent != null) { - mEmojiBottom.setVisibility(View.GONE); - mEmojiContent.setVisibility(View.GONE); - } - if (mCBox != null) { - mCBox.setChecked(false); - } - } - - public void hideFlagButton() { - if (mCboxFlag != null) { - mCboxFlag.setVisibility(View.GONE); - } - } - - @Override - public void onSoftKeyboardClosed() {} - - @Override - public void onStop() { - super.onStop(); - hideSoftKeyboard(); - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/OnEmojiClickListener.java b/app/src/main/java/net/oschina/app/emoji/OnEmojiClickListener.java deleted file mode 100644 index 059cdfa0bebf2ff919c581728041ddf8c8b7c38e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/OnEmojiClickListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.oschina.app.emoji; - -import android.view.View; - -public interface OnEmojiClickListener { - void onDeleteButtonClick(View v); - - void onEmojiClick(Emojicon v); -} diff --git a/app/src/main/java/net/oschina/app/emoji/OnSendClickListener.java b/app/src/main/java/net/oschina/app/emoji/OnSendClickListener.java deleted file mode 100644 index 2cf1791fe6d7b473b6523f6bbd4c9097cf86dcb4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/OnSendClickListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.text.Editable; - -/** - * - * @author kymjs (http://www.kymjs.com) - */ -public interface OnSendClickListener { - void onClickSendButton(Editable str); - - void onClickFlagButton(); -} diff --git a/app/src/main/java/net/oschina/app/emoji/ScrollGridView.java b/app/src/main/java/net/oschina/app/emoji/ScrollGridView.java deleted file mode 100644 index 30686db45da6326f7b836abd20c4646e81b51ca4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/ScrollGridView.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.GridView; - -/** - * - * @author kymjs (http://www.kymjs.com) - */ -public class ScrollGridView extends GridView { - - public ScrollGridView(Context context) { - super(context); - } - - public ScrollGridView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ScrollGridView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - int height = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, - MeasureSpec.AT_MOST); - super.onMeasure(widthMeasureSpec, height); - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/SoftKeyboardStateHelper.java b/app/src/main/java/net/oschina/app/emoji/SoftKeyboardStateHelper.java deleted file mode 100644 index 87dbf2cb7ef9afe94f287aea9a4a777b23d80a1b..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/SoftKeyboardStateHelper.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2015, 张涛. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package net.oschina.app.emoji; - -import java.util.LinkedList; -import java.util.List; - -import android.graphics.Rect; -import android.view.View; -import android.view.ViewTreeObserver; - -/** - * - * @author kymjs (http://www.kymjs.com) - */ -public class SoftKeyboardStateHelper implements - ViewTreeObserver.OnGlobalLayoutListener { - - public interface SoftKeyboardStateListener { - void onSoftKeyboardOpened(int keyboardHeightInPx); - - void onSoftKeyboardClosed(); - } - - private final List listeners = new LinkedList(); - private final View activityRootView; - private int lastSoftKeyboardHeightInPx; - private boolean isSoftKeyboardOpened; - - public SoftKeyboardStateHelper(View activityRootView) { - this(activityRootView, false); - } - - public SoftKeyboardStateHelper(View activityRootView, - boolean isSoftKeyboardOpened) { - this.activityRootView = activityRootView; - this.isSoftKeyboardOpened = isSoftKeyboardOpened; - activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(this); - } - - @Override - public void onGlobalLayout() { - final Rect r = new Rect(); - // r will be populated with the coordinates of your view that area still - // visible. - activityRootView.getWindowVisibleDisplayFrame(r); - - final int heightDiff = activityRootView.getRootView().getHeight() - - (r.bottom - r.top); - if (!isSoftKeyboardOpened && heightDiff > 100) { // if more than 100 - // pixels, its probably - // a keyboard... - isSoftKeyboardOpened = true; - notifyOnSoftKeyboardOpened(heightDiff); - } else if (isSoftKeyboardOpened && heightDiff < 100) { - isSoftKeyboardOpened = false; - notifyOnSoftKeyboardClosed(); - } - } - - public void setIsSoftKeyboardOpened(boolean isSoftKeyboardOpened) { - this.isSoftKeyboardOpened = isSoftKeyboardOpened; - } - - public boolean isSoftKeyboardOpened() { - return isSoftKeyboardOpened; - } - - /** - * Default value is zero (0) - * - * @return last saved keyboard height in px - */ - public int getLastSoftKeyboardHeightInPx() { - return lastSoftKeyboardHeightInPx; - } - - public void addSoftKeyboardStateListener(SoftKeyboardStateListener listener) { - listeners.add(listener); - } - - public void removeSoftKeyboardStateListener( - SoftKeyboardStateListener listener) { - listeners.remove(listener); - } - - private void notifyOnSoftKeyboardOpened(int keyboardHeightInPx) { - this.lastSoftKeyboardHeightInPx = keyboardHeightInPx; - - for (SoftKeyboardStateListener listener : listeners) { - if (listener != null) { - listener.onSoftKeyboardOpened(keyboardHeightInPx); - } - } - } - - private void notifyOnSoftKeyboardClosed() { - for (SoftKeyboardStateListener listener : listeners) { - if (listener != null) { - listener.onSoftKeyboardClosed(); - } - } - } -} diff --git a/app/src/main/java/net/oschina/app/emoji/ToolbarFragment.java b/app/src/main/java/net/oschina/app/emoji/ToolbarFragment.java deleted file mode 100644 index cdf1b5d69f33d527bf954505710e5f1de6ba3be5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/emoji/ToolbarFragment.java +++ /dev/null @@ -1,125 +0,0 @@ -package net.oschina.app.emoji; - -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; - -public class ToolbarFragment extends BaseFragment { - - public interface OnActionClickListener { - public void onActionClick(ToolAction action); - } - - public enum ToolAction { - ACTION_CHANGE, ACTION_WRITE_COMMENT, ACTION_VIEW_COMMENT, ACTION_FAVORITE, ACTION_SHARE, ACTION_REPORT - } - - private OnActionClickListener mActionListener; - - private View mActionWriteComment, mActionViewComment, mActionFavorite, - mActionReport, mActionShare; - - private View mIvFavorite; - private boolean mFavorite; - - private int mCommentCount; - - private TextView mTvCommentCount; - - private View mRootView; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - mRootView = inflater.inflate(R.layout.fragment_detail_tool_bar, - container, false); - initView(mRootView); - return mRootView; - } - - public View getRootView() { - return mRootView; - } - - @Override - public void initView(View view) { - view.findViewById(R.id.btn_change).setOnClickListener(this); - mActionWriteComment = view.findViewById(R.id.write_comment_layout); - mActionWriteComment.setOnClickListener(this); - - mActionFavorite = view.findViewById(R.id.favor_layout); - mActionFavorite.setOnClickListener(this); - - mActionViewComment = view.findViewById(R.id.view_comment_layout); - mActionViewComment.setOnClickListener(this); - - mActionShare = view.findViewById(R.id.repost_layout); - mActionShare.setOnClickListener(this); - - mActionReport = view.findViewById(R.id.report_layout); - mActionReport.setOnClickListener(this); - - mIvFavorite = view.findViewById(R.id.action_favor); - mIvFavorite.setSelected(mFavorite); - - mTvCommentCount = (TextView) view - .findViewById(R.id.action_comment_count); - mTvCommentCount.setText(String.valueOf(mCommentCount)); - - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - ToolAction action = null; - if (id == R.id.btn_change) { - action = ToolAction.ACTION_CHANGE; - } else if (id == R.id.write_comment_layout) { - action = ToolAction.ACTION_WRITE_COMMENT; - } else if (id == R.id.view_comment_layout) { - action = ToolAction.ACTION_VIEW_COMMENT; - } else if (id == R.id.repost_layout) { - action = ToolAction.ACTION_SHARE; - } else if (id == R.id.report_layout) { - action = ToolAction.ACTION_REPORT; - } else if (id == R.id.favor_layout) { - action = ToolAction.ACTION_FAVORITE; - } - if (action != null && mActionListener != null) { - mActionListener.onActionClick(action); - } - } - - public void setOnActionClickListener(OnActionClickListener lis) { - mActionListener = lis; - } - - public void setCommentCount(int count) { - mCommentCount = count; - if (mTvCommentCount != null) { - mTvCommentCount.setText(String.valueOf(mCommentCount)); - mTvCommentCount.setVisibility(mCommentCount > 0 ? View.VISIBLE - : View.GONE); - } - } - - public void setFavorite(boolean favorite) { - mFavorite = favorite; - if (mIvFavorite != null) { - mIvFavorite.setSelected(favorite); - } - } - - public void showReportButton() { - mActionReport.setVisibility(View.VISIBLE); - } - - @Override - public void initData() {} -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/fragment/AboutOSCFragment.java b/app/src/main/java/net/oschina/app/fragment/AboutOSCFragment.java deleted file mode 100644 index 892465ce3527b91a5a91630517e9b5dda5b8bef9..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/AboutOSCFragment.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.oschina.app.fragment; - -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.SimpleBackPage; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.UpdateManager; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class AboutOSCFragment extends BaseFragment { - - @InjectView(R.id.tv_version) - TextView mTvVersionStatus; - - @InjectView(R.id.tv_version_name) - TextView mTvVersionName; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_about, container, false); - ButterKnife.inject(this, view); - initView(view); - initData(); - return view; - } - - @Override - public void initView(View view) { - view.findViewById(R.id.rl_check_update).setOnClickListener(this); - view.findViewById(R.id.rl_feedback).setOnClickListener(this); - view.findViewById(R.id.rl_grade).setOnClickListener(this); - view.findViewById(R.id.rl_gitapp).setOnClickListener(this); - view.findViewById(R.id.tv_oscsite).setOnClickListener(this); - view.findViewById(R.id.tv_knowmore).setOnClickListener(this); - } - - @Override - public void initData() { - mTvVersionName.setText("V " + TDevice.getVersionName()); - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - switch (id) { - case R.id.rl_check_update: - onClickUpdate(); - break; - case R.id.rl_feedback: - showFeedBack(); - break; - case R.id.rl_grade: - TDevice.openAppInMarket(getActivity()); - break; - case R.id.rl_gitapp: - boolean res = TDevice.openAppActivity(getActivity(), - "net.oschina.gitapp", "net.oschina.gitapp.WelcomePage"); - - if (!res) { - if (!TDevice.isHaveMarket(getActivity())) { - UIHelper.openSysBrowser(getActivity(), - "http://git.oschina.net/appclient"); - } else { - TDevice.gotoMarket(getActivity(), "net.oschina.gitapp"); - } - } - break; - case R.id.tv_oscsite: - UIHelper.openBrowser(getActivity(), "https://www.oschina.net"); - break; - case R.id.tv_knowmore: - UIHelper.openBrowser(getActivity(), - "https://www.oschina.net/home/aboutosc"); - break; - default: - break; - } - } - - private void onClickUpdate() { - new UpdateManager(getActivity(), true).checkUpdate(); - } - - private void showFeedBack() { - // TDevice.sendEmail(getActivity(), "用户反馈-OSC Android客户端", "", - // "apposchina@163.com"); - UIHelper.showSimpleBack(getActivity(), SimpleBackPage.FEED_BACK); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/ActiveFragment.java b/app/src/main/java/net/oschina/app/fragment/ActiveFragment.java deleted file mode 100644 index 5657fc4b35c1d18561d1f196817e9f00fee4a247..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/ActiveFragment.java +++ /dev/null @@ -1,212 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.ActiveAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Active; -import net.oschina.app.bean.ActiveList; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.Notice; -import net.oschina.app.service.NoticeUtils; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.viewpagerfragment.NoticeViewPagerFragment; - -import java.io.InputStream; -import java.io.Serializable; - -/** - * 动态fragment - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @author kymjs (https://github.com/kymjs) - * @created 2014年10月22日 下午3:35:43 - * - */ -public class ActiveFragment extends BaseListFragment implements - OnItemLongClickListener { - - protected static final String TAG = ActiveFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "active_list"; - private boolean mIsWatingLogin; // 还没登陆 - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (mErrorLayout != null) { - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mReceiver, filter); - } - - @Override - public void onDestroy() { - getActivity().unregisterReceiver(mReceiver); - super.onDestroy(); - } - - @Override - public void onResume() { - if (mIsWatingLogin) { - mCurrentPage = 0; - mState = STATE_REFRESH; - requestData(false); - } - refreshNotice(); - super.onResume(); - } - - /** - * 开始刷新请求 - */ - private void refreshNotice() { - Notice notice = MainActivity.mNotice; - if (notice == null) { - return; - } - if (notice.getAtmeCount() > 0 && mCatalog == ActiveList.CATALOG_ATME) { - onRefresh(); - } else if (notice.getReviewCount() > 0 - && mCatalog == ActiveList.CATALOG_COMMENT) { - onRefresh(); - } - } - - @Override - protected ActiveAdapter getListAdapter() { - return new ActiveAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return new StringBuffer(CACHE_KEY_PREFIX + mCatalog).append( - AppContext.getInstance().getLoginUid()).toString(); - } - - @Override - protected ActiveList parseList(InputStream is) { - ActiveList list = XmlUtils.toBean(ActiveList.class, is); - return list; - } - - @Override - protected ActiveList readList(Serializable seri) { - return ((ActiveList) seri); - } - - @Override - public void initView(View view) { - if (mCatalog == ActiveList.CATALOG_LASTEST) { - setHasOptionsMenu(true); - } - super.initView(view); - mListView.setOnItemLongClickListener(this); - mListView.setOnItemClickListener(this); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(false); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - }); - if (AppContext.getInstance().isLogin()) { - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - @Override - protected void requestData(boolean refresh) { - if (AppContext.getInstance().isLogin()) { - mIsWatingLogin = false; - super.requestData(refresh); - } else { - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected void sendRequestData() { - OSChinaApi.getActiveList(AppContext.getInstance().getLoginUid(), - mCatalog, mCurrentPage, mHandler); - } - - @Override - protected void onRefreshNetworkSuccess() { - if (AppContext.getInstance().isLogin()) { - if (0 == NoticeViewPagerFragment.sCurrentPage) { - NoticeUtils.clearNotice(Notice.TYPE_ATME); - } else if (1 == NoticeViewPagerFragment.sCurrentPage - || NoticeViewPagerFragment.sShowCount[1] > 0) { // 如果当前显示的是评论页,则发送评论页已被查看的Http请求 - NoticeUtils.clearNotice(Notice.TYPE_COMMENT); - } else { - NoticeUtils.clearNotice(Notice.TYPE_ATME); - } - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Active active = mAdapter.getItem(position); - if (active != null) - UIHelper.showActiveRedirect(view.getContext(), active); - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - final Active active = mAdapter.getItem(position); - if (active == null) - return false; - String[] items = new String[] { getResources().getString(R.string.copy) }; - DialogHelp.getSelectDialog(getActivity(), items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(active.getMessage())); - } - }).show(); - return true; - } - - @Override - protected long getAutoRefreshTime() { - // 最新动态,即是好友圈 - if (mCatalog == ActiveList.CATALOG_LASTEST) { - return 5 * 60; - } - return super.getAutoRefreshTime(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/BlogDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/BlogDetailFragment.java deleted file mode 100644 index 49a31ac2711b163731458bfb39062255904854a1..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/BlogDetailFragment.java +++ /dev/null @@ -1,133 +0,0 @@ -package net.oschina.app.fragment; - -import android.text.Editable; -import android.text.TextUtils; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.CommonDetailFragment; -import net.oschina.app.bean.Blog; -import net.oschina.app.bean.BlogDetail; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.URLsUtils; -import net.oschina.app.util.XmlUtils; - -import java.io.InputStream; - -/** - * Created by 火蚁 on 15/5/25. - */ -public class BlogDetailFragment extends CommonDetailFragment { - @Override - protected String getCacheKey() { - return "blog_" + mId; - } - - @Override - protected void sendRequestDataForNet() { - OSChinaApi.getBlogDetail(mId, mDetailHeandler); - } - - @Override - protected Blog parseData(InputStream is) { - return XmlUtils.toBean(BlogDetail.class, is).getBlog(); - } - - @Override - protected String getWebViewBody(Blog detail) { - StringBuffer body = new StringBuffer(); - body.append(UIHelper.WEB_STYLE).append(UIHelper.WEB_LOAD_IMAGES); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - // 添加title - body.append(String.format("

%s
", mDetail.getTitle())); - // 添加作者和时间 - String time = StringUtils.friendly_time(mDetail.getPubDate()); - String author = String.format("%s", mDetail.getAuthorId(), mDetail.getAuthor()); - body.append(String.format("
%s    %s
", author, time)); - // 添加图片点击放大支持 - body.append(UIHelper.setHtmlCotentSupportImagePreview(mDetail.getBody())); - // 封尾 - body.append(""); - return body.toString(); - } - - @Override - protected void showCommentView() { - if (mDetail != null) { - UIHelper.showBlogComment(getActivity(), mId, - mDetail.getAuthorId()); - } - } - - @Override - protected int getCommentType() { - return CommentList.CATALOG_MESSAGE; - } - - @Override - protected String getShareTitle() { - return mDetail.getTitle(); - } - - @Override - protected String getShareContent() { - return StringUtils.getSubString(0, 55, - getFilterHtmlBody(mDetail.getBody())); - } - - @Override - protected String getShareUrl() { - return String.format(URLsUtils.URL_MOBILE + "blog/%s", mId); - } - - @Override - protected int getFavoriteTargetType() { - return FavoriteList.TYPE_BLOG; - } - - @Override - protected int getFavoriteState() { - return mDetail.getFavorite(); - } - - @Override - protected void updateFavoriteChanged(int newFavoritedState) { - mDetail.setFavorite(newFavoritedState); - saveCache(mDetail); - } - - @Override - protected int getCommentCount() { - return mDetail.getCommentCount(); - } - - @Override - public void onClickSendButton(Editable str) { - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (TextUtils.isEmpty(str)) { - AppContext.showToastShort(R.string.tip_comment_content_empty); - return; - } - showWaitDialog(R.string.progress_submit); - OSChinaApi.publicBlogComment(mId, AppContext.getInstance() - .getLoginUid(), str.toString(), mCommentHandler); - } - - @Override - protected String getRepotrUrl() { - return mDetail.getUrl(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/BlogFragment.java b/app/src/main/java/net/oschina/app/fragment/BlogFragment.java deleted file mode 100644 index ebd209f7497911bd6085455eefc687e723be15ae..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/BlogFragment.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.adapter.BlogAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Blog; -import net.oschina.app.bean.BlogList; -import net.oschina.app.interf.OnTabReselectListener; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -/** - * 博客区中单一模块的展示 - * - * @author kymjs(kymjs123@gmail.com) - */ -public class BlogFragment extends BaseListFragment implements - OnTabReselectListener { - - public static final String BUNDLE_BLOG_TYPE = "BUNDLE_BLOG_TYPE"; - - protected static final String TAG = BlogFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "bloglist_"; - - private String blogType; - - @Override - protected BlogAdapter getListAdapter() { - return new BlogAdapter(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - blogType = args.getString(BUNDLE_BLOG_TYPE); - } - } - - /** - * 获取当前展示页面的缓存数据 - */ - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + blogType; - } - - @Override - protected BlogList parseList(InputStream is) throws Exception { - BlogList list = XmlUtils.toBean(BlogList.class, is); - return list; - } - - @Override - protected BlogList readList(Serializable seri) { - return ((BlogList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getBlogList(blogType, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Blog blog = mAdapter.getItem(position); - if (blog != null) { - UIHelper.showBlogDetail(getActivity(), blog.getId(), - blog.getCommentCount()); - // 保存到已读列表 - saveToReadedList(view, BlogList.PREF_READED_BLOG_LIST, blog.getId() - + ""); - } - } - - @Override - public void onTabReselect() { - onRefresh(); - } - - @Override - protected long getAutoRefreshTime() { - // TODO Auto-generated method stub - // 最新博客 - if (blogType.equals(BlogList.CATALOG_LATEST)) { - return 2 * 60 * 60; - } - return super.getAutoRefreshTime(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/BrowserFragment.java b/app/src/main/java/net/oschina/app/fragment/BrowserFragment.java deleted file mode 100644 index 4fe858e6f11ba70ea852fece339b374802f12e49..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/BrowserFragment.java +++ /dev/null @@ -1,355 +0,0 @@ -package net.oschina.app.fragment; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.content.Intent; -import android.graphics.Bitmap; -import android.net.Uri; -import android.os.Bundle; -import android.view.GestureDetector; -import android.view.GestureDetector.SimpleOnGestureListener; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnTouchListener; -import android.view.ViewGroup; -import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; -import android.view.animation.AnimationUtils; -import android.webkit.CookieManager; -import android.webkit.WebChromeClient; -import android.webkit.WebSettings; -import android.webkit.WebSettings.PluginState; -import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ProgressBar; - -import net.oschina.app.AppConfig; -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.ui.ShareDialog; -import net.oschina.app.ui.SimpleBackActivity; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 浏览器界面 - * - * @author kymjs(kymjs123@gmail.com) - */ -@SuppressLint("NewApi") -public class BrowserFragment extends BaseFragment { - @InjectView(R.id.webview) - WebView mWebView; - @InjectView(R.id.browser_back) - ImageView mImgBack; - @InjectView(R.id.browser_forward) - ImageView mImgForward; - @InjectView(R.id.browser_refresh) - ImageView mImgRefresh; - @InjectView(R.id.browser_system_browser) - ImageView mImgSystemBrowser; - @InjectView(R.id.browser_bottom) - LinearLayout mLayoutBottom; - @InjectView(R.id.progress) - ProgressBar mProgress; - - public static final String BROWSER_KEY = "browser_url"; - public static final String DEFAULT = "http://www.oschina.net/"; - - private int TAG = 1; // 双击事件需要 - private Activity aty; - private String mCurrentUrl = DEFAULT; - - private Animation animBottomIn, animBottomOut; - private GestureDetector mGestureDetector; - private CookieManager cookie; - - @Override - public void onClick(View v) { - switch (v.getId()) { - case R.id.browser_back: - mWebView.goBack(); - break; - case R.id.browser_forward: - mWebView.goForward(); - break; - case R.id.browser_refresh: - mWebView.loadUrl(mWebView.getUrl()); - break; - case R.id.browser_system_browser: - try { - // 启用外部浏览器 - Uri uri = Uri.parse(mCurrentUrl); - Intent it = new Intent(Intent.ACTION_VIEW, uri); - aty.startActivity(it); - } catch (Exception e) { - AppContext.showToast("网页地址错误"); - } - break; - } - } - - @Override - public void initView(View view) { - initWebView(); - initBarAnim(); - mImgBack.setOnClickListener(this); - mImgForward.setOnClickListener(this); - mImgRefresh.setOnClickListener(this); - mImgSystemBrowser.setOnClickListener(this); - - mGestureDetector = new GestureDetector(aty, new MyGestureListener()); - mWebView.loadUrl(mCurrentUrl); - mWebView.setOnTouchListener(new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - return mGestureDetector.onTouchEvent(event); - } - }); - } - - @Override - public void onResume() { - super.onResume(); - mWebView.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - mWebView.onPause(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - mWebView.destroy(); - } - - @Override - public void initData() { - Bundle bundle = getActivity().getIntent().getBundleExtra( - SimpleBackActivity.BUNDLE_KEY_ARGS); - if (bundle != null) { - mCurrentUrl = bundle.getString(BROWSER_KEY); - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - View rootView = inflater.inflate(R.layout.fragment_browser, container, - false); - aty = getActivity(); - ButterKnife.inject(this, rootView); - initData(); - initView(rootView); - return rootView; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setHasOptionsMenu(true); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.browser_menu, menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.public_menu_shared: - showSharedDialog(); - break; - } - return true; - } - - /** - * 初始化上下栏的动画并设置结束监听事件 - */ - private void initBarAnim() { - animBottomIn = AnimationUtils.loadAnimation(aty, R.anim.anim_bottom_in); - animBottomOut = AnimationUtils.loadAnimation(aty, - R.anim.anim_bottom_out); - animBottomIn.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationRepeat(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - mLayoutBottom.setVisibility(View.VISIBLE); - } - }); - animBottomOut.setAnimationListener(new AnimationListener() { - @Override - public void onAnimationStart(Animation animation) {} - - @Override - public void onAnimationRepeat(Animation animation) {} - - @Override - public void onAnimationEnd(Animation animation) { - mLayoutBottom.setVisibility(View.GONE); - } - }); - } - - /** - * 打开分享dialog - */ - private void showSharedDialog() { - final ShareDialog dialog = new ShareDialog(getActivity()); - dialog.setCancelable(true); - dialog.setCanceledOnTouchOutside(true); - dialog.setTitle(R.string.share_to); - dialog.setShareInfo(getShareTitle(), getShareContent(), mCurrentUrl); - dialog.show(); - } - - /** - * 载入链接之前会被调用 - * - * @param view - * WebView - * @param url - * 链接地址 - */ - protected void onUrlLoading(WebView view, String url) { - mProgress.setVisibility(View.VISIBLE); - cookie.setCookie(url, - AppContext.getInstance().getProperty(AppConfig.CONF_COOKIE)); - } - - /** - * 链接载入成功后会被调用 - * - * @param view - * WebView - * @param url - * 链接地址 - */ - protected void onUrlFinished(WebView view, String url) { - mCurrentUrl = url; - mProgress.setVisibility(View.GONE); - } - - /** - * 当前WebView显示页面的标题 - * - * @param view - * WebView - * @param title - * web页面标题 - */ - protected void onWebTitle(WebView view, String title) { - if (aty != null && mWebView != null) { // 必须做判断,由于webview加载属于耗时操作,可能会本Activity已经关闭了才被调用 - ((BaseActivity) aty).setActionBarTitle(mWebView.getTitle()); - } - } - - /** - * 当前WebView显示页面的图标 - * - * @param view - * WebView - * @param icon - * web页面图标 - */ - protected void onWebIcon(WebView view, Bitmap icon) {} - - /** - * 初始化浏览器设置信息 - */ - private void initWebView() { - cookie = CookieManager.getInstance(); - WebSettings webSettings = mWebView.getSettings(); - webSettings.setJavaScriptEnabled(true); // 启用支持javascript - webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);// 优先使用缓存 - webSettings.setAllowFileAccess(true);// 可以访问文件 - webSettings.setBuiltInZoomControls(true);// 支持缩放 - if (android.os.Build.VERSION.SDK_INT >= 11) { - webSettings.setPluginState(PluginState.ON); - webSettings.setDisplayZoomControls(false);// 支持缩放 - } - mWebView.setWebViewClient(new MyWebViewClient()); - mWebView.setWebChromeClient(new MyWebChromeClient()); - } - - private class MyWebChromeClient extends WebChromeClient { - @Override - public void onReceivedTitle(WebView view, String title) { - super.onReceivedTitle(view, title); - onWebTitle(view, title); - } - - @Override - public void onReceivedIcon(WebView view, Bitmap icon) { - super.onReceivedIcon(view, icon); - onWebIcon(view, icon); - } - - @Override - public void onProgressChanged(WebView view, int newProgress) { // 进度 - super.onProgressChanged(view, newProgress); - if (newProgress > 90) { - mProgress.setVisibility(View.GONE); - } - } - } - - private class MyWebViewClient extends WebViewClient { - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - onUrlLoading(view, url); - boolean flag = super.shouldOverrideUrlLoading(view, url); - mCurrentUrl = url; - return flag; - } - - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - onUrlFinished(view, url); - } - } - - private class MyGestureListener extends SimpleOnGestureListener { - - @Override - public boolean onDoubleTap(MotionEvent e) {// webview的双击事件 - if (TAG % 2 == 0) { - TAG++; - mLayoutBottom.startAnimation(animBottomIn); - } else { - TAG++; - mLayoutBottom.startAnimation(animBottomOut); - } - return super.onDoubleTap(e); - } - } - - private String getShareTitle() { - return mWebView.getTitle(); - } - - private String getShareContent() { - return mWebView.getTitle(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/CommentFrament.java b/app/src/main/java/net/oschina/app/fragment/CommentFrament.java deleted file mode 100644 index 1667c7196c6dc00c8e27397b36bb1e6e0b1df0e7..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/CommentFrament.java +++ /dev/null @@ -1,337 +0,0 @@ -package net.oschina.app.fragment; - -import android.app.Activity; -import android.content.DialogInterface; -import android.content.Intent; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.CommentAdapter; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.BlogCommentList; -import net.oschina.app.bean.Comment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.ListEntity; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.emoji.OnSendClickListener; -import net.oschina.app.ui.DetailActivity; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; - -public class CommentFrament extends BaseListFragment implements - OnItemLongClickListener, OnSendClickListener { - - public static final String BUNDLE_KEY_CATALOG = "BUNDLE_KEY_CATALOG"; - public static final String BUNDLE_KEY_BLOG = "BUNDLE_KEY_BLOG"; - public static final String BUNDLE_KEY_ID = "BUNDLE_KEY_ID"; - public static final String BUNDLE_KEY_OWNER_ID = "BUNDLE_KEY_OWNER_ID"; - protected static final String TAG = CommentFrament.class.getSimpleName(); - private static final String BLOG_CACHE_KEY_PREFIX = "blogcomment_list"; - private static final String CACHE_KEY_PREFIX = "comment_list"; - private static final int REQUEST_CODE = 0x10; - - private int mId, mOwnerId; - private boolean mIsBlogComment; - private DetailActivity outAty; - - private final AsyncHttpResponseHandler mCommentHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - ResultBean rsb = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)); - Result res = rsb.getResult(); - if (res.OK()) { - hideWaitDialog(); - AppContext.showToastShort(R.string.comment_publish_success); - - mAdapter.addItem(0, rsb.getComment()); - mAdapter.notifyDataSetChanged(); - UIHelper.sendBroadCastCommentChanged(getActivity(), - mIsBlogComment, mId, mCatalog, Comment.OPT_ADD, - rsb.getComment()); - onRefresh(); - outAty.emojiFragment.clean(); - } else { - hideWaitDialog(); - AppContext.showToastShort(res.getErrorMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - hideWaitDialog(); - AppContext.showToastShort(R.string.comment_publish_faile); - } - }; - - @Override - public void initView(View view) { - super.initView(view); - mListView.setOnItemLongClickListener(this); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - outAty = (DetailActivity) getActivity(); - return super.onCreateView(inflater, container, savedInstanceState); - } - - @Override - public void onCreate(android.os.Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getActivity().getIntent().getExtras(); - if (args != null) { - mCatalog = args.getInt(BUNDLE_KEY_CATALOG, 0); - mId = args.getInt(BUNDLE_KEY_ID, 0); - mOwnerId = args.getInt(BUNDLE_KEY_OWNER_ID, 0); - mIsBlogComment = args.getBoolean(BUNDLE_KEY_BLOG, false); - } - - if (!mIsBlogComment && mCatalog == CommentList.CATALOG_POST) { - ((BaseActivity) getActivity()) - .setActionBarTitle(R.string.post_answer); - } - - int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - getActivity().getWindow().setSoftInputMode(mode); - } - - @Override - public void onResume() { - super.onResume(); - outAty.emojiFragment.hideFlagButton(); - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) { - Comment comment = data - .getParcelableExtra(Comment.BUNDLE_KEY_COMMENT); - if (comment != null) { - mAdapter.addItem(0, comment); - } - } - super.onActivityResult(requestCode, resultCode, data); - } - - @Override - protected CommentAdapter getListAdapter() { - return new CommentAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - String str = mIsBlogComment ? BLOG_CACHE_KEY_PREFIX : CACHE_KEY_PREFIX; - return new StringBuilder(str).append("_").append(mId).append("_Owner") - .append(mOwnerId).toString(); - } - - @Override - protected ListEntity parseList(InputStream is) throws Exception { - if (mIsBlogComment) { - return XmlUtils.toBean(BlogCommentList.class, is); - } else { - return XmlUtils.toBean(CommentList.class, is); - } - } - - @Override - protected ListEntity readList(Serializable seri) { - if (mIsBlogComment) - return ((BlogCommentList) seri); - return ((CommentList) seri); - } - - @Override - protected void sendRequestData() { - if (mIsBlogComment) { - OSChinaApi.getBlogCommentList(mId, mCurrentPage, mHandler); - } else { - OSChinaApi.getCommentList(mId, mCatalog, mCurrentPage, mHandler); - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - final Comment comment = mAdapter.getItem(position); - if (comment == null) - return; - outAty.emojiFragment.getEditText().setTag(comment); - outAty.emojiFragment.getEditText().setHint("回复:" + comment.getAuthor()); - outAty.emojiFragment.showSoftKeyboard(); - } - - private void handleDeleteComment(Comment comment) { - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - AppContext.showToastShort(R.string.deleting); - if (mIsBlogComment) { - OSChinaApi.deleteBlogComment( - AppContext.getInstance().getLoginUid(), mId, - comment.getId(), comment.getAuthorId(), mOwnerId, - new DeleteOperationResponseHandler(comment)); - } else { - OSChinaApi - .deleteComment(mId, mCatalog, comment.getId(), - comment.getAuthorId(), - new DeleteOperationResponseHandler(comment)); - } - } - - class DeleteOperationResponseHandler extends OperationResponseHandler { - - DeleteOperationResponseHandler(Object... args) { - super(args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) { - try { - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res.OK()) { - AppContext.showToastShort(R.string.delete_success); - mAdapter.removeItem(args[0]); - } else { - AppContext.showToastShort(res.getErrorMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(code, e.getMessage(), args); - } - } - - @Override - public void onFailure(int code, String errorMessage, Object[] args) { - AppContext.showToastShort(R.string.delete_faile); - } - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - final Comment item = mAdapter.getItem(position); - if (item == null) - return false; - int itemsLen = item.getAuthorId() == AppContext.getInstance() - .getLoginUid() ? 2 : 1; - String[] items = new String[itemsLen]; - items[0] = getResources().getString(R.string.copy); - if (itemsLen == 2) { - items[1] = getResources().getString(R.string.delete); - } - DialogHelp.getSelectDialog(getActivity(), items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(item - .getContent())); - } else if (i == 1) { - handleDeleteComment(item); - } - } - }).show(); - return true; - } - - @Override - public void onClickSendButton(Editable text) { - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (TextUtils.isEmpty(text)) { - AppContext.showToastShort(R.string.tip_comment_content_empty); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (outAty.emojiFragment.getEditText().getTag() != null) { - handleReplyComment((Comment) outAty.emojiFragment.getEditText().getTag(), - text.toString()); - } else { - sendReply(text.toString()); - } - } - - private void sendReply(String text) { - showWaitDialog(R.string.progress_submit); - if (mIsBlogComment) { - OSChinaApi.publicBlogComment(mId, AppContext.getInstance() - .getLoginUid(), text, mCommentHandler); - } else { - OSChinaApi.publicComment(mCatalog, mId, AppContext.getInstance() - .getLoginUid(), text, 1, mCommentHandler); - } - } - - private void handleReplyComment(Comment comment, String text) { - showWaitDialog(R.string.progress_submit); - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (mIsBlogComment) { - OSChinaApi.replyBlogComment(mId, AppContext.getInstance() - .getLoginUid(), text, comment.getId(), comment - .getAuthorId(), mCommentHandler); - } else { - OSChinaApi.replyComment(mId, mCatalog, comment.getId(), comment - .getAuthorId(), AppContext.getInstance().getLoginUid(), - text, mCommentHandler); - } - } - - @Override - public boolean onBackPressed() { - if (outAty.emojiFragment.isShowEmojiKeyBoard()) { - outAty.emojiFragment.hideAllKeyBoard(); - return true; - } - if (outAty.emojiFragment.getEditText().getTag() != null) { - outAty.emojiFragment.getEditText().setTag(null); - outAty.emojiFragment.getEditText().setHint("说点什么吧"); - return true; - } - return super.onBackPressed(); - } - - @Override - public void onClickFlagButton() {} -} diff --git a/app/src/main/java/net/oschina/app/fragment/EventAppliesFragment.java b/app/src/main/java/net/oschina/app/fragment/EventAppliesFragment.java deleted file mode 100644 index d7ce33c2b08d3e9ba12c419f89d9945afb8eb323..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/EventAppliesFragment.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.AppContext; -import net.oschina.app.adapter.EventApplyAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Apply; -import net.oschina.app.bean.EventAppliesList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.annotation.TargetApi; -import android.os.Build; -import android.view.View; -import android.widget.AdapterView; - -/** - * 活动出席人员列表 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年12月12日 下午7:59:10 - * - */ -@TargetApi(Build.VERSION_CODES.HONEYCOMB) -public class EventAppliesFragment extends BaseListFragment { - - protected static final String TAG = EventAppliesFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "event_apply_user_list"; - - @Override - public void initView(View view) { - super.initView(view); - } - - @Override - protected EventApplyAdapter getListAdapter() { - return new EventApplyAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + "_" + mCatalog; - } - - @Override - protected EventAppliesList parseList(InputStream is) throws Exception { - EventAppliesList list = XmlUtils.toBean(EventAppliesList.class, is); - return list; - } - - @Override - protected EventAppliesList readList(Serializable seri) { - return ((EventAppliesList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getEventApplies(mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Apply item = (Apply) mAdapter.getItem(position); - if (item != null) { - if (AppContext.getInstance().isLogin()) { - UIHelper.showMessageDetail(getActivity(), item.getId(), item.getName()); - return; - } - UIHelper.showUserCenter(getActivity(), item.getId(),item.getName()); - } - - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/EventDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/EventDetailFragment.java deleted file mode 100644 index 60262d4bc1eb1da490fca42be34c4d301a2052d0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/EventDetailFragment.java +++ /dev/null @@ -1,322 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.DialogInterface; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.base.CommonDetailFragment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.Event; -import net.oschina.app.bean.EventApplyData; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.bean.Post; -import net.oschina.app.bean.PostDetail; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.SimpleBackPage; -import net.oschina.app.ui.EventApplyDialog; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.URLsUtils; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import butterknife.InjectView; - -/** - * Created by 火蚁 on 15/5/28. - */ -public class EventDetailFragment extends CommonDetailFragment { - - @InjectView(R.id.tv_event_title) - TextView mTvTitle; - - @InjectView(R.id.tv_event_start_time) - TextView mTvStartTime; - - @InjectView(R.id.tv_event_end_time) - TextView mTvEndTime; - - @InjectView(R.id.tv_event_spot) - TextView mTvSpot; - - @InjectView(R.id.rl_event_location) - View mLocation; - - @InjectView(R.id.bt_event_attend) - Button mBtAttend;// 出席人员 - - @InjectView(R.id.bt_event_apply) - Button mBtEventApply;// 活动报名 - - @InjectView(R.id.tv_event_tip) - TextView mEventTip; - - private EventApplyDialog mEventApplyDialog; - - @Override - public void initView(View view) { - super.initView(view); - mLocation.setOnClickListener(this); - mBtAttend.setOnClickListener(this); - mBtEventApply.setOnClickListener(this); - } - - @Override - protected int getLayoutId() { - return R.layout.fragment_event_detail; - } - - @Override - protected String getCacheKey() { - return "post_" + mId; - } - - @Override - protected void sendRequestDataForNet() { - OSChinaApi.getPostDetail(mId, mDetailHeandler); - } - - @Override - protected Post parseData(InputStream is) { - return XmlUtils.toBean(PostDetail.class, is).getPost(); - } - - @Override - protected String getWebViewBody(Post detail) { - StringBuffer body = new StringBuffer(); - body.append(UIHelper.WEB_STYLE).append(UIHelper.WEB_LOAD_IMAGES); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - // 添加title - body.append(String.format("
%s
", mDetail.getTitle())); - // 添加作者和时间 - String time = StringUtils.friendly_time(mDetail.getPubDate()); - String author = String.format("%s", mDetail.getAuthorId(), mDetail.getAuthor()); - body.append(String.format("
%s    %s
", author, time)); - // 添加图片点击放大支持 - body.append(UIHelper.setHtmlCotentSupportImagePreview(mDetail.getBody())); - // 封尾 - body.append(""); - return body.toString(); - } - - @Override - protected void executeOnLoadDataSuccess(Post detail) { - super.executeOnLoadDataSuccess(detail); - mTvTitle.setText(mDetail.getTitle()); - mTvStartTime.setText(String.format( - getString(R.string.event_start_time), mDetail.getEvent() - .getStartTime())); - mTvEndTime.setText(String.format(getString(R.string.event_end_time), - mDetail.getEvent().getEndTime())); - mTvSpot.setText(mDetail.getEvent().getCity() + " " - + mDetail.getEvent().getSpot()); - - // 站外活动 - if (mDetail.getEvent().getCategory() == 4) { - mBtEventApply.setVisibility(View.VISIBLE); - mBtAttend.setVisibility(View.GONE); - mBtEventApply.setText("报名链接"); - } else { - notifyEventStatus(); - } - } - - // 显示活动 以及报名的状态 - private void notifyEventStatus() { - int eventStatus = mDetail.getEvent().getStatus(); - int applyStatus = mDetail.getEvent().getApplyStatus(); - - if (applyStatus == Event.APPLYSTATUS_ATTEND) { - mBtAttend.setVisibility(View.VISIBLE); - } else { - mBtAttend.setVisibility(View.GONE); - } - - if (eventStatus == Event.EVNET_STATUS_APPLYING) { - mBtEventApply.setVisibility(View.VISIBLE); - mBtEventApply.setEnabled(false); - switch (applyStatus) { - case Event.APPLYSTATUS_CHECKING: - mBtEventApply.setText("待确认"); - break; - case Event.APPLYSTATUS_CHECKED: - mBtEventApply.setText("已确认"); - mBtEventApply.setVisibility(View.GONE); - mEventTip.setVisibility(View.VISIBLE); - break; - case Event.APPLYSTATUS_ATTEND: - mBtEventApply.setText("已出席"); - break; - case Event.APPLYSTATUS_CANCLE: - mBtEventApply.setText("已取消"); - mBtEventApply.setEnabled(true); - break; - case Event.APPLYSTATUS_REJECT: - mBtEventApply.setText("已拒绝"); - break; - default: - mBtEventApply.setText("我要报名"); - mBtEventApply.setEnabled(true); - break; - } - } else { - mBtEventApply.setVisibility(View.GONE); - } - } - - @Override - protected void showCommentView() { - if (mDetail != null) { - UIHelper.showComment(getActivity(), mId, CommentList.CATALOG_POST); - } - } - - @Override - protected int getCommentType() { - return CommentList.CATALOG_POST; - } - - @Override - protected int getFavoriteTargetType() { - return FavoriteList.TYPE_POST; - } - - @Override - protected int getFavoriteState() { - return mDetail.getFavorite(); - } - - @Override - protected void updateFavoriteChanged(int newFavoritedState) { - mDetail.setFavorite(newFavoritedState); - saveCache(mDetail); - } - - @Override - protected int getCommentCount() { - return mDetail.getAnswerCount(); - } - - @Override - public void onClick(View v) { - int id = v.getId(); - switch (id) { - case R.id.rl_event_location: - UIHelper.showEventLocation(getActivity(), mDetail.getEvent() - .getCity(), mDetail.getEvent().getSpot()); - break; - case R.id.bt_event_attend: - showEventApplies(); - break; - case R.id.bt_event_apply: - showEventApply(); - break; - default: - break; - } - } - - private void showEventApplies() { - Bundle args = new Bundle(); - args.putInt(BaseListFragment.BUNDLE_KEY_CATALOG, mDetail.getEvent() - .getId()); - UIHelper.showSimpleBack(getActivity(), SimpleBackPage.EVENT_APPLY, args); - } - - private final AsyncHttpResponseHandler mApplyHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - Result rs = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)).getResult(); - if (rs.OK()) { - AppContext.showToast("报名成功"); - mEventApplyDialog.dismiss(); - mDetail.getEvent().setApplyStatus(Event.APPLYSTATUS_CHECKING); - } else { - AppContext.showToast(rs.getErrorMessage()); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - AppContext.showToast("报名失败"); - } - - @Override - public void onFinish() { - hideWaitDialog(); - } - }; - - /** - * 显示活动报名对话框 - */ - private void showEventApply() { - - if (mDetail.getEvent().getCategory() == 4) { - UIHelper.openSysBrowser(getActivity(), mDetail.getEvent().getUrl()); - return; - } - - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (mEventApplyDialog == null) { - mEventApplyDialog = new EventApplyDialog(getActivity(), mDetail.getEvent()); - mEventApplyDialog.setCanceledOnTouchOutside(true); - mEventApplyDialog.setCancelable(true); - mEventApplyDialog.setTitle("活动报名"); - mEventApplyDialog.setCanceledOnTouchOutside(true); - mEventApplyDialog.setNegativeButton(R.string.cancle, null); - mEventApplyDialog.setPositiveButton(R.string.ok, - new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface d, int which) { - EventApplyData data = null; - if ((data = mEventApplyDialog.getApplyData()) != null) { - data.setEvent(mId); - data.setUser(AppContext.getInstance() - .getLoginUid()); - showWaitDialog(R.string.progress_submit); - OSChinaApi.eventApply(data, mApplyHandler); - } - } - }); - } - - mEventApplyDialog.show(); - } - - @Override - protected String getShareTitle() { - return mDetail.getTitle(); - } - - @Override - protected String getShareContent() { - return StringUtils.getSubString(0, 55, - getFilterHtmlBody(mDetail.getBody())); - } - - @Override - protected String getShareUrl() { - return String.format(URLsUtils.URL_MOBILE + "question/%s_%s", mDetail.getAuthorId(), mId); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/EventFragment.java b/app/src/main/java/net/oschina/app/fragment/EventFragment.java deleted file mode 100644 index 8e8c6d5911e892336ac46c916376f7e1bdd9b762..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/EventFragment.java +++ /dev/null @@ -1,152 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.EventAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.Event; -import net.oschina.app.bean.EventList; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -/** - * 活动列表fragment - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年12月8日 下午5:17:32 - * - */ -public class EventFragment extends BaseListFragment { - - public static final String BUNDLE_KEY_EVENT_TYPE = "eventlist_type"; - - protected static final String TAG = EventFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "eventlist_"; - - private int event_type; - - @Override - protected EventAdapter getListAdapter() { - EventAdapter adapter = new EventAdapter(); - adapter.setEventType(event_type); - return adapter; - } - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - requestData(true); - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - event_type = args.getInt(BUNDLE_KEY_EVENT_TYPE); - } - - if (event_type == EventList.EVENT_LIST_TYPE_MY_EVENT) { - IntentFilter filter = new IntentFilter( - Constants.INTENT_ACTION_USER_CHANGE); - filter.addAction(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mReceiver, filter); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - if (event_type == EventList.EVENT_LIST_TYPE_MY_EVENT) { - getActivity().unregisterReceiver(mReceiver); - } - } - - @Override - public void initView(View view) { - super.initView(view); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - clickErrorLayout(); - } - }); - } - - private void clickErrorLayout() { - if (event_type == EventList.EVENT_LIST_TYPE_NEW_EVENT) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - } - - @Override - protected void requestData(boolean refresh) { - - if (event_type == EventList.EVENT_LIST_TYPE_NEW_EVENT) { - mCatalog = -1; - super.requestData(refresh); - return; - } - if (AppContext.getInstance().isLogin()) { - mCatalog = AppContext.getInstance().getLoginUid(); - super.requestData(refresh); - } else { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected EventList parseList(InputStream is) throws Exception { - EventList list = XmlUtils.toBean(EventList.class, is); - return list; - } - - @Override - protected EventList readList(Serializable seri) { - return ((EventList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getEventList(mCurrentPage, mCatalog, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Event event = mAdapter.getItem(position); - if (event != null) - UIHelper.showEventDetail(view.getContext(), event.getId()); - } - -} diff --git a/app/src/main/java/net/oschina/app/fragment/ExploreFragment.java b/app/src/main/java/net/oschina/app/fragment/ExploreFragment.java deleted file mode 100644 index e8bc09ddd88ba7c5e3d1b1c0a0442b3142febc1d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/ExploreFragment.java +++ /dev/null @@ -1,111 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.Intent; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; - -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.SimpleBackPage; -import net.oschina.app.ui.FindUserActivity; -import net.oschina.app.ui.ShakeActivity; -import net.oschina.app.util.UIHelper; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 发现页面 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年11月4日 下午3:34:07 - * - */ - -public class ExploreFragment extends BaseFragment { - - @InjectView(R.id.rl_active) - View mRlActive; - - @InjectView(R.id.rl_find_osc) - View mFindOSCer; - - @InjectView(R.id.rl_city) - View mCity; - - @InjectView(R.id.rl_activities) - View mActivities; - - @InjectView(R.id.rl_scan) - View mScan; - - @InjectView(R.id.rl_shake) - View mShake; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - View view = inflater.inflate(R.layout.fragment_explore, null); - ButterKnife.inject(this, view); - initView(view); - return view; - } - - @Override - public void onClick(View v) { - int id = v.getId(); - switch (id) { - case R.id.rl_active: - UIHelper.showMyActive(getActivity()); - break; - case R.id.rl_find_osc: - showFindUser(); - break; - case R.id.rl_city: - UIHelper.showSimpleBack(getActivity(), SimpleBackPage.SAME_CITY); - break; - case R.id.rl_activities: - UIHelper.showSimpleBack(getActivity(), SimpleBackPage.EVENT_LIST); - break; - case R.id.rl_scan: - UIHelper.showScanActivity(getActivity()); - break; - case R.id.rl_shake: - showShake(); - break; - default: - break; - } - } - - private void showShake() { - Intent intent = new Intent(); - intent.setClass(getActivity(), ShakeActivity.class); - getActivity().startActivity(intent); - } - - private void showFindUser() { - Intent intent = new Intent(); - intent.setClass(getActivity(), FindUserActivity.class); - getActivity().startActivity(intent); - } - - @Override - public void initView(View view) { - mRlActive.setOnClickListener(this); - - mFindOSCer.setOnClickListener(this); - mCity.setOnClickListener(this); - mActivities.setOnClickListener(this); - mScan.setOnClickListener(this); - mShake.setOnClickListener(this); - } - - @Override - public void initData() { - - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/FeedBackFragment.java b/app/src/main/java/net/oschina/app/fragment/FeedBackFragment.java deleted file mode 100644 index a6f5e403f117c1d24837b918efed9852ffe0bd68..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/FeedBackFragment.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.oschina.app.fragment; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; - -import cz.msebera.android.httpclient.Header; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.EditText; -import butterknife.ButterKnife; -import butterknife.InjectView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -public class FeedBackFragment extends BaseFragment { - @InjectView(R.id.et_feedback) - EditText mEtContent; - @InjectView(R.id.et_contact) - EditText mEtContact; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - View view = inflater.inflate(R.layout.fragment_feedback, null); - ButterKnife.inject(this, view); - initView(view); - return view; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setHasOptionsMenu(true); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.submit_menu, menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.public_menu_send: - String data = mEtContent.getText().toString(); - if (StringUtils.isEmpty(data)) { - AppContext.showToast("你忘记写建议咯"); - } else { - data += "
"; - data += mEtContact.getText() + "
"; - data += TDevice.getVersionName() + "(" - + TDevice.getVersionCode() + ")
"; - OSChinaApi.feedback(data, new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - AppContext.showToast("已收到你的建议,谢谢"); - getActivity().finish(); - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - AppContext.showToast("网络异常,请稍后重试"); - } - }); - } - break; - } - return true; - } - - @Override - public void onClick(View v) { - - } - - @Override - public void initView(View view) { - - } - - @Override - public void initData() { - - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/FriendsFragment.java b/app/src/main/java/net/oschina/app/fragment/FriendsFragment.java deleted file mode 100644 index 9a84cd48dfdb7b89d152890c7727fb4e72b84469..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/FriendsFragment.java +++ /dev/null @@ -1,137 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.List; - -import net.oschina.app.AppContext; -import net.oschina.app.adapter.FriendAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.Friend; -import net.oschina.app.bean.FriendsList; -import net.oschina.app.bean.Notice; -import net.oschina.app.service.NoticeUtils; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.viewpagerfragment.NoticeViewPagerFragment; -import android.annotation.TargetApi; -import android.os.Build; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -/** - * 关注、粉丝 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 上午11:15:37 - * - */ -@TargetApi(Build.VERSION_CODES.HONEYCOMB) -public class FriendsFragment extends BaseListFragment { - - public final static String BUNDLE_KEY_UID = "UID"; - - protected static final String TAG = FriendsFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "friend_list"; - - private int mUid; - - @Override - public void initView(View view) { - super.initView(view); - } - - @Override - public void onCreate(android.os.Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mUid = args.getInt(BUNDLE_KEY_UID, 0); - } - } - - @Override - public void onResume() { - if (mCatalog == FriendsList.TYPE_FANS - && mUid == AppContext.getInstance().getLoginUid()) { - refreshNotice(); - } - super.onResume(); - } - - private void refreshNotice() { - Notice notice = MainActivity.mNotice; - if (notice != null && notice.getNewFansCount() > 0) { - onRefresh(); - } - } - - @Override - protected FriendAdapter getListAdapter() { - return new FriendAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + "_" + mCatalog + "_" + mUid; - } - - @Override - protected FriendsList parseList(InputStream is) throws Exception { - FriendsList list = XmlUtils.toBean(FriendsList.class, is); - return list; - } - - @Override - protected FriendsList readList(Serializable seri) { - return ((FriendsList) seri); - } - - @Override - protected boolean compareTo(List data, Entity enity) { - int s = data.size(); - if (enity != null) { - for (int i = 0; i < s; i++) { - if (((Friend) enity).getUserid() == ((Friend) data.get(i)) - .getUserid()) { - return true; - } - } - } - return false; - } - - @Override - protected void sendRequestData() { - OSChinaApi.getFriendList(mUid, mCatalog, mCurrentPage, mHandler); - } - - @Override - protected void onRefreshNetworkSuccess() { - if ((NoticeViewPagerFragment.sCurrentPage == 3 || NoticeViewPagerFragment.sShowCount[3] > 0) - && mCatalog == FriendsList.TYPE_FANS - && mUid == AppContext.getInstance().getLoginUid()) { - NoticeUtils.clearNotice(Notice.TYPE_NEWFAN); - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Friend item = (Friend) mAdapter.getItem(position); - if (item != null) { - if (mUid == AppContext.getInstance().getLoginUid()) { - UIHelper.showMessageDetail(getActivity(), item.getUserid(), - item.getName()); - return; - } - UIHelper.showUserCenter(getActivity(), item.getUserid(), - item.getName()); - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/MessageDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/MessageDetailFragment.java deleted file mode 100644 index 15c195191915811ad546ef70b4ee793347c24fec..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/MessageDetailFragment.java +++ /dev/null @@ -1,461 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.graphics.Color; -import android.os.Bundle; -import android.text.Editable; -import android.util.SparseArray; -import android.view.View; -import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.MessageDetailAdapter; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Comment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.MessageDetail; -import net.oschina.app.bean.MessageDetailList; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.User; -import net.oschina.app.emoji.KJEmojiFragment; -import net.oschina.app.emoji.OnSendClickListener; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; -import org.kymjs.kjframe.utils.StringUtils; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -/** - * 与某人的聊天记录界面(私信详情) - * - * @author kymjs (http://www.kymjs.com/) - * - */ -public class MessageDetailFragment extends BaseListFragment implements - OnItemLongClickListener, OnSendClickListener,MessageDetailAdapter.OnRetrySendMessageListener{ - protected static final String TAG = ActiveFragment.class.getSimpleName(); - public static final String BUNDLE_KEY_FID = "BUNDLE_KEY_FID"; - public static final String BUNDLE_KEY_FNAME = "BUNDLE_KEY_FNAME"; - private static final String CACHE_KEY_PREFIX = "message_detail_list"; - //时间间隔(要求:聊天时间显示,时间间隔为五分钟以上才显示出来) - private final static long TIME_INTERVAL = 1000 * 60 * 5; - - private int mFid; - private String mFName; - private int mMsgTag; - private int mPageCount; - private long mLastShowDate; //最后显示出来的时间 - public KJEmojiFragment emojiFragment = new KJEmojiFragment(); - //存放正在发送的消息,key 为生成的一个临时messageID(msgTag),value为Message实体 - //当消息发送成功后,从mSendingMsgs删除对应的Message实体 - private SparseArray mSendingMsgs = new SparseArray(); - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (mErrorLayout != null) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mFid = args.getInt(BUNDLE_KEY_FID); - mFName = args.getString(BUNDLE_KEY_FNAME); - mCatalog = CommentList.CATALOG_MESSAGE; - } - IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mReceiver, filter); - - ((BaseActivity) getActivity()).setActionBarTitle(mFName); - - int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - getActivity().getWindow().setSoftInputMode(mode); - - getActivity().getSupportFragmentManager().beginTransaction() - .replace(R.id.emoji_container, emojiFragment).commit(); - } - - @Override - public void onDestroy() { - getActivity().unregisterReceiver(mReceiver); - super.onDestroy(); - } - - @Override - public boolean onBackPressed() { - if (emojiFragment.isShowEmojiKeyBoard()) { - emojiFragment.hideAllKeyBoard(); - return true; - } else { - return super.onBackPressed(); - } - } - - @Override - protected MessageDetailAdapter getListAdapter() { - MessageDetailAdapter adapter = new MessageDetailAdapter(); - adapter.setOnRetrySendMessageListener(this); - return adapter; - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mFid; - } - - @Override - protected MessageDetailList parseList(InputStream is) throws Exception { - MessageDetailList list = XmlUtils.toBean(MessageDetailList.class, is); - handleShowDate(list.getList()); - mPageCount = (int) Math.ceil((float) list.getMessageCount() / getPageSize()); - return list; - } - - @Override - protected MessageDetailList readList(Serializable seri) { - MessageDetailList list = ((MessageDetailList) seri); - handleShowDate(list.getList()); - return list; - } - - /** - * 处理时间显示,设置哪些需要显示时间,哪些不需要显示时间 - * @param list - */ - private void handleShowDate(List list) { - MessageDetail msg = null; - long lastGroupTime = 0l; - //因为获得的列表是按时间降序的,所以需要倒着遍历 - for (int i = list.size() - 1; i >= 0; i--) { - msg = list.get(i); - Date date = net.oschina.app.util.StringUtils.toDate(msg.getPubDate()); - if (date != null && isNeedShowDate(date.getTime(), lastGroupTime)) { - lastGroupTime = date.getTime(); - msg.setShowDate(true); - } - } - //只设置最新的时间 - if (lastGroupTime > mLastShowDate) { - mLastShowDate = lastGroupTime; - } - } - - private boolean isNeedShowDate(long currentTime,long lastTime){ - return currentTime - lastTime > TIME_INTERVAL; - } - - @Override - public void initView(View view) { - super.initView(view); - mListView.setDivider(null); - mListView.setDividerHeight(0); - if(!AppContext.getNightModeSwitch()) { - mListView.setBackgroundColor(Color.parseColor("#ebebeb")); - } - mListView.setOnItemLongClickListener(this); - //移除父类设置的OnScrollListener,这里不需要下拉加载 - mListView.setOnScrollListener(null); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - requestData(false); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - }); - } - - @Override - protected void requestData(boolean refresh) { - mErrorLayout.setErrorMessage(""); - if (AppContext.getInstance().isLogin()) { - super.requestData(refresh); - } else { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected void sendRequestData() { - OSChinaApi.getChatMessageList(mFid, mCurrentPage, mHandler); - } - - @Override - protected boolean isReadCacheData(boolean refresh) { - if (!TDevice.hasInternet()) { - return true; - } else { - return false; - } - } - - @Override - protected void executeOnLoadDataSuccess(List data) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (data == null) { - data = new ArrayList(1); - } - if (mAdapter != null) { - if (mCurrentPage == 0) - mAdapter.clear(); - mAdapter.addData(data); - if (data.size() == 0 && mState == STATE_REFRESH) { - mErrorLayout.setErrorType(EmptyLayout.NODATA); - } else if (data.size() < getPageSize()) { - mAdapter.setState(ListBaseAdapter.STATE_OTHER); - } else { - mAdapter.setState(ListBaseAdapter.STATE_LOAD_MORE); - } - mAdapter.notifyDataSetChanged(); - //只有第一次加载,才需要滚动到底部 - if (mCurrentPage == 0) - mListView.setSelection(mListView.getBottom()); - else if (data.size() > 1) { - mListView.setSelection(data.size() - 1); - } - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) {} - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - final MessageDetail message = mAdapter.getItem(position); - DialogHelp.getSelectDialog(getActivity(), getResources().getStringArray(R.array.message_list_options), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - switch (i) { - case 0: - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(message - .getContent())); - break; - case 1: - handleDeleteMessage(message); - break; - default: - break; - } - } - }).show(); - return true; - } - - // 下拉加载数据 - @Override - public void onRefresh() { - if (mState == STATE_REFRESH) { - return; - } - if(mCurrentPage==mPageCount-1){ - AppContext.showToastShort("已加载全部数据!"); - setSwipeRefreshLoadedState(); - return; - } - // 设置顶部正在刷新 - mListView.setSelection(0); - setSwipeRefreshLoadingState(); - mState = STATE_REFRESH; - mCurrentPage++; - requestData(true); - } - - public void showFriendUserCenter(){ - UIHelper.showUserCenter(getActivity(), mFid, mFName); - } - - @Override - public void onResume() { - super.onResume(); - emojiFragment.hideFlagButton(); - } - - private void handleDeleteMessage(final MessageDetail message) { - DialogHelp.getConfirmDialog(getActivity(), "是否删除该私信?", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - showWaitDialog(R.string.progress_submit); - OSChinaApi.deleteComment(mFid, - CommentList.CATALOG_MESSAGE, message.getId(), - message.getAuthorId(), - new DeleteMessageOperationHandler(message)); - } - }).show(); - } - - class DeleteMessageOperationHandler extends OperationResponseHandler { - - public DeleteMessageOperationHandler(Object... args) { - super(args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res.OK()) { - Comment msg = (Comment) args[0]; - mAdapter.removeItem(msg); - mAdapter.notifyDataSetChanged(); - hideWaitDialog(); - AppContext.showToastShort(R.string.tip_delete_success); - } else { - AppContext.showToastShort(res.getErrorMessage()); - hideWaitDialog(); - } - } - - @Override - public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { - - } - - @Override - public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { - AppContext.showToastShort(R.string.tip_delete_faile); - hideWaitDialog(); - } - } - - @Override - public void onClickSendButton(Editable str) { - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (StringUtils.isEmpty(str)) { - AppContext.showToastShort(R.string.tip_content_empty); - return; - } - MessageDetail message = new MessageDetail(); - User user = AppContext.getInstance().getLoginUser(); - int msgTag = mMsgTag++; - message.setId(msgTag); - message.setPortrait(user.getPortrait()); - message.setAuthor(user.getName()); - message.setAuthorId(user.getId()); - message.setContent(str.toString()); - sendMessage(message); - } - - /** - * 发送消息 - * @param msg - */ - private void sendMessage(MessageDetail msg){ - msg.setStatus(MessageDetail.MessageStatus.SENDING); - Date date = new Date(); - msg.setPubDate(net.oschina.app.util.StringUtils.getDateString(date)); - //如果此次发表的时间距离上次的时间达到了 TIME_INTERVAL 的间隔要求,则显示时间 - if(isNeedShowDate(date.getTime(),mLastShowDate)) { - msg.setShowDate(true); - mLastShowDate = date.getTime(); - } - - //如果待发送列表没有此条消息,说明是新消息,不是发送失败再次发送的,不需要再次添加 - if(mSendingMsgs.indexOfKey(msg.getId())<0) { - mSendingMsgs.put(msg.getId(), msg); - mAdapter.addItem(0, msg); - mListView.setSelection(mListView.getBottom()); - }else{ - mAdapter.notifyDataSetChanged(); - } - OSChinaApi.publicMessage(msg.getAuthorId(), mFid, msg.getContent(), new SendMessageResponseHandler(msg.getId())); - } - - @Override - public void onClickFlagButton() {} - - @Override - public void onRetrySendMessage(int msgId) { - MessageDetail message = mSendingMsgs.get(msgId); - if (message != null) { - sendMessage(message); - } - } - - class SendMessageResponseHandler extends AsyncHttpResponseHandler{ - - private int msgTag; - - public SendMessageResponseHandler(int msgTag) { - this.msgTag = msgTag; - } - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - ResultBean resb = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)); - Result res = resb.getResult(); - if (res.OK()) { - //从mSendingMsgs获取发送时放入的MessageDetail实体 - MessageDetail message = mSendingMsgs.get(this.msgTag); - MessageDetail serverMsg = resb.getMessage(); - //把id设置为服务器返回的id - message.setId(serverMsg.getId()); - message.setStatus(MessageDetail.MessageStatus.NORMAL); - //从待发送列表移除 - mSendingMsgs.remove(this.msgTag); - mAdapter.notifyDataSetChanged(); - } else { - error(); - AppContext.showToastShort(res.getErrorMessage()); - } - emojiFragment.clean(); - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) { - error(); - } - - private void error(){ - mSendingMsgs.get(this.msgTag).setStatus(MessageDetail.MessageStatus.ERROR); - mAdapter.notifyDataSetChanged(); - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/MessageFragment.java b/app/src/main/java/net/oschina/app/fragment/MessageFragment.java deleted file mode 100644 index 39d45505ccff4cd86b053dcfae267314107b4c52..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/MessageFragment.java +++ /dev/null @@ -1,239 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; -import cz.msebera.android.httpclient.Header; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.MessageAdapter; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.MessageList; -import net.oschina.app.bean.Messages; -import net.oschina.app.bean.Notice; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.service.NoticeUtils; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.viewpagerfragment.NoticeViewPagerFragment; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; - -public class MessageFragment extends BaseListFragment implements - OnItemLongClickListener { - protected static final String TAG = ActiveFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "message_list"; - private boolean mIsWatingLogin; - - private final BroadcastReceiver mLogoutReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - if (mErrorLayout != null) { - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mLogoutReceiver, filter); - } - - @Override - public void onDestroy() { - getActivity().unregisterReceiver(mLogoutReceiver); - super.onDestroy(); - } - - @Override - public void onResume() { - if (mIsWatingLogin) { - mCurrentPage = 0; - mState = STATE_REFRESH; - requestData(false); - } - refreshNotice(); - super.onResume(); - } - - private void refreshNotice() { - Notice notice = MainActivity.mNotice; - if (notice != null && notice.getMsgCount() > 0) { - onRefresh(); - } - } - - @Override - protected MessageAdapter getListAdapter() { - return new MessageAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX; - } - - @Override - protected MessageList parseList(InputStream is) throws Exception { - MessageList list = XmlUtils.toBean(MessageList.class, is); - return list; - } - - @Override - protected MessageList readList(Serializable seri) { - return ((MessageList) seri); - } - - @Override - public void initView(View view) { - super.initView(view); - mListView.setDivider(null); - mListView.setDividerHeight(0); - mListView.setOnItemLongClickListener(this); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(false); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - }); - if (AppContext.getInstance().isLogin()) { - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - @Override - protected void requestData(boolean refresh) { - if (AppContext.getInstance().isLogin()) { - mIsWatingLogin = false; - super.requestData(refresh); - } else { - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected void sendRequestData() { - OSChinaApi.getMessageList(AppContext.getInstance().getLoginUid(), - mCurrentPage, mHandler); - } - - @Override - protected void onRefreshNetworkSuccess() { - if (2 == NoticeViewPagerFragment.sCurrentPage - || NoticeViewPagerFragment.sShowCount[2] > 0) { // 在page中第三个位置 - NoticeUtils.clearNotice(Notice.TYPE_MESSAGE); - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Messages message = (Messages) mAdapter.getItem(position); - if (message != null) - UIHelper.showMessageDetail(getActivity(), message.getFriendId(), - message.getFriendName()); - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - final Messages message = (Messages) mAdapter.getItem(position); - DialogHelp.getSelectDialog(getActivity(), getResources().getStringArray(R.array.message_list_options), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - switch (i) { - case 0: - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(message - .getContent())); - break; - case 1: - handleDeleteMessage(message); - break; - default: - break; - } - } - }).show(); - return true; - } - - private void handleDeleteMessage(final Messages message) { - - DialogHelp.getConfirmDialog(getActivity(), getString(R.string.confirm_delete_message, - message.getFriendName()), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - showWaitDialog(R.string.progress_submit); - - OSChinaApi.deleteMessage(AppContext.getInstance() - .getLoginUid(), message.getFriendId(), - new DeleteMessageOperationHandler(message)); - } - }).show(); - } - - class DeleteMessageOperationHandler extends OperationResponseHandler { - - public DeleteMessageOperationHandler(Object... args) { - super(args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res.OK()) { - Messages msg = (Messages) args[0]; - mAdapter.removeItem(msg); - mAdapter.notifyDataSetChanged(); - hideWaitDialog(); - AppContext.showToastShort(R.string.tip_delete_success); - } else { - AppContext.showToastShort(res.getErrorMessage()); - hideWaitDialog(); - } - } - - @Override - public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { - - } - - @Override - public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { - AppContext.showToastShort(R.string.tip_delete_faile); - hideWaitDialog(); - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/MyInformationFragment.java b/app/src/main/java/net/oschina/app/fragment/MyInformationFragment.java deleted file mode 100644 index b2f295f95cdcf268a955c86de54157d74daf93f9..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/MyInformationFragment.java +++ /dev/null @@ -1,421 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.ByteArrayInputStream; -import java.io.Serializable; -import java.lang.ref.WeakReference; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.MyInformation; -import net.oschina.app.bean.Notice; -import net.oschina.app.bean.SimpleBackPage; -import net.oschina.app.bean.User; -import net.oschina.app.cache.CacheManager; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.ui.MyQrodeDialog; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.BadgeView; - - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.AsyncTask; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; -import cz.msebera.android.httpclient.Header; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -/** - * 登录用户中心页面 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @author kymjs (http://my.oschina.net/kymjs) - * @version 创建时间:2014年10月30日 下午4:05:47 - */ -public class MyInformationFragment extends BaseFragment { - - public static final int sChildView = 9; // 在没有加入TeamList控件时rootview有多少子布局 - - @InjectView(R.id.iv_avatar) - AvatarView mIvAvatar; - @InjectView(R.id.iv_gender) - ImageView mIvGender; - @InjectView(R.id.tv_name) - TextView mTvName; - @InjectView(R.id.tv_score) - TextView mTvScore; - @InjectView(R.id.tv_favorite) - TextView mTvFavorite; - @InjectView(R.id.tv_following) - TextView mTvFollowing; - @InjectView(R.id.tv_follower) - TextView mTvFans; - @InjectView(R.id.tv_mes) - View mMesView; - @InjectView(R.id.error_layout) - EmptyLayout mErrorLayout; - @InjectView(R.id.iv_qr_code) - ImageView mQrCode; - @InjectView(R.id.ll_user_container) - View mUserContainer; - @InjectView(R.id.rl_user_unlogin) - View mUserUnLogin; - @InjectView(R.id.rootview) - LinearLayout rootView; - - private static BadgeView mMesCount; - - private boolean mIsWatingLogin; - - private User mInfo; - private AsyncTask mCacheTask; - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (action.equals(Constants.INTENT_ACTION_LOGOUT)) { - if (mErrorLayout != null) { - mIsWatingLogin = true; - steupUser(); - mMesCount.hide(); - } - } else if (action.equals(Constants.INTENT_ACTION_USER_CHANGE)) { - requestData(true); - } else if (action.equals(Constants.INTENT_ACTION_NOTICE)) { - setNotice(); - } - } - }; - - private final AsyncHttpResponseHandler mHandler = new AsyncHttpResponseHandler() { - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - mInfo = XmlUtils.toBean(MyInformation.class, - new ByteArrayInputStream(arg2)).getUser(); - if (mInfo != null) { - fillUI(); - AppContext.getInstance().updateUserInfo(mInfo); - new SaveCacheTask(getActivity(), mInfo, getCacheKey()) - .execute(); - } else { - onFailure(arg0, arg1, arg2, new Throwable()); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) {} - }; - - private void steupUser() { - if (mIsWatingLogin) { - mUserContainer.setVisibility(View.GONE); - mUserUnLogin.setVisibility(View.VISIBLE); - } else { - mUserContainer.setVisibility(View.VISIBLE); - mUserUnLogin.setVisibility(View.GONE); - } - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - IntentFilter filter = new IntentFilter(Constants.INTENT_ACTION_LOGOUT); - filter.addAction(Constants.INTENT_ACTION_USER_CHANGE); - getActivity().registerReceiver(mReceiver, filter); - } - - @Override - public void onResume() { - super.onResume(); - setNotice(); - } - - public void setNotice() { - if (MainActivity.mNotice != null) { - - Notice notice = MainActivity.mNotice; - int atmeCount = notice.getAtmeCount();// @我 - int msgCount = notice.getMsgCount();// 留言 - int reviewCount = notice.getReviewCount();// 评论 - int newFansCount = notice.getNewFansCount();// 新粉丝 - int newLikeCount = notice.getNewLikeCount();// 获得点赞 - int activeCount = atmeCount + reviewCount + msgCount + newFansCount + newLikeCount;// 信息总数 - if (activeCount > 0) { - mMesCount.setText(activeCount + ""); - mMesCount.show(); - } else { - mMesCount.hide(); - } - - } else { - mMesCount.hide(); - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - getActivity().unregisterReceiver(mReceiver); - } - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_my_information, - container, false); - ButterKnife.inject(this, view); - initView(view); - return view; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - requestData(true); - mInfo = AppContext.getInstance().getLoginUser(); - fillUI(); - } - - @Override - public void initView(View view) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - mIvAvatar.setOnClickListener(this); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - requestData(true); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - }); - view.findViewById(R.id.ly_favorite).setOnClickListener(this); - view.findViewById(R.id.ly_following).setOnClickListener(this); - view.findViewById(R.id.ly_follower).setOnClickListener(this); - view.findViewById(R.id.rl_message).setOnClickListener(this); - view.findViewById(R.id.rl_team).setOnClickListener(this); - view.findViewById(R.id.rl_blog).setOnClickListener(this); - view.findViewById(R.id.rl_note).setOnClickListener( - new OnClickListener() { - @Override - public void onClick(View v) { - UIHelper.showSimpleBack(getActivity(), - SimpleBackPage.NOTE); - } - }); - mUserUnLogin.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - UIHelper.showLoginActivity(getActivity()); - } - }); - - mMesCount = new BadgeView(getActivity(), mMesView); - mMesCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10); - mMesCount.setBadgePosition(BadgeView.POSITION_CENTER); - mMesCount.setGravity(Gravity.CENTER); - mMesCount.setBackgroundResource(R.drawable.notification_bg); - mQrCode.setOnClickListener(this); - // // 初始化团队列表数据 - // String cache = PreferenceHelper.readString(getActivity(), - // TEAM_LIST_FILE, TEAM_LIST_KEY); - // if (!StringUtils.isEmpty(cache)) { - // List teams = TeamList.toTeamList(cache); - // addTeamLayout(teams); - // } - } - - private void fillUI() { - if (mInfo == null) - return; - mIvAvatar.setAvatarUrl(mInfo.getPortrait()); - mTvName.setText(mInfo.getName()); - mIvGender - .setImageResource(StringUtils.toInt(mInfo.getGender()) != 2 ? R.drawable.userinfo_icon_male - : R.drawable.userinfo_icon_female); - mTvScore.setText(String.valueOf(mInfo.getScore())); - mTvFavorite.setText(String.valueOf(mInfo.getFavoritecount())); - mTvFollowing.setText(String.valueOf(mInfo.getFollowers())); - mTvFans.setText(String.valueOf(mInfo.getFans())); - } - - private void requestData(boolean refresh) { - if (AppContext.getInstance().isLogin()) { - mIsWatingLogin = false; - String key = getCacheKey(); - if (refresh || TDevice.hasInternet() - && (!CacheManager.isExistDataCache(getActivity(), key))) { - sendRequestData(); - } else { - readCacheData(key); - } - } else { - mIsWatingLogin = true; - } - steupUser(); - } - - private void readCacheData(String key) { - cancelReadCacheTask(); - mCacheTask = new CacheTask(getActivity()).execute(key); - } - - private void cancelReadCacheTask() { - if (mCacheTask != null) { - mCacheTask.cancel(true); - mCacheTask = null; - } - } - - private void sendRequestData() { - int uid = AppContext.getInstance().getLoginUid(); - OSChinaApi.getMyInformation(uid, mHandler); - } - - private String getCacheKey() { - return "my_information" + AppContext.getInstance().getLoginUid(); - } - - private class CacheTask extends AsyncTask { - private final WeakReference mContext; - - private CacheTask(Context context) { - mContext = new WeakReference(context); - } - - @Override - protected User doInBackground(String... params) { - Serializable seri = CacheManager.readObject(mContext.get(), - params[0]); - if (seri == null) { - return null; - } else { - return (User) seri; - } - } - - @Override - protected void onPostExecute(User info) { - super.onPostExecute(info); - if (info != null) { - mInfo = info; - // mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - // } else { - // mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - fillUI(); - } - } - } - - private class SaveCacheTask extends AsyncTask { - private final WeakReference mContext; - private final Serializable seri; - private final String key; - - private SaveCacheTask(Context context, Serializable seri, String key) { - mContext = new WeakReference(context); - this.seri = seri; - this.key = key; - } - - @Override - protected Void doInBackground(Void... params) { - CacheManager.saveObject(mContext.get(), seri, key); - return null; - } - } - - @Override - public void onClick(View v) { - if (mIsWatingLogin) { - AppContext.showToast(R.string.unlogin); - UIHelper.showLoginActivity(getActivity()); - return; - } - final int id = v.getId(); - switch (id) { - case R.id.iv_avatar: - UIHelper.showSimpleBack(getActivity(), - SimpleBackPage.MY_INFORMATION_DETAIL); - break; - case R.id.iv_qr_code: - showMyQrCode(); - break; - case R.id.ly_following: - UIHelper.showFriends(getActivity(), AppContext.getInstance() - .getLoginUid(), 0); - break; - case R.id.ly_follower: - UIHelper.showFriends(getActivity(), AppContext.getInstance() - .getLoginUid(), 1); - break; - case R.id.ly_favorite: - UIHelper.showUserFavorite(getActivity(), AppContext.getInstance() - .getLoginUid()); - break; - case R.id.rl_message: - UIHelper.showMyMes(getActivity()); - setNoticeReaded(); - break; - case R.id.rl_team: - UIHelper.showTeamMainActivity(getActivity()); - break; - case R.id.rl_blog: - UIHelper.showUserBlog(getActivity(), AppContext.getInstance() - .getLoginUid()); - break; - case R.id.rl_user_center: - UIHelper.showUserCenter(getActivity(), AppContext.getInstance() - .getLoginUid(), AppContext.getInstance().getLoginUser() - .getName()); - break; - default: - break; - } - } - - private void showMyQrCode() { - MyQrodeDialog dialog = new MyQrodeDialog(getActivity()); - dialog.show(); - } - - @Override - public void initData() {} - - private void setNoticeReaded() { - mMesCount.setText(""); - mMesCount.hide(); - } - -} diff --git a/app/src/main/java/net/oschina/app/fragment/MyInformationFragmentDetail.java b/app/src/main/java/net/oschina/app/fragment/MyInformationFragmentDetail.java deleted file mode 100644 index a47663fa47305d33bb23d0c2b27f0b452ba3432b..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/MyInformationFragmentDetail.java +++ /dev/null @@ -1,402 +0,0 @@ -package net.oschina.app.fragment; - -import android.app.Activity; -import android.content.DialogInterface; -import android.content.Intent; -import android.graphics.Bitmap; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.provider.MediaStore; -import android.provider.MediaStore.Images; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.MyInformation; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.User; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.FileUtil; -import net.oschina.app.util.ImageUtils; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import org.kymjs.kjframe.Core; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import butterknife.OnClick; -import cz.msebera.android.httpclient.Header; - -/** - * 登录用户信息详情 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月6日 上午10:33:18 - */ - -public class MyInformationFragmentDetail extends BaseFragment { - - public static final int ACTION_TYPE_ALBUM = 0; - public static final int ACTION_TYPE_PHOTO = 1; - - @InjectView(R.id.iv_avatar) - ImageView mUserFace; - - @InjectView(R.id.tv_name) - TextView mName; - - @InjectView(R.id.tv_join_time) - TextView mJoinTime; - - @InjectView(R.id.tv_location) - TextView mFrom; - - @InjectView(R.id.tv_development_platform) - TextView mPlatFrom; - - @InjectView(R.id.tv_academic_focus) - TextView mFocus; - - @InjectView(R.id.error_layout) - EmptyLayout mErrorLayout; - - private User mUser; - - private boolean isChangeFace = false; - - private String theLarge; - - private final static int CROP = 200; - - private final static String FILE_SAVEPATH = Environment - .getExternalStorageDirectory().getAbsolutePath() - + "/OSChina/Portrait/"; - private Uri origUri; - private Uri cropUri; - private File protraitFile; - private Bitmap protraitBitmap; - private String protraitPath; - - private final AsyncHttpResponseHandler mHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - MyInformation user = XmlUtils.toBean(MyInformation.class, - new ByteArrayInputStream(arg2)); - if (user != null && user.getUser() != null) { - mUser = user.getUser(); - fillUI(); - } else { - this.onFailure(arg0, arg1, arg2, null); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - } - - }; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - ViewGroup view = (ViewGroup) inflater.inflate( - R.layout.fragment_my_information_detail, container, false); - initView(view); - initData(); - return view; - } - - @Override - @OnClick({R.id.iv_avatar, R.id.btn_logout}) - public void onClick(View v) { - switch (v.getId()) { - case R.id.iv_avatar: - showClickAvatar(); - break; - case R.id.btn_logout: - AppContext.getInstance().Logout(); - AppContext.showToastShort(R.string.tip_logout_success); - getActivity().finish(); - break; - default: - break; - } - } - - public void showClickAvatar() { - if (mUser == null) { - AppContext.showToast(""); - return; - } - DialogHelp.getSelectDialog(getActivity(), "选择操作", getResources().getStringArray(R.array.avatar_option), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - handleSelectPicture(); - } else { - UIHelper.showUserAvatar(getActivity(), - mUser.getPortrait()); - } - } - }).show(); - } - - private void handleSelectPicture() { - DialogHelp.getSelectDialog(getActivity(), "选择图片", getResources().getStringArray(R.array.choose_picture), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - goToSelectPicture(i); - } - }).show(); - } - - private void goToSelectPicture(int position) { - switch (position) { - case ACTION_TYPE_ALBUM: - startImagePick(); - break; - case ACTION_TYPE_PHOTO: - startTakePhoto(); - break; - default: - break; - } - } - - @Override - public void initView(View view) { - ButterKnife.inject(this, view); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - sendRequiredData(); - } - }); - - mUserFace.setOnClickListener(this); - } - - @Override - public void initData() { - sendRequiredData(); - } - - public void fillUI() { - Core.getKJBitmap().displayWithLoadBitmap(mUserFace, mUser.getPortrait(), - R.drawable.widget_dface); - mName.setText(mUser.getName()); - mJoinTime.setText(StringUtils.friendly_time(mUser.getJointime())); - mFrom.setText(mUser.getFrom()); - mPlatFrom.setText(mUser.getDevplatform()); - mFocus.setText(mUser.getExpertise()); - } - - public void sendRequiredData() { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - OSChinaApi.getMyInformation(AppContext.getInstance().getLoginUid(), - mHandler); - } - - /** - * 上传新照片 - */ - private void uploadNewPhoto() { - showWaitDialog("正在上传头像..."); - - // 获取头像缩略图 - if (!StringUtils.isEmpty(protraitPath) && protraitFile.exists()) { - protraitBitmap = ImageUtils - .loadImgThumbnail(protraitPath, 200, 200); - } else { - AppContext.showToast("图像不存在,上传失败"); - } - if (protraitBitmap != null) { - - try { - OSChinaApi.updatePortrait(AppContext.getInstance() - .getLoginUid(), protraitFile, - new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, - byte[] arg2) { - Result res = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)) - .getResult(); - if (res.OK()) { - AppContext.showToast("更换成功"); - // 显示新头像 - mUserFace.setImageBitmap(protraitBitmap); - isChangeFace = true; - } else { - AppContext.showToast(res.getErrorMessage()); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, - byte[] arg2, Throwable arg3) { - AppContext.showToast("更换头像失败"); - } - - @Override - public void onFinish() { - hideWaitDialog(); - } - }); - } catch (FileNotFoundException e) { - AppContext.showToast("图像不存在,上传失败"); - } - } - } - - /** - * 选择图片裁剪 - */ - private void startImagePick() { - Intent intent; - if (Build.VERSION.SDK_INT < 19) { - intent = new Intent(); - intent.setAction(Intent.ACTION_GET_CONTENT); - intent.setType("image/*"); - startActivityForResult(Intent.createChooser(intent, "选择图片"), - ImageUtils.REQUEST_CODE_GETIMAGE_BYCROP); - } else { - intent = new Intent(Intent.ACTION_PICK, - Images.Media.EXTERNAL_CONTENT_URI); - intent.setType("image/*"); - startActivityForResult(Intent.createChooser(intent, "选择图片"), - ImageUtils.REQUEST_CODE_GETIMAGE_BYCROP); - } - } - - private void startTakePhoto() { - Intent intent; - // 判断是否挂载了SD卡 - String savePath = ""; - String storageState = Environment.getExternalStorageState(); - if (storageState.equals(Environment.MEDIA_MOUNTED)) { - savePath = Environment.getExternalStorageDirectory() - .getAbsolutePath() + "/oschina/Camera/"; - File savedir = new File(savePath); - if (!savedir.exists()) { - savedir.mkdirs(); - } - } - - // 没有挂载SD卡,无法保存文件 - if (StringUtils.isEmpty(savePath)) { - AppContext.showToastShort("无法保存照片,请检查SD卡是否挂载"); - return; - } - - String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss") - .format(new Date()); - String fileName = "osc_" + timeStamp + ".jpg";// 照片命名 - File out = new File(savePath, fileName); - Uri uri = Uri.fromFile(out); - origUri = uri; - - theLarge = savePath + fileName;// 该照片的绝对路径 - - intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - startActivityForResult(intent, - ImageUtils.REQUEST_CODE_GETIMAGE_BYCAMERA); - } - - // 裁剪头像的绝对路径 - private Uri getUploadTempFile(Uri uri) { - String storageState = Environment.getExternalStorageState(); - if (storageState.equals(Environment.MEDIA_MOUNTED)) { - File savedir = new File(FILE_SAVEPATH); - if (!savedir.exists()) { - savedir.mkdirs(); - } - } else { - AppContext.showToast("无法保存上传的头像,请检查SD卡是否挂载"); - return null; - } - String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss") - .format(new Date()); - String thePath = ImageUtils.getAbsolutePathFromNoStandardUri(uri); - - // 如果是标准Uri - if (StringUtils.isEmpty(thePath)) { - thePath = ImageUtils.getAbsoluteImagePath(getActivity(), uri); - } - String ext = FileUtil.getFileFormat(thePath); - ext = StringUtils.isEmpty(ext) ? "jpg" : ext; - // 照片命名 - String cropFileName = "osc_crop_" + timeStamp + "." + ext; - // 裁剪头像的绝对路径 - protraitPath = FILE_SAVEPATH + cropFileName; - protraitFile = new File(protraitPath); - - cropUri = Uri.fromFile(protraitFile); - return this.cropUri; - } - - /** - * 拍照后裁剪 - * - * @param data 原始图片 - */ - private void startActionCrop(Uri data) { - Intent intent = new Intent("com.android.camera.action.CROP"); - intent.setDataAndType(data, "image/*"); - intent.putExtra("output", this.getUploadTempFile(data)); - intent.putExtra("crop", "true"); - intent.putExtra("aspectX", 1);// 裁剪框比例 - intent.putExtra("aspectY", 1); - intent.putExtra("outputX", CROP);// 输出图片大小 - intent.putExtra("outputY", CROP); - intent.putExtra("scale", true);// 去黑边 - intent.putExtra("scaleUpIfNeeded", true);// 去黑边 - startActivityForResult(intent, - ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD); - } - - @Override - public void onActivityResult(final int requestCode, final int resultCode, - final Intent imageReturnIntent) { - if (resultCode != Activity.RESULT_OK) - return; - - switch (requestCode) { - case ImageUtils.REQUEST_CODE_GETIMAGE_BYCAMERA: - startActionCrop(origUri);// 拍照后裁剪 - break; - case ImageUtils.REQUEST_CODE_GETIMAGE_BYCROP: - startActionCrop(imageReturnIntent.getData());// 选图后裁剪 - break; - case ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD: - uploadNewPhoto(); - break; - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/NewsDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/NewsDetailFragment.java deleted file mode 100644 index b574db747d519f9d5998c7a25d598a5300dbea1f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/NewsDetailFragment.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.oschina.app.fragment; - -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.CommonDetailFragment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.bean.News; -import net.oschina.app.bean.NewsDetail; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import java.io.InputStream; - -/** - * Created by 火蚁 on 15/5/25. - */ -public class NewsDetailFragment extends CommonDetailFragment { - - @Override - protected String getCacheKey() { - return "news_" + mId; - } - - @Override - protected void sendRequestDataForNet() { - OSChinaApi.getNewsDetail(mId, mDetailHeandler); - } - - @Override - protected News parseData(InputStream is) { - return XmlUtils.toBean(NewsDetail.class, is).getNews(); - } - - @Override - protected String getWebViewBody(News detail) { - StringBuffer body = new StringBuffer(); - body.append(UIHelper.WEB_STYLE).append(UIHelper.WEB_LOAD_IMAGES); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - // 添加title - body.append(String.format("
%s
", mDetail.getTitle())); - // 添加作者和时间 - String time = StringUtils.friendly_time(mDetail.getPubDate()); - String author = String.format("%s", mDetail.getAuthorId(), mDetail.getAuthor()); - body.append(String.format("
%s    %s
", author, time)); - // 添加图片点击放大支持 - body.append(UIHelper.setHtmlCotentSupportImagePreview(mDetail.getBody())); - - - // 更多关于***软件的信息 - String softwareName = mDetail.getSoftwareName(); - String softwareLink = mDetail.getSoftwareLink(); - if (!StringUtils.isEmpty(softwareName) - && !StringUtils.isEmpty(softwareLink)) - body.append(String - .format("
更多关于: %s 的详细信息
", - softwareLink, softwareName)); - - // 相关新闻 - if (mDetail != null && mDetail.getRelatives() != null - && mDetail.getRelatives().size() > 0) { - String strRelative = ""; - for (News.Relative relative : mDetail.getRelatives()) { - strRelative += String.format( - "
  • %s
  • ", - relative.url, relative.title); - } - body.append("

    " - + String.format("
    相关资讯
      %s
    ", - strRelative)); - } - body.append("
    "); - // 封尾 - body.append("
    "); - return body.toString(); - } - - @Override - protected void showCommentView() { - if (mDetail != null) - UIHelper.showComment(getActivity(), mId, - CommentList.CATALOG_NEWS); - } - - @Override - protected int getCommentType() { - return CommentList.CATALOG_NEWS; - } - - @Override - protected int getFavoriteTargetType() { - return FavoriteList.TYPE_NEWS; - } - - @Override - protected String getShareTitle() { - return mDetail.getTitle(); - } - - @Override - protected String getShareContent() { - return StringUtils.getSubString(0, 55, - getFilterHtmlBody(mDetail.getBody())); - } - - @Override - protected String getShareUrl() { - return mDetail.getUrl().replace("http://www", "http://m"); - } - - @Override - protected int getFavoriteState() { - return mDetail.getFavorite(); - } - - @Override - protected void updateFavoriteChanged(int newFavoritedState) { - mDetail.setFavorite(newFavoritedState); - saveCache(mDetail); - } - - @Override - protected int getCommentCount() { - return mDetail.getCommentCount(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/NewsFragment.java b/app/src/main/java/net/oschina/app/fragment/NewsFragment.java deleted file mode 100644 index c52d3a57b28ed372c12e58da0dd65832d833ba4c..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/NewsFragment.java +++ /dev/null @@ -1,106 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.List; - -import net.oschina.app.adapter.NewsAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.News; -import net.oschina.app.bean.NewsList; -import net.oschina.app.interf.OnTabReselectListener; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.view.View; -import android.widget.AdapterView; - -/** - * 新闻资讯 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月12日 下午4:17:45 - * - */ -public class NewsFragment extends BaseListFragment implements - OnTabReselectListener { - - protected static final String TAG = NewsFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "newslist_"; - - @Override - protected NewsAdapter getListAdapter() { - return new NewsAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected NewsList parseList(InputStream is) throws Exception { - NewsList list = null; - try { - list = XmlUtils.toBean(NewsList.class, is); - } catch (NullPointerException e) { - list = new NewsList(); - } - return list; - } - - @Override - protected NewsList readList(Serializable seri) { - return ((NewsList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getNewsList(mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - News news = mAdapter.getItem(position); - if (news != null) { - UIHelper.showNewsRedirect(view.getContext(), news); - - // 放入已读列表 - saveToReadedList(view, NewsList.PREF_READED_NEWS_LIST, news.getId() - + ""); - } - } - - @Override - protected void executeOnLoadDataSuccess(List data) { - if (mCatalog == NewsList.CATALOG_WEEK - || mCatalog == NewsList.CATALOG_MONTH) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (mState == STATE_REFRESH) - mAdapter.clear(); - mAdapter.addData(data); - mState = STATE_NOMORE; - mAdapter.setState(ListBaseAdapter.STATE_NO_MORE); - return; - } - super.executeOnLoadDataSuccess(data); - } - - @Override - public void onTabReselect() { - onRefresh(); - } - - @Override - protected long getAutoRefreshTime() { - // 最新资讯两小时刷新一次 - if (mCatalog == NewsList.CATALOG_ALL) { - - return 2 * 60 * 60; - } - return super.getAutoRefreshTime(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/PostDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/PostDetailFragment.java deleted file mode 100644 index fe4e6ede8de76602f0b71c4333755ac5e67b18b2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/PostDetailFragment.java +++ /dev/null @@ -1,129 +0,0 @@ -package net.oschina.app.fragment; - -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.CommonDetailFragment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.bean.Post; -import net.oschina.app.bean.PostDetail; -import net.oschina.app.ui.DetailActivity; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.URLsUtils; -import net.oschina.app.util.XmlUtils; - -import java.io.InputStream; -import java.net.URLEncoder; - -/** - * Created by 火蚁 on 15/5/25. - */ -public class PostDetailFragment extends CommonDetailFragment { - @Override - protected String getCacheKey() { - return "post_" + mId; - } - - @Override - protected void sendRequestDataForNet() { - OSChinaApi.getPostDetail(mId, mDetailHeandler); - } - - @Override - protected Post parseData(InputStream is) { - return XmlUtils.toBean(PostDetail.class, is).getPost(); - } - - @Override - protected String getWebViewBody(Post detail) { - StringBuffer body = new StringBuffer(); - body.append(UIHelper.WEB_STYLE).append(UIHelper.WEB_LOAD_IMAGES); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - // 添加title - body.append(String.format("
    %s
    ", mDetail.getTitle())); - // 添加作者和时间 - String time = StringUtils.friendly_time(mDetail.getPubDate()); - String author = String.format("%s", mDetail.getAuthorId(), mDetail.getAuthor()); - body.append(String.format("
    %s    %s
    ", author, time)); - // 添加图片点击放大支持 - body.append(UIHelper.setHtmlCotentSupportImagePreview(mDetail.getBody())); - body.append(getPostTags(mDetail.getTags())); - // 封尾 - body.append(""); - return body.toString(); - } - - @SuppressWarnings("deprecation") - private String getPostTags(Post.Tags taglist) { - if (taglist == null) - return ""; - StringBuffer tags = new StringBuffer(); - for (String tag : taglist.getTags()) { - tags.append(String - .format(" %s   ", - URLEncoder.encode(tag), tag)); - } - return String.format("
    %s
    ", tags); - } - - @Override - protected void showCommentView() { - if (mDetail != null) { - UIHelper.showComment(getActivity(), mId, CommentList.CATALOG_POST); - } - } - - @Override - protected int getCommentType() { - return CommentList.CATALOG_POST; - } - - @Override - protected String getShareTitle() { - return mDetail.getTitle(); - } - - @Override - protected String getShareContent() { - return StringUtils.getSubString(0, 55, - getFilterHtmlBody(mDetail.getBody())); - } - - @Override - protected String getShareUrl() { - return String.format(URLsUtils.URL_MOBILE + "question/%s_%s", mDetail.getAuthorId(), mId); - } - - @Override - protected int getFavoriteTargetType() { - return FavoriteList.TYPE_POST; - } - - @Override - protected int getFavoriteState() { - return mDetail.getFavorite(); - } - - @Override - protected void updateFavoriteChanged(int newFavoritedState) { - mDetail.setFavorite(newFavoritedState); - saveCache(mDetail); - } - - @Override - protected int getCommentCount() { - return mDetail.getAnswerCount(); - } - - @Override - public void onResume() { - super.onResume(); - ((DetailActivity) getActivity()).toolFragment.showReportButton(); - } - - @Override - protected String getRepotrUrl() { - return mDetail.getUrl(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/PostsFragment.java b/app/src/main/java/net/oschina/app/fragment/PostsFragment.java deleted file mode 100644 index 03939793102bc4dbbc19ea2af392358201c90f57..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/PostsFragment.java +++ /dev/null @@ -1,64 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.adapter.PostAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Post; -import net.oschina.app.bean.PostList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.view.View; -import android.widget.AdapterView; - -/** - * 问答 - * - * @author william_sim - */ -public class PostsFragment extends BaseListFragment { - - protected static final String TAG = PostsFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "postslist_"; - - @Override - protected PostAdapter getListAdapter() { - return new PostAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected PostList parseList(InputStream is) throws Exception { - PostList list = XmlUtils.toBean(PostList.class, is); - return list; - } - - @Override - protected PostList readList(Serializable seri) { - return ((PostList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getPostList(mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Post post = mAdapter.getItem(position); - if (post != null) { - UIHelper.showPostDetail(view.getContext(), post.getId(), - post.getAnswerCount()); - // 放入已读列表 - saveToReadedList(view, PostList.PREF_READED_POST_LIST, post.getId() - + ""); - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/QuestionTagFragment.java b/app/src/main/java/net/oschina/app/fragment/QuestionTagFragment.java deleted file mode 100644 index 7f002b30d48a1f68b2608115ebd1a711dc2fe156..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/QuestionTagFragment.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.R; -import net.oschina.app.adapter.PostAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Post; -import net.oschina.app.bean.PostList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -/** - * 标签相关帖子 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月6日 下午3:39:07 - * - */ -public class QuestionTagFragment extends BaseListFragment { - - public static final String BUNDLE_KEY_TAG = "BUNDLE_KEY_TAG"; - protected static final String TAG = QuestionTagFragment.class - .getSimpleName(); - private static final String CACHE_KEY_PREFIX = "post_tag_"; - private String mTag; - - @Override - public void onCreate(android.os.Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mTag = args.getString(BUNDLE_KEY_TAG); - ((BaseActivity) getActivity()).setActionBarTitle(getString( - R.string.actionbar_title_question_tag, mTag)); - } - } - - @Override - protected PostAdapter getListAdapter() { - return new PostAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return new StringBuffer(CACHE_KEY_PREFIX).append(mTag).toString(); - } - - @Override - protected PostList parseList(InputStream is) throws Exception { - PostList list = XmlUtils.toBean(PostList.class, is); - return list; - } - - @Override - protected PostList readList(Serializable seri) { - return ((PostList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getPostListByTag(mTag, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Post post = mAdapter.getItem(position); - if (post != null) - UIHelper.showPostDetail(view.getContext(), post.getId(), - post.getAnswerCount()); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SearchFragment.java b/app/src/main/java/net/oschina/app/fragment/SearchFragment.java deleted file mode 100644 index 3b9055ab075b969114f9977a5fa80cfc89edc8a6..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SearchFragment.java +++ /dev/null @@ -1,93 +0,0 @@ -package net.oschina.app.fragment; - -import android.os.Bundle; -import android.view.View; -import android.view.WindowManager; -import android.widget.AdapterView; - -import net.oschina.app.adapter.SearchAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.SearchList; -import net.oschina.app.bean.SearchResult; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import java.io.InputStream; -import java.io.Serializable; - -public class SearchFragment extends BaseListFragment { - protected static final String TAG = SearchFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "search_list_"; - private String mCatalog; - private String mSearch; - private boolean mRquestDataIfCreated = false; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mCatalog = args.getString(BUNDLE_KEY_CATALOG); - } - int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; - getActivity().getWindow().setSoftInputMode(mode); - } - - public void search(String search) { - mSearch = search; - if (mErrorLayout != null) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - mState = STATE_REFRESH; - requestData(true); - } else { - mRquestDataIfCreated = true; - } - } - - @Override - protected boolean requestDataIfViewCreated() { - return mRquestDataIfCreated; - } - - @Override - protected SearchAdapter getListAdapter() { - return new SearchAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog + mSearch; - } - - @Override - protected SearchList parseList(InputStream is) throws Exception { - SearchList list = XmlUtils.toBean(SearchList.class, is); - return list; - } - - @Override - protected SearchList readList(Serializable seri) { - return ((SearchList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getSearchList(mCatalog, mSearch, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - SearchResult res = mAdapter.getItem(position); - if (res != null) { - if (res.getType().equalsIgnoreCase(SearchList.CATALOG_SOFTWARE)) { - UIHelper.showSoftwareDetailById(getActivity(), res.getId()); - } else { - UIHelper.showUrlRedirect(getActivity(), res.getUrl()); - } - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SettingsFragment.java b/app/src/main/java/net/oschina/app/fragment/SettingsFragment.java deleted file mode 100644 index 9df9372bdad1428eb4482779bf3a4fcba06efad1..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SettingsFragment.java +++ /dev/null @@ -1,174 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.DialogInterface; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.AppConfig; -import net.oschina.app.AppContext; -import net.oschina.app.AppManager; -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.FileUtil; -import net.oschina.app.util.MethodsCompat; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.togglebutton.ToggleButton; -import net.oschina.app.widget.togglebutton.ToggleButton.OnToggleChanged; - -import org.kymjs.kjframe.http.HttpConfig; - -import java.io.File; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 系统设置界面 - * - * @author kymjs - */ -public class SettingsFragment extends BaseFragment { - - @InjectView(R.id.tb_loading_img) - ToggleButton mTbLoadImg; - @InjectView(R.id.tv_cache_size) - TextView mTvCacheSize; - @InjectView(R.id.setting_logout) - TextView mTvExit; - @InjectView(R.id.tb_double_click_exit) - ToggleButton mTbDoubleClickExit; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_settings, container, - false); - ButterKnife.inject(this, view); - initView(view); - initData(); - return view; - } - - @Override - public void initView(View view) { - mTbLoadImg.setOnToggleChanged(new OnToggleChanged() { - @Override - public void onToggle(boolean on) { - AppContext.setLoadImage(on); - } - }); - - mTbDoubleClickExit.setOnToggleChanged(new OnToggleChanged() { - @Override - public void onToggle(boolean on) { - AppContext.set(AppConfig.KEY_DOUBLE_CLICK_EXIT, on); - } - }); - - view.findViewById(R.id.rl_loading_img).setOnClickListener(this); - view.findViewById(R.id.rl_notification_settings).setOnClickListener( - this); - view.findViewById(R.id.rl_clean_cache).setOnClickListener(this); - view.findViewById(R.id.rl_double_click_exit).setOnClickListener(this); - view.findViewById(R.id.rl_about).setOnClickListener(this); - view.findViewById(R.id.rl_exit).setOnClickListener(this); - - if (!AppContext.getInstance().isLogin()) { - mTvExit.setText("退出"); - } - } - - @Override - public void initData() { - if (AppContext.get(AppConfig.KEY_LOAD_IMAGE, true)) { - mTbLoadImg.setToggleOn(); - } else { - mTbLoadImg.setToggleOff(); - } - - if (AppContext.get(AppConfig.KEY_DOUBLE_CLICK_EXIT, true)) { - mTbDoubleClickExit.setToggleOn(); - } else { - mTbDoubleClickExit.setToggleOff(); - } - - caculateCacheSize(); - } - - /** - * 计算缓存的大小 - */ - private void caculateCacheSize() { - long fileSize = 0; - String cacheSize = "0KB"; - File filesDir = getActivity().getFilesDir(); - File cacheDir = getActivity().getCacheDir(); - - fileSize += FileUtil.getDirSize(filesDir); - fileSize += FileUtil.getDirSize(cacheDir); - // 2.2版本才有将应用缓存转移到sd卡的功能 - if (AppContext.isMethodsCompat(android.os.Build.VERSION_CODES.FROYO)) { - File externalCacheDir = MethodsCompat - .getExternalCacheDir(getActivity()); - fileSize += FileUtil.getDirSize(externalCacheDir); - fileSize += FileUtil.getDirSize(new File( - org.kymjs.kjframe.utils.FileUtils.getSDCardPath() - + File.separator + HttpConfig.CACHEPATH)); - } - if (fileSize > 0) - cacheSize = FileUtil.formatFileSize(fileSize); - mTvCacheSize.setText(cacheSize); - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - switch (id) { - case R.id.rl_loading_img: - mTbLoadImg.toggle(); - break; - case R.id.rl_notification_settings: - UIHelper.showSettingNotification(getActivity()); - break; - case R.id.rl_clean_cache: - onClickCleanCache(); - break; - case R.id.rl_double_click_exit: - mTbDoubleClickExit.toggle(); - break; - case R.id.rl_about: - UIHelper.showAboutOSC(getActivity()); - break; - case R.id.rl_exit: - onClickExit(); - break; - default: - break; - } - - } - - private void onClickCleanCache() { - DialogHelp.getConfirmDialog(getActivity(), "是否清空缓存?", new DialogInterface.OnClickListener - () { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - UIHelper.clearAppCache(getActivity()); - mTvCacheSize.setText("0KB"); - } - }).show(); - } - - private void onClickExit() { - AppContext - .set(AppConfig.KEY_NOTIFICATION_DISABLE_WHEN_EXIT, - false); - AppManager.getAppManager().AppExit(getActivity()); - getActivity().finish(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SettingsNotificationFragment.java b/app/src/main/java/net/oschina/app/fragment/SettingsNotificationFragment.java deleted file mode 100644 index 11a22e4d6338fe84d48e2a5b2d7f958e99c5d803..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SettingsNotificationFragment.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.oschina.app.fragment; - -import net.oschina.app.AppConfig; -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.widget.togglebutton.ToggleButton; -import net.oschina.app.widget.togglebutton.ToggleButton.OnToggleChanged; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class SettingsNotificationFragment extends BaseFragment { - - @InjectView(R.id.tb_accept) ToggleButton mTbAccept; - @InjectView(R.id.tb_voice) ToggleButton mTbVoice; - @InjectView(R.id.tb_vibration) ToggleButton mTbVibration; - @InjectView(R.id.tb_app_exit) ToggleButton mTbAppExit; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_settings_notifcation, container, - false); - ButterKnife.inject(this, view); - initView(view); - initData(); - return view; - } - - @Override - public void initView(View view) { - setToggleChanged(mTbAccept, AppConfig.KEY_NOTIFICATION_ACCEPT); - setToggleChanged(mTbVoice, AppConfig.KEY_NOTIFICATION_SOUND); - setToggleChanged(mTbVibration, AppConfig.KEY_NOTIFICATION_VIBRATION); - setToggleChanged(mTbAppExit, AppConfig.KEY_NOTIFICATION_DISABLE_WHEN_EXIT); - - view.findViewById(R.id.rl_accept).setOnClickListener(this); - view.findViewById(R.id.rl_voice).setOnClickListener(this); - view.findViewById(R.id.rl_vibration).setOnClickListener(this); - view.findViewById(R.id.rl_app_exit).setOnClickListener(this); - } - - public void initData() { - setToggle(AppContext.get(AppConfig.KEY_NOTIFICATION_ACCEPT, true), mTbAccept); - setToggle(AppContext.get(AppConfig.KEY_NOTIFICATION_SOUND, true), mTbVoice); - setToggle(AppContext.get(AppConfig.KEY_NOTIFICATION_VIBRATION, true), mTbVibration); - setToggle(AppContext.get(AppConfig.KEY_NOTIFICATION_DISABLE_WHEN_EXIT, true), mTbAppExit); - } - - private void setToggleChanged(ToggleButton tb, final String key) { - tb.setOnToggleChanged(new OnToggleChanged() { - - @Override - public void onToggle(boolean on) { - AppContext.set(key, on); - } - }); - } - - private void setToggle(boolean value, ToggleButton tb) { - if (value) - tb.setToggleOn(); - else - tb.setToggleOff(); - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - switch (id) { - case R.id.rl_accept: - mTbAccept.toggle(); - break; - case R.id.rl_voice: - mTbVoice.toggle(); - break; - case R.id.rl_vibration: - mTbVibration.toggle(); - break; - case R.id.rl_app_exit: - mTbAppExit.toggle(); - break; - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SoftWareTweetsFrament.java b/app/src/main/java/net/oschina/app/fragment/SoftWareTweetsFrament.java deleted file mode 100644 index 067b922ac107e5a6250907fa78df63a61db1c00f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SoftWareTweetsFrament.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.TweetAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Tweet; -import net.oschina.app.bean.TweetsList; -import net.oschina.app.service.ServerTaskUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.view.WindowManager; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; - -public class SoftWareTweetsFrament extends BaseListFragment implements - OnItemLongClickListener { - - public static final String BUNDLE_KEY_ID = "BUNDLE_KEY_ID"; - protected static final String TAG = SoftWareTweetsFrament.class - .getSimpleName(); - private static final String CACHE_KEY_PREFIX = "software_tweet_list"; - - private int mId; - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - BaseActivity act = ((BaseActivity) activity); - try { - activity.findViewById(R.id.emoji_container).setVisibility( - View.VISIBLE); - } catch (NullPointerException e) { - } - } - - protected int getLayoutRes() { - return R.layout.fragment_pull_refresh_listview; - } - - @Override - public void initView(View view) { - super.initView(view); - mListView.setOnItemLongClickListener(this); - } - - @Override - public void onCreate(android.os.Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - mId = args.getInt(BUNDLE_KEY_ID, 0); - } - - int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - getActivity().getWindow().setSoftInputMode(mode); - } - - @Override - protected TweetAdapter getListAdapter() { - return new TweetAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return new StringBuilder(CACHE_KEY_PREFIX).append("_").append(mId) - .toString(); - } - - @Override - protected TweetsList parseList(InputStream is) throws Exception { - return XmlUtils.toBean(TweetsList.class, is); - } - - @Override - protected TweetsList readList(Serializable seri) { - return ((TweetsList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getSoftTweetList(mId, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - final Tweet tweet = mAdapter.getItem(position); - if (tweet == null) { - return; - } - UIHelper.showTweetDetail(parent.getContext(), tweet, tweet.getId()); - } - - private void handleComment(String text) { - Tweet tweet = new Tweet(); - tweet.setAuthorid(AppContext.getInstance().getLoginUid()); - tweet.setBody(text); - ServerTaskUtils.pubSoftWareTweet(getActivity(), tweet, mId); - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - return true; - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SoftwareCatalogListFragment.java b/app/src/main/java/net/oschina/app/fragment/SoftwareCatalogListFragment.java deleted file mode 100644 index d2eae81525915956a15fc1ae620a2ad254050734..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SoftwareCatalogListFragment.java +++ /dev/null @@ -1,329 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.ByteArrayInputStream; -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.adapter.SoftwareAdapter; -import net.oschina.app.adapter.SoftwareCatalogListAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.SoftwareCatalogList; -import net.oschina.app.bean.SoftwareCatalogList.SoftwareType; -import net.oschina.app.bean.SoftwareDec; -import net.oschina.app.bean.SoftwareList; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.widget.ScrollLayout; - -import cz.msebera.android.httpclient.Header; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView; -import android.widget.AbsListView.OnScrollListener; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ListView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -public class SoftwareCatalogListFragment extends BaseFragment implements - OnItemClickListener, OnScrollListener { - protected static final int STATE_NONE = 0; - protected static final int STATE_REFRESH = 1; - protected static final int STATE_LOADMORE = 2; - - private final static int SCREEN_CATALOG = 0; - private final static int SCREEN_TAG = 1; - private final static int SCREEN_SOFTWARE = 2; - - private static ScrollLayout mScrollLayout; - private static ListView mLvCatalog, mLvTag, mLvSoftware; - private static EmptyLayout mEmptyView; - private static SoftwareCatalogListAdapter mCatalogAdapter, mTagAdapter; - private static SoftwareAdapter mSoftwareAdapter; - private static int mState = STATE_NONE; - private static int curScreen = SCREEN_CATALOG;// 默认当前屏幕 - private static int mCurrentTag; - private static int mCurrentPage; - - private AsyncHttpResponseHandler mCatalogHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - SoftwareCatalogList list = XmlUtils.toBean( - SoftwareCatalogList.class, new ByteArrayInputStream( - arg2)); - if (mState == STATE_REFRESH) - mCatalogAdapter.clear(); - List data = list.getSoftwarecataloglist(); - mCatalogAdapter.addData(data); - mEmptyView.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (data.size() == 0 && mState == STATE_REFRESH) { - mEmptyView.setErrorType(EmptyLayout.NODATA); - } else { - mCatalogAdapter - .setState(ListBaseAdapter.STATE_LESS_ONE_PAGE); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - mEmptyView.setErrorType(EmptyLayout.NETWORK_ERROR); - } - - public void onFinish() { - mState = STATE_NONE; - } - }; - - private AsyncHttpResponseHandler mTagHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - SoftwareCatalogList list = XmlUtils.toBean( - SoftwareCatalogList.class, new ByteArrayInputStream( - arg2)); - if (mState == STATE_REFRESH) - mTagAdapter.clear(); - List data = list.getSoftwarecataloglist(); - mTagAdapter.addData(data); - mEmptyView.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (data.size() == 0 && mState == STATE_REFRESH) { - mEmptyView.setErrorType(EmptyLayout.NODATA); - } else { - mTagAdapter.setState(ListBaseAdapter.STATE_LESS_ONE_PAGE); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - mEmptyView.setErrorType(EmptyLayout.NETWORK_ERROR); - } - - public void onFinish() { - mState = STATE_NONE; - } - }; - - private AsyncHttpResponseHandler mSoftwareHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int statusCode, Header[] headers, - byte[] responseBytes) { - try { - SoftwareList list = XmlUtils.toBean(SoftwareList.class, - new ByteArrayInputStream(responseBytes)); - executeOnLoadDataSuccess(list.getSoftwarelist()); - - } catch (Exception e) { - e.printStackTrace(); - onFailure(statusCode, headers, responseBytes, null); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - mEmptyView.setErrorType(EmptyLayout.NETWORK_ERROR); - } - - public void onFinish() { - mState = STATE_NONE; - } - }; - - private OnItemClickListener mCatalogOnItemClick = new OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - SoftwareType type = (SoftwareType) mCatalogAdapter - .getItem(position); - if (type != null && type.getTag() > 0) { - // 加载二级分类 - curScreen = SCREEN_TAG; - mScrollLayout.scrollToScreen(curScreen); - mCurrentTag = type.getTag(); - sendRequestCatalogData(mTagHandler); - } - } - }; - - private OnItemClickListener mTagOnItemClick = new OnItemClickListener() { - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - SoftwareType type = (SoftwareType) mTagAdapter.getItem(position); - if (type != null && type.getTag() > 0) { - // 加载二级分类里面的软件列表 - curScreen = SCREEN_SOFTWARE; - mScrollLayout.scrollToScreen(curScreen); - mCurrentTag = type.getTag(); - mState = STATE_REFRESH; - sendRequestTagData(); - } - } - }; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_opensoftware, container, - false); - initViews(view); - return view; - } - - private void initViews(View view) { - mScrollLayout = (ScrollLayout) view.findViewById(R.id.scrolllayout); - mScrollLayout.setIsScroll(false); - - mEmptyView = (EmptyLayout) view.findViewById(R.id.error_layout); - mLvCatalog = (ListView) view.findViewById(R.id.lv_catalog); - mLvCatalog.setOnItemClickListener(mCatalogOnItemClick); - mLvTag = (ListView) view.findViewById(R.id.lv_tag); - mLvTag.setOnItemClickListener(mTagOnItemClick); - if (mCatalogAdapter == null) { - mCatalogAdapter = new SoftwareCatalogListAdapter(); - sendRequestCatalogData(mCatalogHandler); - } - mLvCatalog.setAdapter(mCatalogAdapter); - - if (mTagAdapter == null) { - mTagAdapter = new SoftwareCatalogListAdapter(); - } - mLvTag.setAdapter(mTagAdapter); - - if (mSoftwareAdapter == null) { - mSoftwareAdapter = new SoftwareAdapter(); - } - - mLvSoftware = (ListView) view.findViewById(R.id.lv_software); - mLvSoftware.setOnItemClickListener(this); - mLvSoftware.setOnScrollListener(this); - mLvSoftware.setAdapter(mSoftwareAdapter); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - SoftwareDec software = (SoftwareDec) mSoftwareAdapter.getItem(position); - if (software != null) - UIHelper.showUrlRedirect(view.getContext(), software.getUrl()); - } - - @Override - public boolean onBackPressed() { - mEmptyView.setErrorType(EmptyLayout.HIDE_LAYOUT); - mCurrentPage = 0; - switch (curScreen) { - case SCREEN_SOFTWARE: - curScreen = SCREEN_TAG; - mScrollLayout.scrollToScreen(SCREEN_TAG); - return true; - case SCREEN_TAG: - curScreen = SCREEN_CATALOG; - mScrollLayout.scrollToScreen(SCREEN_CATALOG); - return true; - case SCREEN_CATALOG: - return false; - } - return super.onBackPressed(); - } - - private void sendRequestCatalogData(AsyncHttpResponseHandler handler) { - mState = STATE_REFRESH; - mEmptyView.setErrorType(EmptyLayout.NETWORK_LOADING); - OSChinaApi.getSoftwareCatalogList(mCurrentTag, handler); - } - - private void sendRequestTagData() { - OSChinaApi.getSoftwareTagList(mCurrentTag, mCurrentPage, - mSoftwareHandler); - } - - private void executeOnLoadDataSuccess(List data) { - if (data == null) { - return; - } - mEmptyView.setErrorType(EmptyLayout.HIDE_LAYOUT); - - if (mCurrentPage == 0) { - mSoftwareAdapter.clear(); - } - - for (int i = 0; i < data.size(); i++) { - if (compareTo(mSoftwareAdapter.getData(), data.get(i))) { - data.remove(i); - } - } - int adapterState = ListBaseAdapter.STATE_EMPTY_ITEM; - if (mSoftwareAdapter.getCount() == 0 && mState == STATE_NONE) { - mEmptyView.setErrorType(EmptyLayout.NODATA); - } else if (data.size() == 0 || (data.size() < 20 && mCurrentPage == 0)) { - adapterState = ListBaseAdapter.STATE_NO_MORE; - } else { - adapterState = ListBaseAdapter.STATE_LOAD_MORE; - } - mSoftwareAdapter.setState(adapterState); - mSoftwareAdapter.addData(data); - } - - private boolean compareTo(List data, SoftwareDec enity) { - int s = data.size(); - if (enity != null) { - for (int i = 0; i < s; i++) { - if (enity.getName().equals( - ((SoftwareDec) data.get(i)).getName())) { - return true; - } - } - } - return false; - } - - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, - int visibleItemCount, int totalItemCount) { - // 数据已经全部加载,或数据为空时,或正在加载,不处理滚动事件 - if (mState == STATE_NOMORE || mState == STATE_LOADMORE - || mState == STATE_REFRESH) { - return; - } - if (mSoftwareAdapter != null - && mSoftwareAdapter.getDataSize() > 0 - && mLvSoftware.getLastVisiblePosition() == (mLvSoftware - .getCount() - 1)) { - if (mState == STATE_NONE - && mSoftwareAdapter.getState() == ListBaseAdapter.STATE_LOAD_MORE) { - mState = STATE_LOADMORE; - mCurrentPage++; - sendRequestTagData(); - } - } - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SoftwareDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/SoftwareDetailFragment.java deleted file mode 100644 index 6e76225e382bf07d115cb312b37a4dfa24fc2388..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SoftwareDetailFragment.java +++ /dev/null @@ -1,196 +0,0 @@ -package net.oschina.app.fragment; - -import android.text.Editable; -import android.text.TextUtils; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.CommonDetailFragment; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.bean.Software; -import net.oschina.app.bean.SoftwareDetail; -import net.oschina.app.bean.Tweet; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.URLsUtils; -import net.oschina.app.util.XmlUtils; - -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -/** - * Created by 火蚁 on 15/5/26. - */ -public class SoftwareDetailFragment extends CommonDetailFragment { - - private String mIden; - - @Override - protected String getCacheKey() { - if (TextUtils.isEmpty(mIden)) { - return "software_" + mId; - } - return "software_" + mIden; - } - - @Override - protected void sendRequestDataForNet() { - // 通过id来获取软件详情 - if (mId > 0) { - OSChinaApi.getSoftwareDetail(mId, mDetailHeandler); - return; - } - - if (TextUtils.isEmpty(mIden)) { - executeOnLoadDataError(); - return; - } - OSChinaApi.getSoftwareDetail(mIden, mDetailHeandler); - } - - @Override - public void initData() { - super.initData(); - mIden = getActivity().getIntent().getStringExtra("ident"); - if (TextUtils.isEmpty(mIden)) { - return; - } - try { - mIden = URLEncoder.encode(mIden, "UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - - @Override - protected Software parseData(InputStream is) { - return XmlUtils.toBean(SoftwareDetail.class, is).getSoftware(); - } - - @Override - protected String getWebViewBody(Software detail) { - mId = detail.getId(); - if (TextUtils.isEmpty(detail.getBody())) { - return ""; - } - StringBuffer body = new StringBuffer(); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - body.append(UIHelper.WEB_STYLE).append(UIHelper.WEB_LOAD_IMAGES); - // 添加title - String title = ""; - // 判断是否推荐 - if (mDetail.getRecommended() == 4) { - title = String.format("
    %s %s
    ", mDetail.getLogo(), mDetail.getExtensionTitle(), mDetail.getTitle(), "file:///android_asset/ic_soft_recommend.png"); - } else { - title = String.format("
    %s %s
    ", mDetail.getLogo(), mDetail.getExtensionTitle(), mDetail.getTitle()); - } - body.append(title); - // 添加图片点击放大支持 - body.append(UIHelper.setHtmlCotentSupportImagePreview(mDetail.getBody())); - - // 软件信息 - body.append("
    "); - if (!TextUtils.isEmpty(mDetail.getAuthor())) { - String author = String.format("%s", mDetail.getAuthorId(), mDetail.getAuthor()); - body.append(String.format("
  • 软件作者:  %s
  • ", author)); - } - body.append(String.format("
  • 开源协议:  %s
  • ", mDetail.getLicense())); - body.append(String.format("
  • 开发语言:  %s
  • ", mDetail.getLanguage())); - body.append(String.format("
  • 操作系统:  %s
  • ", mDetail.getOs())); - body.append(String.format("
  • 收录时间:  %s
  • ", mDetail.getRecordtime())); - body.append("
    "); - - // 软件的首页、文档、下载 - body.append("
    "); - if (!TextUtils.isEmpty(mDetail.getHomepage())) { - body.append(String.format("
  • 软件首页
  • ", mDetail.getHomepage())); - } - if (!TextUtils.isEmpty(mDetail.getDocument())) { - body.append(String.format("
  • 软件文档
  • ", mDetail.getDocument())); - } - if (!TextUtils.isEmpty(mDetail.getDownload())) { - body.append(String.format("
  • 软件下载
  • ", mDetail.getDownload())); - } - body.append("
    "); - // 封尾 - body.append(""); - return body.toString(); - } - - @Override - protected void showCommentView() { - if (mDetail != null) - UIHelper.showSoftWareTweets(getActivity(), mDetail.getId()); - } - - @Override - public void onClickSendButton(Editable str) { - if (mDetail.getId() == 0) { - AppContext.showToast("无法获取该软件~"); - return; - } - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (TextUtils.isEmpty(str)) { - AppContext.showToastShort(R.string.tip_comment_content_empty); - return; - } - Tweet tweet = new Tweet(); - tweet.setAuthorid(AppContext.getInstance().getLoginUid()); - tweet.setBody(str.toString()); - showWaitDialog(R.string.progress_submit); - OSChinaApi.pubSoftWareTweet(tweet, mDetail.getId(), mCommentHandler); - } - - @Override - protected int getCommentType() { - return 0; - } - - @Override - protected int getFavoriteTargetType() { - return FavoriteList.TYPE_SOFTWARE; - } - - @Override - protected int getFavoriteState() { - return mDetail.getFavorite(); - } - - @Override - protected void updateFavoriteChanged(int newFavoritedState) { - mDetail.setFavorite(newFavoritedState); - saveCache(mDetail); - } - - @Override - protected int getCommentCount() { - return mDetail.getTweetCount(); - } - - @Override - protected String getShareTitle() { - return String.format("%s %s", mDetail.getExtensionTitle(), mDetail.getTitle()); - } - - @Override - protected String getShareContent() { - return StringUtils.getSubString(0, 55, - getFilterHtmlBody(mDetail.getBody())); - } - - @Override - protected String getShareUrl() { - return String.format(URLsUtils.URL_MOBILE + "p/%s", mIden); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/SoftwareListFragment.java b/app/src/main/java/net/oschina/app/fragment/SoftwareListFragment.java deleted file mode 100644 index 266682c0aa08b12e168aec2ede8d086b8a6fd2a0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/SoftwareListFragment.java +++ /dev/null @@ -1,92 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.List; - -import net.oschina.app.adapter.SoftwareAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.ListEntity; -import net.oschina.app.bean.SoftwareDec; -import net.oschina.app.bean.SoftwareList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -public class SoftwareListFragment extends BaseListFragment { - - public static final String BUNDLE_SOFTWARE = "BUNDLE_SOFTWARE"; - - protected static final String TAG = SoftwareListFragment.class - .getSimpleName(); - private static final String CACHE_KEY_PREFIX = "softwarelist_"; - - private String softwareType = "recommend"; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Bundle args = getArguments(); - if (args != null) { - softwareType = args.getString(BUNDLE_SOFTWARE); - } - } - - @Override - protected SoftwareAdapter getListAdapter() { - return new SoftwareAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + softwareType; - } - - @Override - protected SoftwareList parseList(InputStream is) throws Exception { - SoftwareList list = XmlUtils.toBean(SoftwareList.class, is); - return list; - } - - @Override - protected ListEntity readList(Serializable seri) { - return ((SoftwareList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getSoftwareList(softwareType, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - SoftwareDec softwaredec = (SoftwareDec) mAdapter.getItem(position); - if (softwaredec != null) { - String ident = softwaredec.getUrl().substring(softwaredec.getUrl().lastIndexOf("/") + 1); - UIHelper.showSoftwareDetail(getActivity(), ident); - // 放入已读列表 - saveToReadedList(view, SoftwareList.PREF_READED_SOFTWARE_LIST, - softwaredec.getName()); - } - } - - @Override - protected boolean compareTo(List data, Entity enity) { - int s = data.size(); - if (enity != null) { - for (int i = 0; i < s; i++) { - if (((SoftwareDec) enity).getName().equals( - ((SoftwareDec) data.get(i)).getName())) { - return true; - } - } - } - return false; - } - -} diff --git a/app/src/main/java/net/oschina/app/fragment/TweetDetailFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetDetailFragment.java deleted file mode 100644 index b200143e8194e0b0554c828fe7cc9a90491d0190..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetDetailFragment.java +++ /dev/null @@ -1,548 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.DialogInterface; -import android.content.Intent; -import android.graphics.drawable.AnimationDrawable; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.webkit.WebView; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.AdapterView.OnItemLongClickListener; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.CommentAdapter; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BeseHaveHeaderListFragment; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Comment; -import net.oschina.app.bean.CommentList; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.Tweet; -import net.oschina.app.bean.TweetDetail; -import net.oschina.app.cache.CacheManager; -import net.oschina.app.emoji.OnSendClickListener; -import net.oschina.app.ui.DetailActivity; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.KJAnimations; -import net.oschina.app.util.PlatfromUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.ThemeSwitchUtils; -import net.oschina.app.util.TypefaceUtils; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.RecordButtonUtil; -import net.oschina.app.widget.RecordButtonUtil.OnPlayListener; - -import cz.msebera.android.httpclient.Header; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; -import java.util.List; - -/*** - * 动弹详情,实际每个item显示的数据类型是Comment - * - * TweetDetailFragment.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-1-28 上午11:48:41 - */ -public class TweetDetailFragment extends - BeseHaveHeaderListFragment implements - OnItemClickListener, OnItemLongClickListener, OnSendClickListener { - - private static final String CACHE_KEY_PREFIX = "tweet_"; - private static final String CACHE_KEY_TWEET_COMMENT = "tweet_comment_"; - private AvatarView mIvAvatar; - private TextView mTvName, mTvFrom, mTvTime, mTvCommentCount; - private WebView mContent; - private int mTweetId; - private Tweet mTweet; - private RelativeLayout mRlRecordSound; - private final RecordButtonUtil util = new RecordButtonUtil(); - - private TextView mLikeUser; - private TextView mTvLikeState; - - private DetailActivity outAty; - - @Override - protected CommentAdapter getListAdapter() { - return new CommentAdapter(); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - outAty = (DetailActivity) getActivity(); - return super.onCreateView(inflater, container, savedInstanceState); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_TWEET_COMMENT + mTweetId + "_" + mCurrentPage; - } - - @Override - protected CommentList parseList(InputStream is) throws Exception { - CommentList list = XmlUtils.toBean(CommentList.class, is); - return list; - } - - @Override - protected CommentList readList(Serializable seri) { - return ((CommentList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getCommentList(mTweetId, CommentList.CATALOG_TWEET, - mCurrentPage, mHandler); - } - - /** - * 初始化声音动弹的录音View - * - * @param header - */ - private void initSoundView(View header) { - final ImageView playerButton = (ImageView) header - .findViewById(R.id.tweet_img_record); - final TextView playerTime = (TextView) header - .findViewById(R.id.tweet_tv_record); - final AnimationDrawable drawable = (AnimationDrawable) playerButton - .getBackground(); - mRlRecordSound = (RelativeLayout) header - .findViewById(R.id.tweet_bg_record); - mRlRecordSound.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (mTweet != null) { - util.startPlay(mTweet.getAttach(), playerTime); - } else { - AppContext.showToast("找不到语音动弹,可能已经被主人删除了"); - } - } - }); - - util.setOnPlayListener(new OnPlayListener() { - @SuppressWarnings("deprecation") - @Override - public void stopPlay() { - drawable.stop(); - playerButton.setBackgroundDrawable(drawable.getFrame(0)); - } - - @SuppressWarnings("deprecation") - @Override - public void starPlay() { - playerButton.setBackgroundDrawable(drawable); - drawable.start(); - } - }); - } - - @Override - public void onStop() { - super.onStop(); - if (util != null && util.isPlaying()) { - util.stopPlay(); - } - } - - @Override - protected boolean requestDataIfViewCreated() { - return false; - } - - @Override - public void onResume() { - super.onResume(); - outAty.emojiFragment.hideFlagButton(); - } - - private void fillUI() { - mIvAvatar.setAvatarUrl(mTweet.getPortrait()); - mIvAvatar.setUserInfo(mTweet.getAuthorid(), mTweet.getAuthor()); - mTvName.setText(mTweet.getAuthor()); - mTvTime.setText(StringUtils.friendly_time(mTweet.getPubDate())); - PlatfromUtil.setPlatFromString(mTvFrom, mTweet.getAppclient()); - - mTvCommentCount.setText(mTweet.getCommentCount() + ""); - if (StringUtils.isEmpty(mTweet.getAttach())) { - mRlRecordSound.setVisibility(View.GONE); - } else { - mRlRecordSound.setVisibility(View.VISIBLE); - } - fillWebViewBody(); - setLikeUser(); - setLikeState(); - } - - private void setLikeState() { - if (mTweet != null) { - if (mTweet.getIsLike() == 1) { - mTvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color.day_colorPrimary)); - } else { - mTvLikeState.setTextColor(AppContext.getInstance().getResources().getColor(R.color.gray)); - } - } - } - - private void setLikeUser() { - if (mTweet == null || mTweet.getLikeUser() == null - || mTweet.getLikeUser().isEmpty()) { - mLikeUser.setVisibility(View.GONE); - } else { - mLikeUser.setVisibility(View.VISIBLE); - mTweet.setLikeUsers(getActivity(), mLikeUser, false); - } - } - - /** - * 填充webview内容 - */ - private void fillWebViewBody() { - StringBuffer body = new StringBuffer(); - body.append(ThemeSwitchUtils.getWebViewBodyString()); - body.append(UIHelper.WEB_STYLE + UIHelper.WEB_LOAD_IMAGES); - - StringBuilder tweetbody = new StringBuilder(mTweet.getBody()); - - String tweetBody = TextUtils.isEmpty(mTweet.getImgSmall()) ? tweetbody - .toString() : tweetbody.toString() + "
    "; - body.append(setHtmlCotentSupportImagePreview(tweetBody)); - - UIHelper.addWebImageShow(getActivity(), mContent); - // 封尾 - body.append(""); - mContent.loadDataWithBaseURL(null, body.toString(), "text/html", - "utf-8", null); - } - - /** - * 添加图片放大支持 - * - * @param body - * @return - */ - private String setHtmlCotentSupportImagePreview(String body) { - // 过滤掉 img标签的width,height属性 - body = body.replaceAll("(]*?)\\s+width\\s*=\\s*\\S+", "$1"); - body = body.replaceAll("(]*?)\\s+height\\s*=\\s*\\S+", "$1"); - return body.replaceAll("(]+src=\")(\\S+)\"", - "$1$2\" onClick=\"javascript:mWebViewImageListener.showImagePreview('" - + mTweet.getImgBig() + "')\""); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - final Comment comment = mAdapter.getItem(position - 1); - if (comment == null) - return; - outAty.emojiFragment.getEditText().setHint("回复:" + comment.getAuthor()); - outAty.emojiFragment.getEditText().setTag(comment); - outAty.emojiFragment.showSoftKeyboard(); - } - - private final AsyncHttpResponseHandler mCommentHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - ResultBean rsb = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)); - Result res = rsb.getResult(); - if (res.OK()) { - hideWaitDialog(); - AppContext.showToastShort(R.string.comment_publish_success); - mAdapter.setState(ListBaseAdapter.STATE_NO_MORE); - mAdapter.addItem(0, rsb.getComment()); - setTweetCommentCount(); - } else { - hideWaitDialog(); - AppContext.showToastShort(res.getErrorMessage()); - } - outAty.emojiFragment.clean(); - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - hideWaitDialog(); - AppContext.showToastShort(R.string.comment_publish_faile); - } - }; - - class DeleteOperationResponseHandler extends OperationResponseHandler { - - DeleteOperationResponseHandler(Object... args) { - super(args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) { - try { - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res.OK()) { - AppContext.showToastShort(R.string.delete_success); - mAdapter.removeItem(args[0]); - setTweetCommentCount(); - } else { - AppContext.showToastShort(res.getErrorMessage()); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(code, e.getMessage(), args); - } - } - - @Override - public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { - - } - - @Override - public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { - AppContext.showToastShort(R.string.delete_faile); - } - } - - private void handleDeleteComment(Comment comment) { - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - AppContext.showToastShort(R.string.deleting); - OSChinaApi.deleteComment(mTweetId, CommentList.CATALOG_TWEET, - comment.getId(), comment.getAuthorId(), - new DeleteOperationResponseHandler(comment)); - } - - private void setTweetCommentCount() { - mAdapter.notifyDataSetChanged(); - if (mTweet != null) { - mTweet.setCommentCount(mAdapter.getDataSize() + ""); - mTvCommentCount.setText(mTweet.getCommentCount() + ""); - } - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - if (position - 1 == -1) { - return false; - } - final Comment item = mAdapter.getItem(position - 1); - if (item == null) - return false; - int itemsLen = item.getAuthorId() == AppContext.getInstance() - .getLoginUid() ? 2 : 1; - String[] items = new String[itemsLen]; - items[0] = getResources().getString(R.string.copy); - if (itemsLen == 2) { - items[1] = getResources().getString(R.string.delete); - } - DialogHelp.getSelectDialog(getActivity(), items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(item - .getContent())); - } else if (i == 1) { - handleDeleteComment(item); - } - } - }).show(); - return true; - } - - @Override - protected void requestDetailData(boolean isRefresh) { - String key = getDetailCacheKey(); - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - if (TDevice.hasInternet() - && (!CacheManager.isExistDataCache(getActivity(), key) || isRefresh)) { - OSChinaApi.getTweetDetail(mTweetId, mDetailHandler); - } else { - readDetailCacheData(key); - } - } - - @Override - protected boolean isRefresh() { - return true; - } - - @Override - protected View initHeaderView() { - Intent args = getActivity().getIntent(); - mTweetId = args.getIntExtra("tweet_id", 0); - mTweet = (Tweet) args.getParcelableExtra("tweet"); - - mListView.setOnItemLongClickListener(this); - View header = LayoutInflater.from(getActivity()).inflate( - R.layout.list_header_tweet_detail, null); - mIvAvatar = (AvatarView) header.findViewById(R.id.iv_avatar); - - mTvName = (TextView) header.findViewById(R.id.tv_name); - mTvFrom = (TextView) header.findViewById(R.id.tv_from); - mTvTime = (TextView) header.findViewById(R.id.tv_time); - mTvCommentCount = (TextView) header.findViewById(R.id.tv_comment_count); - mContent = (WebView) header.findViewById(R.id.webview); - UIHelper.initWebView(mContent); - mContent.loadUrl("file:///android_asset/detail_page.html"); - initSoundView(header); - mLikeUser = (TextView) header.findViewById(R.id.tv_likeusers); - mTvLikeState = (TextView) header.findViewById(R.id.tv_like_state); - mTvLikeState.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - likeOption(); - } - }); - TypefaceUtils.setTypeface(mTvLikeState); - return header; - } - - private void likeOption() { - if (mTweet == null) - return; - AsyncHttpResponseHandler handler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {} - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) {} - }; - if (AppContext.getInstance().isLogin()) { - if (mTweet.getIsLike() == 1) { - mTweet.setIsLike(0); - mTweet.getLikeUser().remove(0); - mTweet.setLikeCount(mTweet.getLikeCount() - 1); - OSChinaApi.pubUnLikeTweet(mTweetId, mTweet.getAuthorid(), - handler); - } else { - mTvLikeState.setAnimation(KJAnimations.getScaleAnimation(1.5f, - 300)); - mTweet.setIsLike(1); - mTweet.getLikeUser().add(0, - AppContext.getInstance().getLoginUser()); - mTweet.setLikeCount(mTweet.getLikeCount() + 1); - OSChinaApi - .pubLikeTweet(mTweetId, mTweet.getAuthorid(), handler); - } - setLikeState(); - mTweet.setLikeUsers(getActivity(), mLikeUser, false); - } else { - AppContext.showToast("先登陆再点赞~"); - UIHelper.showLoginActivity(getActivity()); - } - } - - @Override - protected String getDetailCacheKey() { - return CACHE_KEY_PREFIX + mTweetId; - } - - @Override - protected void executeOnLoadDetailSuccess(TweetDetail detailBean) { - mErrorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT); - this.mTweet = detailBean.getTweet(); - fillUI(); - mAdapter.setNoDataText(R.string.comment_empty); - } - - @Override - protected TweetDetail getDetailBean(ByteArrayInputStream is) { - return XmlUtils.toBean(TweetDetail.class, is); - } - - @Override - protected void executeOnLoadDataSuccess(List data) { - super.executeOnLoadDataSuccess(data); - int commentCount = StringUtils.toInt(mTweet == null ? 0 : this.mTweet - .getCommentCount()); - if (commentCount < (mAdapter.getCount() - 1)) { - commentCount = mAdapter.getCount() - 1; - } - mTvCommentCount.setText(commentCount + ""); - } - - @Override - public void onClickSendButton(Editable str) { - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (TextUtils.isEmpty(str)) { - AppContext.showToastShort(R.string.tip_comment_content_empty); - return; - } - showWaitDialog(R.string.progress_submit); - try { - if (outAty.emojiFragment.getEditText().getTag() != null) { - Comment comment = (Comment) outAty.emojiFragment.getEditText() - .getTag(); - OSChinaApi.replyComment(mTweetId, CommentList.CATALOG_TWEET, - comment.getId(), comment.getAuthorId(), AppContext - .getInstance().getLoginUid(), str.toString(), - mCommentHandler); - } else { - OSChinaApi.publicComment(CommentList.CATALOG_TWEET, mTweetId, - AppContext.getInstance().getLoginUid(), str.toString(), - 0, mCommentHandler); - } - } catch (Exception e) { - } - } - - @Override - public void onClickFlagButton() {} - - @Override - public boolean onBackPressed() { - if (outAty.emojiFragment.isShowEmojiKeyBoard()) { - outAty.emojiFragment.hideAllKeyBoard(); - return true; - } - if (outAty.emojiFragment.getEditText().getTag() != null) { - outAty.emojiFragment.getEditText().setTag(null); - outAty.emojiFragment.getEditText().setHint("说点什么吧"); - return true; - } - return super.onBackPressed(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/TweetLikeUsersFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetLikeUsersFragment.java deleted file mode 100644 index 8ece7df02377853f9d4cb2163d2743427c16ef5f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetLikeUsersFragment.java +++ /dev/null @@ -1,77 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -import net.oschina.app.adapter.TweetLikeUsersAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseActivity; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.TweetLikeUserList; -import net.oschina.app.bean.User; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -/** - * TweetLikeUsersFragment.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-3-26 下午4:04:12 - */ -public class TweetLikeUsersFragment extends BaseListFragment { - - @Override - protected TweetLikeUsersAdapter getListAdapter() { - // TODO Auto-generated method stub - return new TweetLikeUsersAdapter(); - } - - @Override - public void onCreate(Bundle savedInstanceState) { - // TODO Auto-generated method stub - super.onCreate(savedInstanceState); - BaseActivity activity = (BaseActivity) getActivity(); - activity.setActionBarTitle("动弹点赞列表"); - } - - @Override - protected String getCacheKeyPrefix() { - // TODO Auto-generated method stub - return "tweet_like_list_" + mCatalog; - } - - @Override - protected TweetLikeUserList parseList(InputStream is) throws Exception { - // TODO Auto-generated method stub - TweetLikeUserList list = XmlUtils.toBean(TweetLikeUserList.class, is); - return list; - } - - @Override - protected TweetLikeUserList readList(Serializable seri) { - // TODO Auto-generated method stub - return (TweetLikeUserList) seri; - } - - @Override - protected void sendRequestData() { - // TODO Auto-generated method stub - OSChinaApi.getTweetLikeList(mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - // TODO Auto-generated method stub - User item = mAdapter.getItem(position); - if (item != null && item.getId() > 0) { - UIHelper.showUserCenter(getActivity(), item.getId(), item.getName()); - } - } -} - diff --git a/app/src/main/java/net/oschina/app/fragment/TweetPubFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetPubFragment.java deleted file mode 100644 index 54a2d751c9dbd70f62af9eaf8bbfbe669e4a7b52..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetPubFragment.java +++ /dev/null @@ -1,687 +0,0 @@ -package net.oschina.app.fragment; - -import android.app.Activity; -import android.content.DialogInterface; -import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.os.Handler; -import android.os.Message; -import android.provider.MediaStore; -import android.provider.MediaStore.Images; -import android.support.annotation.Nullable; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.ImageButton; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.Tweet; -import net.oschina.app.emoji.EmojiKeyboardFragment; -import net.oschina.app.emoji.Emojicon; -import net.oschina.app.emoji.InputHelper; -import net.oschina.app.emoji.OnEmojiClickListener; -import net.oschina.app.service.ServerTaskUtils; -import net.oschina.app.ui.SelectFriendsActivity; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.FileUtil; -import net.oschina.app.util.ImageUtils; -import net.oschina.app.util.SimpleTextWatcher; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.bitmap.BitmapCallBack; -import org.kymjs.kjframe.bitmap.BitmapCreate; -import org.kymjs.kjframe.bitmap.DiskImageRequest; -import org.kymjs.kjframe.http.KJAsyncTask; -import org.kymjs.kjframe.utils.FileUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class TweetPubFragment extends BaseFragment implements - OnEmojiClickListener { - - public static final int ACTION_TYPE_ALBUM = 0; - public static final int ACTION_TYPE_PHOTO = 1; - public static final int ACTION_TYPE_RECORD = 2; // 录音 - public static final int ACTION_TYPE_TOPIC = 3; // 录音 - public static final String FROM_IMAGEPAGE_KEY = "from_image_page"; - - public static final String ACTION_TYPE = "action_type"; - - private static final int MAX_TEXT_LENGTH = 160; - private static final String TEXT_ATME = "@请输入用户名 "; - private static final String TEXT_SOFTWARE = "#请输入软件名#"; - - private static final int SELECT_FRIENDS_REEQUEST_CODE = 100; - - private String fromSharedTextContent = ""; - - @InjectView(R.id.ib_emoji_keyboard) - ImageButton mIbEmoji; - - @InjectView(R.id.ib_picture) - ImageButton mIbPicture; - - @InjectView(R.id.ib_mention) - ImageButton mIbMention; - - @InjectView(R.id.ib_trend_software) - ImageButton mIbTrendSoftware; - - @InjectView(R.id.tv_clear) - TextView mTvClear; - - @InjectView(R.id.rl_img) - View mLyImage; - - @InjectView(R.id.iv_img) - ImageView mIvImage; - - @InjectView(R.id.et_content) - EditText mEtInput; - - private MenuItem mSendMenu; - - private boolean mIsKeyboardVisible; - - private final EmojiKeyboardFragment keyboardFragment = new EmojiKeyboardFragment(); - - private String theLarge, theThumbnail; - private File imgFile; - - private final Handler handler = new Handler() { - @Override - public void handleMessage(Message msg) { - if (msg.what == 1 && msg.obj != null) { - // 显示图片 - mIvImage.setImageBitmap((Bitmap) msg.obj); - mLyImage.setVisibility(View.VISIBLE); - } - } - }; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - int mode = WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; - getActivity().getWindow().setSoftInputMode(mode); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - super.onCreateOptionsMenu(menu, inflater); - inflater.inflate(R.menu.pub_topic_menu, menu); - mSendMenu = menu.findItem(R.id.public_menu_send); - updateMenuState(); - } - - public void updateMenuState() { - if (mSendMenu == null) { - return; - } - if (mEtInput.getText().length() == 0) { - mSendMenu.setEnabled(false); - mSendMenu.setIcon(R.drawable.actionbar_unsend_icon); - } else { - mSendMenu.setEnabled(true); - mSendMenu.setIcon(R.drawable.actionbar_send_icon); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.public_menu_send: - handleSubmit(); - break; - default: - break; - } - return true; - } - - /** - * 方便外部Activity调用 - */ - public void setContentText(String content) { - fromSharedTextContent = content; - if (mEtInput != null) { - mEtInput.setText(content); - } - } - - /** - * 方便外部Activity调用 - */ - public void setContentImage(String url) { - handleImageFile(url); - } - - private void handleSubmit() { - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - String content = mEtInput.getText().toString().trim(); - if (TextUtils.isEmpty(content)) { - mEtInput.requestFocus(); - AppContext.showToastShort(R.string.tip_content_empty); - return; - } - if (content.length() > MAX_TEXT_LENGTH) { - AppContext.showToastShort(R.string.tip_content_too_long); - return; - } - - Tweet tweet = new Tweet(); - tweet.setAuthorid(AppContext.getInstance().getLoginUid()); - tweet.setBody(content); - if (imgFile != null && imgFile.exists()) { - tweet.setImageFilePath(imgFile.getAbsolutePath()); - } - ServerTaskUtils.pubTweet(getActivity(), tweet); - if (mIsKeyboardVisible) { - TDevice.hideSoftKeyboard(getActivity().getCurrentFocus()); - } - getActivity().finish(); - } - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.fragment_tweet_pub, container, - false); - - initView(view); - return view; - } - - @Override - public void onViewCreated(View view, Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - Bundle bundle = getArguments(); - if (bundle != null) { - int action_type = bundle.getInt(ACTION_TYPE, -1); - goToSelectPicture(action_type); - final String imgUrl = bundle.getString(FROM_IMAGEPAGE_KEY); - handleImageUrl(imgUrl); - } - } - - /** - * 处理从第三方分享跳转来的图片 - * - * @param filePath - */ - private void handleImageFile(final String filePath) { - if (!StringUtils.isEmpty(filePath)) { - KJAsyncTask.execute(new Runnable() { - @Override - public void run() { - final Message msg = Message.obtain(); - msg.what = 1; - try { - msg.obj = BitmapCreate.bitmapFromStream( - new FileInputStream(filePath), 300, 300); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } - String path = FileUtils.getSDCardPath() - + "/OSChina/tempfile.jpg"; - FileUtils.bitmapToFile((Bitmap) msg.obj, path); - imgFile = new File(path); - handler.sendMessage(msg); - } - }); - } - } - - /** - * 处理从图片浏览跳转来的图片 - * - * @param url - */ - private void handleImageUrl(final String url) { - if (!StringUtils.isEmpty(url)) { - final Message msg = Message.obtain(); - msg.what = 1; - byte[] cache = Core.getKJBitmap().getCache(url); - msg.obj = BitmapFactory.decodeByteArray(cache, 0, cache.length); - if (msg.obj == null) { - DiskImageRequest req = new DiskImageRequest(); - req.load(url, 300, 300, new BitmapCallBack() { - @Override - public void onSuccess(Bitmap bitmap) { - super.onSuccess(bitmap); - msg.obj = bitmap; - String path = FileUtils.getSDCardPath() - + "/OSChina/tempfile.jpg"; - handler.sendMessage(msg); - FileUtils.bitmapToFile((Bitmap) msg.obj, path); - imgFile = new File(path); - } - }); - } else { - String path = FileUtils.getSDCardPath() - + "/OSChina/tempfile.jpg"; - FileUtils.bitmapToFile((Bitmap) msg.obj, path); - imgFile = new File(path); - handler.sendMessage(msg); - } - } - } - - @Override - public void initView(View view) { - super.initView(view); - ButterKnife.inject(this, view); - setHasOptionsMenu(true); - mIbEmoji.setOnClickListener(this); - mIbPicture.setOnClickListener(this); - mIbMention.setOnClickListener(this); - mIbTrendSoftware.setOnClickListener(this); - mTvClear.setOnClickListener(this); - mTvClear.setText(String.valueOf(MAX_TEXT_LENGTH)); - view.findViewById(R.id.iv_clear_img).setOnClickListener(this); - - mEtInput.addTextChangedListener(new SimpleTextWatcher() { - @Override - public void onTextChanged(CharSequence s, int start, int before, - int count) { - mTvClear.setText((MAX_TEXT_LENGTH - s.length()) + ""); - updateMenuState(); - } - }); - // 获取保存的tweet草稿 - mEtInput.setText(AppContext.getTweetDraft()); - mEtInput.setSelection(mEtInput.getText().toString().length()); - - mEtInput.addTextChangedListener(new SimpleTextWatcher() { - @Override - public void onTextChanged(CharSequence s, int start, int before, - int count) { - mTvClear.setText((MAX_TEXT_LENGTH - s.length()) + ""); - } - }); - // 获取保存的tweet草稿 - String content = fromSharedTextContent; - if (StringUtils.isEmpty(fromSharedTextContent)) { - content = AppContext.getTweetDraft(); - } - mEtInput.setText(content); - mEtInput.setSelection(mEtInput.getText().toString().length()); - - getFragmentManager().beginTransaction() - .replace(R.id.emoji_keyboard_fragment, keyboardFragment) - .commit(); - keyboardFragment.setOnEmojiClickListener(new OnEmojiClickListener() { - @Override - public void onEmojiClick(Emojicon v) { - InputHelper.input2OSC(mEtInput, v); - } - - @Override - public void onDeleteButtonClick(View v) { - InputHelper.backspace(mEtInput); - } - }); - } - - @Override - public boolean onBackPressed() { - final String tweet = mEtInput.getText().toString(); - if (!TextUtils.isEmpty(tweet)) { - DialogHelp.getConfirmDialog(getActivity(), "是否保存为草稿?", new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - AppContext.setTweetDraft(tweet); - getActivity().finish(); - } - }, new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - AppContext.setTweetDraft(""); - getActivity().finish(); - } - }).show(); - return true; - } - return super.onBackPressed(); - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - if (id == R.id.ib_picture) { - handleSelectPicture(); - } else if (id == R.id.ib_mention) { - //insertMention(); - handleSelectFriends(); - } else if (id == R.id.ib_trend_software) { - insertTrendSoftware(); - } else if (id == R.id.tv_clear) { - handleClearWords(); - } else if (id == R.id.iv_clear_img) { - mIvImage.setImageBitmap(null); - mLyImage.setVisibility(View.GONE); - imgFile = null; - } else if (id == R.id.ib_emoji_keyboard) { - if (!keyboardFragment.isShow()) {// emoji隐藏中 - keyboardFragment.showEmojiKeyBoard(); - keyboardFragment.hideSoftKeyboard(); - } else { - keyboardFragment.hideEmojiKeyBoard(); - keyboardFragment.showSoftKeyboard(mEtInput); - } - } - } - - @Override - public void onActivityResult(final int requestCode, final int resultCode, - final Intent imageReturnIntent) { - if (resultCode != Activity.RESULT_OK) - return; - if(requestCode == SELECT_FRIENDS_REEQUEST_CODE) { - //选中好友的名字 - String names[] = imageReturnIntent.getStringArrayExtra("names"); - if(names != null && names.length > 0) { - //拼成字符串 - String text = ""; - for(String n : names) { - text += "@" + n + " "; - } - //插入到文本中 - mEtInput.getText().insert(mEtInput.getSelectionStart(), text); - } - return; - } - new Thread() { - private String selectedImagePath; - - @Override - public void run() { - Bitmap bitmap = null; - - if (requestCode == ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD) { - if (imageReturnIntent == null) - return; - Uri selectedImageUri = imageReturnIntent.getData(); - if (selectedImageUri != null) { - selectedImagePath = ImageUtils.getImagePath( - selectedImageUri, getActivity()); - } - - if (selectedImagePath != null) { - theLarge = selectedImagePath; - } else { - bitmap = ImageUtils.loadPicasaImageFromGalley( - selectedImageUri, getActivity()); - } - - if (AppContext - .isMethodsCompat(android.os.Build.VERSION_CODES.ECLAIR_MR1)) { - String imaName = FileUtil.getFileName(theLarge); - if (imaName != null) - bitmap = ImageUtils.loadImgThumbnail(getActivity(), - imaName, - MediaStore.Images.Thumbnails.MICRO_KIND); - } - if (bitmap == null && !StringUtils.isEmpty(theLarge)) - bitmap = ImageUtils - .loadImgThumbnail(theLarge, 100, 100); - } else if (requestCode == ImageUtils.REQUEST_CODE_GETIMAGE_BYCAMERA) { - // 拍摄图片 - if (bitmap == null && !StringUtils.isEmpty(theLarge)) { - bitmap = ImageUtils - .loadImgThumbnail(theLarge, 100, 100); - } - } - - if (bitmap != null) {// 存放照片的文件夹 - String savePath = Environment.getExternalStorageDirectory() - .getAbsolutePath() + "/OSChina/Camera/"; - File savedir = new File(savePath); - if (!savedir.exists()) { - savedir.mkdirs(); - } - - String largeFileName = FileUtil.getFileName(theLarge); - String largeFilePath = savePath + largeFileName; - // 判断是否已存在缩略图 - if (largeFileName.startsWith("thumb_") - && new File(largeFilePath).exists()) { - theThumbnail = largeFilePath; - imgFile = new File(theThumbnail); - } else { - // 生成上传的800宽度图片 - String thumbFileName = "thumb_" + largeFileName; - theThumbnail = savePath + thumbFileName; - if (new File(theThumbnail).exists()) { - imgFile = new File(theThumbnail); - } else { - try { - // 压缩上传的图片 - ImageUtils.createImageThumbnail(getActivity(), - theLarge, theThumbnail, 800, 80); - imgFile = new File(theThumbnail); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - // 保存动弹临时图片 - // ((AppContext) getApplication()).setProperty( - // tempTweetImageKey, theThumbnail); - - Message msg = new Message(); - msg.what = 1; - msg.obj = bitmap; - handler.sendMessage(msg); - } - }; - }.start(); - } - - private void handleClearWords() { - if (TextUtils.isEmpty(mEtInput.getText().toString())) - return; - DialogHelp.getConfirmDialog(getActivity(), "是否清空内容?", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - mEtInput.getText().clear(); - if (mIsKeyboardVisible) { - TDevice.showSoftKeyboard(mEtInput); - } - } - }).show(); - } - - @Override - public void onResume() { - super.onResume(); - keyboardFragment.showSoftKeyboard(mEtInput); - keyboardFragment.hideEmojiKeyBoard(); - } - - /** 跳转选择好友*/ - private void handleSelectFriends() { - //如果没登录,则先去登录界面 - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - Intent intent = new Intent(getActivity(), SelectFriendsActivity.class); - startActivityForResult(intent, SELECT_FRIENDS_REEQUEST_CODE); - } - - private void handleSelectPicture() { - DialogHelp.getSelectDialog(getActivity(), getResources().getStringArray(R.array.choose_picture), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - goToSelectPicture(i); - } - }).show(); - } - - private void goToSelectPicture(int position) { - switch (position) { - case ACTION_TYPE_ALBUM: - Intent intent; - if (Build.VERSION.SDK_INT < 19) { - intent = new Intent(); - intent.setAction(Intent.ACTION_GET_CONTENT); - intent.setType("image/*"); - startActivityForResult(Intent.createChooser(intent, "选择图片"), - ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD); - } else { - intent = new Intent(Intent.ACTION_PICK, - Images.Media.EXTERNAL_CONTENT_URI); - intent.setType("image/*"); - startActivityForResult(Intent.createChooser(intent, "选择图片"), - ImageUtils.REQUEST_CODE_GETIMAGE_BYSDCARD); - } - break; - case ACTION_TYPE_PHOTO: - // 判断是否挂载了SD卡 - String savePath = ""; - String storageState = Environment.getExternalStorageState(); - if (storageState.equals(Environment.MEDIA_MOUNTED)) { - savePath = Environment.getExternalStorageDirectory() - .getAbsolutePath() + "/oschina/Camera/"; - File savedir = new File(savePath); - if (!savedir.exists()) { - savedir.mkdirs(); - } - } - - // 没有挂载SD卡,无法保存文件 - if (StringUtils.isEmpty(savePath)) { - AppContext.showToastShort("无法保存照片,请检查SD卡是否挂载"); - return; - } - - String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss") - .format(new Date()); - String fileName = "osc_" + timeStamp + ".jpg";// 照片命名 - File out = new File(savePath, fileName); - Uri uri = Uri.fromFile(out); - - theLarge = savePath + fileName;// 该照片的绝对路径 - - intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); - intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); - startActivityForResult(intent, - ImageUtils.REQUEST_CODE_GETIMAGE_BYCAMERA); - break; - case ACTION_TYPE_TOPIC: - Bundle bundle = getArguments(); - if (bundle != null) { - String topic = bundle.getString("tweet_topic"); - setContentText(topic); - if (mEtInput != null) { - mEtInput.setSelection(topic.length()); - } - } - break; - default: - break; - } - } - - private void insertMention() { - TDevice.showSoftKeyboard(mEtInput); - // 在光标所在处插入“@用户名” - int curTextLength = mEtInput.getText().length(); - if (curTextLength >= MAX_TEXT_LENGTH) - return; - String atme = TEXT_ATME; - int start, end; - if ((MAX_TEXT_LENGTH - curTextLength) >= atme.length()) { - start = mEtInput.getSelectionStart() + 1; - end = start + atme.length() - 2; - } else { - int num = MAX_TEXT_LENGTH - curTextLength; - if (num < atme.length()) { - atme = atme.substring(0, num); - } - start = mEtInput.getSelectionStart() + 1; - end = start + atme.length() - 1; - } - if (start > MAX_TEXT_LENGTH || end > MAX_TEXT_LENGTH) { - start = MAX_TEXT_LENGTH; - end = MAX_TEXT_LENGTH; - } - mEtInput.getText().insert(mEtInput.getSelectionStart(), atme); - mEtInput.setSelection(start, end);// 设置选中文字 - } - - private void insertTrendSoftware() { - // 在光标所在处插入“#软件名#” - int curTextLength = mEtInput.getText().length(); - if (curTextLength >= MAX_TEXT_LENGTH) - return; - String software = TEXT_SOFTWARE; - int start, end; - if ((MAX_TEXT_LENGTH - curTextLength) >= software.length()) { - start = mEtInput.getSelectionStart() + 1; - end = start + software.length() - 2; - } else { - int num = MAX_TEXT_LENGTH - curTextLength; - if (num < software.length()) { - software = software.substring(0, num); - } - start = mEtInput.getSelectionStart() + 1; - end = start + software.length() - 1; - } - if (start > MAX_TEXT_LENGTH || end > MAX_TEXT_LENGTH) { - start = MAX_TEXT_LENGTH; - end = MAX_TEXT_LENGTH; - } - mEtInput.getText().insert(mEtInput.getSelectionStart(), software); - mEtInput.setSelection(start, end);// 设置选中文字 - } - - @Override - public void initData() {} - - @Override - public void onDeleteButtonClick(View v) {} - - @Override - public void onEmojiClick(Emojicon v) { - InputHelper.input2OSC(mEtInput, v); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/TweetRecordFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetRecordFragment.java deleted file mode 100644 index a7b3b5eae7969e299a433407e17ef8d41939a6e8..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetRecordFragment.java +++ /dev/null @@ -1,213 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.File; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.bean.Tweet; -import net.oschina.app.service.ServerTaskUtils; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.RecordButton; -import net.oschina.app.widget.RecordButton.OnFinishedRecordListener; -import net.oschina.app.widget.RecordButtonUtil.OnPlayListener; - -import org.kymjs.kjframe.utils.DensityUtils; - -import android.graphics.drawable.AnimationDrawable; -import android.os.Bundle; -import android.text.Editable; -import android.text.Selection; -import android.text.Spannable; -import android.text.TextWatcher; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.RelativeLayout.LayoutParams; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 语音动弹发布界面 - * - * @author kymjs(kymjs123@gmail.com) - * - */ -public class TweetRecordFragment extends BaseFragment { - - @InjectView(R.id.tweet_layout_record) - RelativeLayout mLayout; - @InjectView(R.id.tweet_btn_record) - RecordButton mBtnRecort; - @InjectView(R.id.tweet_time_record) - TextView mTvTime; - @InjectView(R.id.tweet_text_record) - TextView mTvInputLen; - @InjectView(R.id.tweet_edit_record) - EditText mEtSpeech; - @InjectView(R.id.tweet_img_volume) - ImageView mImgVolume; - - public static int MAX_LEN = 160; - - private AnimationDrawable drawable; // 录音播放时的动画背景 - - private String strSpeech = "#语音动弹#"; - private int currentRecordTime = 0; - - @Override - public void onClick(View v) { - if (v == mLayout) { - mBtnRecort.playRecord(); - } - } - - @Override - public void initView(View view) { - RelativeLayout.LayoutParams params = (LayoutParams) mBtnRecort - .getLayoutParams(); - params.width = DensityUtils.getScreenW(getActivity()); - params.height = (int) (DensityUtils.getScreenH(getActivity()) * 0.4); - mBtnRecort.setLayoutParams(params); - mLayout.setOnClickListener(this); - - mBtnRecort.setOnFinishedRecordListener(new OnFinishedRecordListener() { - @Override - public void onFinishedRecord(String audioPath, int recordTime) { - currentRecordTime = recordTime; - mLayout.setVisibility(View.VISIBLE); - if (recordTime < 10) { - mTvTime.setText("0" + recordTime + "\""); - } else { - mTvTime.setText(recordTime + "\""); - } - } - - @Override - public void onCancleRecord() { - mLayout.setVisibility(View.GONE); - } - }); - - drawable = (AnimationDrawable) mImgVolume.getBackground(); - mBtnRecort.getAudioUtil().setOnPlayListener(new OnPlayListener() { - @Override - public void stopPlay() { - drawable.stop(); - mImgVolume.setBackgroundDrawable(drawable.getFrame(0)); - } - - @Override - public void starPlay() { - mImgVolume.setBackgroundDrawable(drawable); - drawable.start(); - } - }); - - mEtSpeech.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence s, int start, int before, - int count) { - if (s.length() > MAX_LEN) { - mTvInputLen.setText("已达到最大长度"); - } else { - mTvInputLen.setText("您还可以输入" + (MAX_LEN - s.length()) - + "个字符"); - } - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) {} - - @Override - public void afterTextChanged(Editable s) { - if (s.length() > MAX_LEN) { - mEtSpeech.setText(s.subSequence(0, MAX_LEN)); - CharSequence text = mEtSpeech.getText(); - if (text instanceof Spannable) - Selection.setSelection((Spannable) text, MAX_LEN); - } - } - }); - } - - @Override - public void initData() {} - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - View rootView = inflater.inflate(R.layout.item_tweet_pub_record, - container, false); - ButterKnife.inject(this, rootView); - initView(rootView); - initData(); - return rootView; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setHasOptionsMenu(true); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.pub_tweet_menu, menu); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.public_menu_send: - handleSubmit(mBtnRecort.getCurrentAudioPath()); - break; - } - return true; - } - - /** - * 发布动弹 - */ - private void handleSubmit(String audioPath) { - if (!TDevice.hasInternet()) { - AppContext.showToastShort(R.string.tip_network_error); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - if (StringUtils.isEmpty(audioPath)) { - AppContext.showToastShort(R.string.record_sound_notfound); - return; - } - File file = new File(audioPath); - if (!file.exists()) { - AppContext.showToastShort(R.string.record_sound_notfound); - return; - } - - String body = mEtSpeech.getText().toString(); - if (!StringUtils.isEmpty(body)) { - strSpeech = body; - } - Tweet tweet = new Tweet(); - tweet.setAuthorid(AppContext.getInstance().getLoginUid()); - tweet.setAudioPath(audioPath); - tweet.setBody(strSpeech); - ServerTaskUtils.pubTweet(getActivity(), tweet); - getActivity().finish(); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/TweetsFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetsFragment.java deleted file mode 100644 index d384666ca97597aedad4fb349a25b7a32d8013d1..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetsFragment.java +++ /dev/null @@ -1,273 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemLongClickListener; -import cz.msebera.android.httpclient.Header; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.TweetAdapter; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.Tweet; -import net.oschina.app.bean.TweetsList; -import net.oschina.app.interf.OnTabReselectListener; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Serializable; - -/** - * @author kymjs (http://www.kymjs.com) - */ -public class TweetsFragment extends BaseListFragment implements - OnItemLongClickListener, OnTabReselectListener { - - protected static final String TAG = TweetsFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "tweetslist_"; - - class DeleteTweetResponseHandler extends OperationResponseHandler { - - DeleteTweetResponseHandler(Object... args) { - super(args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - try { - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res != null && res.OK()) { - AppContext.showToastShort(R.string.delete_success); - Tweet tweet = (Tweet) args[0]; - mAdapter.removeItem(tweet); - mAdapter.notifyDataSetChanged(); - } else { - onFailure(code, res.getErrorMessage(), args); - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(code, e.getMessage(), args); - } - } - - @Override - public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { - - } - - @Override - public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { - AppContext.showToastShort(R.string.delete_faile); - } - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (mCatalog > 0) { - IntentFilter filter = new IntentFilter( - Constants.INTENT_ACTION_USER_CHANGE); - filter.addAction(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mReceiver, filter); - } - } - - @Override - public void onDestroy() { - if (mCatalog > 0) { - getActivity().unregisterReceiver(mReceiver); - } - super.onDestroy(); - } - - @Override - protected TweetAdapter getListAdapter() { - return new TweetAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - Bundle bundle = getArguments(); - if (bundle != null) { - String str = bundle.getString("topic"); - if (str != null) { - return str; - } - } - return CACHE_KEY_PREFIX + mCatalog; - } - - public String getTopic() { - Bundle bundle = getArguments(); - if (bundle != null) { - String str = bundle.getString("topic"); - if (str != null) { - return str; - } - } - return ""; - } - - @Override - protected TweetsList parseList(InputStream is) throws Exception { - TweetsList list = XmlUtils.toBean(TweetsList.class, is); - return list; - } - - @Override - protected TweetsList readList(Serializable seri) { - return ((TweetsList) seri); - } - - @Override - protected void sendRequestData() { - Bundle bundle = getArguments(); - if (bundle != null) { - String str = bundle.getString("topic"); - if (str != null) { - OSChinaApi.getTweetTopicList(mCurrentPage, str, mHandler); - return; - } - } - OSChinaApi.getTweetList(mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Tweet tweet = mAdapter.getItem(position); - if (tweet != null) { - UIHelper.showTweetDetail(view.getContext(), null, tweet.getId()); - } - } - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - setupContent(); - } - }; - - private void setupContent() { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - mCatalog = TweetsList.CATALOG_ME; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected void requestData(boolean refresh) { - if (mCatalog > 0) { - if (AppContext.getInstance().isLogin()) { - mCatalog = AppContext.getInstance().getLoginUid(); - super.requestData(refresh); - } else { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } else { - super.requestData(refresh); - } - } - - @Override - public void initView(View view) { - super.initView(view); - mListView.setOnItemLongClickListener(this); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - if (mCatalog > 0) { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } else { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } - } - }); - } - - @Override - public boolean onItemLongClick(AdapterView parent, View view, - int position, long id) { - Tweet tweet = mAdapter.getItem(position); - if (tweet != null) { - handleLongClick(tweet); - return true; - } - return false; - } - - private void handleLongClick(final Tweet tweet) { - String[] items = null; - if (AppContext.getInstance().getLoginUid() == tweet.getAuthorid()) { - items = new String[] { getResources().getString(R.string.copy), - getResources().getString(R.string.delete) }; - } else { - items = new String[] { getResources().getString(R.string.copy) }; - } - - DialogHelp.getSelectDialog(getActivity(), items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - if (i == 0) { - TDevice.copyTextToBoard(HTMLUtil.delHTMLTag(tweet.getBody())); - } else if (i == 1) { - handleDeleteTweet(tweet); - } - } - }).show(); - } - - private void handleDeleteTweet(final Tweet tweet) { - DialogHelp.getConfirmDialog(getActivity(), "是否删除该动弹?", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - OSChinaApi.deleteTweet(tweet.getAuthorid(), tweet - .getId(), new DeleteTweetResponseHandler(tweet)); - } - }).show(); - } - - @Override - public void onTabReselect() { - onRefresh(); - } - - @Override - protected long getAutoRefreshTime() { - // 最新动弹3分钟刷新一次 - if (mCatalog == TweetsList.CATALOG_LATEST) { - return 3 * 60; - } - return super.getAutoRefreshTime(); - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/fragment/TweetsLikesFragment.java b/app/src/main/java/net/oschina/app/fragment/TweetsLikesFragment.java deleted file mode 100644 index 68f5c900fbe3c97294597815a7664c0eb80a9e14..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/TweetsLikesFragment.java +++ /dev/null @@ -1,183 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; -import java.util.List; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.TweetLikeAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.Notice; -import net.oschina.app.bean.Tweet; -import net.oschina.app.bean.TweetLike; -import net.oschina.app.bean.TweetLikeList; -import net.oschina.app.bean.TweetsList; -import net.oschina.app.service.NoticeUtils; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.viewpagerfragment.NoticeViewPagerFragment; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.os.Bundle; -import android.view.View; -import android.widget.AdapterView; - -/** - * 赞过我动弹的列表 - * - * @date 2014年10月10日 - */ -public class TweetsLikesFragment extends BaseListFragment { - - protected static final String TAG = TweetsLikesFragment.class - .getSimpleName(); - private static final String CACHE_KEY_PREFIX = "mytweets_like_list_"; - - private boolean mIsWatingLogin; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (mCatalog > 0) { - IntentFilter filter = new IntentFilter( - Constants.INTENT_ACTION_USER_CHANGE); - filter.addAction(Constants.INTENT_ACTION_LOGOUT); - getActivity().registerReceiver(mReceiver, filter); - } - } - - @Override - public void onDestroy() { - if (mCatalog > 0) { - getActivity().unregisterReceiver(mReceiver); - } - super.onDestroy(); - } - - @Override - protected TweetLikeAdapter getListAdapter() { - return new TweetLikeAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected TweetLikeList parseList(InputStream is) throws Exception { - TweetLikeList list = XmlUtils.toBean(TweetLikeList.class, is); - return list; - } - - @Override - protected TweetLikeList readList(Serializable seri) { - return ((TweetLikeList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getTweetLikeList(mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Tweet tweet = mAdapter.getItem(position).getTweet(); - if (tweet != null) { - UIHelper.showTweetDetail(view.getContext(), null, tweet.getId()); - } - } - - private BroadcastReceiver mReceiver = new BroadcastReceiver() { - - @Override - public void onReceive(Context context, Intent intent) { - setupContent(); - } - }; - - private void setupContent() { - if (AppContext.getInstance().isLogin()) { - mIsWatingLogin = false; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - mCatalog = TweetsList.CATALOG_ME; - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - protected void requestData(boolean refresh) { - if (AppContext.getInstance().isLogin()) { - mCatalog = AppContext.getInstance().getLoginUid(); - mIsWatingLogin = false; - super.requestData(refresh); - } else { - mIsWatingLogin = true; - mErrorLayout.setErrorType(EmptyLayout.NETWORK_ERROR); - mErrorLayout.setErrorMessage(getString(R.string.unlogin_tip)); - } - } - - @Override - public void initView(View view) { - super.initView(view); - mErrorLayout.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - if (AppContext.getInstance().isLogin()) { - mErrorLayout.setErrorType(EmptyLayout.NETWORK_LOADING); - requestData(true); - } else { - UIHelper.showLoginActivity(getActivity()); - } - } - }); - } - - @Override - protected long getAutoRefreshTime() { - if (mCatalog == TweetsList.CATALOG_LATEST) { - return 3 * 60; - } - return super.getAutoRefreshTime(); - } - - @Override - protected void onRefreshNetworkSuccess() { - // TODO Auto-generated method stub - super.onRefreshNetworkSuccess(); - if (AppContext.getInstance().isLogin() - && mCatalog == AppContext.getInstance().getLoginUid() - && 4 == NoticeViewPagerFragment.sCurrentPage) { - NoticeUtils.clearNotice(Notice.TYPE_NEWLIKE); - UIHelper.sendBroadcastForNotice(getActivity()); - } - } - - protected boolean compareTo(List data, Entity enity) { - int s = data.size(); - - if (enity != null && enity instanceof TweetLike) { - TweetLike tweetLike = (TweetLike) enity; - for (int i = 0; i < s; i++) { - if (tweetLike.getUser().getId() == ((TweetLike)data.get(i)).getId()) { - return true; - } - } - } - return false; - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/fragment/UserBlogFragment.java b/app/src/main/java/net/oschina/app/fragment/UserBlogFragment.java deleted file mode 100644 index b3ae9c3e96ddc74fa9680d2437b990ebaebf890a..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/UserBlogFragment.java +++ /dev/null @@ -1,61 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.adapter.BlogAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Blog; -import net.oschina.app.bean.BlogList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.view.View; -import android.widget.AdapterView; - -/** - * 用户的博客列表(用用户的id来获取) - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月29日 下午5:09:13 - * - */ -public class UserBlogFragment extends BaseListFragment { - - protected static final String TAG = UserBlogFragment.class.getSimpleName(); - private static final String CACHE_KEY_PREFIX = "user_bloglist_"; - - @Override - protected BlogAdapter getListAdapter() { - return new BlogAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected BlogList parseList(InputStream is) throws Exception { - BlogList list = XmlUtils.toBean(BlogList.class, is); - return list; - } - - @Override - protected BlogList readList(Serializable seri) { - return ((BlogList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getUserBlogList(mCatalog, "", mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - Blog blog = (Blog) mAdapter.getItem(position); - if (blog != null) - UIHelper.showUrlRedirect(view.getContext(), blog.getUrl()); - } -} diff --git a/app/src/main/java/net/oschina/app/fragment/UserCenterFragment.java b/app/src/main/java/net/oschina/app/fragment/UserCenterFragment.java deleted file mode 100644 index 4acc36494451d8453a0ad9dd313eb732b3ffe5f3..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/UserCenterFragment.java +++ /dev/null @@ -1,473 +0,0 @@ -package net.oschina.app.fragment; - -import android.content.DialogInterface; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AlertDialog; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView; -import android.widget.AbsListView.OnScrollListener; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.TextView; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.adapter.ActiveAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseFragment; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Active; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.User; -import net.oschina.app.bean.UserInformation; -import net.oschina.app.ui.empty.EmptyLayout; -import net.oschina.app.util.DialogHelp; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import net.oschina.app.widget.AvatarView; - - -import java.io.ByteArrayInputStream; -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; -import cz.msebera.android.httpclient.Header; - -/** - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年10月29日 下午2:33:18 - * - */ - -public class UserCenterFragment extends BaseFragment implements - OnItemClickListener, OnScrollListener { - - private static final Object FEMALE = "女"; - - @InjectView(R.id.error_layout) - EmptyLayout mEmptyView; - - @InjectView(R.id.lv_user_active) - ListView mListView; - private ImageView mIvAvatar, mIvGender; - private TextView mTvName, mTvFollowing, mTvFollower, mTvSore, - mBtnPrivateMsg, mBtnFollowUser, mTvLastestLoginTime; - - private ActiveAdapter mAdapter; - private int mHisUid; - private String mHisName; - private int mUid; - private User mUser; - - private int mActivePage = 0; - - private final AsyncHttpResponseHandler mActiveHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - UserInformation information = XmlUtils.toBean( - UserInformation.class, new ByteArrayInputStream(arg2)); - mUser = information.getUser(); - fillUI(); - List data = information.getActiveList(); - if (mState == STATE_REFRESH) - mAdapter.clear(); - mAdapter.addData(data); - mEmptyView.setErrorType(EmptyLayout.HIDE_LAYOUT); - if (data.size() == 0 && mState == STATE_REFRESH) { - mEmptyView.setErrorType(EmptyLayout.NODATA); - mAdapter.setState(ListBaseAdapter.STATE_NO_MORE); - } else if (data.size() == 0) { - if (mState == STATE_REFRESH) - mAdapter.setState(ListBaseAdapter.STATE_NO_MORE); - else - mAdapter.setState(ListBaseAdapter.STATE_NO_MORE); - } else { - mAdapter.setState(ListBaseAdapter.STATE_LOAD_MORE); - } - } catch (Exception e) { - onFailure(arg0, arg1, arg2, e); - e.printStackTrace(); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - mEmptyView.setErrorType(EmptyLayout.NETWORK_ERROR); - } - - @Override - public void onFinish() { - mState = STATE_NONE; - } - }; - - @Override - public View onCreateView(LayoutInflater inflater, - @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - super.onCreateView(inflater, container, savedInstanceState); - View view = inflater.inflate(R.layout.fragment_user_center, container, - false); - - Bundle args = getArguments(); - - mHisUid = args.getInt("his_id", 0); - mHisName = args.getString("his_name"); - mUid = AppContext.getInstance().getLoginUid(); - ButterKnife.inject(this, view); - initView(view); - - return view; - } - - @Override - public void onClick(View v) { - final int id = v.getId(); - switch (id) { - case R.id.iv_avatar: - UIHelper.showUserAvatar(getActivity(), mUser.getPortrait()); - break; - case R.id.ly_following: - UIHelper.showFriends(getActivity(), mUser.getId(), 0); - break; - case R.id.ly_follower: - UIHelper.showFriends(getActivity(), mUser.getId(), 1); - break; - case R.id.tv_follow_user: - handleUserRelation(); - break; - case R.id.tv_private_message: - if (mHisUid == AppContext.getInstance().getLoginUid()) { - AppContext.showToast("不能给自己发送留言:)"); - return; - } - if (!AppContext.getInstance().isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - UIHelper.showMessageDetail(getActivity(), mHisUid, mHisName); - break; - case R.id.tv_blog: - UIHelper.showUserBlog(getActivity(), mHisUid); - break; - case R.id.tv_information: - showInformationDialog(); - break; - default: - break; - } - } - - @Override - public void initView(View view) { - mListView.setOnItemClickListener(this); - mListView.setOnScrollListener(this); - - View header = LayoutInflater.from(getActivity()).inflate( - R.layout.fragment_user_center_header, null, false); - - mIvAvatar = (ImageView) header.findViewById(R.id.iv_avatar); - mIvAvatar.setOnClickListener(this); - mIvGender = (ImageView) header.findViewById(R.id.iv_gender); - mTvName = (TextView) header.findViewById(R.id.tv_name); - mTvFollowing = (TextView) header.findViewById(R.id.tv_following_count); - header.findViewById(R.id.ly_following).setOnClickListener(this); - mTvFollower = (TextView) header.findViewById(R.id.tv_follower_count); - header.findViewById(R.id.ly_follower).setOnClickListener(this); - mTvSore = (TextView) header.findViewById(R.id.tv_score); - mTvLastestLoginTime = (TextView) header - .findViewById(R.id.tv_latest_login_time); - - mBtnPrivateMsg = (TextView) header - .findViewById(R.id.tv_private_message); - mBtnPrivateMsg.setOnClickListener(this); - mBtnFollowUser = (TextView) header.findViewById(R.id.tv_follow_user); - mBtnFollowUser.setOnClickListener(this); - - header.findViewById(R.id.tv_blog).setOnClickListener(this); - header.findViewById(R.id.tv_information).setOnClickListener(this); - - mListView.addHeaderView(header); - - mBtnPrivateMsg.setOnClickListener(this); - mBtnFollowUser.setOnClickListener(this); - - if (mAdapter == null) { - mAdapter = new ActiveAdapter(); - - fristSendGetUserInfomation(); - } - mListView.setAdapter(mAdapter); - - mEmptyView.setOnLayoutClickListener(new View.OnClickListener() { - - @Override - public void onClick(View v) { - fristSendGetUserInfomation(); - } - }); - } - - private void fristSendGetUserInfomation() { - mState = STATE_REFRESH; - mListView.setVisibility(View.GONE); - mEmptyView.setErrorType(EmptyLayout.NETWORK_LOADING); - sendGetUserInfomation(); - } - - private void sendGetUserInfomation() { - OSChinaApi.getUserInformation(mUid, mHisUid, mHisName, mActivePage, - mActiveHandler); - } - - private void fillUI() { - mListView.setVisibility(View.VISIBLE); - ((AvatarView) mIvAvatar).setAvatarUrl(mUser.getPortrait()); - mHisUid = mUser.getId(); - mHisName = mUser.getName(); - mTvName.setText(mHisName); - - int genderIcon = R.drawable.userinfo_icon_male; - if (FEMALE.equals(mUser.getGender())) { - genderIcon = R.drawable.userinfo_icon_female; - } - mIvGender.setBackgroundResource(genderIcon); - - mTvFollowing.setText(mUser.getFollowers() + ""); - mTvFollower.setText(mUser.getFans() + ""); - mTvSore.setText(mUser.getScore() + ""); - mTvLastestLoginTime.setText(getString(R.string.latest_login_time, - StringUtils.friendly_time(mUser.getLatestonline()))); - updateUserRelation(); - } - - private void updateUserRelation() { - switch (mUser.getRelation()) { - case User.RELATION_TYPE_BOTH: - mBtnFollowUser.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_follow_each_other, 0, 0, 0); - mBtnFollowUser.setText(R.string.follow_each_other); - mBtnFollowUser.setTextColor(getResources().getColor(R.color.black)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_white_selector); - break; - case User.RELATION_TYPE_FANS_HIM: - mBtnFollowUser.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_followed, 0, 0, 0); - mBtnFollowUser.setText(R.string.unfollow_user); - mBtnFollowUser.setTextColor(getResources().getColor(R.color.black)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_white_selector); - break; - case User.RELATION_TYPE_FANS_ME: - mBtnFollowUser.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_add_follow, 0, 0, 0); - mBtnFollowUser.setText(R.string.follow_user); - mBtnFollowUser.setTextColor(getResources().getColor(R.color.white)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_green_selector); - break; - case User.RELATION_TYPE_NULL: - mBtnFollowUser.setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_add_follow, 0, 0, 0); - mBtnFollowUser.setText(R.string.follow_user); - mBtnFollowUser.setTextColor(getResources().getColor(R.color.white)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_green_selector); - break; - } - int padding = (int) TDevice.dpToPixel(20); - mBtnFollowUser.setPadding(padding, 0, padding, 0); - } - - private AlertDialog mInformationDialog; - - private void showInformationDialog() { - if (mInformationDialog == null) { - mInformationDialog = DialogHelp.getDialog(getActivity()).show(); - View view = LayoutInflater.from(getActivity()).inflate( - R.layout.fragment_user_center_information, null); - ((TextView) view.findViewById(R.id.tv_join_time)) - .setText(StringUtils.friendly_time(mUser.getJointime())); - ((TextView) view.findViewById(R.id.tv_location)) - .setText(StringUtils.getString(mUser.getFrom())); - ((TextView) view.findViewById(R.id.tv_development_platform)) - .setText(StringUtils.getString(mUser.getDevplatform())); - ((TextView) view.findViewById(R.id.tv_academic_focus)) - .setText(StringUtils.getString(mUser.getExpertise())); - mInformationDialog.setContentView(view); - } - - mInformationDialog.show(); - } - - private void handleUserRelation() { - if (mUser == null) - return; - // 判断登录 - final AppContext ac = AppContext.getInstance(); - if (!ac.isLogin()) { - UIHelper.showLoginActivity(getActivity()); - return; - } - String dialogTitle = ""; - int relationAction = 0; - switch (mUser.getRelation()) { - case User.RELATION_TYPE_BOTH: - dialogTitle = "确定取消互粉吗?"; - relationAction = User.RELATION_ACTION_DELETE; - break; - case User.RELATION_TYPE_FANS_HIM: - dialogTitle = "确定取消关注吗?"; - relationAction = User.RELATION_ACTION_DELETE; - break; - case User.RELATION_TYPE_FANS_ME: - dialogTitle = "确定关注Ta吗?"; - relationAction = User.RELATION_ACTION_ADD; - break; - case User.RELATION_TYPE_NULL: - dialogTitle = "确定关注Ta吗?"; - relationAction = User.RELATION_ACTION_ADD; - break; - } - final int ra = relationAction; - - DialogHelp.getConfirmDialog(getActivity(), dialogTitle, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - sendUpdateRelcationRequest(ra); - } - }).show(); - } - - private void sendUpdateRelcationRequest(int ra) { - OSChinaApi.updateRelation(mUid, mHisUid, ra, - new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - Result result = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)).getResult(); - if (result.OK()) { - switch (mUser.getRelation()) { - case User.RELATION_TYPE_BOTH: - mBtnFollowUser - .setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_add_follow, - 0, 0, 0); - mBtnFollowUser - .setText(R.string.follow_user); - mBtnFollowUser.setTextColor(getResources() - .getColor(R.color.white)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_green_selector); - mUser.setRelation(User.RELATION_TYPE_FANS_ME); - break; - case User.RELATION_TYPE_FANS_HIM: - mBtnFollowUser - .setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_add_follow, - 0, 0, 0); - mBtnFollowUser - .setText(R.string.follow_user); - mBtnFollowUser.setTextColor(getResources() - .getColor(R.color.white)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_green_selector); - mUser.setRelation(User.RELATION_TYPE_NULL); - break; - case User.RELATION_TYPE_FANS_ME: - mBtnFollowUser - .setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_followed, 0, - 0, 0); - mBtnFollowUser - .setText(R.string.follow_each_other); - mBtnFollowUser.setTextColor(getResources() - .getColor(R.color.black)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_white_selector); - mUser.setRelation(User.RELATION_TYPE_BOTH); - break; - case User.RELATION_TYPE_NULL: - mBtnFollowUser - .setCompoundDrawablesWithIntrinsicBounds( - R.drawable.ic_followed, 0, - 0, 0); - mBtnFollowUser - .setText(R.string.unfollow_user); - mBtnFollowUser.setTextColor(getResources() - .getColor(R.color.black)); - mBtnFollowUser - .setBackgroundResource(R.drawable.btn_small_white_selector); - mUser.setRelation(User.RELATION_TYPE_FANS_HIM); - break; - } - int padding = (int) TDevice.dpToPixel(20); - mBtnFollowUser.setPadding(padding, 0, padding, - 0); - } - AppContext.showToastShort(result.getErrorMessage()); - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) {} - }); - } - - @Override - public void initData() {} - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - if (position - 1 < 0) { - return; - } - Active active = (Active) mAdapter.getItem(position - 1); - if (active != null) - UIHelper.showActiveRedirect(view.getContext(), active); - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, - int visibleItemCount, int totalItemCount) { - // 数据已经全部加载,或数据为空时,或正在加载,不处理滚动事件 - if (mState == STATE_NOMORE || mState == STATE_LOADMORE - || mState == STATE_REFRESH) { - return; - } - if (mAdapter != null - && mAdapter.getDataSize() > 0 - && mListView.getLastVisiblePosition() == (mListView.getCount() - 1)) { - if (mState == STATE_NONE - && mAdapter.getState() == ListBaseAdapter.STATE_LOAD_MORE) { - mState = STATE_LOADMORE; - mActivePage++; - sendGetUserInfomation(); - } - } - } - - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) {} -} diff --git a/app/src/main/java/net/oschina/app/fragment/UserFavoriteFragment.java b/app/src/main/java/net/oschina/app/fragment/UserFavoriteFragment.java deleted file mode 100644 index aae6ba005ae13aaaedd698db03257ddcf28d1c13..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/fragment/UserFavoriteFragment.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.oschina.app.fragment; - -import java.io.InputStream; -import java.io.Serializable; - -import net.oschina.app.AppContext; -import net.oschina.app.adapter.UserFavoriteAdapter; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.BaseListFragment; -import net.oschina.app.bean.Favorite; -import net.oschina.app.bean.FavoriteList; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; -import android.view.View; -import android.widget.AdapterView; - -public class UserFavoriteFragment extends BaseListFragment { - - protected static final String TAG = UserFavoriteFragment.class - .getSimpleName(); - private static final String CACHE_KEY_PREFIX = "userfavorite_"; - - @Override - protected UserFavoriteAdapter getListAdapter() { - return new UserFavoriteAdapter(); - } - - @Override - protected String getCacheKeyPrefix() { - return CACHE_KEY_PREFIX + mCatalog; - } - - @Override - protected FavoriteList parseList(InputStream is) throws Exception { - - FavoriteList list = XmlUtils.toBean(FavoriteList.class, is); - return list; - } - - @Override - protected FavoriteList readList(Serializable seri) { - return ((FavoriteList) seri); - } - - @Override - protected void sendRequestData() { - OSChinaApi.getFavoriteList(AppContext.getInstance().getLoginUid(), - mCatalog, mCurrentPage, mHandler); - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, - long id) { - - Favorite favorite = (Favorite) mAdapter.getItem(position); - if (favorite != null) { - switch (favorite.getType()) { - - case Favorite.CATALOG_BLOGS: - UIHelper.showUrlRedirect(getActivity(), favorite.getUrl()); - break; - case Favorite.CATALOG_CODE: - UIHelper.showUrlRedirect(getActivity(), favorite.getUrl()); - break; - case Favorite.CATALOG_NEWS: - UIHelper.showUrlRedirect(getActivity(), favorite.getUrl()); - break; - case Favorite.CATALOG_SOFTWARE: - UIHelper.showUrlRedirect(getActivity(), favorite.getUrl()); - break; - case Favorite.CATALOG_TOPIC: - UIHelper.showUrlRedirect(getActivity(), favorite.getUrl()); - break; - - } - } - - } -} diff --git a/app/src/main/java/net/oschina/app/interf/BaseFragmentInterface.java b/app/src/main/java/net/oschina/app/interf/BaseFragmentInterface.java deleted file mode 100644 index 486c930351c5fd95d081d96b7f4d3f29817564cc..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/interf/BaseFragmentInterface.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.oschina.app.interf; - -import android.view.View; - - -/** - * 基类fragment实现接口 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年9月25日 上午11:00:25 - * - */ -public interface BaseFragmentInterface { - - public void initView(View view); - - public void initData(); -} diff --git a/app/src/main/java/net/oschina/app/interf/BaseViewInterface.java b/app/src/main/java/net/oschina/app/interf/BaseViewInterface.java deleted file mode 100644 index 2ea5be2dffb139f156ab3a90490df03576febbd6..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/interf/BaseViewInterface.java +++ /dev/null @@ -1,14 +0,0 @@ -package net.oschina.app.interf; - -/** - * - * @author deyi - * - */ -public interface BaseViewInterface { - - public void initView(); - - public void initData(); - -} diff --git a/app/src/main/java/net/oschina/app/interf/ICallbackResult.java b/app/src/main/java/net/oschina/app/interf/ICallbackResult.java deleted file mode 100644 index 929f80c080c5fbf696a60f6dd8bf92a0662e9c1a..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/interf/ICallbackResult.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.oschina.app.interf; - -/** - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年11月18日 上午11:18:28 - * - */ - -public interface ICallbackResult { - - public void OnBackResult(Object s); -} diff --git a/app/src/main/java/net/oschina/app/interf/OnTabReselectListener.java b/app/src/main/java/net/oschina/app/interf/OnTabReselectListener.java deleted file mode 100644 index ca491922c7a6e173b6b34fed82729cb9252f42e3..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/interf/OnTabReselectListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.oschina.app.interf; - -/** - * 当tabHost再次被点击时 - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2014年11月17日 上午11:00:15 - * - */ -public interface OnTabReselectListener { - - public void onTabReselect(); -} diff --git a/app/src/main/java/net/oschina/app/interf/OnWebViewImageListener.java b/app/src/main/java/net/oschina/app/interf/OnWebViewImageListener.java deleted file mode 100644 index 7ea96a5764ad466ad8c7bfc5a7c8d557bf331745..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/interf/OnWebViewImageListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.oschina.app.interf; - -/** - * 监听webview上的图片 - * - * @author yeguozhong@yeah.net - * - */ -public interface OnWebViewImageListener { - - /** - * 点击webview上的图片,传入该缩略图的大图Url - * @param bigImageUrl - */ - void showImagePreview(String bigImageUrl); - -} diff --git a/app/src/main/java/net/oschina/app/service/DownloadService.java b/app/src/main/java/net/oschina/app/service/DownloadService.java deleted file mode 100644 index 9da874a9cdb3a09f3c8d552b865bbce5ad5a3657..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/DownloadService.java +++ /dev/null @@ -1,302 +0,0 @@ -package net.oschina.app.service; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; - -import net.oschina.app.AppConfig; -import net.oschina.app.R; -import net.oschina.app.interf.ICallbackResult; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TDevice; -import android.app.Notification; -import android.app.NotificationManager; -import android.app.PendingIntent; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.os.Binder; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.widget.RemoteViews; - -/** - * download service - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年11月18日 下午3:02:36 - * - */ -public class DownloadService extends Service { - - public static final String BUNDLE_KEY_DOWNLOAD_URL = "download_url"; - - public static final String BUNDLE_KEY_TITLE = "title"; - - private final String tag = "download"; - private static final int NOTIFY_ID = 0; - private int progress; - private NotificationManager mNotificationManager; - private boolean canceled; - - private String downloadUrl; - - private String mTitle = "正在下载%s"; - - private String saveFileName = AppConfig.DEFAULT_SAVE_FILE_PATH; - - private ICallbackResult callback; - - private DownloadBinder binder; - - private boolean serviceIsDestroy = false; - - private Context mContext = this; - - private Thread downLoadThread; - - private Notification mNotification; - - private Handler mHandler = new Handler() { - - @Override - public void handleMessage(Message msg) { - // TODO Auto-generated method stub - super.handleMessage(msg); - switch (msg.what) { - case 0: - // 下载完毕 - mNotificationManager.cancel(NOTIFY_ID); - installApk(); - break; - case 2: - // 取消通知 - mNotificationManager.cancel(NOTIFY_ID); - break; - case 1: - int rate = msg.arg1; - if (rate < 100) { - RemoteViews contentview = mNotification.contentView; - contentview.setTextViewText(R.id.tv_download_state, mTitle + "(" + rate - + "%" + ")"); - contentview.setProgressBar(R.id.pb_download, 100, rate, - false); - } else { - // 下载完毕后变换通知形式 - mNotification.flags = Notification.FLAG_AUTO_CANCEL; - mNotification.contentView = null; - Intent intent = new Intent(mContext, MainActivity.class); - // 告知已完成 - intent.putExtra("completed", "yes"); - // 更新参数,注意flags要使用FLAG_UPDATE_CURRENT - PendingIntent contentIntent = PendingIntent.getActivity( - mContext, 0, intent, - PendingIntent.FLAG_UPDATE_CURRENT); -// mNotification.setLatestEventInfo(mContext, "下载完成", -// "文件已下载完毕", contentIntent); - serviceIsDestroy = true; - stopSelf();// 停掉服务自身 - } - mNotificationManager.notify(NOTIFY_ID, mNotification); - break; - } - } - }; - - @Override - public IBinder onBind(Intent intent) { - downloadUrl = intent.getStringExtra(BUNDLE_KEY_DOWNLOAD_URL); - saveFileName = saveFileName + getSaveFileName(downloadUrl); - mTitle = String.format(mTitle, intent.getStringExtra(BUNDLE_KEY_TITLE)); - return binder; - } - - private String getSaveFileName(String downloadUrl) { - if (downloadUrl == null || StringUtils.isEmpty(downloadUrl)) { - return ""; - } - return downloadUrl.substring(downloadUrl.lastIndexOf("/")); - } - - @Override - public void onCreate() { - super.onCreate(); - binder = new DownloadBinder(); - mNotificationManager = (NotificationManager) getSystemService(android.content.Context.NOTIFICATION_SERVICE); - stopForeground(true);// 这个不确定是否有作用 - } - - private void startDownload() { - canceled = false; - downloadApk(); - } - - /** - * 创建通知 - */ - private void setUpNotification() { - int icon = R.drawable.ic_notification; - CharSequence tickerText = "准备下载"; - long when = System.currentTimeMillis(); - mNotification = new Notification(icon, tickerText, when); - ; - // 放置在"正在运行"栏目中 - mNotification.flags = Notification.FLAG_ONGOING_EVENT; - - RemoteViews contentView = new RemoteViews(getPackageName(), - R.layout.download_notification_show); - contentView.setTextViewText(R.id.tv_download_state, mTitle); - // 指定个性化视图 - mNotification.contentView = contentView; - - Intent intent = new Intent(this, MainActivity.class); - PendingIntent contentIntent = PendingIntent.getActivity(this, 0, - intent, PendingIntent.FLAG_UPDATE_CURRENT); - - // 指定内容意图 - mNotification.contentIntent = contentIntent; - mNotificationManager.notify(NOTIFY_ID, mNotification); - } - - private void downloadApk() { - downLoadThread = new Thread(mdownApkRunnable); - downLoadThread.start(); - } - - /** - * 安装apk - */ - private void installApk() { - File apkfile = new File(saveFileName); - if (!apkfile.exists()) { - return; - } - TDevice.installAPK(mContext, apkfile); - } - - private Runnable mdownApkRunnable = new Runnable() { - @Override - public void run() { - File file = new File(AppConfig.DEFAULT_SAVE_FILE_PATH); - if (!file.exists()) { - file.mkdirs(); - } - String apkFile = saveFileName; - File saveFile = new File(apkFile); - try { - downloadUpdateFile(downloadUrl, saveFile); - } catch (Exception e) { - e.printStackTrace(); - } - } - }; - - public long downloadUpdateFile(String downloadUrl, File saveFile) - throws Exception { - int downloadCount = 0; - int currentSize = 0; - long totalSize = 0; - int updateTotalSize = 0; - - HttpURLConnection httpConnection = null; - InputStream is = null; - FileOutputStream fos = null; - - try { - URL url = new URL(downloadUrl); - httpConnection = (HttpURLConnection) url.openConnection(); - httpConnection - .setRequestProperty("User-Agent", "PacificHttpClient"); - if (currentSize > 0) { - httpConnection.setRequestProperty("RANGE", "bytes=" - + currentSize + "-"); - } - httpConnection.setConnectTimeout(10000); - httpConnection.setReadTimeout(20000); - updateTotalSize = httpConnection.getContentLength(); - if (httpConnection.getResponseCode() == 404) { - throw new Exception("fail!"); - } - is = httpConnection.getInputStream(); - fos = new FileOutputStream(saveFile, false); - byte buffer[] = new byte[1024]; - int readsize = 0; - while ((readsize = is.read(buffer)) > 0) { - fos.write(buffer, 0, readsize); - totalSize += readsize; - // 为了防止频繁的通知导致应用吃紧,百分比增加10才通知一次 - if ((downloadCount == 0) - || (int) (totalSize * 100 / updateTotalSize) - 10 >= downloadCount) { - downloadCount += 10; - // 更新进度 - Message msg = mHandler.obtainMessage(); - msg.what = 1; - msg.arg1 = downloadCount; - mHandler.sendMessage(msg); - if (callback != null) - callback.OnBackResult(progress); - } - } - - // 下载完成通知安装 - mHandler.sendEmptyMessage(0); - // 下载完了,cancelled也要设置 - canceled = true; - - } finally { - if (httpConnection != null) { - httpConnection.disconnect(); - } - if (is != null) { - is.close(); - } - if (fos != null) { - fos.close(); - } - } - return totalSize; - } - - public class DownloadBinder extends Binder { - public void start() { - if (downLoadThread == null || !downLoadThread.isAlive()) { - progress = 0; - setUpNotification(); - new Thread() { - public void run() { - // 下载 - startDownload(); - }; - }.start(); - } - } - - public void cancel() { - canceled = true; - } - - public int getProgress() { - return progress; - } - - public boolean isCanceled() { - return canceled; - } - - public boolean serviceIsDestroy() { - return serviceIsDestroy; - } - - public void cancelNotification() { - mHandler.sendEmptyMessage(2); - } - - public void addCallback(ICallbackResult callback) { - DownloadService.this.callback = callback; - } - } -} diff --git a/app/src/main/java/net/oschina/app/service/INoticeService.aidl b/app/src/main/java/net/oschina/app/service/INoticeService.aidl deleted file mode 100644 index fcd7d7b32e3f0f2b404384036f62b9e36eb2795d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/INoticeService.aidl +++ /dev/null @@ -1,8 +0,0 @@ -package net.oschina.app.service; - -interface INoticeService -{ - void scheduleNotice(); - void requestNotice(); - void clearNotice(int uid,int type); -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/service/NoticeService.java b/app/src/main/java/net/oschina/app/service/NoticeService.java deleted file mode 100644 index 3a5b08dab6bf017240505e2a529cac39e195ca15..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/NoticeService.java +++ /dev/null @@ -1,308 +0,0 @@ -package net.oschina.app.service; - -import java.io.ByteArrayInputStream; -import java.lang.ref.WeakReference; - -import net.oschina.app.AppConfig; -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.bean.Constants; -import net.oschina.app.bean.Notice; -import net.oschina.app.bean.NoticeDetail; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.broadcast.AlarmReceiver; -import net.oschina.app.ui.MainActivity; -import net.oschina.app.util.UIHelper; -import net.oschina.app.util.XmlUtils; - -import cz.msebera.android.httpclient.Header; -import android.app.AlarmManager; -import android.app.Notification; -import android.app.PendingIntent; -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.res.Resources; -import android.net.Uri; -import android.os.IBinder; -import android.os.RemoteException; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; - -import com.loopj.android.http.AsyncHttpResponseHandler; - -public class NoticeService extends Service { - public static final String INTENT_ACTION_GET = "net.oschina.app.service.GET_NOTICE"; - public static final String INTENT_ACTION_CLEAR = "net.oschina.app.service.CLEAR_NOTICE"; - public static final String INTENT_ACTION_BROADCAST = "net.oschina.app.service.BROADCAST"; - public static final String INTENT_ACTION_SHUTDOWN = "net.oschina.app.service.SHUTDOWN"; - public static final String INTENT_ACTION_REQUEST = "net.oschina.app.service.REQUEST"; - public static final String BUNDLE_KEY_TPYE = "bundle_key_type"; - - private static final long INTERVAL = 1000 * 120; - private AlarmManager mAlarmMgr; - - private Notice mNotice; - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - String action = intent.getAction(); - if (Constants.INTENT_ACTION_NOTICE.equals(action)) { - Notice notice = (Notice) intent.getSerializableExtra("notice_bean"); - int atmeCount = notice.getAtmeCount();// @我 - int msgCount = notice.getMsgCount();// 私信 - int reviewCount = notice.getReviewCount();// 评论 - int newFansCount = notice.getNewFansCount();// 新粉丝 - int newLikeCount = notice.getNewLikeCount();// 点赞数 - int activeCount = atmeCount + reviewCount + msgCount - + newFansCount + newLikeCount; - if (activeCount == 0) { - NotificationManagerCompat.from(NoticeService.this).cancel( - R.string.you_have_news_messages); - } - } else if (INTENT_ACTION_BROADCAST.equals(action)) { - if (mNotice != null) { - UIHelper.sendBroadCast(NoticeService.this, mNotice); - } - } else if (INTENT_ACTION_SHUTDOWN.equals(action)) { - stopSelf(); - } else if (INTENT_ACTION_REQUEST.equals(action)) { - requestNotice(); - } - } - }; - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - @Override - public void onCreate() { - super.onCreate(); - mAlarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); - startRequestAlarm(); - requestNotice(); - - IntentFilter filter = new IntentFilter(INTENT_ACTION_BROADCAST); - filter.addAction(Constants.INTENT_ACTION_NOTICE); - filter.addAction(INTENT_ACTION_SHUTDOWN); - filter.addAction(INTENT_ACTION_REQUEST); - registerReceiver(mReceiver, filter); - } - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - return super.onStartCommand(intent, flags, startId); - } - - @Override - public void onDestroy() { - cancelRequestAlarm(); - unregisterReceiver(mReceiver); - super.onDestroy(); - } - - private void startRequestAlarm() { - cancelRequestAlarm(); - // 从1秒后开始,每隔2分钟执行getOperationIntent() - mAlarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, - System.currentTimeMillis() + 1000, INTERVAL, - getOperationIntent()); - } - - /** - * 即使启动PendingIntent的原进程结束了的话,PendingIntent本身仍然还存在,可在其他进程( - * PendingIntent被递交到的其他程序)中继续使用. - * 如果我在从系统中提取一个PendingIntent的,而系统中有一个和你描述的PendingIntent对等的PendingInent, - * 那么系统会直接返回和该PendingIntent其实是同一token的PendingIntent, - * 而不是一个新的token和PendingIntent。然而你在从提取PendingIntent时,通过FLAG_CANCEL_CURRENT参数, - * 让这个老PendingIntent的先cancel()掉,这样得到的pendingInten和其token的就是新的了。 - */ - private void cancelRequestAlarm() { - mAlarmMgr.cancel(getOperationIntent()); - } - - /** - * OSC采用轮询方式实现消息推送
    - * 每次被调用都去执行一次{@link #AlarmReceiver}onReceive()方法 - * - * @return - */ - private PendingIntent getOperationIntent() { - Intent intent = new Intent(this, AlarmReceiver.class); - PendingIntent operation = PendingIntent.getBroadcast(this, 0, intent, - PendingIntent.FLAG_UPDATE_CURRENT); - return operation; - } - - private void clearNotice(int uid, int type) { - OSChinaApi.clearNotice(uid, type, mClearNoticeHandler); - } - - private int lastNotifiyCount; - - private void notification(Notice notice) { - int atmeCount = notice.getAtmeCount(); - int msgCount = notice.getMsgCount(); - int reviewCount = notice.getReviewCount(); - int newFansCount = notice.getNewFansCount(); - int newLikeCount = notice.getNewLikeCount(); - - int count = atmeCount + msgCount + reviewCount + newFansCount + newLikeCount; - - if (count == 0) { - lastNotifiyCount = 0; - NotificationManagerCompat.from(this).cancel( - R.string.you_have_news_messages); - return; - } - if (count == lastNotifiyCount) - return; - - lastNotifiyCount = count; - - Resources res = getResources(); - String contentTitle = res.getString(R.string.you_have_news_messages, - count); - String contentText; - StringBuffer sb = new StringBuffer(); - if (atmeCount > 0) { - sb.append(getString(R.string.atme_count, atmeCount)).append(" "); - } - if (msgCount > 0) { - sb.append(getString(R.string.msg_count, msgCount)).append(" "); - } - if (reviewCount > 0) { - sb.append(getString(R.string.review_count, reviewCount)) - .append(" "); - } - if (newFansCount > 0) { - sb.append(getString(R.string.fans_count, newFansCount)); - } - if (newLikeCount > 0) { - sb.append(getString(R.string.like_count, newLikeCount)); - } - contentText = sb.toString(); - - Intent intent = new Intent(this, MainActivity.class); - intent.putExtra("NOTICE", true); - - PendingIntent pi = PendingIntent.getActivity(this, 1000, intent, - PendingIntent.FLAG_CANCEL_CURRENT); - - NotificationCompat.Builder builder = new NotificationCompat.Builder( - this).setTicker(contentTitle).setContentTitle(contentTitle) - .setContentText(contentText).setAutoCancel(true) - .setContentIntent(pi).setSmallIcon(R.drawable.ic_notification); - - if (AppContext.get(AppConfig.KEY_NOTIFICATION_SOUND, true)) { - builder.setSound(Uri.parse("android.resource://" - + AppContext.getInstance().getPackageName() + "/" - + R.raw.notificationsound)); - } - if (AppContext.get(AppConfig.KEY_NOTIFICATION_VIBRATION, true)) { - long[] vibrate = { 0, 10, 20, 30 }; - builder.setVibrate(vibrate); - } - - Notification notification = builder.build(); - - NotificationManagerCompat.from(this).notify( - R.string.you_have_news_messages, notification); - } - - private final AsyncHttpResponseHandler mGetNoticeHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - Notice notice = XmlUtils.toBean(NoticeDetail.class, - arg2).getNotice(); - if (notice != null) { - UIHelper.sendBroadCast(NoticeService.this, notice); - if (AppContext.get(AppConfig.KEY_NOTIFICATION_ACCEPT, true)) { - notification(notice); - } - mNotice = notice; - } else { -// ResultBean resultBean = XmlUtils.toBean(ResultBean.class, arg2); -// if (resultBean != null && resultBean.getResult() != null) { -// AppContext appContext = AppContext.getInstance(); -// if (appContext != null) { -// appContext.Logout(); -// } -// } - } - } catch (Exception e) { - e.printStackTrace(); - onFailure(arg0, arg1, arg2, e); - } - }; - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) { - arg3.printStackTrace(); - } - }; - - private final AsyncHttpResponseHandler mClearNoticeHandler = new AsyncHttpResponseHandler() { - - @Override - public void onSuccess(int arg0, Header[] arg1, byte[] arg2) { - try { - ResultBean rsb = XmlUtils.toBean(ResultBean.class, - new ByteArrayInputStream(arg2)); - Result res = rsb.getResult(); - if (res.OK() && rsb.getNotice() != null) { - mNotice = rsb.getNotice(); - UIHelper.sendBroadCast(NoticeService.this, rsb.getNotice()); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void onFailure(int arg0, Header[] arg1, byte[] arg2, - Throwable arg3) {} - }; - - /** - * 请求是否有新通知 - */ - private void requestNotice() { - OSChinaApi.getNotices(mGetNoticeHandler); - } - - private static class ServiceStub extends INoticeService.Stub { - WeakReference mService; - - ServiceStub(NoticeService service) { - mService = new WeakReference(service); - } - - @Override - public void clearNotice(int uid, int type) throws RemoteException { - mService.get().clearNotice(uid, type); - } - - @Override - public void scheduleNotice() throws RemoteException { - mService.get().startRequestAlarm(); - } - - @Override - public void requestNotice() throws RemoteException { - mService.get().requestNotice(); - } - } - - private final IBinder mBinder = new ServiceStub(this); -} diff --git a/app/src/main/java/net/oschina/app/service/NoticeUtils.java b/app/src/main/java/net/oschina/app/service/NoticeUtils.java deleted file mode 100644 index 9d836947986baae701252c91573ecd82f08b0b18..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/NoticeUtils.java +++ /dev/null @@ -1,116 +0,0 @@ -package net.oschina.app.service; - -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.RemoteException; -import android.util.Log; - -import net.oschina.app.AppConfig; -import net.oschina.app.AppContext; -import net.oschina.app.util.TLog; - -import java.util.HashMap; - -public class NoticeUtils { - - public static INoticeService sService = null; - private static HashMap sConnectionMap = new HashMap(); - - public static boolean bindToService(Context context) { - return bindToService(context, null); - } - - public static boolean bindToService(Context context, - ServiceConnection callback) { - context.startService(new Intent(context, NoticeService.class)); - ServiceBinder sb = new ServiceBinder(callback); - sConnectionMap.put(context, sb); - return context.bindService( - (new Intent()).setClass(context, NoticeService.class), sb, 0); - } - - public static void unbindFromService(Context context) { - ServiceBinder sb = sConnectionMap.remove(context); - if (sb == null) { - Log.e("MusicUtils", "Trying to unbind for unknown Context"); - return; - } - context.unbindService(sb); - if (sConnectionMap.isEmpty()) { - // presumably there is nobody interested in the service at this - // point, - // so don't hang on to the ServiceConnection - sService = null; - } - } - - public static void clearNotice(int type) { - if (sService != null) { - try { - sService.clearNotice(AppContext.getInstance().getLoginUid(), - type); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - } - - public static void requestNotice(Context context) { - if (sService != null) { - try { - TLog.log("requestNotice..."); - sService.requestNotice(); - } catch (RemoteException e) { - e.printStackTrace(); - } - } else { - context.sendBroadcast(new Intent( - NoticeService.INTENT_ACTION_REQUEST)); - TLog.log("requestNotice,service is null"); - } - } - - public static void scheduleNotice() { - if (sService != null) { - try { - sService.scheduleNotice(); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - } - - private static class ServiceBinder implements ServiceConnection { - ServiceConnection mCallback; - - ServiceBinder(ServiceConnection callback) { - mCallback = callback; - } - - @Override - public void onServiceConnected(ComponentName className, - android.os.IBinder service) { - sService = INoticeService.Stub.asInterface(service); - if (mCallback != null) { - mCallback.onServiceConnected(className, service); - } - } - - @Override - public void onServiceDisconnected(ComponentName className) { - if (mCallback != null) { - mCallback.onServiceDisconnected(className); - } - sService = null; - } - } - - public static void tryToShutDown(Context context) { - if (AppContext.get(AppConfig.KEY_NOTIFICATION_DISABLE_WHEN_EXIT, true)) { - context.sendBroadcast(new Intent( - NoticeService.INTENT_ACTION_SHUTDOWN)); - } - } -} diff --git a/app/src/main/java/net/oschina/app/service/PublicCommentTask.java b/app/src/main/java/net/oschina/app/service/PublicCommentTask.java deleted file mode 100644 index e5eb65c68f212be4fea1af7aa13953fbd7631cc0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/PublicCommentTask.java +++ /dev/null @@ -1,90 +0,0 @@ -package net.oschina.app.service; - -import android.os.Parcel; -import android.os.Parcelable; - -public class PublicCommentTask implements Parcelable { - private int catalog; - private int id; - private int uid; - private String content; - private int isPostToMyZone; - - public PublicCommentTask() { - } - - public PublicCommentTask(Parcel source) { - catalog = source.readInt(); - id = source.readInt(); - uid = source.readInt(); - content = source.readString(); - isPostToMyZone = source.readInt(); - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(catalog); - dest.writeInt(id); - dest.writeInt(uid); - dest.writeString(content); - dest.writeInt(isPostToMyZone); - } - - public int getCatalog() { - return catalog; - } - - public void setCatalog(int catalog) { - this.catalog = catalog; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public int getUid() { - return uid; - } - - public void setUid(int uid) { - this.uid = uid; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public int getIsPostToMyZone() { - return isPostToMyZone; - } - - public void setIsPostToMyZone(int isPostToMyZone) { - this.isPostToMyZone = isPostToMyZone; - } - - @Override - public int describeContents() { - return 0; - } - - public static final Parcelable.Creator CREATOR = new Creator() { - - @Override - public PublicCommentTask[] newArray(int size) { - return new PublicCommentTask[size]; - } - - @Override - public PublicCommentTask createFromParcel(Parcel source) { - return new PublicCommentTask(source); - } - }; -} diff --git a/app/src/main/java/net/oschina/app/service/ServerTaskService.java b/app/src/main/java/net/oschina/app/service/ServerTaskService.java deleted file mode 100644 index bbb618a3883df4e2fec8029f699f9a55a1befc7f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/ServerTaskService.java +++ /dev/null @@ -1,306 +0,0 @@ -package net.oschina.app.service; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.AppContext; -import net.oschina.app.R; -import net.oschina.app.api.OperationResponseHandler; -import net.oschina.app.api.remote.OSChinaApi; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.bean.Comment; -import net.oschina.app.bean.Result; -import net.oschina.app.bean.ResultBean; -import net.oschina.app.bean.Tweet; -import net.oschina.app.util.XmlUtils; -import android.app.IntentService; -import android.app.Notification; -import android.app.PendingIntent; -import android.content.Intent; -import android.os.Handler; -import android.os.Looper; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; - -public class ServerTaskService extends IntentService { - private static final String SERVICE_NAME = "ServerTaskService"; - public static final String ACTION_PUB_BLOG_COMMENT = "net.oschina.app.ACTION_PUB_BLOG_COMMENT"; - public static final String ACTION_PUB_COMMENT = "net.oschina.app.ACTION_PUB_COMMENT"; - public static final String ACTION_PUB_POST = "net.oschina.app.ACTION_PUB_POST"; - public static final String ACTION_PUB_TWEET = "net.oschina.app.ACTION_PUB_TWEET"; - public static final String ACTION_PUB_SOFTWARE_TWEET = "net.oschina.app.ACTION_PUB_SOFTWARE_TWEET"; - - public static final String KEY_ADAPTER = "adapter"; - - public static final String BUNDLE_PUB_COMMENT_TASK = "BUNDLE_PUB_COMMENT_TASK"; - public static final String BUNDLE_PUB_POST_TASK = "BUNDLE_PUB_POST_TASK"; - public static final String BUNDLE_PUB_TWEET_TASK = "BUNDLE_PUB_TWEET_TASK"; - public static final String BUNDLE_PUB_SOFTWARE_TWEET_TASK = "BUNDLE_PUB_SOFTWARE_TWEET_TASK"; - public static final String KEY_SOFTID = "soft_id"; - - private static final String KEY_COMMENT = "comment_"; - private static final String KEY_TWEET = "tweet_"; - private static final String KEY_SOFTWARE_TWEET = "software_tweet_"; - private static final String KEY_POST = "post_"; - - public static List penddingTasks = new ArrayList(); - - class PublicCommentResponseHandler extends OperationResponseHandler { - - public PublicCommentResponseHandler(Looper looper, Object... args) { - super(looper, args); - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - PublicCommentTask task = (PublicCommentTask) args[0]; - final int id = task.getId() * task.getUid(); - ResultBean resB = XmlUtils.toBean(ResultBean.class, is); - Result res = resB.getResult(); - if (res.OK()) { - final Comment comment = resB.getComment(); - // UIHelper.sendBroadCastCommentChanged(ServerTaskService.this, - // isBlog, task.getId(), task.getCatalog(), - // Comment.OPT_ADD, comment); - notifySimpleNotifycation(id, - getString(R.string.comment_publish_success), - getString(R.string.comment_blog), - getString(R.string.comment_publish_success), false, - true); - removePenddingTask(KEY_COMMENT + id); - } else { - onFailure(100, res.getErrorMessage(), args); - } - } - - @Override - public void onFailure(int code, String errorMessage, Object[] args) { - PublicCommentTask task = (PublicCommentTask) args[0]; - int id = task.getId() * task.getUid(); - notifySimpleNotifycation(id, - getString(R.string.comment_publish_faile), - getString(R.string.comment_blog), - code == 100 ? errorMessage - : getString(R.string.comment_publish_faile), false, - true); - removePenddingTask(KEY_COMMENT + id); - } - - @Override - public void onFinish() { - tryToStopServie(); - } - } - - class PublicTweetResponseHandler extends OperationResponseHandler { - - String key = null; - - public PublicTweetResponseHandler(Looper looper, Object... args) { - super(looper, args); - key = (String) args[1]; - } - - @Override - public void onSuccess(int code, ByteArrayInputStream is, Object[] args) - throws Exception { - Tweet tweet = (Tweet) args[0]; - final int id = tweet.getId(); - Result res = XmlUtils.toBean(ResultBean.class, is).getResult(); - if (res.OK()) { - notifySimpleNotifycation(id, - getString(R.string.tweet_publish_success), - getString(R.string.tweet_public), - getString(R.string.tweet_publish_success), false, true); - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - cancellNotification(id); - } - }, 3000); - removePenddingTask(key + id); - if (tweet.getImageFilePath() != null) { - File imgFile = new File(tweet.getImageFilePath()); - if (imgFile.exists()) { - imgFile.delete(); - } - } - } else { - onFailure(100, res.getErrorMessage(), args); - } - } - - @Override - public void onFailure(int code, String errorMessage, Object[] args) { - Tweet tweet = (Tweet) args[0]; - int id = tweet.getId(); - notifySimpleNotifycation(id, - getString(R.string.tweet_publish_faile), - getString(R.string.tweet_public), - code == 100 ? errorMessage - : getString(R.string.tweet_publish_faile), false, - true); - removePenddingTask(key + id); - } - - @Override - public void onFinish() { - tryToStopServie(); - } - } - - public ServerTaskService() { - this(SERVICE_NAME); - } - - private synchronized void tryToStopServie() { - if (penddingTasks == null || penddingTasks.size() == 0) { - stopSelf(); - } - } - - private synchronized void addPenddingTask(String key) { - penddingTasks.add(key); - } - - private synchronized void removePenddingTask(String key) { - penddingTasks.remove(key); - } - - public ServerTaskService(String name) { - super(name); - } - - @Override - public void onCreate() { - super.onCreate(); - - } - - @Override - protected void onHandleIntent(Intent intent) { - String action = intent.getAction(); - - if (ACTION_PUB_BLOG_COMMENT.equals(action)) { - PublicCommentTask task = intent - .getParcelableExtra(BUNDLE_PUB_COMMENT_TASK); - if (task != null) { - publicBlogComment(task); - } - } else if (ACTION_PUB_COMMENT.equals(action)) { - PublicCommentTask task = intent - .getParcelableExtra(BUNDLE_PUB_COMMENT_TASK); - if (task != null) { - publicComment(task); - } - } else if (ACTION_PUB_POST.equals(action)) { - // Post post = intent.getParcelableExtra(BUNDLE_PUBLIC_POST_TASK); - // if (post != null) { - // publicPost(post); - // } - } else if (ACTION_PUB_TWEET.equals(action)) { - Tweet tweet = intent.getParcelableExtra(BUNDLE_PUB_TWEET_TASK); - if (tweet != null) { - pubTweet(tweet); - } - } else if (ACTION_PUB_SOFTWARE_TWEET.equals(action)) { - Tweet tweet = intent - .getParcelableExtra(BUNDLE_PUB_SOFTWARE_TWEET_TASK); - int softid = intent.getIntExtra(KEY_SOFTID, -1); - if (tweet != null && softid != -1) { - pubSoftWareTweet(tweet, softid); - } - } - } - - private void publicBlogComment(final PublicCommentTask task) { - int id = task.getId() * task.getUid(); - addPenddingTask(KEY_COMMENT + id); - - notifySimpleNotifycation(id, getString(R.string.comment_publishing), - getString(R.string.comment_blog), - getString(R.string.comment_publishing), true, false); - - OSChinaApi.publicBlogComment(task.getId(), task.getUid(), task - .getContent(), new PublicCommentResponseHandler( - getMainLooper(), task, true)); - } - - private void publicComment(final PublicCommentTask task) { - int id = task.getId() * task.getUid(); - addPenddingTask(KEY_COMMENT + id); - - notifySimpleNotifycation(id, getString(R.string.comment_publishing), - getString(R.string.comment_blog), - getString(R.string.comment_publishing), true, false); - - OSChinaApi.publicComment(task.getCatalog(), task.getId(), - task.getUid(), task.getContent(), task.getIsPostToMyZone(), - new PublicCommentResponseHandler(getMainLooper(), task, false)); - } - - // private void publicPost(Post post) { - // post.setId((int) System.currentTimeMillis()); - // int id = post.getId(); - // addPenddingTask(KEY_POST + id); - // notifySimpleNotifycation(id, getString(R.string.post_publishing), - // getString(R.string.post_public), - // getString(R.string.post_publishing), true, false); - // OSChinaApi.publicPost(post, new - // PublicPostResponseHandler(getMainLooper(), - // post)); - // } - // - private void pubTweet(final Tweet tweet) { - tweet.setId((int) System.currentTimeMillis()); - int id = tweet.getId(); - addPenddingTask(KEY_TWEET + id); - notifySimpleNotifycation(id, getString(R.string.tweet_publishing), - getString(R.string.tweet_public), - getString(R.string.tweet_publishing), true, false); - OSChinaApi.pubTweet(tweet, new PublicTweetResponseHandler( - getMainLooper(), tweet, KEY_TWEET)); - } - - private void pubSoftWareTweet(final Tweet tweet, int softid) { - tweet.setId((int) System.currentTimeMillis()); - int id = tweet.getId(); - addPenddingTask(KEY_SOFTWARE_TWEET + id); - notifySimpleNotifycation(id, getString(R.string.tweet_publishing), - getString(R.string.tweet_public), - getString(R.string.tweet_publishing), true, false); - OSChinaApi.pubSoftWareTweet(tweet, softid, - new PublicTweetResponseHandler(getMainLooper(), tweet, - KEY_SOFTWARE_TWEET)); - } - - private void notifySimpleNotifycation(int id, String ticker, String title, - String content, boolean ongoing, boolean autoCancel) { - NotificationCompat.Builder builder = new NotificationCompat.Builder( - this) - .setTicker(ticker) - .setContentTitle(title) - .setContentText(content) - .setAutoCancel(true) - .setOngoing(false) - .setOnlyAlertOnce(true) - .setContentIntent( - PendingIntent.getActivity(this, 0, new Intent(), 0)) - .setSmallIcon(R.drawable.ic_notification); - - // if (AppContext.isNotificationSoundEnable()) { - // builder.setDefaults(Notification.DEFAULT_SOUND); - // } - - Notification notification = builder.build(); - - NotificationManagerCompat.from(this).notify(id, notification); - } - - private void cancellNotification(int id) { - NotificationManagerCompat.from(this).cancel(id); - } -} diff --git a/app/src/main/java/net/oschina/app/service/ServerTaskUtils.java b/app/src/main/java/net/oschina/app/service/ServerTaskUtils.java deleted file mode 100644 index 4ae0f3bbcec62345d0e3a72fc77f9d5738b7ed67..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/service/ServerTaskUtils.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.oschina.app.service; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; - -import net.oschina.app.AppContext; -import net.oschina.app.bean.Tweet; - -public class ServerTaskUtils { - - public static void pubTweet(Context context, Tweet tweet) { - Intent intent = new Intent(ServerTaskService.ACTION_PUB_TWEET); - Bundle bundle = new Bundle(); - bundle.putParcelable(ServerTaskService.BUNDLE_PUB_TWEET_TASK, tweet); - intent.putExtras(bundle); - intent.setPackage(AppContext.getInstance().getPackageName()); - context.startService(intent); - } - - public static void pubSoftWareTweet(Context context, Tweet tweet, int softid) { - Intent intent = new Intent(ServerTaskService.ACTION_PUB_SOFTWARE_TWEET); - Bundle bundle = new Bundle(); - bundle.putParcelable(ServerTaskService.BUNDLE_PUB_SOFTWARE_TWEET_TASK, - tweet); - bundle.putInt(ServerTaskService.KEY_SOFTID, softid); - intent.putExtras(bundle); - intent.setPackage(AppContext.getInstance().getPackageName()); - context.startService(intent); - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/NotebookAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/NotebookAdapter.java deleted file mode 100644 index 95ca76af42a91d47829a509ae6d66fd05d9580c3..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/NotebookAdapter.java +++ /dev/null @@ -1,164 +0,0 @@ -package net.oschina.app.team.adapter; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.bean.NotebookData; -import net.oschina.app.team.fragment.NoteEditFragment; -import net.oschina.app.widget.KJDragGridView.DragGridBaseAdapter; - -import org.kymjs.kjframe.utils.DensityUtils; - -import android.app.Activity; -import android.text.Html; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.RelativeLayout.LayoutParams; -import android.widget.TextView; - -/** - * 便签列表适配器 - * - * @author kymjs (https://github.com/kymjs) - * - */ -public class NotebookAdapter extends BaseAdapter implements DragGridBaseAdapter { - private List datas; - private final Activity aty; - private int currentHidePosition = -1; - private final int width; - private final int height; - private boolean dataChange = false; - - public NotebookAdapter(Activity aty, List datas) { - super(); - Collections.sort(datas); - this.datas = datas; - this.aty = aty; - width = DensityUtils.getScreenW(aty) / 2; - height = (int) aty.getResources().getDimension(R.dimen.space_35); - } - - public void refurbishData(List datas) { - if (datas == null) { - datas = new ArrayList(1); - } - Collections.sort(datas); - this.datas = datas; - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return datas.size(); - } - - @Override - public Object getItem(int position) { - return datas.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - public List getDatas() { - return datas; - } - - /** - * 数据是否发生了改变 - * - * @return - */ - public boolean getDataChange() { - return dataChange; - } - - static class ViewHolder { - TextView date; - ImageView state; - ImageView thumbtack; - View titleBar; - TextView content; - } - - @Override - public View getView(int position, View v, ViewGroup parent) { - datas.get(position).setIid(position); - NotebookData data = datas.get(position); - - ViewHolder holder = null; - if (v == null) { - holder = new ViewHolder(); - v = View.inflate(aty, R.layout.item_notebook, null); - holder.titleBar = v.findViewById(R.id.item_note_titlebar); - holder.date = (TextView) v.findViewById(R.id.item_note_tv_date); - holder.state = (ImageView) v.findViewById(R.id.item_note_img_state); - holder.thumbtack = (ImageView) v - .findViewById(R.id.item_note_img_thumbtack); - holder.content = (TextView) v.findViewById(R.id.item_note_content); - v.setTag(holder); - } else { - holder = (ViewHolder) v.getTag(); - } - - RelativeLayout.LayoutParams params = (LayoutParams) holder.content - .getLayoutParams(); - params.width = width; - params.height = (params.width - height); - holder.content.setLayoutParams(params); - - holder.titleBar - .setBackgroundColor(NoteEditFragment.sTitleBackGrounds[data - .getColor()]); - holder.date.setText(data.getDate()); - if (data.getId() > 0) { - holder.state.setVisibility(View.GONE); - } else { - holder.state.setVisibility(View.VISIBLE); - } - holder.thumbtack.setImageResource(NoteEditFragment.sThumbtackImgs[data - .getColor()]); - holder.content.setText(Html.fromHtml(data.getContent())); - holder.content.setBackgroundColor(NoteEditFragment.sBackGrounds[data - .getColor()]); - if (position == currentHidePosition) { - v.setVisibility(View.GONE); - } else { - v.setVisibility(View.VISIBLE); - } - return v; - } - - @Override - public void reorderItems(int oldPosition, int newPosition) { - dataChange = true; - if (oldPosition >= datas.size() || oldPosition < 0) { - return; - } - NotebookData temp = datas.get(oldPosition); - if (oldPosition < newPosition) { - for (int i = oldPosition; i < newPosition; i++) { - Collections.swap(datas, i, i + 1); - } - } else if (oldPosition > newPosition) { - for (int i = oldPosition; i > newPosition; i--) { - Collections.swap(datas, i, i - 1); - } - } - datas.set(newPosition, temp); - } - - @Override - public void setHideItem(int hidePosition) { - this.currentHidePosition = hidePosition; - notifyDataSetChanged(); - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamActiveAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamActiveAdapter.java deleted file mode 100644 index 70a89a0c30d6df8e8b1da93958a9d8959a3c4f6e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamActiveAdapter.java +++ /dev/null @@ -1,151 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.content.Context; -import android.graphics.Bitmap; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamActive; -import net.oschina.app.ui.ImagePreviewActivity; -import net.oschina.app.util.BitmapHelper; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.TweetTextView; - -import org.kymjs.kjframe.Core; -import org.kymjs.kjframe.bitmap.BitmapCallBack; - -/** - * Team动态界面ListView适配器 (kymjs123@gmail.com) - * - * @author kymjs (https://github.com/kymjs) - */ -public class TeamActiveAdapter extends ListBaseAdapter { - private final Context context; - - public TeamActiveAdapter(Context cxt) { - this.context = cxt; - } - - static class ViewHolder { - AvatarView img_head; - TextView tv_name; - TweetTextView tv_content; - TextView tv_client; - TextView tv_date; - TextView tv_commit; - TextView tv_title; - ImageView iv_pic; - } - - @Override - protected View getRealView(int position, View v, ViewGroup parent) { - super.getRealView(position, v, parent); - ViewHolder holder = null; - TeamActive data = mDatas.get(position); - if (v == null || v.getTag() == null) { - v = View.inflate(context, R.layout.list_cell_team_active, null); - holder = new ViewHolder(); - holder.img_head = (AvatarView) v - .findViewById(R.id.event_listitem_userface); - holder.tv_name = (TextView) v - .findViewById(R.id.event_listitem_username); - holder.tv_title = (TextView) v.findViewById(R.id.title); - holder.tv_content = (TweetTextView) v - .findViewById(R.id.event_listitem_content); - holder.tv_client = (TextView) v - .findViewById(R.id.event_listitem_client); - holder.iv_pic = (ImageView) v.findViewById(R.id.iv_pic); - holder.tv_date = (TextView) v - .findViewById(R.id.event_listitem_date); - holder.tv_commit = (TextView) v.findViewById(R.id.tv_comment_count); - v.setTag(holder); - } else { - holder = (ViewHolder) v.getTag(); - } - holder.img_head.setAvatarUrl(data.getAuthor().getPortrait()); - holder.img_head.setUserInfo(data.getAuthor().getId(), data.getAuthor() - .getName()); - holder.tv_name.setText(data.getAuthor().getName()); - setContent(holder.tv_content, stripTags(data.getBody().getTitle())); - - String date = StringUtils.friendly_time2(data.getCreateTime()); - String preDate = ""; - if (position > 0) { - preDate = StringUtils.friendly_time2(mDatas.get(position - 1) - .getCreateTime()); - } - if (preDate.equals(date)) { - holder.tv_title.setVisibility(View.GONE); - } else { - holder.tv_title.setText(date); - holder.tv_title.setVisibility(View.VISIBLE); - } - - holder.tv_content.setMaxLines(3); - holder.tv_date.setText(StringUtils.friendly_time(data.getCreateTime())); - holder.tv_commit.setText(data.getReply()); - - String imgPath = data.getBody().getImage(); - if (!StringUtils.isEmpty(imgPath)) { - holder.iv_pic.setVisibility(View.VISIBLE); - setTweetImage(holder.iv_pic, imgPath); - } else { - holder.iv_pic.setVisibility(View.GONE); - } - return v; - } - - /** - * 移除字符串中的Html标签 - * - * @param pHTMLString - * @return - * @author kymjs (https://github.com/kymjs) - */ - public static String stripTags(final String pHTMLString) { - // String str = pHTMLString.replaceAll("\\<.*?>", ""); - String str = pHTMLString.replaceAll("\\t", ""); - str = str.replaceAll("<\\s*img\\s+([^>]*)\\s*>", "").trim(); - return str; - } - - @Override - public TeamActive getItem(int arg0) { - super.getItem(arg0); - return mDatas.get(arg0); - } - - /** - * 动态设置图片显示样式 - * - * @author kymjs - */ - private void setTweetImage(final ImageView pic, final String url) { - pic.setVisibility(View.VISIBLE); - - Core.getKJBitmap().display(pic, url, R.drawable.pic_bg, 0, 0, new BitmapCallBack() { - @Override - public void onSuccess(Bitmap bitmap) { - super.onSuccess(bitmap); - if (bitmap != null) { - bitmap = BitmapHelper.scaleWithXY(bitmap, - 360 / bitmap.getHeight()); - pic.setImageBitmap(bitmap); - } - } - }); - - pic.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - ImagePreviewActivity.showImagePrivew(context, 0, - new String[]{url}); - } - }); - } -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryDetailAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryDetailAdapter.java deleted file mode 100644 index 61c0c5af6ac7eb22a70f8199671596ecf5776f35..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryDetailAdapter.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.content.Context; -import android.text.Html; -import android.text.Spanned; -import android.view.View; -import android.view.ViewGroup; -import android.webkit.WebView; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.team.bean.TeamDiaryDetail; -import net.oschina.app.team.bean.TeamDiaryDetail.DayData; - -import java.util.ArrayList; -import java.util.List; - -public class TeamDiaryDetailAdapter extends BaseAdapter { - - private final TeamDiaryDetail data; - private final Context cxt; - private final List datas; - private final int[] weekIndex = new int[7]; - - public TeamDiaryDetailAdapter(Context cxt, TeamDiaryDetail datas) { - this.cxt = cxt; - this.data = datas; - this.datas = new ArrayList(20); - } - - @Override - public int getCount() { - if (data == null) { - return 0; - } - int count = 0; - weekIndex[0] = count; - count += isNull(data.getSun()); - weekIndex[1] = count; - count += isNull(data.getSat()); - weekIndex[2] = count; - count += isNull(data.getFri()); - weekIndex[3] = count; - count += isNull(data.getThu()); - weekIndex[4] = count; - count += isNull(data.getWed()); - weekIndex[5] = count; - count += isNull(data.getTue()); - weekIndex[6] = count; - count += isNull(data.getMon()); - return count; - } - - private String getWeek(int position, View hide) { - String week = ""; - hide.setVisibility(View.GONE); - if (position == weekIndex[0]) { - hide.setVisibility(View.VISIBLE); - week = "星期日"; - } - if (position == weekIndex[1]) { - hide.setVisibility(View.VISIBLE); - week = "星期六"; - } - if (position == weekIndex[2]) { - hide.setVisibility(View.VISIBLE); - week = "星期五"; - } - if (position == weekIndex[3]) { - hide.setVisibility(View.VISIBLE); - week = "星期四"; - } - if (position == weekIndex[4]) { - hide.setVisibility(View.VISIBLE); - week = "星期三"; - } - if (position == weekIndex[5]) { - hide.setVisibility(View.VISIBLE); - week = "星期二"; - } - if (position == weekIndex[6]) { - hide.setVisibility(View.VISIBLE); - week = "星期一"; - } - return week; - } - - private int isNull(DayData data) { - if (data == null) { - return 0; - } - datas.addAll(data.getList()); - return data.getList().size(); - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return 0; - } - - static class ViewHolder { - TextView week; - TextView content; - ImageView imageWeek; - WebView webView; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder holder = null; - if (convertView == null) { - holder = new ViewHolder(); - convertView = View.inflate(cxt, R.layout.list_cell_diary_detail, - null); - holder.week = (TextView) convertView - .findViewById(R.id.item_diary_detail_week); - holder.content = (TextView) convertView - .findViewById(R.id.item_diary_detail_content); - holder.imageWeek = (ImageView) convertView - .findViewById(R.id.item_diary_detail_img); - convertView.setTag(holder); - } else { - holder = (ViewHolder) convertView.getTag(); - } - holder.week.setText(getWeek(position, holder.imageWeek)); - holder.content.setText(stripTags(datas.get(position).toString())); - return convertView; - } - - /** - * 移除字符串中的Html标签 - * - * @author kymjs (https://github.com/kymjs) - * @param pHTMLString - * @return - */ - public static Spanned stripTags(final String pHTMLString) { - // String str = pHTMLString.replaceAll("\\<.*?>", ""); - String str = pHTMLString.replaceAll("", "
    "); - return Html.fromHtml(str); - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryListAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryListAdapter.java deleted file mode 100644 index 774f52f69ea45f00371f8b34ad3c248cfba0d83e..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryListAdapter.java +++ /dev/null @@ -1,91 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.content.Context; -import android.text.Html; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.team.bean.TeamDiary; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; - -import java.util.ArrayList; -import java.util.List; - -/** - * 周报的ListView适配器 - * - * @author kymjs (http://www.kymjs.com) - * - */ -public class TeamDiaryListAdapter extends BaseAdapter { - private final Context cxt; - private List list; - - public TeamDiaryListAdapter(Context cxt, List list) { - this.cxt = cxt; - if (list == null) { - list = new ArrayList(1); - } - this.list = list; - } - - public void refresh(List list) { - if (list == null) { - list = new ArrayList(1); - } - this.list = list; - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return list.size(); - } - - @Override - public Object getItem(int position) { - return list.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public View getView(int position, View v, ViewGroup parent) { - TeamDiary data = list.get(position); - ViewHolder holder = null; - if (v == null) { - v = View.inflate(cxt, R.layout.list_cell_team_diary, null); - holder = new ViewHolder(); - holder.iv_face = (AvatarView) v.findViewById(R.id.iv_face); - holder.tv_author = (TextView) v.findViewById(R.id.tv_author); - holder.tv_title = (TextView) v.findViewById(R.id.tv_title); - holder.tv_date = (TextView) v.findViewById(R.id.tv_date); - holder.tv_count = (TextView) v.findViewById(R.id.tv_count); - v.setTag(holder); - } else { - holder = (ViewHolder) v.getTag(); - } - holder.iv_face.setAvatarUrl(data.getAuthor().getPortrait()); - holder.tv_author.setText(data.getAuthor().getName()); - holder.tv_date.setText(StringUtils.friendly_time(data.getCreateTime())); - holder.tv_count.setText(data.getReply() + ""); - holder.tv_title.setText(Html.fromHtml(data.getTitle()).toString() - .trim()); - return v; - } - - static class ViewHolder { - AvatarView iv_face; - TextView tv_author; - TextView tv_title; - TextView tv_date; - TextView tv_count; - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryPagerAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryPagerAdapter.java deleted file mode 100644 index 453769086077c7e7d412daed7e928d4637dae5f0..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamDiaryPagerAdapter.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.oschina.app.team.adapter; - -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.DiaryPageContentView; -import android.content.Context; -import android.support.v4.view.PagerAdapter; -import android.view.View; -import android.view.ViewGroup; - -/** - * 周报ViewPager适配器 - * - * @author kymjs (http://www.kymjs.com) - */ -public class TeamDiaryPagerAdapter extends PagerAdapter { - private final Context cxt; - private final int currentYear; - private final int teamId; - - public TeamDiaryPagerAdapter(Context cxt, int currentYear, int teamId) { - this.currentYear = currentYear; - this.cxt = cxt; - this.teamId = teamId; - } - - @Override - public int getCount() { - return currentYear == 2015 ? StringUtils.getWeekOfYear() : 52; - } - - @Override - public boolean isViewFromObject(View arg0, Object arg1) { - return arg0 == arg1; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView((View) object); - } - - @Override - public Object instantiateItem(ViewGroup container, int position) { - View pagerView = new DiaryPageContentView(cxt, teamId, currentYear, - position + 1).getView(); - (container).addView(pagerView); - return pagerView; - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamDiscussAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamDiscussAdapter.java deleted file mode 100755 index 31fff0a4ac7d4f7873011a18e2f5e89bae32da03..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamDiscussAdapter.java +++ /dev/null @@ -1,78 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamDiscuss; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * team 讨论区帖子 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @created 2014年10月9日 下午6:22:54 - */ -public class TeamDiscussAdapter extends ListBaseAdapter { - - static class ViewHolder { - - @InjectView(R.id.tv_title) - TextView title; - @InjectView(R.id.tv_description) - TextView description; - @InjectView(R.id.tv_author) - TextView author; - @InjectView(R.id.tv_date) - TextView time; - @InjectView(R.id.tv_count) - TextView comment_count; - @InjectView(R.id.tv_vote_up) - TextView vote_up; - - @InjectView(R.id.iv_face) - public AvatarView face; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_team_discuss, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamDiscuss item = mDatas.get(position); - - vh.face.setUserInfo(item.getAuthor().getId(), item.getAuthor() - .getName()); - vh.face.setAvatarUrl(item.getAuthor().getPortrait()); - vh.title.setText(item.getTitle()); - String body = item.getBody().trim(); - vh.description.setVisibility(View.GONE); - if (null != body || !StringUtils.isEmpty(body)) { - vh.description.setVisibility(View.VISIBLE); - vh.description.setText(HTMLUtil.replaceTag(item.getBody()).trim()); - } - vh.author.setText(item.getAuthor().getName()); - vh.time.setText(StringUtils.friendly_time(item.getCreateTime())); - vh.vote_up.setText(item.getVoteUp() + ""); - vh.comment_count.setText(item.getAnswerCount() + ""); - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamIssueAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamIssueAdapter.java deleted file mode 100644 index 265f6a650465667038d842886feb1b26b854f8f2..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamIssueAdapter.java +++ /dev/null @@ -1,199 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.graphics.Paint; -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamIssue; -import net.oschina.app.util.StringUtils; -import net.oschina.app.util.TypefaceUtils; -import net.oschina.app.util.ViewUtils; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 任务列表适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月14日 下午5:28:51 - * - */ -public class TeamIssueAdapter extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - int type = getItemViewType(position); - if (convertView == null || convertView.getTag() == null) { - - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_team_issue, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamIssue item = mDatas.get(position); - - vh.title.setText(item.getTitle()); - - String date = StringUtils.friendly_time2(item.getCreateTime()); - String preDate = ""; - if (position > 0) { - preDate = StringUtils.friendly_time2(mDatas.get(position - 1) - .getCreateTime()); - } - if (preDate.equals(date)) { - vh.title_line.setVisibility(View.GONE); - } else { - vh.title_line.setText(date); - vh.title_line.setVisibility(View.VISIBLE); - } - - setIssueState(vh, item); - - setIssueSource(vh, item); - - vh.author.setText(item.getAuthor().getName()); - if (item.getToUser() == null - || TextUtils.isEmpty(item.getToUser().getName())) { - vh.to.setText("未指派"); - vh.touser.setVisibility(View.GONE); - } else { - vh.to.setText("指派给"); - vh.touser.setVisibility(View.VISIBLE); - vh.touser.setText(item.getToUser().getName()); - } - - vh.time.setText(StringUtils.friendly_time(item.getCreateTime())); - vh.comment.setText(item.getReplyCount() + ""); - - if (item.getProject() != null && item.getProject().getGit() != null) { - vh.project.setVisibility(View.VISIBLE); - String gitState = item.getGitpush() == TeamIssue.TEAM_ISSUE_GITPUSHED ? "" - : " -未同步"; - setText(vh.project, item.getProject().getGit().getName() + gitState); - } else { - vh.project.setVisibility(View.GONE); - } - - String deadlineTime = item.getDeadlineTime(); - if (!StringUtils.isEmpty(deadlineTime)) { - vh.accept_time.setVisibility(View.VISIBLE); - setText(vh.accept_time, getDeadlineTime(item), true); - } else { - vh.accept_time.setVisibility(View.GONE); - } - - if (item.getAttachments().getTotalCount() != 0) { - vh.attachments.setVisibility(View.VISIBLE); - vh.attachments.setText("附件" + item.getAttachments().getTotalCount() - + ""); - } else { - vh.attachments.setVisibility(View.GONE); - } - - if (item.getChildIssues() != null - && item.getChildIssues().getTotalCount() != 0) { - vh.childissues.setVisibility(View.VISIBLE); - setText(vh.childissues, "子任务(" - + item.getChildIssues().getClosedCount() + "/" - + item.getChildIssues().getTotalCount() + ")"); - } else { - vh.childissues.setVisibility(View.GONE); - } - - if (item.getRelations().getTotalCount() != 0) { - vh.relations.setVisibility(View.VISIBLE); - vh.relations.setText("关联" + item.getRelations().getTotalCount() - + ""); - } else { - vh.relations.setVisibility(View.GONE); - } - - return convertView; - } - - private void setIssueState(ViewHolder vh, TeamIssue teamIssue) { - String state = teamIssue.getState(); - if (TextUtils.isEmpty(state)) - return; - TypefaceUtils.setTypeface(vh.state, teamIssue.getIssueStateFaTextId()); - - if (teamIssue.getState().equals("closed") - || teamIssue.getState().equals("accepted")) { - ViewUtils.setTextViewLineFlag(vh.title, Paint.STRIKE_THRU_TEXT_FLAG - | Paint.ANTI_ALIAS_FLAG); - } else { - ViewUtils.setTextViewLineFlag(vh.title, 0 | Paint.ANTI_ALIAS_FLAG); - } - } - - private void setIssueSource(ViewHolder vh, TeamIssue teamIssue) { - String source = teamIssue.getSource(); - if (TextUtils.isEmpty(source)) - return; - TextView tv = vh.issueSource; - if (source.equalsIgnoreCase(TeamIssue.TEAM_ISSUE_SOURCE_GITOSC)) { - // 来自gitosc - TypefaceUtils.setTypeface(tv, R.string.fa_gitosc); - } else if (source.equalsIgnoreCase(TeamIssue.TEAM_ISSUE_SOURCE_GITHUB)) { - // 来自github - TypefaceUtils.setTypeface(tv, R.string.fa_github); - } else { - // 来自teamosc - TypefaceUtils.setTypeface(tv, R.string.fa_team); - } - } - - private String getDeadlineTime(TeamIssue teamIssue) { - SimpleDateFormat dataFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date date = StringUtils.toDate(teamIssue.getUpdateTime(), dataFormat); - return DateFormat.getDateInstance(DateFormat.SHORT).format(date); - } - - static class ViewHolder { - @InjectView(R.id.iv_issue_state) - TextView state; - @InjectView(R.id.tv_title) - TextView title; - @InjectView(R.id.iv_issue_source) - TextView issueSource; - @InjectView(R.id.tv_project) - TextView project; - @InjectView(R.id.tv_attachments) - TextView attachments;// 附件 - @InjectView(R.id.tv_childissues) - TextView childissues;// 子任务 - @InjectView(R.id.tv_relations) - TextView relations;// 关联任务 - @InjectView(R.id.tv_accept_time) - TextView accept_time; - @InjectView(R.id.tv_author) - TextView author; - @InjectView(R.id.tv_to) - TextView to; - @InjectView(R.id.tv_touser) - TextView touser; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_comment_count) - TextView comment; - @InjectView(R.id.title) - TextView title_line; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamIssueCatalogAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamIssueCatalogAdapter.java deleted file mode 100644 index d54eef8781ccb2d15b1ec97938f819b5dc970678..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamIssueCatalogAdapter.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.oschina.app.team.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamIssueCatalog; -import net.oschina.app.util.StringUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * TeamIssueCatalogAdapter.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-3-1 下午3:37:03 - */ -public class TeamIssueCatalogAdapter extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_team_issue_catalog, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamIssueCatalog item = mDatas.get(position); - - vh.title.setText(item.getTitle()); - vh.state.setText(item.getOpenedIssueCount() + "/" - + item.getAllIssueCount()); - - String description = item.getDescription(); - if (description != null && !StringUtils.isEmpty(description)) { - vh.description.setText(description); - } else { - vh.description.setText("暂无描述"); - } - - return convertView; - } - - static class ViewHolder { - - @InjectView(R.id.tv_team_issue_catalog_title) - TextView title; - @InjectView(R.id.tv_team_issue_catalog_desc) - TextView description; - @InjectView(R.id.tv_team_issue_catalog_state) - TextView state; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamMemberAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamMemberAdapter.java deleted file mode 100644 index c729341782afcdbe7a2e4f20189d022956590782..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamMemberAdapter.java +++ /dev/null @@ -1,106 +0,0 @@ -package net.oschina.app.team.adapter; - -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.team.bean.Team; -import net.oschina.app.team.bean.TeamMember; -import net.oschina.app.util.UIHelper; -import net.oschina.app.widget.AvatarView; -import android.content.Context; -import android.graphics.drawable.ColorDrawable; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -/** - * 团队成员GridView适配器 - * - * @author kymjs (kymjs123@gmail.com) - * - */ -public class TeamMemberAdapter extends BaseAdapter { - private final Context cxt; - private List datas; - private final Team team; - public static final String TEAM_MEMBER_KEY = "TeamMemberAdapter_teammemberkey"; - public static final String TEAM_ID_KEY = "TeamMemberAdapter_teaminfokey"; - - public TeamMemberAdapter(Context context, List datas, Team team) { - this.cxt = context; - this.team = team; - if (datas == null) { - datas = new ArrayList(1); - } - this.datas = datas; - } - - public void refresh(List datas) { - if (datas == null) { - datas = new ArrayList(1); - } - this.datas = datas; - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return datas.size(); - } - - @Override - public Object getItem(int position) { - return null; - } - - @Override - public long getItemId(int position) { - return 0; - } - - static class ViewHolder { - ImageView img_tip; - AvatarView img_head; - TextView tv_name; - } - - @Override - public View getView(final int position, View v, ViewGroup parent) { - ViewHolder holder = null; - TeamMember data = datas.get(position); - if (v == null) { - v = View.inflate(cxt, R.layout.item_team_member, null); - holder = new ViewHolder(); - holder.img_head = (AvatarView) v - .findViewById(R.id.item_team_member_head); - holder.img_tip = (ImageView) v - .findViewById(R.id.item_team_membar_tip); - holder.tv_name = (TextView) v - .findViewById(R.id.item_team_membar_name); - v.setTag(holder); - } else { - holder = (ViewHolder) v.getTag(); - } - holder.tv_name.setText(data.getName()); - holder.img_head.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - UIHelper.showTeamMemberInfo(cxt, team.getId(), - datas.get(position)); - } - }); - holder.img_head.setAvatarUrl(data.getPortrait()); - if (127 == data.getTeamRole()) { // 创建人,红色 - holder.img_tip.setImageDrawable(new ColorDrawable(0xffff0000)); - } else if (126 == data.getTeamRole()) { // 管理者,黄色 - holder.img_tip.setImageDrawable(new ColorDrawable(0xffffb414)); - } else { - holder.img_tip.setImageDrawable(null); - } - return v; - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapter.java deleted file mode 100644 index 843a260854400fa0db52bd88f37ae7c6daf15940..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapter.java +++ /dev/null @@ -1,101 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.team.bean.TeamProject; -import net.oschina.app.util.TypefaceUtils; - -import java.util.ArrayList; -import java.util.List; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 团队项目适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月19日 下午6:00:33 - * - */ - -public class TeamProjectListAdapter extends BaseAdapter { - - private final ArrayList datas = new ArrayList(); - - public void add(TeamProject project) { - this.datas.add(project); - notifyDataSetChanged(); - } - - public void add(List datas) { - this.datas.addAll(datas); - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return datas.size(); - } - - @Override - public TeamProject getItem(int position) { - return datas.get(position); - } - - @Override - public long getItemId(int position) { - return 0; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder vh; - if (convertView == null || convertView.getTag() == null) { - convertView = View.inflate(parent.getContext(), - R.layout.list_cell_team_project, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamProject item = datas.get(position); - - String source = item.getSource(); - TextView tvSource = vh.source; - if (TextUtils.isEmpty(source)) { - if (item.getGit().getId() == -1) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_tasks); - } else { - TypefaceUtils.setTypeface(tvSource, R.string.fa_inbox); - } - } else if (source.equalsIgnoreCase(TeamProject.GITOSC)) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_gitosc); - } else if (source.equalsIgnoreCase(TeamProject.GITHUB)) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_github); - } else { - TypefaceUtils.setTypeface(tvSource, R.string.fa_list_alt); - } - vh.name.setText(item.getGit().getName()); - - return convertView; - } - - public static class ViewHolder { - @InjectView(R.id.iv_source) - TextView source; - @InjectView(R.id.tv_project_name) - TextView name; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapterNew.java b/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapterNew.java deleted file mode 100644 index 2654a37f66ac823ede90e07b311ecc0588f103dc..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectListAdapterNew.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.oschina.app.team.adapter; - -import android.text.TextUtils; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamProject; -import net.oschina.app.util.TypefaceUtils; - -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 团队项目适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月19日 下午6:00:33 - */ - -public class TeamProjectListAdapterNew extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - // TODO Auto-generated method stub - ViewHolder vh; - if (convertView == null || convertView.getTag() == null) { - convertView = View.inflate(parent.getContext(), - R.layout.list_cell_team_project, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamProject item = mDatas.get(position); - - String source = item.getSource(); - TextView tvSource = vh.source; - if (TextUtils.isEmpty(source)) { - if (item.getGit().getId() == -1) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_tasks); - } else { - TypefaceUtils.setTypeface(tvSource, R.string.fa_inbox); - } - } else if (source.equalsIgnoreCase(TeamProject.GITOSC)) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_gitosc); - } else if (source.equalsIgnoreCase(TeamProject.GITHUB)) { - TypefaceUtils.setTypeface(tvSource, R.string.fa_github); - } else { - TypefaceUtils.setTypeface(tvSource, R.string.fa_list_alt); - } - - vh.name.setText(item.getGit().getOwnerName() + " / " + item.getGit().getName()); - vh.issue.setText(item.getIssue().getOpened() + "/" + item.getIssue().getAll()); - - return convertView; - } - - public static class ViewHolder { - @InjectView(R.id.iv_source) - TextView source; - @InjectView(R.id.tv_project_name) - TextView name; - @InjectView(R.id.tv_project_issue) - TextView issue; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectMemberAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamProjectMemberAdapter.java deleted file mode 100644 index 2334c5908dba95f909883c810fdd21e9c870469f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamProjectMemberAdapter.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.oschina.app.team.adapter; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamMember; -import net.oschina.app.widget.AvatarView; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 团队项目适配器 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月19日 下午6:00:33 - * - */ - -public class TeamProjectMemberAdapter extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - // TODO Auto-generated method stub - ViewHolder vh; - if (convertView == null || convertView.getTag() == null) { - convertView = View.inflate(parent.getContext(), - R.layout.list_cell_team_project_member, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamMember item = mDatas.get(position); - - vh.avatar.setAvatarUrl(item.getPortrait()); - vh.name.setText(item.getName()); - - return convertView; - } - - public static class ViewHolder { - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_name) - TextView name; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamReplyAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamReplyAdapter.java deleted file mode 100644 index 93da945975880301ea0ef3381457f07b8669b38d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamReplyAdapter.java +++ /dev/null @@ -1,119 +0,0 @@ -package net.oschina.app.team.adapter; - -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.base.ListBaseAdapter; -import net.oschina.app.team.bean.TeamReply; -import net.oschina.app.util.HTMLUtil; -import net.oschina.app.util.StringUtils; -import net.oschina.app.widget.AvatarView; -import net.oschina.app.widget.TweetTextView; -import android.content.Context; -import android.view.View; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -/** - * 评论适配器 TeamReply.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-1-30 下午4:05:00 - */ -public class TeamReplyAdapter extends ListBaseAdapter { - - @Override - protected View getRealView(int position, View convertView, ViewGroup parent) { - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - convertView = getLayoutInflater(parent.getContext()).inflate( - R.layout.list_cell_team_reply, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - TeamReply item = mDatas.get(position); - vh.name.setText(item.getAuthor().getName()); - vh.avatar.setAvatarUrl(item.getAuthor().getPortrait()); - setContent(vh.content, HTMLUtil.delHTMLTag(item.getContent())); - vh.time.setText(StringUtils.friendly_time(item.getCreateTime())); - - if (StringUtils.isEmpty(item.getAppName())) { - vh.from.setVisibility(View.GONE); - } else { - vh.from.setVisibility(View.VISIBLE); - vh.from.setText(item.getAppName()); - } - setReplies(parent.getContext(), item, vh); - return convertView; - } - - private void setReplies(Context context, TeamReply item, ViewHolder vh) { - List replies = item.getReplies(); - vh.relies.removeAllViews(); - if (replies == null || replies.size() <= 0) { - vh.relies.setVisibility(View.GONE); - } else { - vh.relies.setVisibility(View.VISIBLE); - - // add count layout - View countView = getLayoutInflater(context).inflate( - R.layout.list_cell_reply_count, null, false); - TextView count = (TextView) countView - .findViewById(R.id.tv_comment_reply_count); - count.setText(context.getResources().getString( - R.string.comment_reply_count, replies.size())); - vh.relies.addView(countView); - - for (TeamReply teamReply : replies) { - View replyItemView = getLayoutInflater( - context).inflate(R.layout.list_cell_team_reply_refers, - null, false); - replyItemView.setBackgroundResource(R.drawable.comment_background); - - AvatarView avatarView = (AvatarView) replyItemView.findViewById(R.id.iv_avatar); - avatarView.setAvatarUrl(teamReply.getAuthor().getPortrait()); - TextView name = (TextView) replyItemView.findViewById(R.id.tv_name); - name.setText(teamReply.getAuthor().getName()); - TweetTextView content = (TweetTextView) replyItemView.findViewById(R.id.tv_content); - setContent(content, HTMLUtil.delHTMLTag(teamReply.getContent())); - TextView time = (TextView) replyItemView.findViewById(R.id.tv_time); - time.setText(StringUtils.friendly_time(teamReply.getCreateTime())); - TextView from = (TextView) replyItemView.findViewById(R.id.tv_from); - if (StringUtils.isEmpty(teamReply.getAppName())) { - from.setVisibility(View.GONE); - } else { - from.setVisibility(View.VISIBLE); - from.setText(teamReply.getAppName()); - } - vh.relies.addView(replyItemView); - } - } - } - - static class ViewHolder { - - @InjectView(R.id.iv_avatar) - AvatarView avatar; - @InjectView(R.id.tv_name) - TextView name; - @InjectView(R.id.tv_time) - TextView time; - @InjectView(R.id.tv_from) - TextView from; - @InjectView(R.id.tv_content) - TweetTextView content; - @InjectView(R.id.ly_relies) - LinearLayout relies; - - public ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } -} diff --git a/app/src/main/java/net/oschina/app/team/adapter/TeamSelectMemberAdapter.java b/app/src/main/java/net/oschina/app/team/adapter/TeamSelectMemberAdapter.java deleted file mode 100644 index 8b330aa3ea62f2c451b3800c9264bc19a2293fda..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/adapter/TeamSelectMemberAdapter.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.oschina.app.team.adapter; - -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.team.bean.TeamMember; -import net.oschina.app.widget.AvatarView; -import android.content.Context; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.BaseAdapter; -import android.widget.TextView; -import butterknife.ButterKnife; -import butterknife.InjectView; - -public class TeamSelectMemberAdapter extends BaseAdapter { - - static class ViewHolder { - @InjectView(R.id.iv_avatar) - AvatarView aView; - @InjectView(R.id.tv_name) - TextView name; - - ViewHolder(View view) { - ButterKnife.inject(this, view); - } - } - - private List members; - - public TeamSelectMemberAdapter(List members) { - this.members = members; - } - - @Override - public int getCount() { - // TODO Auto-generated method stub - return members.size(); - } - - @Override - public Object getItem(int position) { - // TODO Auto-generated method stub - return members.get(position); - } - - @Override - public long getItemId(int position) { - // TODO Auto-generated method stub - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - // TODO Auto-generated method stub - ViewHolder vh = null; - if (convertView == null || convertView.getTag() == null) { - LayoutInflater inflater = (LayoutInflater) parent.getContext() - .getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = inflater.inflate(R.layout.list_cell_team_project_member, null); - vh = new ViewHolder(convertView); - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - TeamMember item = members.get(position); - vh.aView.setAvatarUrl(item.getPortrait()); - vh.name.setText(item.getName()); - return convertView; - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/Author.java b/app/src/main/java/net/oschina/app/team/bean/Author.java deleted file mode 100644 index 455a683f255c1d36344a49d1990adb949729661d..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/Author.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.oschina.app.team.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; - -/** - * 帖子、任务、讨论的创建者, - * 注:节点 - * - * @author fireant - */ -@SuppressWarnings("serial") -@XStreamAlias("author") -public class Author extends Entity { - - @XStreamAlias("name") - private String name; - - @XStreamAlias("portrait") - private String portrait; - - @XStreamAlias("") - private String oscName; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/MyIssueState.java b/app/src/main/java/net/oschina/app/team/bean/MyIssueState.java deleted file mode 100644 index ae52bf8f9ed22298cb402df94ee4f3733e04f27a..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/MyIssueState.java +++ /dev/null @@ -1,97 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 我的任务中要显示的状态 - * - * @author kymjs (https://github.com/kymjs) - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class MyIssueState extends Entity { - @XStreamAlias("opened") - private String opened; // 待办中 - @XStreamAlias("outdate") - private String outdate; // 已过期 - @XStreamAlias("closed") - private String closed; // 已完成 - @XStreamAlias("finished") - private String finished; // 已完成 + 已验收 - @XStreamAlias("underway") - private String underway; // 进行中 - @XStreamAlias("accepted") - private String accepted; // 已验收 - @XStreamAlias("all") - private String all; - - @XStreamAlias("member") - private TeamMember user; - - public String getFinished() { - return finished; - } - - public void setFinished(String finished) { - this.finished = finished; - } - - public String getUnderway() { - return underway; - } - - public void setUnderway(String underway) { - this.underway = underway; - } - - public String getAccepted() { - return accepted; - } - - public void setAccepted(String accepted) { - this.accepted = accepted; - } - - public String getOpened() { - return opened; - } - - public void setOpened(String opened) { - this.opened = opened; - } - - public String getOutdate() { - return outdate; - } - - public void setOutdate(String outdate) { - this.outdate = outdate; - } - - public String getClosed() { - return closed; - } - - public void setClosed(String closed) { - this.closed = closed; - } - - public String getAll() { - return all; - } - - public void setAll(String all) { - this.all = all; - } - - public TeamMember getUser() { - return user; - } - - public void setUser(TeamMember user) { - this.user = user; - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/Team.java b/app/src/main/java/net/oschina/app/team/bean/Team.java deleted file mode 100644 index ec6ae221e916749452db780937d62de6009e7a4f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/Team.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 团队属性 - * - * @author kymjs - * - */ -@SuppressWarnings("serial") -@XStreamAlias("team") -public class Team extends Entity { - @XStreamAlias("type") - private String type; - @XStreamAlias("status") - private String status; - @XStreamAlias("name") - private String name; - @XStreamAlias("ident") - private String ident; - @XStreamAlias("createTime") - private String createTime; - @XStreamAlias("about") - private About about = new About(); - - public About getAbout() { - return about; - } - - public void setAbout(About about) { - this.about = about; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getIdent() { - return ident; - } - - public void setIdent(String ident) { - this.ident = ident; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - @XStreamAlias("about") - public class About extends Entity { - @XStreamAlias("createTime") - String sign; - @XStreamAlias("address") - String address; - @XStreamAlias("telephone") - String telephone; - @XStreamAlias("email") - String email; - @XStreamAlias("qq") - String qq; - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getTelephone() { - return telephone; - } - - public void setTelephone(String telephone) { - this.telephone = telephone; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getQq() { - return qq; - } - - public void setQq(String qq) { - this.qq = qq; - } - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamActive.java b/app/src/main/java/net/oschina/app/team/bean/TeamActive.java deleted file mode 100644 index e1786d84c527838128364af84553c14c54209289..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamActive.java +++ /dev/null @@ -1,167 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * Team模块的动态JavaBean - * - * @author kymjs - * - */ -@SuppressWarnings("serial") -@XStreamAlias("active") -public class TeamActive extends Entity { - - @XStreamAlias("id") - private int id; - @XStreamAlias("body") - private Body body; - @XStreamAlias("reply") - private String reply; - @XStreamAlias("createTime") - private String createTime; - @XStreamAlias("author") - private Author author; - @XStreamAlias("type") - private int type; - - public Body getBody() { - return body; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - @Override - public int getId() { - return id; - } - - @Override - public void setId(int id) { - this.id = id; - } - - public void setBody(Body body) { - this.body = body; - } - - public String getReply() { - return reply; - } - - public void setReply(String reply) { - this.reply = reply; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public Author getAuthor() { - return author; - } - - public void setAuthor(Author author) { - this.author = author; - } - - @XStreamAlias("body") - public class Body extends Entity { - @XStreamAlias("detail") - private String detail; - @XStreamAlias("title") - private String title; - @XStreamAlias("code") - private String code; - @XStreamAlias("codeType") - private String codeType; - @XStreamAlias("image") - private String image; - @XStreamAlias("imageOrigin") - private String imageOrigin; - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDetail() { - return detail; - } - - public void setDetail(String detail) { - this.detail = detail; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getCodeType() { - return codeType; - } - - public void setCodeType(String codeType) { - this.codeType = codeType; - } - - public String getImage() { - return image; - } - - public void setImage(String image) { - this.image = image; - } - - public String getImageOrigin() { - return imageOrigin; - } - - public void setImageOrigin(String imageOrigin) { - this.imageOrigin = imageOrigin; - } - } - - @XStreamAlias("author") - public class Author extends Entity { - @XStreamAlias("name") - private String name; - @XStreamAlias("portrait") - private String portrait; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPortrait() { - return portrait; - } - - public void setPortrait(String portrait) { - this.portrait = portrait; - } - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamActiveDetail.java b/app/src/main/java/net/oschina/app/team/bean/TeamActiveDetail.java deleted file mode 100644 index 25ce3afe681ad45e63c007a07ef311d7117f9f07..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamActiveDetail.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * Team模块的动态JavaBean - * - * @author kymjs - * - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TeamActiveDetail extends Entity { - - @XStreamAlias("active") - private TeamActive teamActive; - - public TeamActive getTeamActive() { - return teamActive; - } - - public void setTeamActive(TeamActive teamActive) { - this.teamActive = teamActive; - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamActives.java b/app/src/main/java/net/oschina/app/team/bean/TeamActives.java deleted file mode 100644 index facd05912c96269bf307d509cd56b4c42b7a7617..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamActives.java +++ /dev/null @@ -1,41 +0,0 @@ -package net.oschina.app.team.bean; - -import java.util.ArrayList; -import java.util.List; - -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.ListEntity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -/** - * 动态列表 - * - * @author kymjs - * - */ -@XStreamAlias("oschina") -public class TeamActives extends Entity implements ListEntity { - private static final long serialVersionUID = 1L; - - @XStreamAlias("actives") - ArrayList actives = new ArrayList(); - - public static long getSerialversionuid() { - return serialVersionUID; - } - - @Override - public List getList() { - return actives; - } - - public ArrayList getActives() { - return actives; - } - - public void setActives(ArrayList actives) { - this.actives = actives; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiary.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiary.java deleted file mode 100644 index ddcbe79fc154dbfb26b2bfb6f412fc216d703395..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiary.java +++ /dev/null @@ -1,66 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@SuppressWarnings("serial") -@XStreamAlias("diary") -public class TeamDiary extends Entity { - - @XStreamAlias("title") - private String title; - - @XStreamAlias("reply") - private int reply; - - @XStreamAlias("createTime") - private String createTime; - - @XStreamAlias("author") - private Author author; - - @XStreamAlias("detail") - private TeamDiaryDetail teamDiaryDetail; - - public TeamDiaryDetail getTeamDiaryDetail() { - return teamDiaryDetail; - } - - public void setTeamDiaryDetail(TeamDiaryDetail teamDiaryDetail) { - this.teamDiaryDetail = teamDiaryDetail; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public int getReply() { - return reply; - } - - public void setReply(int reply) { - this.reply = reply; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public Author getAuthor() { - return author; - } - - public void setAuthor(Author author) { - this.author = author; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetail.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetail.java deleted file mode 100644 index be0e00655853b2071534432e7650de6e20dc4ea9..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetail.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.oschina.app.team.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -import net.oschina.app.bean.Entity; - -import java.io.Serializable; -import java.util.List; - -@XStreamAlias("detail") -public class TeamDiaryDetail extends Entity { - @XStreamAlias("sun") - private DayData sun; - @XStreamAlias("thu") - private DayData thu; - @XStreamAlias("wed") - private DayData wed; - @XStreamAlias("tue") - private DayData tue; - @XStreamAlias("mon") - private DayData mon; - @XStreamAlias("fri") - private DayData fri; - @XStreamAlias("sat") - private DayData sat; - - public class DayData implements Serializable { - @XStreamImplicit(itemFieldName = "list") - private List list; - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - - } - - public DayData getSun() { - return sun; - } - - public void setSun(DayData sun) { - this.sun = sun; - } - - public DayData getThu() { - return thu; - } - - public void setThu(DayData thu) { - this.thu = thu; - } - - public DayData getWed() { - return wed; - } - - public void setWed(DayData wed) { - this.wed = wed; - } - - public DayData getTue() { - return tue; - } - - public void setTue(DayData tue) { - this.tue = tue; - } - - public DayData getMon() { - return mon; - } - - public void setMon(DayData mon) { - this.mon = mon; - } - - public DayData getFri() { - return fri; - } - - public void setFri(DayData fri) { - this.fri = fri; - } - - public DayData getSat() { - return sat; - } - - public void setSat(DayData sat) { - this.sat = sat; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetailBean.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetailBean.java deleted file mode 100644 index fb315309bbf459d8207e9147a0830fcac107fd42..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryDetailBean.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.oschina.app.team.bean; - -import net.oschina.app.bean.Entity; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -@XStreamAlias("oschina") -public class TeamDiaryDetailBean extends Entity { - - @XStreamAlias("diary") - private TeamDiary teamDiary; - - public TeamDiary getTeamDiary() { - return teamDiary; - } - - public void setTeamDiary(TeamDiary teamDiary) { - this.teamDiary = teamDiary; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryList.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiaryList.java deleted file mode 100644 index ac64584becdfc5826f080bce39e5e6522f545b5f..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiaryList.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.oschina.app.team.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.ListEntity; - -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TeamDiaryList extends Entity implements ListEntity { - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("totalCount") - private int totalCount; - - @XStreamAlias("diaries") - private List list = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getTotalCount() { - return totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiscuss.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiscuss.java deleted file mode 100644 index 05150baa58af7e9523699d1310e057e2432ec1b5..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiscuss.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.oschina.app.team.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; - -@SuppressWarnings("serial") -@XStreamAlias("discuss") -public class TeamDiscuss extends Entity { - - @XStreamAlias("type") - private String type; - - @XStreamAlias("title") - private String title; - - @XStreamAlias("body") - private String body; - - @XStreamAlias("createTime") - private String createTime; - - @XStreamAlias("answerCount") - private int answerCount;// 回复数量 - - @XStreamAlias("voteUp") - private int voteUp;// 点赞数 - - @XStreamAlias("author") - private Author author; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public int getAnswerCount() { - return answerCount; - } - - public void setAnswerCount(int answerCount) { - this.answerCount = answerCount; - } - - public int getVoteUp() { - return voteUp; - } - - public void setVoteUp(int voteUp) { - this.voteUp = voteUp; - } - - public Author getAuthor() { - return author; - } - - public void setAuthor(Author author) { - this.author = author; - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiscussDetail.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiscussDetail.java deleted file mode 100644 index 6769b072542a085885ced4c3f6012ed3e4fb1d69..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiscussDetail.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.oschina.app.team.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; - -/** - * TeamDisscussDetail.java - * - * @author 火蚁(http://my.oschina.net/u/253900) - * - * @data 2015-2-2 下午5:33:07 - */ -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TeamDiscussDetail extends Entity { - - @XStreamAlias("discuss") - private TeamDiscuss discuss; - - public TeamDiscuss getDiscuss() { - return discuss; - } - - public void setDiscuss(TeamDiscuss discuss) { - this.discuss = discuss; - } -} - diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamDiscussList.java b/app/src/main/java/net/oschina/app/team/bean/TeamDiscussList.java deleted file mode 100644 index 6af54ded0b53c4f31764de09a7548ce7dec683fa..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamDiscussList.java +++ /dev/null @@ -1,48 +0,0 @@ -package net.oschina.app.team.bean; - -import java.util.ArrayList; -import java.util.List; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; -import net.oschina.app.bean.ListEntity; - -@SuppressWarnings("serial") -@XStreamAlias("oschina") -public class TeamDiscussList extends Entity implements ListEntity { - - @XStreamAlias("pagesize") - private int pageSize; - - @XStreamAlias("totalCount") - private int totalCount; - - @XStreamAlias("discusses") - private List list = new ArrayList(); - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getTotalCount() { - return totalCount; - } - - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } - -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamGit.java b/app/src/main/java/net/oschina/app/team/bean/TeamGit.java deleted file mode 100644 index 9a16ca469a603c7954b001caa1686d38a5ca0aa4..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamGit.java +++ /dev/null @@ -1,68 +0,0 @@ -package net.oschina.app.team.bean; - -import com.thoughtworks.xstream.annotations.XStreamAlias; - -import net.oschina.app.bean.Entity; - -/** - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月20日 上午10:49:39 - * - */ - -@SuppressWarnings("serial") -@XStreamAlias("git") -public class TeamGit extends Entity { - - @XStreamAlias("name") - private String name; - - @XStreamAlias("path") - private String path; - - @XStreamAlias("ownerName") - private String ownerName; - - @XStreamAlias("ownerUserName") - private String ownerUserName; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getOwnerName() { - return ownerName; - } - - public void setOwnerName(String ownerName) { - this.ownerName = ownerName; - } - - public String getOwnerUserName() { - return ownerUserName; - } - - public void setOwnerUserName(String ownerUserName) { - this.ownerUserName = ownerUserName; - } -} diff --git a/app/src/main/java/net/oschina/app/team/bean/TeamIssue.java b/app/src/main/java/net/oschina/app/team/bean/TeamIssue.java deleted file mode 100644 index 6ac084bf431f44fcbf4c9937d9e5c89f07204d22..0000000000000000000000000000000000000000 --- a/app/src/main/java/net/oschina/app/team/bean/TeamIssue.java +++ /dev/null @@ -1,584 +0,0 @@ -package net.oschina.app.team.bean; - -import java.io.Serializable; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.List; - -import net.oschina.app.R; -import net.oschina.app.bean.Entity; -import net.oschina.app.util.StringUtils; - -import com.thoughtworks.xstream.annotations.XStreamAlias; -import com.thoughtworks.xstream.annotations.XStreamImplicit; - -/** - * 任务实体类 - * - * @author FireAnt(http://my.oschina.net/LittleDY) - * @version 创建时间:2015年1月14日 下午4:26:28 - * - */ - -@SuppressWarnings("serial") -@XStreamAlias("issue") -public class TeamIssue extends Entity { - - public final static String TEAM_ISSUE_STATE_OPENED = "opened"; - public final static String TEAM_ISSUE_STATE_UNDERWAY = "underway"; - public final static String TEAM_ISSUE_STATE_ACCEPTED = "accepted"; - public final static String TEAM_ISSUE_STATE_CLOSED = "closed"; - - public final static String TEAM_ISSUE_SOURCE_GITOSC = "Git@OSC"; - public final static String TEAM_ISSUE_SOURCE_GITHUB = "GitHub"; - public final static String TEAM_ISSUE_SOURCE_TEAMOSC = "Team@OSC"; - - public final static int TEAM_ISSUE_GITPUSHED = 1;// 已同步到git - - @XStreamAlias("state") - private String state; - - @XStreamAlias("stateLevel") - private int stateLevel; - - @XStreamAlias("priority") - private String priority; - - @XStreamAlias("source") - private String source; - - @XStreamAlias("title") - private String title; - - @XStreamAlias("description") - private String description; - - @XStreamAlias("createTime") - private String createTime; - - @XStreamAlias("updateTime") - private String updateTime; - - @XStreamAlias("acceptTime") - private String acceptTime; - - @XStreamAlias("deadlineTime") - private String deadlineTime; - - @XStreamAlias("author") - private Author author; - - @XStreamAlias("toUser") - private ToUser toUser; - - @XStreamAlias("replyCount") - private int replyCount; - - @XStreamAlias("labels") - private List