├── cls ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── vcs.xml ├── runConfigurations.xml ├── modules.xml ├── compiler.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── raw │ │ │ │ └── certificate │ │ │ ├── mipmap-hdpi │ │ │ │ ├── icon.png │ │ │ │ ├── guide_first.png │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── time_text_bg.png │ │ │ │ ├── menu_joke_press.png │ │ │ │ ├── menu_mine_press.png │ │ │ │ ├── menu_news_press.png │ │ │ │ ├── menu_joke_normal.png │ │ │ │ ├── menu_mine_normal.png │ │ │ │ ├── menu_news_normal.png │ │ │ │ ├── menu_video_normal.png │ │ │ │ ├── menu_video_press.png │ │ │ │ └── ic_default_user_image_normal.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-hdpi │ │ │ │ └── activity_flash.9.png │ │ │ ├── layout │ │ │ │ ├── activity_guide.xml │ │ │ │ ├── fragment_news.xml │ │ │ │ ├── fragment_jokes.xml │ │ │ │ ├── fragment_video.xml │ │ │ │ ├── activity_flash.xml │ │ │ │ ├── item_recycle_view.xml │ │ │ │ ├── fragment_mine.xml │ │ │ │ ├── activity_login.xml │ │ │ │ └── activity_main.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── drawable │ │ │ │ ├── menu_joke_selector.xml │ │ │ │ ├── menu_mine_selector.xml │ │ │ │ ├── menu_new_selector.xml │ │ │ │ └── menu_video_selector.xml │ │ │ └── values │ │ │ │ ├── attrs.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── zbao │ │ │ │ └── news │ │ │ │ ├── main │ │ │ │ ├── joke │ │ │ │ │ ├── model │ │ │ │ │ │ ├── JokesFragmentModel.java │ │ │ │ │ │ └── JokesFragmentModelImpl.java │ │ │ │ │ ├── view │ │ │ │ │ │ └── JokesFragmentView.java │ │ │ │ │ ├── presenter │ │ │ │ │ │ ├── JokesFragmentPresenter.java │ │ │ │ │ │ └── JokesFragmentPresenterImpl.java │ │ │ │ │ └── widget │ │ │ │ │ │ └── JokesFragment.java │ │ │ │ ├── mine │ │ │ │ │ ├── view │ │ │ │ │ │ └── MineFragmentView.java │ │ │ │ │ ├── model │ │ │ │ │ │ ├── MineFragmentModel.java │ │ │ │ │ │ └── MineFragmentModelImpl.java │ │ │ │ │ ├── presenter │ │ │ │ │ │ ├── MineFragmentPresenter.java │ │ │ │ │ │ └── MineFragmentPresenterImpl.java │ │ │ │ │ └── widget │ │ │ │ │ │ └── MineFragment.java │ │ │ │ ├── video │ │ │ │ │ ├── view │ │ │ │ │ │ └── VideoFragmentView.java │ │ │ │ │ ├── model │ │ │ │ │ │ ├── VideoFragmentModel.java │ │ │ │ │ │ └── VideoFragmentModelImpl.java │ │ │ │ │ ├── presenter │ │ │ │ │ │ ├── VideoFragmentPresenter.java │ │ │ │ │ │ └── VideoFragmentPresenterImpl.java │ │ │ │ │ └── widget │ │ │ │ │ │ └── VideoFragment.java │ │ │ │ └── news │ │ │ │ │ ├── presenter │ │ │ │ │ ├── NewsFragmentPresenter.java │ │ │ │ │ └── NewsFragmentPresenterImpl.java │ │ │ │ │ ├── model │ │ │ │ │ ├── NewsFragmentModel.java │ │ │ │ │ └── NewsFragmentModelImpl.java │ │ │ │ │ ├── view │ │ │ │ │ └── NewFragmentView.java │ │ │ │ │ ├── adapter │ │ │ │ │ └── JokeRectclerAdapter.java │ │ │ │ │ └── widget │ │ │ │ │ └── NewsFragment.java │ │ │ │ ├── db │ │ │ │ └── NativeDBService.java │ │ │ │ ├── greendao │ │ │ │ ├── service │ │ │ │ │ ├── PatientService.java │ │ │ │ │ └── BaseService.java │ │ │ │ ├── utils │ │ │ │ │ ├── DBUtils.java │ │ │ │ │ └── DBCore.java │ │ │ │ ├── dao │ │ │ │ │ ├── DaoSession.java │ │ │ │ │ ├── DaoMaster.java │ │ │ │ │ └── PatientDao.java │ │ │ │ └── entity │ │ │ │ │ └── Patient.java │ │ │ │ ├── config │ │ │ │ ├── AppConstants.java │ │ │ │ └── OttoService.java │ │ │ │ ├── entity │ │ │ │ ├── MessageEvent.java │ │ │ │ ├── User.java │ │ │ │ └── JokeInf.java │ │ │ │ ├── TestDemo.java │ │ │ │ ├── app │ │ │ │ └── NewsApplication.java │ │ │ │ ├── base │ │ │ │ ├── BaseFragmentActivity.java │ │ │ │ ├── BaseActivity.java │ │ │ │ └── BaseFragment.java │ │ │ │ ├── utils │ │ │ │ ├── SharedPreferenceUtils.java │ │ │ │ ├── CommonUtil.java │ │ │ │ └── ChannelUtil.java │ │ │ │ ├── network │ │ │ │ ├── InternetService.java │ │ │ │ ├── RetrofitWapper.java │ │ │ │ └── RetrofitHttpsWapper.java │ │ │ │ ├── GuideaActivity.java │ │ │ │ ├── LoginActivity.java │ │ │ │ ├── custonView │ │ │ │ └── LoadProgressView.java │ │ │ │ ├── FlashActivity.java │ │ │ │ └── MainActivity.java │ │ ├── jni │ │ │ ├── news.c │ │ │ └── com_zbao_news_FlashActivity.h │ │ └── AndroidManifest.xml │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── zbao │ │ │ └── news │ │ │ └── ApplicationTest.java │ └── test │ │ └── java │ │ └── com │ │ └── zbao │ │ └── news │ │ └── ExampleUnitTest.java ├── proguard-rules.pro ├── 控件使用 │ └── 底部导航栏使用 └── build.gradle ├── java-base ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── zbao │ ├── ProxyDemo.java │ └── MainDemo.java ├── greendao-lib ├── .gitignore ├── build.gradle └── src │ └── main │ └── java │ └── com │ └── zbao │ └── news │ └── NewGenerator.java ├── settings.gradle ├── apk.keystore.jks ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── jni └── com_zbao_news_FlashActivity.h ├── gradle.properties ├── gradlew.bat └── gradlew /cls: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | News -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/src/main/res/raw/certificate: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /java-base/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /greendao-lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':greendao-lib', ':java-base' 2 | -------------------------------------------------------------------------------- /apk.keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/apk.keystore.jks -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/guide_first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/guide_first.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/time_text_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/time_text_bg.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_joke_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_joke_press.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_mine_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_mine_press.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_news_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_news_press.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_joke_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_joke_normal.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_mine_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_mine_normal.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_news_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_news_normal.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_video_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_video_normal.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/menu_video_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/menu_video_press.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/activity_flash.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/drawable-hdpi/activity_flash.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_default_user_image_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangyubao/frameStudy/HEAD/app/src/main/res/mipmap-hdpi/ic_default_user_image_normal.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/model/JokesFragmentModel.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.model; 2 | 3 | /** 4 | * 娱乐界面数据获取接口 5 | */ 6 | public interface JokesFragmentModel { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/view/JokesFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.view; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface JokesFragmentView { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/mine/view/MineFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.mine.view; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface MineFragmentView { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/mine/model/MineFragmentModel.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.mine.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface MineFragmentModel { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/view/VideoFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.view; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface VideoFragmentView { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/mine/model/MineFragmentModelImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.mine.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class MineFragmentModelImpl { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/model/VideoFragmentModel.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface VideoFragmentModel { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/model/VideoFragmentModelImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class VideoFragmentModelImpl { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/db/NativeDBService.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.db; 2 | 3 | /** 4 | * 缓存数据访问服务------与数据库交互 5 | *

6 | * Created by zhangYB on 2016/5/10. 7 | */ 8 | public class NativeDBService { 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/presenter/JokesFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface JokesFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/mine/presenter/MineFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.mine.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface MineFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /greendao-lib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: ['*.jar']) 5 | compile 'de.greenrobot:greendao:2.0.0' 6 | compile 'de.greenrobot:greendao-generator:2.0.0' 7 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/presenter/VideoFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface VideoFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /java-base/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: ['*.jar']) 5 | compile 'com.squareup.retrofit2:retrofit:2.0.2' 6 | /*log信息打印*/ 7 | compile 'com.orhanobut:logger:1.3' 8 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/mine/presenter/MineFragmentPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.mine.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class MineFragmentPresenterImpl implements MineFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/model/JokesFragmentModelImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class JokesFragmentModelImpl implements JokesFragmentModel { 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/presenter/JokesFragmentPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class JokesFragmentPresenterImpl implements JokesFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/presenter/VideoFragmentPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public class VideoFragmentPresenterImpl implements VideoFragmentPresenter { 7 | } 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/jni/news.c: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Administrator on 2016/5/10. 3 | // 4 | #include 5 | 6 | /* 7 | JNIEXPORT jstring JNICALL Java_com_zbao_news_FlashActivity_getUrl(JNIEnv *env, jobject obj) { 8 | char* tmpstr = "return string succeeded"; 9 | return env->NewStringUTF(tmpstr); 10 | }*/ 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/news/presenter/NewsFragmentPresenter.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.news.presenter; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface NewsFragmentPresenter { 7 | 8 | /** 9 | * 联网获取数据 10 | */ 11 | void getNewsOnInternet(); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_guide.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/greendao/service/PatientService.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.greendao.service; 2 | 3 | 4 | import com.zbao.news.greendao.dao.PatientDao; 5 | 6 | /** 7 | * Created by zhangYB on 2016/5/5. 8 | */ 9 | public class PatientService extends BaseService { 10 | 11 | public PatientService(PatientDao dao) { 12 | super(dao); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/news/model/NewsFragmentModel.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.news.model; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/3. 5 | */ 6 | public interface NewsFragmentModel { 7 | /** 8 | * 获取新闻列表 9 | * 10 | * @param listener 11 | */ 12 | public void getNewsList(NewsFragmentModelImpl.OnNewsLoadFinishedListener listener); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/config/AppConstants.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.config; 2 | 3 | /** 4 | * Created by Administrator on 2016/4/18. 5 | */ 6 | public class AppConstants { 7 | //服务器地址 8 | public static final String SERVER_URL = "http://japi.juhe.cn"; 9 | // 自己定义服务器的测试地址即本机的测试地址 10 | public static final String TEST_SERVER_URL = "http://192.168.10.13:8080/518Android/"; 11 | } 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/menu_joke_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/menu_mine_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/menu_new_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/menu_video_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/config/OttoService.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.config; 2 | 3 | import com.squareup.otto.Bus; 4 | 5 | /** 6 | * OTTO 事件总线单例模式 7 | * Created by zhangYB on 2016/4/26. 8 | */ 9 | public class OttoService { 10 | 11 | 12 | private OttoService() { 13 | } 14 | 15 | private static final Bus BUS = new Bus(); 16 | 17 | public static Bus getInstance() { 18 | return BUS; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/zbao/news/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * 只能在设备上执行的测试代码 (只能将项目发布到手机或者模拟器上才能运行的代码) 8 | * Testing Fundamentals 9 | */ 10 | public class ApplicationTest extends ApplicationTestCase { 11 | public ApplicationTest() { 12 | super(Application.class); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 5dp 6 | 8dp 7 | 16sp 8 | 22sp 9 | 14sp 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/entity/MessageEvent.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.entity; 2 | 3 | /** 4 | * EventBus测试实体 5 | * Created by zhangYB on 2016/5/11. 6 | */ 7 | public class MessageEvent { 8 | private String message; 9 | 10 | public MessageEvent(String message) { 11 | this.message = message; 12 | } 13 | 14 | public String getMessage() { 15 | return message; 16 | } 17 | 18 | public void setMessage(String message) { 19 | this.message = message; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | #F4F5F6 7 | #000000 8 | #D43D3D 9 | #D43D3D 10 | #FFFFFF 11 | #f5d903 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/TestDemo.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/9. 5 | */ 6 | public class TestDemo { 7 | 8 | public int add(int one, int anthor) { 9 | return one + anthor; 10 | } 11 | 12 | public int mutiply(int one, int anthor) { 13 | return one + anthor; 14 | } 15 | 16 | 17 | public int divider(int a, int b) { 18 | // if (b == 0) 19 | // throw new IllegalArgumentException("B can be not zero(b不能为零)"); 20 | return a / b; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/news/view/NewFragmentView.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.news.view; 2 | 3 | import com.zbao.news.entity.JokeInf; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * Created by zhangYB on 2016/5/3. 9 | */ 10 | public interface NewFragmentView { 11 | /** 12 | * 适配RecyclarView数据 13 | */ 14 | void setDataForList(List news); 15 | 16 | /** 17 | * 显示加载进度条 18 | */ 19 | void showProgress(); 20 | 21 | /** 22 | * 隐藏加载进度条 23 | */ 24 | void hideProgress(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /jni/com_zbao_news_FlashActivity.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_zbao_news_FlashActivity */ 4 | 5 | #ifndef _Included_com_zbao_news_FlashActivity 6 | #define _Included_com_zbao_news_FlashActivity 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_zbao_news_FlashActivity 12 | * Method: getUrl 13 | * Signature: ()Ljava/lang/String; 14 | */ 15 | JNIEXPORT jstring JNICALL Java_com_zbao_news_FlashActivity_getUrl 16 | (JNIEnv *, jobject); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /app/src/main/jni/com_zbao_news_FlashActivity.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class com_zbao_news_FlashActivity */ 4 | 5 | #ifndef _Included_com_zbao_news_FlashActivity 6 | #define _Included_com_zbao_news_FlashActivity 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: com_zbao_news_FlashActivity 12 | * Method: getUrl 13 | * Signature: ()Ljava/lang/String; 14 | */ 15 | JNIEXPORT jstring JNICALL Java_com_zbao_news_FlashActivity_getUrl 16 | (JNIEnv *, jobject); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_news.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_jokes.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_video.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/entity/User.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.entity; 2 | 3 | public class User { 4 | 5 | private String userName; 6 | private String passWord; 7 | private String nickName; 8 | 9 | public String getUserName() { 10 | return userName; 11 | } 12 | 13 | public void setUserName(String userName) { 14 | this.userName = userName; 15 | } 16 | 17 | public String getPassWord() { 18 | return passWord; 19 | } 20 | 21 | public void setPassWord(String passWord) { 22 | this.passWord = passWord; 23 | } 24 | 25 | public String getNickName() { 26 | return nickName; 27 | } 28 | 29 | public void setNickName(String nickName) { 30 | this.nickName = nickName; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 网罗天下 3 | 新闻 4 | 娱乐 5 | 视频 6 | 我的 7 | 数据获取失败 8 | 在Android 6.0中谷歌摒弃了之前的instmodel,这个大家不陌生,就是当Android App安装的时候会向用户展示一坨权限,如果此时用户选择安装,则表示用户同意将这些权限赋予App,如果用户不同意那么这个App就会取消安装。runtime permissions model就牛逼了,在App安装的时候同样会向用户展示所需要的权限,并且在用户选择安装App的时候并不表示用户将这些权限赋予了App,而是需要App在运行阶段主动去申请这些权限。这样做的好处显而易见,App对权限的申请对于用户来说变得更加透明,而且用户对App权限的控制也更加灵活。 9 | 10 | Hello blank fragment 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\Users\Administrator\AppData\Local\Android\Sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/greendao/utils/DBUtils.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.greendao.utils; 2 | 3 | 4 | import com.zbao.news.greendao.dao.PatientDao; 5 | import com.zbao.news.greendao.service.PatientService; 6 | 7 | /** 8 | * 工具类获得service 9 | * Created by zhangYB on 2016/5/5. 10 | */ 11 | public class DBUtils { 12 | 13 | private static PatientService patientService; 14 | 15 | 16 | private static PatientDao getPatientDao() { 17 | PatientDao dao = DBCore.getDaoSession().getPatientDao(); 18 | return dao; 19 | } 20 | 21 | public static PatientService getPatietService() { 22 | if (patientService == null) { 23 | patientService = new PatientService(getPatientDao()); 24 | } 25 | return patientService; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/app/NewsApplication.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.app; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.zbao.news.greendao.utils.DBCore; 7 | 8 | /** 9 | * Created by zhangYB on 2016/4/29. 10 | */ 11 | public class NewsApplication extends Application { 12 | 13 | 14 | private static Context mContext; 15 | //数据库名称 16 | private static final String DB_NAME = "mobile.db";//可以是文件(mobile.db)也可以是路径加文件名(data/data/com.zbao.news/mobile.db) 17 | 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | DBCore.initialize(this, DB_NAME); 22 | mContext = getApplicationContext(); 23 | } 24 | 25 | public static Context getContext() { 26 | return mContext; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | ## Project-wide Gradle settings. 2 | # 3 | # For more details on how to configure your build environment visit 4 | # http://www.gradle.org/docs/current/userguide/build_environment.html 5 | # 6 | # Specifies the JVM arguments used for the daemon process. 7 | # The setting is particularly useful for tweaking memory settings. 8 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 9 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 10 | # 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true 15 | #Tue May 10 15:24:41 CST 2016 16 | android.useDeprecatedNdk = true 17 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_flash.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/base/BaseFragmentActivity.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.base; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.FragmentActivity; 7 | import android.view.Window; 8 | 9 | import com.orhanobut.logger.LogLevel; 10 | import com.orhanobut.logger.Logger; 11 | 12 | import butterknife.ButterKnife; 13 | 14 | /** 15 | * Created by zhangYB on 2016/4/29. 16 | */ 17 | public abstract class BaseFragmentActivity extends FragmentActivity { 18 | 19 | protected Context mContext; 20 | 21 | @Override 22 | protected void onCreate(@Nullable Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | requestWindowFeature(Window.FEATURE_NO_TITLE); 25 | setContentView(getLayout()); 26 | ButterKnife.bind(this); 27 | mContext = this; 28 | Logger.init().hideThreadInfo().setLogLevel(LogLevel.FULL); 29 | } 30 | 31 | 32 | @Override 33 | public void onDetachedFromWindow() { 34 | super.onDetachedFromWindow(); 35 | ButterKnife.unbind(this); 36 | } 37 | 38 | public abstract int getLayout(); 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/utils/SharedPreferenceUtils.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.utils; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | /** 7 | * Created by zhangYB on 2016/5/4. 8 | */ 9 | public class SharedPreferenceUtils { 10 | 11 | //工具类不允许创建对象 12 | private SharedPreferenceUtils() { 13 | throw new AssertionError("No instances."); 14 | } 15 | 16 | /** 17 | * 保存安装状态 18 | * 19 | * @param context 20 | * @param state 21 | */ 22 | public static void saveInstallState(Context context, boolean state) { 23 | SharedPreferences isInstall = context.getSharedPreferences("install", Context.MODE_PRIVATE); 24 | SharedPreferences.Editor editor = isInstall.edit(); 25 | editor.putBoolean("state", state); 26 | editor.commit(); 27 | } 28 | 29 | /** 30 | * 获取安装状态(是否是第一次安装) 31 | * 32 | * @param context 33 | * @return 34 | */ 35 | public static boolean getInstallState(Context context) { 36 | SharedPreferences isInstall = context.getSharedPreferences("install", Context.MODE_PRIVATE); 37 | return isInstall.getBoolean("state", false); 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 28 | 29 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.base; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.view.Window; 8 | 9 | import com.orhanobut.logger.LogLevel; 10 | import com.orhanobut.logger.Logger; 11 | 12 | import butterknife.ButterKnife; 13 | 14 | /** 15 | * 1、集成ButterKnife View 注入框架 16 | *

17 | * 2、集成EventBus 事件总线框架 18 | *

19 | * Created by zhangYB on 2016/4/29. 20 | */ 21 | public abstract class BaseActivity extends AppCompatActivity { 22 | 23 | protected Context mContext; 24 | 25 | @Override 26 | protected void onCreate(@Nullable Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | supportRequestWindowFeature(Window.FEATURE_NO_TITLE); 29 | setContentView(getLayout()); 30 | ButterKnife.bind(this); 31 | mContext = this; 32 | Logger.init().hideThreadInfo().setLogLevel(LogLevel.FULL); 33 | } 34 | 35 | @Override 36 | protected void onDestroy() { 37 | super.onDestroy(); 38 | ButterKnife.unbind(this); 39 | } 40 | 41 | public abstract int getLayout(); 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/joke/widget/JokesFragment.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.joke.widget; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.orhanobut.logger.Logger; 10 | import com.zbao.news.R; 11 | import com.zbao.news.base.BaseFragment; 12 | 13 | /** 14 | * 娱乐模块. 15 | */ 16 | public class JokesFragment extends BaseFragment { 17 | 18 | private static final String TAG = "JokesFragment"; 19 | 20 | public JokesFragment() { 21 | // Required empty public constructor 22 | } 23 | 24 | 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 27 | Bundle savedInstanceState) { 28 | super.onCreateView(inflater,container,savedInstanceState); 29 | return mView; 30 | } 31 | 32 | @Override 33 | public void loadLayout() { 34 | if (isPrepared && isVisiable) { 35 | //初始化界面控件等 36 | Logger.d("joke fragment add"); 37 | } 38 | } 39 | 40 | @Override 41 | public int getLayoutId() { 42 | return R.layout.fragment_jokes; 43 | } 44 | 45 | @Override 46 | public void createPresenter() { 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/video/widget/VideoFragment.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.video.widget; 2 | 3 | 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.orhanobut.logger.Logger; 10 | import com.zbao.news.R; 11 | import com.zbao.news.base.BaseFragment; 12 | 13 | /** 14 | * 视频. 15 | */ 16 | public class VideoFragment extends BaseFragment { 17 | 18 | private static final String TAG = "VideoFragment"; 19 | 20 | public VideoFragment() { 21 | // Required empty public constructor 22 | } 23 | 24 | 25 | @Override 26 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 27 | Bundle savedInstanceState) { 28 | super.onCreateView(inflater, container, savedInstanceState); 29 | return mView; 30 | } 31 | 32 | @Override 33 | public void loadLayout() { 34 | if (isPrepared && isVisiable) { 35 | //初始化界面控件等 36 | Logger.d("video fragment add"); 37 | } 38 | } 39 | 40 | @Override 41 | public int getLayoutId() { 42 | return R.layout.fragment_video; 43 | } 44 | 45 | @Override 46 | public void createPresenter() { 47 | 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /app/控件使用/底部导航栏使用: -------------------------------------------------------------------------------- 1 | 在XML布局中添加一个底部导航栏控件 2 | 3 | 9 | 然后在Activity中初始化 10 | 11 | PagerBottomTabLayout bottomTabLayout = (PagerBottomTabLayout) findViewById(R.id.tab); 12 | 13 | bottomTabLayout.builder() 14 | .addTabItem(android.R.drawable.ic_menu_camera, "相机") 15 | .addTabItem(android.R.drawable.ic_menu_compass, "位置") 16 | .addTabItem(android.R.drawable.ic_menu_search, "搜索") 17 | .addTabItem(android.R.drawable.ic_menu_help, "帮助") 18 | .build(); 19 | 通过上面的2个步骤,最基本的底部导航栏就出来了,按钮默认选中颜色是取的colorAccent 20 | 21 | .builder()后面还可以设置很多有关导航栏的属性,具体看这里:导航栏构建属性 22 | 23 | 构建完成之后就需要对导航栏进行一些控制,比如手动控制选中项、添加事件监听等等,上面构建完成调用的build()返回一个Controller接口的实现类,通过Controller就可以对导航栏进行后续控 24 | 完成导航栏构建获得Controller实例后就可以进行对导航栏的后续控制 25 | 26 | addTabItemClickListener 27 | 最常用的方法,添加导航栏选中监听,回掉的监听分解成了2个,一个是选中,另一个在已经选中的状态下重复选中。 28 | 29 | setMessageNumber 30 | 设置某个导航按钮的消息数字,需要传入2个参数,一个索引(顺数数字、Tag)和消息数字。 31 | 32 | setDisplayOval 33 | 设置是否显示一个无数字的消息小红点,true显示 34 | 35 | setSelect 36 | 手动设置选中项 37 | 38 | getSelected 39 | 获得当前的选中项的索引数字 40 | 41 | getSelectedTag 42 | 获取当前选中项的TAG 43 | 44 | setBackgroundColor、setBackground、setBackgroundResource 45 | 都是设置导航栏背景的 -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/network/InternetService.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.network; 2 | 3 | import com.zbao.news.entity.JokeInf; 4 | import com.zbao.news.entity.User; 5 | 6 | import retrofit2.Call; 7 | import retrofit2.http.GET; 8 | import retrofit2.http.Query; 9 | import rx.Observable; 10 | 11 | 12 | /** 13 | * 网络接口类,定义所有的数据获取接口 14 | * Created by Administrator on 2016/4/18. 15 | */ 16 | public interface InternetService { 17 | /** 18 | * 获取笑话列表 19 | * 20 | * @param sort 排序 desc倒序 21 | * @param page 页码 22 | * @param pagesize 每页的条数 23 | * @param time 请求时间 24 | * @param key 应用的key 25 | * @return 26 | */ 27 | @GET("/joke/content/list.from") 28 | Call getNewsList(@Query("sort") String sort, @Query("page") int page, @Query("pagesize") int pagesize, @Query("time") String time, @Query("key") String key); 29 | 30 | /** 31 | * Rxjava方式获取网络数据 32 | * 33 | * @param sort 34 | * @param page 35 | * @param pagesize 36 | * @param time 37 | * @param key 38 | * @return 39 | */ 40 | @GET("/joke/content/list.from") 41 | Observable getJokeListByRxjava(@Query("sort") String sort, @Query("page") int page, @Query("pagesize") int pagesize, @Query("time") String time, @Query("key") String key); 42 | 43 | 44 | @GET("UserController/user.html") 45 | Call getList(); 46 | 47 | } 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_recycle_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 15 | 16 | 22 | 23 | 30 | 31 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /java-base/src/main/java/com/zbao/ProxyDemo.java: -------------------------------------------------------------------------------- 1 | package com.zbao; 2 | 3 | import retrofit2.http.GET; 4 | 5 | 6 | /** 7 | * java 动态代理代码示例 8 | */ 9 | public interface ProxyDemo { 10 | 11 | /** 12 | * 加法操作 13 | * 14 | * @param a 15 | * @param b 16 | */ 17 | @GET("default") 18 | public int add(int a, int b); 19 | 20 | /* CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); 21 | Certificate certificate = certificateFactory.generateCertificate(inputStream); 22 | KeyStore keyStore = KeyStore.getInstance("PKCS12", "BC"); 23 | keyStore.load(null,null); 24 | keyStore.setCertificateEntry("trust",certificate); 25 | 26 | TrustManagerFactory trustManagerFactory = TrustManagerFactory 27 | .getInstance(TrustManagerFactory.getDefaultAlgorithm()); 28 | trustManagerFactory.init(keyStore); 29 | SSLContext sslContext = SSLContext.getInstance("TLS"); 30 | sslContext.init(null,trustManagerFactory.getTrustManagers(),null); 31 | mOkHttpClient=new 32 | 33 | OkHttpClient(); 34 | 35 | mOkHttpClient.setSslSocketFactory(sslContext.getSocketFactory()); 36 | mOkHttpClient.setHostnameVerifier(new 37 | 38 | HostnameVerifier() { 39 | @Override 40 | public boolean verify (String hostname, SSLSession session){ 41 | if (HOST_NAME.equals(hostname)) 42 | return true; 43 | return false; 44 | } 45 | } 46 | 47 | );*/ 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/greendao/dao/DaoSession.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.greendao.dao; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import java.util.Map; 6 | 7 | import de.greenrobot.dao.AbstractDao; 8 | import de.greenrobot.dao.AbstractDaoSession; 9 | import de.greenrobot.dao.identityscope.IdentityScopeType; 10 | import de.greenrobot.dao.internal.DaoConfig; 11 | 12 | import com.zbao.news.greendao.entity.Patient; 13 | 14 | import com.zbao.news.greendao.dao.PatientDao; 15 | 16 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. 17 | 18 | /** 19 | * {@inheritDoc} 20 | * 21 | * @see de.greenrobot.dao.AbstractDaoSession 22 | */ 23 | public class DaoSession extends AbstractDaoSession { 24 | 25 | private final DaoConfig patientDaoConfig; 26 | 27 | private final PatientDao patientDao; 28 | 29 | public DaoSession(SQLiteDatabase db, IdentityScopeType type, Map>, DaoConfig> 30 | daoConfigMap) { 31 | super(db); 32 | 33 | patientDaoConfig = daoConfigMap.get(PatientDao.class).clone(); 34 | patientDaoConfig.initIdentityScope(type); 35 | 36 | patientDao = new PatientDao(patientDaoConfig, this); 37 | 38 | registerDao(Patient.class, patientDao); 39 | } 40 | 41 | public void clear() { 42 | patientDaoConfig.getIdentityScope().clear(); 43 | } 44 | 45 | public PatientDao getPatientDao() { 46 | return patientDao; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/news/model/NewsFragmentModelImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.news.model; 2 | 3 | import com.zbao.news.entity.JokeInf; 4 | import com.zbao.news.network.InternetService; 5 | import com.zbao.news.network.RetrofitWapper; 6 | 7 | import retrofit2.Call; 8 | import retrofit2.Callback; 9 | import retrofit2.Response; 10 | 11 | /** 12 | * Created by zhangYB on 2016/5/3. 13 | */ 14 | public class NewsFragmentModelImpl implements NewsFragmentModel { 15 | 16 | @Override 17 | public void getNewsList(final OnNewsLoadFinishedListener listener) { 18 | final Call list = RetrofitWapper.getInstance().create(InternetService.class).getNewsList("desc", 1, 20, "1418816972", "eb46c85bea73462583e38b84c3a25c4b"); 19 | list.enqueue(new Callback() { 20 | @Override 21 | public void onResponse(Call call, Response response) { 22 | listener.onSucess(response.body()); 23 | } 24 | 25 | @Override 26 | public void onFailure(Call call, Throwable t) { 27 | listener.onFailure("get news list failure", t); 28 | 29 | } 30 | }); 31 | } 32 | 33 | /** 34 | * 新闻数据加载完成回调接口 35 | */ 36 | public interface OnNewsLoadFinishedListener { 37 | //数据记载成功 38 | void onSucess(JokeInf jokeInf); 39 | 40 | //数据加载失败 41 | void onFailure(String tag, Throwable throwable); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /java-base/src/main/java/com/zbao/MainDemo.java: -------------------------------------------------------------------------------- 1 | package com.zbao; 2 | 3 | /** 4 | * Created by zhangYB on 2016/5/12. 5 | */ 6 | public class MainDemo { 7 | 8 | /*** 9 | * 动态代理演示代码 10 | * 11 | * @param args 12 | */ 13 | // public static void main(String[] args) { 14 | // Double number = 100.01; 15 | // BigDecimal bd = new BigDecimal(number); 16 | // BigDecimal setScale = bd.setScale(2, bd.ROUND_CEILING); 17 | // System.out.println(setScale+"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); 18 | 19 | /* ProxyDemo proxyDemo = (ProxyDemo) Proxy.newProxyInstance(ProxyDemo.class.getClassLoader(), new Class[]{ProxyDemo.class}, new InvocationHandler() { 20 | @Override 21 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 22 | 23 | String methodName = method.getName(); 24 | Integer a = (Integer) args[0]; 25 | Integer b = (Integer) args[1]; 26 | Annotation[] annotations = method.getAnnotations(); 27 | for (int i = 0; i < annotations.length; i++) { 28 | System.out.println("annotations is " + annotations[i]); 29 | } 30 | System.out.println("first paramster is " + a); 31 | System.out.println("second paramster is " + b); 32 | System.out.println("method is " + methodName); 33 | return null; 34 | } 35 | });*/ 36 | // } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/network/RetrofitWapper.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.network; 2 | 3 | import com.zbao.news.config.AppConstants; 4 | 5 | import okhttp3.OkHttpClient; 6 | import retrofit2.GsonConverterFactory; 7 | import retrofit2.Retrofit; 8 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory; 9 | 10 | 11 | /** 12 | * 获取服务器数据包装类 13 | * Created by Administrator on 2016/4/18. 14 | */ 15 | public class RetrofitWapper { 16 | 17 | private Retrofit mRetrofit; 18 | private static RetrofitWapper mRetrofitWapper; 19 | 20 | private RetrofitWapper() { 21 | mRetrofit = new Retrofit.Builder() 22 | .client(new OkHttpClient()) 23 | .baseUrl(AppConstants.SERVER_URL) 24 | .addConverterFactory(GsonConverterFactory.create()) 25 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) 26 | .build(); 27 | } 28 | 29 | public static RetrofitWapper getInstance() { 30 | if (mRetrofitWapper == null) { 31 | synchronized (RetrofitWapper.class) { 32 | if (mRetrofitWapper == null) { 33 | mRetrofitWapper = new RetrofitWapper(); 34 | } 35 | } 36 | } 37 | return mRetrofitWapper; 38 | } 39 | 40 | /** 41 | * 生成service对象 42 | * 43 | * @param clazz 44 | * @param 45 | * @return 46 | */ 47 | public T create(Class clazz) { 48 | return mRetrofit.create(clazz); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_mine.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 18 | 19 | 26 | 27 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/test/java/com/zbao/news/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news; 2 | 3 | import org.junit.Before; 4 | import org.junit.Ignore; 5 | import org.junit.Test; 6 | 7 | import static org.junit.Assert.assertEquals; 8 | 9 | /** 10 | * 可以直接在机器上执行的代码(即可以直接在开发工具或者开发环境下运行的代码) 11 | *

12 | *

13 | * Mockito使用 进行无返回值的单元测试 14 | * http://chriszou.com/2016/04/29/android-unit-testing-mockito.html 15 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 16 | */ 17 | public class ExampleUnitTest { 18 | private TestDemo mTestDemo; 19 | 20 | @Before 21 | public void gerentor() { //在执行所有的测试方法之前会执行此注解的方法 22 | mTestDemo = new TestDemo(); 23 | } 24 | 25 | 26 | @Test 27 | public void addition_isCorrect() throws Exception { 28 | assertEquals(4, 2 + 2); 29 | } 30 | 31 | /*** 32 | * testAdd() testMutiply() 两个方法用来演示@Before注解的使用 33 | */ 34 | @Test 35 | public void testAdd() { 36 | int result = mTestDemo.add(1, 1); 37 | //期望值 实际结果值 38 | assertEquals(2, result); 39 | } 40 | 41 | @Test 42 | public void testMutiply() { 43 | int result = mTestDemo.mutiply(1, 2); 44 | assertEquals(3, result); 45 | } 46 | 47 | /** 48 | * 用来演示期望抛出异常的测试 49 | */ 50 | @Test(expected = ArithmeticException.class) 51 | public void testDvider() { 52 | int result = mTestDemo.divider(5, 0); 53 | assertEquals(2, result); 54 | } 55 | 56 | @Test 57 | @Ignore("method is not implemented yet") 58 | public void testFunction() { 59 | 60 | } 61 | } -------------------------------------------------------------------------------- /app/src/main/java/com/zbao/news/main/news/presenter/NewsFragmentPresenterImpl.java: -------------------------------------------------------------------------------- 1 | package com.zbao.news.main.news.presenter; 2 | 3 | import com.zbao.news.R; 4 | import com.zbao.news.app.NewsApplication; 5 | import com.zbao.news.entity.JokeInf; 6 | import com.zbao.news.main.news.model.NewsFragmentModel; 7 | import com.zbao.news.main.news.model.NewsFragmentModelImpl; 8 | import com.zbao.news.main.news.view.NewFragmentView; 9 | import com.zbao.news.utils.CommonUtil; 10 | 11 | /** 12 | * Created by zhangYB on 2016/5/3. 13 | */ 14 | public class NewsFragmentPresenterImpl implements NewsFragmentPresenter, NewsFragmentModelImpl.OnNewsLoadFinishedListener { 15 | 16 | 17 | private NewFragmentView mNewFragmentView; 18 | 19 | private NewsFragmentModel mNewsFragmentModel; 20 | 21 | public NewsFragmentPresenterImpl() { 22 | this.mNewsFragmentModel = new NewsFragmentModelImpl(); 23 | } 24 | 25 | 26 | @Override 27 | public void getNewsOnInternet() { 28 | mNewsFragmentModel.getNewsList(this); 29 | } 30 | 31 | @Override 32 | public void onSucess(JokeInf jokeInf) { 33 | mNewFragmentView.setDataForList(jokeInf.getResult().getData()); 34 | } 35 | 36 | @Override 37 | public void onFailure(String tag, Throwable throwable) { 38 | CommonUtil.showToast(NewsApplication.getContext(), NewsApplication.getContext().getResources().getString(R.string.load_failure)); 39 | } 40 | 41 | 42 | public NewFragmentView getNewFragmentView() { 43 | return mNewFragmentView; 44 | } 45 | 46 | public void setNewFragmentView(NewFragmentView newFragmentView) { 47 | mNewFragmentView = newFragmentView; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 22 | 23 | 29 | 30 |