diff --git a/.gitignore b/.gitignore
index eef2d45..63fc54f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,5 +39,6 @@ captures/
.idea/vcs.xml
.idea/libraries
+
# Keystore files
*.jks
diff --git a/README.md b/README.md
index fde3234..438a057 100644
--- a/README.md
+++ b/README.md
@@ -1,29 +1,59 @@
-### 你知道吗?Github的 “star” 功能就像微信朋友圈中的 **“点赞”** 功能,如果你觉得我的代码对你有帮助,你可以帮我点个赞,随手 “star” 一下。
-
-
+# 应用截图
+
![]() |
+ ![]() |
+ ![]() |
+ ![]() |
+
这就是个壳工程,没有任何界面,只负责管理组件
- * - * @author 张华洋 2017/2/15 20:42 - * @version V1.2.0 - * @name AppModule - */ - -@Module("app") -public class App { -} diff --git a/app/src/main/java/com/guiying/androidmodulepattern/MyApplication.java b/app/src/main/java/com/guiying/androidmodulepattern/MyApplication.java deleted file mode 100644 index 9fb5a5b..0000000 --- a/app/src/main/java/com/guiying/androidmodulepattern/MyApplication.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.guiying.androidmodulepattern; - -import com.github.mzule.activityrouter.annotation.Modules; -import com.guiying.common.base.BaseApplication; - -/** - *应用程序的Application只负责管理组件
- * - * @author 张华洋 2017/2/15 20:14 - * @version V1.2.0 - * @name MyApplication - */ -@Modules({"app", "main", "girls", "news"}) -public class MyApplication extends BaseApplication { - - - @Override - public void onCreate() { - super.onCreate(); - } - -} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml deleted file mode 100644 index 99d6e54..0000000 --- a/app/src/main/res/values/strings.xml +++ /dev/null @@ -1,6 +0,0 @@ -Activity基类
- * - * @author 2016/12/2 17:33 - * @version V1.0.0 - * @name BaseActivity - */ -public abstract class BaseActivity extends AppCompatActivity { - - /** - * 处理Intent,防止开发人员没做Intent判空 - */ - protected void handleIntent(Intent intent) { - } - - /** - * 封装的findViewByID方法 - */ - @SuppressWarnings("unchecked") - protected类说明
- * - * @author 张华洋 2017/2/15 16:34 - * @version V1.2.0 - * @name Girls - */ -@Module("girls") -public class Girls { -} diff --git a/gradle.properties b/gradle.properties index cc07a2a..9b51cd5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,17 +9,18 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx1536m +org.gradle.jvmargs=-Xmx2048m # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects + org.gradle.daemon=true org.gradle.configureondemand=true org.gradle.parallel=true -# ΪԶ(ΪÿĵԻһ) -localBuildToolsVersion=25.0.2 -localGradlePluginVersion=2.3.0 +# ֵһAndroidStudio汾һ +localGradlePluginVersion=3.0.1 # ÿθġisModuleֵҪ "Sync Project" ť -isModule=true \ No newline at end of file +# isModuleǡɿģʽ͡ģʽл +isModule=false diff --git a/keystore.properties b/keystore.properties new file mode 100644 index 0000000..dabd93e --- /dev/null +++ b/keystore.properties @@ -0,0 +1,4 @@ +storePassword=guiying712 +keyPassword=guiying712 +keyAlias=guiying712 +storeFile=/mykey.jks \ No newline at end of file diff --git a/common/.gitignore b/lib_common/.gitignore similarity index 100% rename from common/.gitignore rename to lib_common/.gitignore diff --git a/lib_common/build.gradle b/lib_common/build.gradle new file mode 100644 index 0000000..87eb2af --- /dev/null +++ b/lib_common/build.gradle @@ -0,0 +1,76 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion build_versions.target_sdk + defaultConfig { + minSdkVersion build_versions.min_sdk + targetSdkVersion build_versions.target_sdk + versionCode 1 + versionName "1.0" + } + + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildTypes { + release { + buildConfigField "boolean", "LOG_DEBUG", "true" + zipAlignEnabled false + shrinkResources false + minifyEnabled false + debuggable true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + +} + +dependencies { + api fileTree(include: ['*.jar'], dir: 'libs') + // Support libraries + api deps.support.app_compat + api deps.support.v4 + api deps.support.v13 + api deps.support.design + api deps.support.cardview + api deps.support.percent + api deps.support.recyclerview + api deps.constraint_layout + + // RxJava and retrofit + api deps.rx_android + api deps.rxjava2 + api deps.retrofit.runtime + api deps.retrofit.gson + api deps.persistent_cookie + + //Dagger + api deps.dagger.runtime + api deps.dagger.android + api deps.dagger.android_support + + // other + api deps.kotlin.stdlib + api deps.event_bus + api deps.gson + api deps.permission + api deps.utils + api deps.glide + + //view + api deps.photo_view + api deps.easy_recycler + api deps.material_dialog + api deps.logger + api deps.toasty + + //router + api deps.arouter_api + + //annotationProcessor + annotationProcessor deps.dagger.android_support_compiler + annotationProcessor deps.dagger.compiler +} diff --git a/common/libs/simple-xml-core.jar b/lib_common/libs/simple-xml-core.jar similarity index 100% rename from common/libs/simple-xml-core.jar rename to lib_common/libs/simple-xml-core.jar diff --git a/lib_common/src/main/AndroidManifest.xml b/lib_common/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8039311 --- /dev/null +++ b/lib_common/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ +Activity基类
+ * + * @author 2016/12/2 17:33 + * @version V1.0.0 + * @name BaseActivity + */ +@Keep +public abstract class BaseActivity extends AppCompatActivity { + + + /** + * 封装的findViewByID方法 + */ + @SuppressWarnings("unchecked") + protectedFragment的基类
+ * + * @author 张华洋 + * @name BaseFragment + */ +@Keep +public abstract class BaseFragment extends Fragment { + + protected BaseActivity mActivity; + + @Override + public void onAttach(Context context) { + super.onAttach(context); + this.mActivity = (BaseActivity) context; + } + + + /** + * 获取宿主Activity + * + * @return BaseActivity + */ + protected BaseActivity getHoldingActivity() { + return mActivity; + } + + + /** + * 添加fragment + * + * @param fragment + * @param frameId + */ + protected void addFragment(BaseFragment fragment, @IdRes int frameId) { + Utils.checkNotNull(fragment); + getHoldingActivity().addFragment(fragment, frameId); + + } + + + /** + * 替换fragment + * + * @param fragment + * @param frameId + */ + protected void replaceFragment(BaseFragment fragment, @IdRes int frameId) { + Utils.checkNotNull(fragment); + getHoldingActivity().replaceFragment(fragment, frameId); + } + + + /** + * 隐藏fragment + * + * @param fragment + */ + protected void hideFragment(BaseFragment fragment) { + Utils.checkNotNull(fragment); + getHoldingActivity().hideFragment(fragment); + } + + + /** + * 显示fragment + * + * @param fragment + */ + protected void showFragment(BaseFragment fragment) { + Utils.checkNotNull(fragment); + getHoldingActivity().showFragment(fragment); + } + + + /** + * 移除Fragment + * + * @param fragment + */ + protected void removeFragment(BaseFragment fragment) { + Utils.checkNotNull(fragment); + getHoldingActivity().removeFragment(fragment); + + } + + + /** + * 弹出栈顶部的Fragment + */ + protected void popFragment() { + getHoldingActivity().popFragment(); + } + +} diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java b/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java new file mode 100644 index 0000000..be56ad9 --- /dev/null +++ b/lib_common/src/main/java/com/guiying/module/common/base/BasePresenter.java @@ -0,0 +1,16 @@ +package com.guiying.module.common.base; + +import android.support.annotation.Keep; + +/** + *Presenter的基类
+ * + * @author 张华洋 + * @name BasePresenter + */ +@Keep +public interface BasePresenter { + + void start(); + +} diff --git a/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java b/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java new file mode 100644 index 0000000..e1b0b21 --- /dev/null +++ b/lib_common/src/main/java/com/guiying/module/common/base/BaseView.java @@ -0,0 +1,17 @@ +package com.guiying.module.common.base; + + +import android.support.annotation.Keep; + +/** + *View接口的基类
+ * + * @author 张华洋 + * @name BaseView + */ +@Keep +public interface BaseView类说明
+ * + * @author 张华洋 2017/9/20 22:23 + * @version V2.8.3 + * @name ApplicationDelegate + */ +@Keep +public interface IApplicationDelegate { + + void onCreate(); + + void onTerminate(); + + void onLowMemory(); + + void onTrimMemory(int level); + +} diff --git a/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java b/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java new file mode 100644 index 0000000..3c35b8e --- /dev/null +++ b/lib_common/src/main/java/com/guiying/module/common/base/IViewDelegate.java @@ -0,0 +1,21 @@ +package com.guiying.module.common.base; + + +import android.support.annotation.Keep; +import android.view.View; + +/** + *类说明
+ * + * @author 张华洋 2018/1/4 22:10 + * @version V2.8.3 + * @name IFragmentDelegate + */ +@Keep +public interface IViewDelegate { + + BaseFragment getFragment(String name); + + View getView(String name); + +} diff --git a/common/src/main/java/com/guiying/common/http/InfoCallback.java b/lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java similarity index 72% rename from common/src/main/java/com/guiying/common/http/InfoCallback.java rename to lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java index ec1fda9..8a5cf9b 100644 --- a/common/src/main/java/com/guiying/common/http/InfoCallback.java +++ b/lib_common/src/main/java/com/guiying/module/common/base/InfoCallback.java @@ -1,4 +1,6 @@ -package com.guiying.common.http; +package com.guiying.module.common.base; + +import android.support.annotation.Keep; /** *数据回调接口
@@ -7,6 +9,7 @@ * @version V1.2.0 * @name InfoCallback */ +@Keep public interface InfoCallback图片加载工具类
+ * + * @name ImageUtils + */ +public class ImageUtils { + + /** + * 默认加载 + */ + public static void loadImageView(String path, ImageView mImageView) { + Glide.with(mImageView.getContext()).load(path).into(mImageView); + } + + public static void loadImageWithError(String path, int errorRes, ImageView mImageView) { + Glide.with(mImageView.getContext()) + .load(path) + .crossFade() + .diskCacheStrategy(DiskCacheStrategy.SOURCE) + .error(errorRes) + .into(mImageView); + } + + /** + * 设置加载中以及加载失败图片 + */ + public static void loadImageWithLoading(String path, ImageView mImageView, int lodingImage, int errorRes) { + Glide.with(mImageView.getContext()).load(path).placeholder(lodingImage). + error(errorRes).into(mImageView); + } + + /** + * 设置加载动画 + * api也提供了几个常用的动画:比如crossFade() + */ + public static void loadImageViewAnim(String path, int anim, ImageView mImageView) { + Glide.with(mImageView.getContext()).load(path).animate(anim).into(mImageView); + } + + + /** + * 加载为bitmap + * + * @param path 图片地址 + * @param listener 回调 + */ + public static void loadBitMap(String path, final onLoadBitmap listener) { + Glide.with(Utils.getContext()).load(path).asBitmap().into(new SimpleTarget服务端响应的数据类型
+ * + * @author 张华洋 2017/5/2 21:53 + * @version V1.2.0 + * @name DataType + */ +public class DataType { + + /*返回数据为String*/ + public static final int STRING = 1; + /*返回数据为xml类型*/ + public static final int XML = 2; + /*返回数据为json对象*/ + public static final int JSON_OBJECT = 3; + /*返回数据为json数组*/ + public static final int JSON_ARRAY = 4; + + /** + * 自定义一个播放器状态注解 + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef({STRING, XML, JSON_OBJECT, JSON_ARRAY}) + public @interface Type { + } + +} diff --git a/common/src/main/java/com/guiying/common/http/HttpClient.java b/lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java similarity index 84% rename from common/src/main/java/com/guiying/common/http/HttpClient.java rename to lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java index 23c7151..2be900b 100644 --- a/common/src/main/java/com/guiying/common/http/HttpClient.java +++ b/lib_common/src/main/java/com/guiying/module/common/http/HttpClient.java @@ -1,16 +1,17 @@ -package com.guiying.common.http; +package com.guiying.module.common.http; +import android.support.annotation.NonNull; import android.text.TextUtils; import com.franmontiel.persistentcookiejar.ClearableCookieJar; import com.franmontiel.persistentcookiejar.PersistentCookieJar; import com.franmontiel.persistentcookiejar.cache.SetCookieCache; import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor; -import com.guiying.common.R; -import com.guiying.common.utils.NetworkUtils; -import com.guiying.common.utils.StringUtils; -import com.guiying.common.utils.ToastUtils; -import com.guiying.common.utils.Utils; +import com.guiying.module.common.R; +import com.guiying.module.common.utils.NetworkUtils; +import com.guiying.module.common.utils.StringUtils; +import com.guiying.module.common.utils.ToastUtils; +import com.guiying.module.common.utils.Utils; import com.orhanobut.logger.Logger; import java.io.IOException; @@ -37,15 +38,8 @@ public class HttpClient { /*The certificate's password*/ - private static final String STORE_PASS = "4444444"; - /*返回数据为String*/ - public static final int STRING = 0; - /*返回数据为json对象*/ - public static final int OBJECT = 1; - /*返回数据为json数组*/ - public static final int ARRAY = 2; - /*返回数据为xml类型*/ - public static final int XML = 3; + private static final String STORE_PASS = "6666666"; + private static final String STORE_ALIAS = "666666"; /*用户设置的BASE_URL*/ private static String BASE_URL = ""; /*本地使用的baseUrl*/ @@ -74,11 +68,11 @@ private static class HttpClientHolder { private HttpClient() { ClearableCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(Utils.getContext())); - //HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(Utils.getContext(), new int[0], , STORE_PASS); + //HttpsUtil.SSLParams sslParams = HttpsUtil.getSslSocketFactory(Utils.getContext(), R.raw.cer,STORE_PASS , STORE_ALIAS); okHttpClient = new OkHttpClient.Builder() .connectTimeout(10000L, TimeUnit.MILLISECONDS) //.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager) - .hostnameVerifier(HttpsUtil.getHostnameVerifier()) + // .hostnameVerifier(HttpsUtil.getHostnameVerifier()) .addInterceptor(new LoggerInterceptor(null, true)) .cookieJar(cookieJar) .build(); @@ -146,8 +140,8 @@ public void onResponse(CallHttps证书校验工具类
+ * + * @author 张华洋 2017/5/11 16:14 + * @version V1.2.0 + * @name HttpsUtils + */ +public class HttpsUtils { + + + public static class SSLParams { + public SSLSocketFactory sSLSocketFactory; + public X509TrustManager trustManager; + } + + /** + * @param context 上下文 + * @param bksFileId "XXX.bks"文件(文件位置res/raw/XXX.bks) + * @param password The certificate's password. + * @return SSLParams + */ + public static SSLParams getSslSocketFactory(Context context, @RawRes int bksFileId, String password, String alias) { + if (context == null) { + throw new NullPointerException("context == null"); + } + if (TextUtils.isEmpty(password) || TextUtils.isEmpty(alias)) { + throw new NullPointerException("password == null or alias == null!"); + } + SSLParams sslParams = new SSLParams(); + try { + // 创建一个BKS类型的KeyStore,存储我们信任的证书 + KeyStore clientKeyStore = KeyStore.getInstance("BKS"); + clientKeyStore.load(context.getResources().openRawResource(bksFileId), password.toCharArray()); + //通过alias直接从密钥库中读取证书 + Certificate rootCA = clientKeyStore.getCertificate(alias); + // Turn it to X509 format. + InputStream certInput = new ByteArrayInputStream(rootCA.getEncoded()); + X509Certificate serverCert = (X509Certificate) CertificateFactory.getInstance("X.509").generateCertificate(certInput); + //关闭流 + CloseUtils.closeIO(certInput); + + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + //用我们之前的keyStore实例初始化TrustManagerFactory,这样trustManagerFactory就会信任keyStore中的证书 + trustManagerFactory.init(clientKeyStore); + + KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); + keyManagerFactory.init(clientKeyStore, password.toCharArray()); + + X509TrustManager x509TrustManager = new SafeTrustManager(serverCert); + + //创建TLS类型的SSLContext对象,that uses our TrustManager + SSLContext sslContext = SSLContext.getInstance("TLS"); + + //用上面得到的trustManagers初始化SSLContext,这样sslContext就会信任keyStore中的证书 + sslContext.init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(), new SecureRandom()); + + //Android 4.X 对TLS1.1、TLS1.2的支持 + sslParams.sSLSocketFactory = new Tls12SocketFactory(sslContext.getSocketFactory()); + sslParams.trustManager = x509TrustManager; + return sslParams; + } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException | UnrecoverableKeyException | IOException | CertificateException e) { + throw new AssertionError(e); + } + } + + /** + * 不做证书校验,信任所有证书 + */ + public static SSLParams getSslSocketFactoryUnsafe() { + SSLParams sslParams = new SSLParams(); + try { + X509TrustManager x509TrustManager = new UnSafeTrustManager(); + + //创建TLS类型的SSLContext对象,that uses our TrustManager + SSLContext sslContext = SSLContext.getInstance("TLS"); + + //用上面得到的trustManagers初始化SSLContext,这样sslContext就会信任keyStore中的证书 + sslContext.init(null, new TrustManager[]{x509TrustManager}, null); + + //Android 4.X 对TLS1.1、TLS1.2的支持 + sslParams.sSLSocketFactory = new Tls12SocketFactory(sslContext.getSocketFactory()); + sslParams.trustManager = x509TrustManager; + return sslParams; + } catch (NoSuchAlgorithmException | KeyManagementException e) { + throw new AssertionError(e); + } + } + + + /** + * 主机名校验方法,请把”192.168.0.10”换成你们公司的主机IP: + */ + public static HostnameVerifier getHostnameVerifier() { + return new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + if ("192.168.0.10".equals(hostname)) { + return true; + } else { + HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier(); + return hv.verify(hostname, session); + } + } + }; + } + + + /** + * 对服务器证书域名进行强校验 + */ + private static class SafeTrustManager implements X509TrustManager { + private X509Certificate mCertificate; + + private SafeTrustManager(X509Certificate serverCert) { + mCertificate = serverCert; + } + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { + + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String authType) throws CertificateException { + if (x509Certificates == null) { + throw new IllegalArgumentException("Check Server x509Certificates is null"); + } + + if (x509Certificates.length < 0) { + throw new IllegalArgumentException("Check Server x509Certificates is empty"); + } + + try { + for (X509Certificate cert : x509Certificates) { + // Make sure that it hasn't expired. + cert.checkValidity(); + //和App预埋的证书做对比 + cert.verify(mCertificate.getPublicKey()); + } + } catch (NoSuchAlgorithmException | InvalidKeyException | NoSuchProviderException | SignatureException e) { + e.printStackTrace(); + } + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + } + + + /** + * 客户端不对证书做任何验证的做法有很大的安全漏洞。 + */ + private static class UnSafeTrustManager implements X509TrustManager { + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType) + throws CertificateException { + } + + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[]{}; + } + } + + + /** + * 自定义SSLSocketFactory ,实现Android 4.X 对TLSv1.1、TLSv1.2的支持 + */ + private static class Tls12SocketFactory extends SSLSocketFactory { + + private static final String[] TLS_SUPPORT_VERSION = {"TLSv1.1", "TLSv1.2"}; + + final SSLSocketFactory delegate; + + private Tls12SocketFactory(SSLSocketFactory base) { + this.delegate = base; + } + + @Override + public String[] getDefaultCipherSuites() { + return delegate.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + return delegate.getSupportedCipherSuites(); + } + + @Override + public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException { + return patch(delegate.createSocket(s, host, port, autoClose)); + } + + @Override + public Socket createSocket(String host, int port) throws IOException { + return patch(delegate.createSocket(host, port)); + } + + @Override + public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException { + return patch(delegate.createSocket(host, port, localHost, localPort)); + } + + @Override + public Socket createSocket(InetAddress host, int port) throws IOException { + return patch(delegate.createSocket(host, port)); + } + + @Override + public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException { + return patch(delegate.createSocket(address, port, localAddress, localPort)); + } + + private Socket patch(Socket s) { + //代理SSLSocketFactory在创建一个Socket连接的时候,会设置Socket的可用的TLS版本。 + if (s instanceof SSLSocket) { + ((SSLSocket) s).setEnabledProtocols(TLS_SUPPORT_VERSION); + } + return s; + } + } + +} diff --git a/common/src/main/java/com/guiying/common/http/LoggerInterceptor.java b/lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java similarity index 99% rename from common/src/main/java/com/guiying/common/http/LoggerInterceptor.java rename to lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java index 46cbff8..16d0660 100644 --- a/common/src/main/java/com/guiying/common/http/LoggerInterceptor.java +++ b/lib_common/src/main/java/com/guiying/module/common/http/LoggerInterceptor.java @@ -1,4 +1,4 @@ -package com.guiying.common.http; +package com.guiying.module.common.http; import android.text.TextUtils; diff --git a/common/src/main/java/com/guiying/common/http/OnResultListener.java b/lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java similarity index 94% rename from common/src/main/java/com/guiying/common/http/OnResultListener.java rename to lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java index 6274b58..527f5f0 100644 --- a/common/src/main/java/com/guiying/common/http/OnResultListener.java +++ b/lib_common/src/main/java/com/guiying/module/common/http/OnResultListener.java @@ -1,4 +1,4 @@ -package com.guiying.common.http; +package com.guiying.module.common.http; /** *在Retrofit中接口会导致泛型擦除,所以这里回调使用Class
diff --git a/common/src/main/java/com/guiying/common/utils/CloseUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java similarity index 96% rename from common/src/main/java/com/guiying/common/utils/CloseUtils.java rename to lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java index dae8eca..336cde0 100644 --- a/common/src/main/java/com/guiying/common/utils/CloseUtils.java +++ b/lib_common/src/main/java/com/guiying/module/common/utils/CloseUtils.java @@ -1,4 +1,4 @@ -package com.guiying.common.utils; +package com.guiying.module.common.utils; import java.io.Closeable; import java.io.IOException; diff --git a/common/src/main/java/com/guiying/common/utils/NetworkUtils.java b/lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java similarity index 98% rename from common/src/main/java/com/guiying/common/utils/NetworkUtils.java rename to lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java index 842a52e..e788077 100644 --- a/common/src/main/java/com/guiying/common/utils/NetworkUtils.java +++ b/lib_common/src/main/java/com/guiying/module/common/utils/NetworkUtils.java @@ -1,4 +1,4 @@ -package com.guiying.common.utils; +package com.guiying.module.common.utils; import android.content.Context; import android.content.Intent; @@ -144,7 +144,7 @@ public static boolean is4G() { * @return {@code true}: 是解决图片缩放崩溃的问题
+ * @name HackyViewPager + * @author 张华洋 2017/9/27 10:10 + * @version V1.1 + */ +public class HackyViewPager extends ViewPager { + + public HackyViewPager(Context context) { + super(context); + } + + public HackyViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + try { + return super.onInterceptTouchEvent(ev); + } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java b/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java new file mode 100644 index 0000000..be8f2b9 --- /dev/null +++ b/lib_common/src/main/java/com/guiying/module/common/widget/NoScrollViewPager.java @@ -0,0 +1,41 @@ +package com.guiying.module.common.widget; + +import android.content.Context; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.MotionEvent; + +/** + *可以禁止滑动翻页的ViewPager
+ * + * @author 张华洋 2017/9/27 10:10 + * @version V1.1 + * @name NoScrollViewPager + */ +public class NoScrollViewPager extends ViewPager { + + private boolean isPagingEnabled = true; + + public NoScrollViewPager(Context context) { + super(context); + } + + public NoScrollViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + return this.isPagingEnabled && super.onTouchEvent(event); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + return this.isPagingEnabled && super.onInterceptTouchEvent(event); + } + + public void setPagerEnabled(boolean b) { + this.isPagingEnabled = b; + } + +} diff --git a/lib_common/src/main/res/drawable-xxhdpi/ic_arrow_back.png b/lib_common/src/main/res/drawable-xxhdpi/ic_arrow_back.png new file mode 100644 index 0000000..38c9a6d Binary files /dev/null and b/lib_common/src/main/res/drawable-xxhdpi/ic_arrow_back.png differ diff --git a/common/src/main/res/drawable/shape_loading_bg.xml b/lib_common/src/main/res/drawable/shape_loading_bg.xml similarity index 100% rename from common/src/main/res/drawable/shape_loading_bg.xml rename to lib_common/src/main/res/drawable/shape_loading_bg.xml diff --git a/common/src/main/res/layout/layout_load_error.xml b/lib_common/src/main/res/layout/layout_load_error.xml similarity index 100% rename from common/src/main/res/layout/layout_load_error.xml rename to lib_common/src/main/res/layout/layout_load_error.xml diff --git a/common/src/main/res/layout/layout_load_more.xml b/lib_common/src/main/res/layout/layout_load_more.xml similarity index 72% rename from common/src/main/res/layout/layout_load_more.xml rename to lib_common/src/main/res/layout/layout_load_more.xml index 46425fa..b6c5d09 100644 --- a/common/src/main/res/layout/layout_load_more.xml +++ b/lib_common/src/main/res/layout/layout_load_more.xml @@ -7,14 +7,14 @@ android:layout_height="50dp">声明主要组件
- *
- * 这个组件是应用默认启动的组件
- *
- * @author 张华洋 2017/4/1 12:39
- * @version V1.2.0
- * @name Main
- */
-
-@Module("main")
-public class Main {
-}
diff --git a/main/src/main/java/com/guiying/main/MainActivity.java b/main/src/main/java/com/guiying/main/MainActivity.java
deleted file mode 100644
index 8110108..0000000
--- a/main/src/main/java/com/guiying/main/MainActivity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package com.guiying.main;
-
-import android.os.Bundle;
-import android.support.design.widget.Snackbar;
-import android.view.KeyEvent;
-import android.view.View;
-import android.widget.Button;
-
-import com.github.mzule.activityrouter.router.Routers;
-import com.guiying.common.base.BaseActivity;
-import com.guiying.common.base.BaseApplication;
-
-public class MainActivity extends BaseActivity implements View.OnClickListener {
-
-
- private long exitTime = 0;
-
- protected Button newsButton;
- protected Button girlsButton;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- newsButton = (Button) findViewById(R.id.news_button);
- newsButton.setOnClickListener(MainActivity.this);
- girlsButton = (Button) findViewById(R.id.girls_button);
- girlsButton.setOnClickListener(MainActivity.this);
- }
-
- @Override
- public void onClick(View view) {
- if (view.getId() == R.id.news_button) {
- Routers.open(MainActivity.this, "module://news");
- } else if (view.getId() == R.id.girls_button) {
- Routers.open(MainActivity.this, "module://girls");
- }
- }
-
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
- //两秒之内按返回键就会退出
- if ((System.currentTimeMillis() - exitTime) > 2000) {
- Snackbar.make(girlsButton, getString(R.string.app_exit_hint), Snackbar.LENGTH_LONG).show();
- exitTime = System.currentTimeMillis();
- } else {
- BaseApplication.getIns().exitApp(this);
- }
- return true;
- }
- return super.onKeyDown(keyCode, event);
- }
-
-}
diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml
deleted file mode 100644
index 1c3948f..0000000
--- a/main/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
- 这里仅需做一些初始化的工作 类说明 类说明 类说明
+ * + * @author 张华洋 2017/9/27 10:23 + * @version V1.1 + * @name BottomNavigationActivity + */ +public class BottomNavigationActivity extends BaseActivity { + + private NoScrollViewPager mPager; + private List
Fragments适配器
+ * + * @author 张华洋 2017/9/27 10:14 + * @version V1.1 + * @name ResourcePagerAdapter + */ +public class FragmentAdapter extends FragmentStatePagerAdapter { + private List类说明
+ * + * @author 张华洋 2017/7/1 13:13 + * @version V1.2.0 + * @name MainActivity + */ +public class MainActivity extends BaseActivity implements View.OnClickListener { + + private long mExitTime = 0; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + findViewById(R.id.news_button).setOnClickListener(this); + findViewById(R.id.girls_button).setOnClickListener(this); + findViewById(R.id.fragment_button).setOnClickListener(this); + } + + @Override + public void onClick(View view) { + if (view.getId() == R.id.news_button) { + //跳转到NewsCenterActivity + ARouter.getInstance().build("/news/center").navigation(); + } else if (view.getId() == R.id.girls_button) { + //跳转到GirlsActivity + ARouter.getInstance().build("/girls/list").navigation(); + } else if (view.getId() == R.id.fragment_button) { + startActivity(new Intent(this, BottomNavigationActivity.class)); + } + } + + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { + //两秒之内按返回键就会退出 + if ((System.currentTimeMillis() - mExitTime) > 2000) { + ToastUtils.showShortToast(getString(R.string.app_exit_hint)); + mExitTime = System.currentTimeMillis(); + } else { + ViewManager.getInstance().exitApp(this); + } + return true; + } + return super.onKeyDown(keyCode, event); + } + +} diff --git a/main/src/main/java/debug/MainApplication.java b/module_main/src/main/java/debug/MainApplication.java similarity index 87% rename from main/src/main/java/debug/MainApplication.java rename to module_main/src/main/java/debug/MainApplication.java index 293f166..24509f5 100644 --- a/main/src/main/java/debug/MainApplication.java +++ b/module_main/src/main/java/debug/MainApplication.java @@ -1,8 +1,8 @@ package debug; -import com.guiying.common.base.BaseApplication; -import com.guiying.common.http.HttpClient; -import com.guiying.common.http.OnResultListener; +import com.guiying.module.common.base.BaseApplication; +import com.guiying.module.common.http.HttpClient; +import com.guiying.module.common.http.OnResultListener; import com.orhanobut.logger.Logger; /** diff --git a/main/src/main/debug/AndroidManifest.xml b/module_main/src/main/module/AndroidManifest.xml similarity index 83% rename from main/src/main/debug/AndroidManifest.xml rename to module_main/src/main/module/AndroidManifest.xml index fc3933a..0443b12 100644 --- a/main/src/main/debug/AndroidManifest.xml +++ b/module_main/src/main/module/AndroidManifest.xml @@ -1,6 +1,6 @@类说明
+ * + * @author 张华洋 2017/9/20 22:29 + * @version V2.8.3 + * @name MyDelegate + */ +@Keep +public class MyDelegate implements IApplicationDelegate { + + @Override + public void onCreate() { + Logger.init("pattern"); + //主动添加 + ViewManager.getInstance().addFragment(0, NewsFragment.newInstance()); + } + + @Override + public void onTerminate() { + + } + + @Override + public void onLowMemory() { + + } + + @Override + public void onTrimMemory(int level) { + + } +} diff --git a/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java b/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java new file mode 100644 index 0000000..0620bb5 --- /dev/null +++ b/module_news/src/main/java/com/guiying/module/news/MyViewDelegate.java @@ -0,0 +1,28 @@ +package com.guiying.module.news; + +import android.support.annotation.Keep; +import android.view.View; + +import com.guiying.module.common.base.BaseFragment; +import com.guiying.module.common.base.IViewDelegate; + +/** + *类说明
+ * + * @author 张华洋 2018/1/4 22:16 + * @version V2.8.3 + * @name MyViewDelegate + */ +@Keep +public class MyViewDelegate implements IViewDelegate { + + @Override + public BaseFragment getFragment(String name) { + return NewsFragment.newInstance(); + } + + @Override + public View getView(String name) { + return null; + } +} diff --git a/module_news/src/main/java/com/guiying/module/news/NewsFragment.java b/module_news/src/main/java/com/guiying/module/news/NewsFragment.java new file mode 100644 index 0000000..93c039a --- /dev/null +++ b/module_news/src/main/java/com/guiying/module/news/NewsFragment.java @@ -0,0 +1,43 @@ +package com.guiying.module.news; + + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.guiying.module.common.base.BaseFragment; + + +/** + * A simple {@link Fragment} subclass. + */ +public class NewsFragment extends BaseFragment { + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @return A new instance of fragment NewsFragment. + */ + public static NewsFragment newInstance() { + return new NewsFragment(); + } + + + + public NewsFragment() { + // Required empty public constructor + } + + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_news, container, false); + } + + +} diff --git a/module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java b/module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java new file mode 100644 index 0000000..8990f08 --- /dev/null +++ b/module_news/src/main/java/com/guiying/module/news/data/NewsDataSource.java @@ -0,0 +1,34 @@ +package com.guiying.module.news.data; + +import com.guiying.module.common.base.InfoCallback; +import com.guiying.module.news.data.bean.MessageDetail; +import com.guiying.module.news.data.bean.StoryList; + +/** + *类说明
+ * + * @author 张华洋 2017/4/20 22:02 + * @version V1.2.0 + * @name NewsDataSource + */ +public interface NewsDataSource { + + + /** + * 获取当天的新闻列表 + * + * @param date 日期 + * @param callback 回调 + */ + void getNewsList(String date, InfoCallback类说明
+ * + * @author 张华洋 2017/4/20 23:32 + * @version V1.2.0 + * @name RemoteNewsDataSource + */ +public class RemoteNewsDataSource implements NewsDataSource { + + @Override + public void getNewsList(String date, final InfoCallback类说明
+ * + * @author 张华洋 2017/7/1 13:13 + * @version V1.2.0 + * @name NewsDetailActivity + */ +@Route(path = "/news/detail") +public class NewsDetailActivity extends BaseActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + NewsDetailView detailView = new NewsDetailView(this); + setContentView(detailView); + String id = getIntent().getStringExtra("id"); + new NewsDetailPresenter(detailView).getNewsDetail(id); + } + +} diff --git a/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java new file mode 100644 index 0000000..6a21ef5 --- /dev/null +++ b/module_news/src/main/java/com/guiying/module/news/detail/NewsDetailContract.java @@ -0,0 +1,35 @@ +package com.guiying.module.news.detail; + +import com.guiying.module.common.base.BasePresenter; +import com.guiying.module.common.base.BaseView; +import com.guiying.module.news.data.bean.MessageDetail; + +/** + *类说明
+ * + * @author 张华洋 2017/2/22 20:33 + * @version V1.2.0 + * @name NewsContract + */ +public interface NewsDetailContract { + + interface View extends BaseView类说明
+ * + * @author 张华洋 2017/2/22 20:33 + * @version V1.2.0 + * @name GirlsPresenter + */ +public class NewsDetailPresenter implements NewsDetailContract.Presenter { + + private NewsDetailContract.View mView; + private NewsDataSource mDataSource; + + public NewsDetailPresenter(NewsDetailContract.View view) { + mView = view; + mDataSource = new RemoteNewsDataSource(); + mView.setPresenter(this); + } + + @Override + public void start() { + + } + + + @Override + public void getNewsDetail(String newsId) { + mDataSource.getNewsDetail(newsId, new InfoCallback类说明
+ * + * @author 张华洋 2017/7/1 13:18 + * @version V1.2.0 + * @name NewsDetailView + */ + +public class NewsDetailView extends FrameLayout implements NewsDetailContract.View { + + private boolean isActive = false; + private NewsDetailContract.Presenter mPresenter; + private ImageView mToolbarImage; + private TextView mToolbarText; + private CollapsingToolbarLayout mCollapsingLayout; + private TextView mDetailText; + + + public NewsDetailView(Context context) { + super(context); + initView(); + } + + public NewsDetailView(Context context, AttributeSet attrs) { + super(context, attrs); + initView(); + } + + private void initView() { + inflate(getContext(), R.layout.view_news_detail, this); + mToolbarImage = (ImageView) findViewById(R.id.toolbar_image); + mToolbarText = (TextView) findViewById(R.id.toolbar_text); + mCollapsingLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_layout); + mDetailText = (TextView) findViewById(R.id.news_detail_text); + + isActive = true; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + isActive = true; + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + isActive = false; + } + + @Override + public boolean isActive() { + return isActive; + } + + + @Override + public void setPresenter(NewsDetailContract.Presenter presenter) { + mPresenter = presenter; + } + + @Override + public void showNewsDetail(MessageDetail detail) { + mCollapsingLayout.setTitle(detail.getTitle()); + //设置还没收缩时状态下字体颜色 + mCollapsingLayout.setExpandedTitleColor(Color.WHITE); + //设置收缩后Toolbar上字体的颜色 + mCollapsingLayout.setCollapsedTitleTextColor(Color.WHITE); + mToolbarText.setText(detail.getImage_source()); + Glide.with(getContext()) + .load(detail.getImage()) + .thumbnail(0.2f) + .into(mToolbarImage); + mDetailText.setMovementMethod(LinkMovementMethod.getInstance()); + mDetailText.setText(Html.fromHtml(detail.getBody(), new Html.ImageGetter() { + @Override + public Drawable getDrawable(String source) { + final URLDrawable urlDrawable = new URLDrawable(); + Glide.with(getContext()).load(source).asBitmap().into(new SimpleTarget类说明
+ * + * @author 张华洋 2017/4/20 22:26 + * @version V1.2.0 + * @name NewsCenterActivity + */ +@Route(path = "/news/center") public class NewsCenterActivity extends BaseActivity { protected Toolbar mToolBar; @@ -28,7 +35,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.activity_news); mToolBar = (Toolbar) findViewById(R.id.news_title_bar); - setToolbar(mToolBar, "知乎日报"); + mToolBar.setTitle("知乎日报"); + setupToolBar(mToolBar, false); mTabLayout = (TabLayout) findViewById(R.id.date_tab); mViewPager = (ViewPager) findViewById(R.id.message_pager); mListAdapter = new NewsListViewAdapter(getMessageListViews(), getWeekDate()); diff --git a/news/src/main/java/com/guiying/news/main/NewsListAdapter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java similarity index 68% rename from news/src/main/java/com/guiying/news/main/NewsListAdapter.java rename to module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java index a7bf285..76e452f 100644 --- a/news/src/main/java/com/guiying/news/main/NewsListAdapter.java +++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListAdapter.java @@ -1,14 +1,17 @@ -package com.guiying.news.main; +package com.guiying.module.news.main; import android.content.Context; +import android.content.Intent; +import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; -import com.guiying.news.R; -import com.guiying.news.data.bean.Story; +import com.guiying.module.news.R; +import com.guiying.module.news.data.bean.Story; +import com.guiying.module.news.detail.NewsDetailActivity; import com.jude.easyrecyclerview.adapter.BaseViewHolder; import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter; @@ -19,8 +22,6 @@ * @version V1.2.0 * @name NewsListAdapter */ - - public class NewsListAdapter extends RecyclerArrayAdapter类说明
diff --git a/news/src/main/java/com/guiying/news/main/NewsListPresenter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java similarity index 78% rename from news/src/main/java/com/guiying/news/main/NewsListPresenter.java rename to module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java index 77f8ac5..8ac69db 100644 --- a/news/src/main/java/com/guiying/news/main/NewsListPresenter.java +++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListPresenter.java @@ -1,9 +1,9 @@ -package com.guiying.news.main; +package com.guiying.module.news.main; -import com.guiying.common.http.InfoCallback; -import com.guiying.news.data.NewsDataSource; -import com.guiying.news.data.bean.StoryList; -import com.guiying.news.data.source.RemoteNewsDataSource; +import com.guiying.module.common.base.InfoCallback; +import com.guiying.module.news.data.NewsDataSource; +import com.guiying.module.news.data.bean.StoryList; +import com.guiying.module.news.data.source.RemoteNewsDataSource; /** *类说明
diff --git a/news/src/main/java/com/guiying/news/main/NewsListView.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListView.java similarity index 84% rename from news/src/main/java/com/guiying/news/main/NewsListView.java rename to module_news/src/main/java/com/guiying/module/news/main/NewsListView.java index c016e88..254aca0 100644 --- a/news/src/main/java/com/guiying/news/main/NewsListView.java +++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListView.java @@ -1,12 +1,13 @@ -package com.guiying.news.main; +package com.guiying.module.news.main; import android.content.Context; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.LinearLayoutManager; import android.util.AttributeSet; -import com.guiying.news.R; -import com.guiying.news.data.bean.StoryList; +import com.guiying.module.news.R; +import com.guiying.module.news.data.bean.StoryList; import com.jude.easyrecyclerview.EasyRecyclerView; import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter; import com.jude.easyrecyclerview.decoration.DividerDecoration; @@ -36,6 +37,11 @@ public NewsListView(Context context, AttributeSet attrs) { } private void initView() { + setRefreshingColor( + ContextCompat.getColor(getContext(), R.color.colorPrimary), + ContextCompat.getColor(getContext(), android.R.color.holo_blue_light), + ContextCompat.getColor(getContext(), android.R.color.holo_green_light) + ); LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false); setLayoutManager(layoutManager); DividerDecoration dividerDecoration = new DividerDecoration(getResources().getColor(R.color.gray_e0), 20, 20, 0); diff --git a/news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java b/module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java similarity index 85% rename from news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java rename to module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java index 7e539cf..4fe1893 100644 --- a/news/src/main/java/com/guiying/news/main/NewsListViewAdapter.java +++ b/module_news/src/main/java/com/guiying/module/news/main/NewsListViewAdapter.java @@ -1,9 +1,11 @@ -package com.guiying.news.main; +package com.guiying.module.news.main; import android.support.v4.view.PagerAdapter; import android.view.View; import android.view.ViewGroup; +import java.text.DateFormat; +import java.util.Calendar; import java.util.List; /** @@ -50,7 +52,10 @@ public CharSequence getPageTitle(int position) { if (mTabList == null) { return null; } - return mTabList.get(position); + Calendar displayDate = Calendar.getInstance(); + displayDate.add(Calendar.DAY_OF_YEAR, -position); + + return DateFormat.getDateInstance().format(displayDate.getTime()); } /** diff --git a/module_news/src/main/java/debug/LauncherActivity.java b/module_news/src/main/java/debug/LauncherActivity.java new file mode 100644 index 0000000..373f765 --- /dev/null +++ b/module_news/src/main/java/debug/LauncherActivity.java @@ -0,0 +1,28 @@ +package debug; + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +import com.guiying.module.news.detail.NewsDetailActivity; + +/** + *组件开发模式下,用于传递数据的启动Activity,集成模式下无效
+ * + * @author 张华洋 + * @version V1.2.0 + * @name LauncherActivity + */ +public class LauncherActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + //在这里传值给需要调试的Activity + Intent intent = new Intent(this, NewsDetailActivity.class); + intent.putExtra("id", "9500116"); + startActivity(intent); + finish(); + } + +} diff --git a/news/src/main/java/debug/NewsApplication.java b/module_news/src/main/java/debug/NewsApplication.java similarity index 75% rename from news/src/main/java/debug/NewsApplication.java rename to module_news/src/main/java/debug/NewsApplication.java index 57057a7..8bcfdcb 100644 --- a/news/src/main/java/debug/NewsApplication.java +++ b/module_news/src/main/java/debug/NewsApplication.java @@ -1,14 +1,13 @@ package debug; -import com.guiying.common.base.BaseApplication; -import com.guiying.common.http.HttpClient; -import com.guiying.common.http.OnResultListener; -import com.guiying.news.Constants; -import com.guiying.news.data.bean.StoryList; +import com.guiying.module.common.base.BaseApplication; +import com.guiying.module.common.http.DataType; +import com.guiying.module.common.http.HttpClient; +import com.guiying.module.common.http.OnResultListener; +import com.guiying.module.news.Constants; +import com.guiying.module.news.data.bean.StoryList; import com.orhanobut.logger.Logger; -import static com.guiying.common.http.HttpClient.OBJECT; - /** *类说明
* @@ -33,7 +32,7 @@ private void login() { HttpClient client = new HttpClient.Builder() .baseUrl(Constants.ZHIHU_DAILY_BEFORE_MESSAGE) .url("20170419") - .bodyType(OBJECT, StoryList.class) + .bodyType(DataType.JSON_OBJECT, StoryList.class) .build(); client.get(new OnResultListener类说明
- * - * @author 张华洋 2017/2/15 16:31 - * @version V1.2.0 - * @name news - */ -@Module("news") -public class News { -} diff --git a/news/src/main/java/com/guiying/news/data/NewsDataSource.java b/news/src/main/java/com/guiying/news/data/NewsDataSource.java deleted file mode 100644 index e13c4a5..0000000 --- a/news/src/main/java/com/guiying/news/data/NewsDataSource.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.guiying.news.data; - -import com.guiying.common.http.InfoCallback; -import com.guiying.news.data.bean.StoryList; - -/** - *类说明
- * - * @author 张华洋 2017/4/20 22:02 - * @version V1.2.0 - * @name NewsDataSource - */ -public interface NewsDataSource { - - - /** - * 获取 - * - * @param date - * @param callback 回调 - */ - void getNewsList(String date, InfoCallback类说明
- * - * @author 张华洋 2017/4/20 23:32 - * @version V1.2.0 - * @name RemoteNewsDataSource - */ -public class RemoteNewsDataSource implements NewsDataSource { - - @Override - public void getNewsList(String date, final InfoCallback