Browse Source

1、删除组件中的style文件,保持UI统一;
2、在主工程的Application中声明所有组件;

guiying712 8 years ago
parent
commit
dfefb5f620

+ 5 - 2
Girls/src/main/java/com/guiying/girls/GirlsActivity.java

@@ -1,9 +1,12 @@
 package com.guiying.girls;
 package com.guiying.girls;
 
 
-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.os.Bundle;
 
 
-public class GirlsActivity extends AppCompatActivity {
+import com.github.mzule.activityrouter.annotation.Router;
+import com.guiying.common.base.BaseActivity;
+
+@Router("girls")
+public class GirlsActivity extends BaseActivity {
 
 
     @Override
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {

+ 0 - 4
Girls/src/main/res/layout/activity_girls.xml

@@ -2,10 +2,6 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_girls"
     xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_girls"
     android:layout_width="match_parent" android:layout_height="match_parent"
     android:layout_width="match_parent" android:layout_height="match_parent"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="com.guiying.girls.GirlsActivity">
     tools:context="com.guiying.girls.GirlsActivity">
 
 
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"

+ 0 - 6
Girls/src/main/res/values-w820dp/dimens.xml

@@ -1,6 +0,0 @@
-<resources>
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
-         (such as screen margins) for screens with more than 820dp of available width. This
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
-    <dimen name="activity_horizontal_margin">64dp</dimen>
-</resources>

+ 1 - 3
Girls/src/main/res/values/colors.xml

@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <resources>
-    <color name="colorPrimary">#3F51B5</color>
-    <color name="colorPrimaryDark">#303F9F</color>
-    <color name="colorAccent">#FF4081</color>
+
 </resources>
 </resources>

+ 1 - 2
Girls/src/main/res/values/dimens.xml

@@ -1,5 +1,4 @@
 <resources>
 <resources>
     <!-- Default screen margins, per the Android Design guidelines. -->
     <!-- Default screen margins, per the Android Design guidelines. -->
-    <dimen name="activity_horizontal_margin">16dp</dimen>
-    <dimen name="activity_vertical_margin">16dp</dimen>
+
 </resources>
 </resources>

+ 0 - 11
Girls/src/main/res/values/styles.xml

@@ -1,11 +0,0 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
-        <!-- Customize your theme here. -->
-        <item name="colorPrimary">@color/colorPrimary</item>
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
-        <item name="colorAccent">@color/colorAccent</item>
-    </style>
-
-</resources>

+ 5 - 2
News/src/main/java/com/guiying/news/NewsActivity.java

@@ -1,9 +1,12 @@
 package com.guiying.news;
 package com.guiying.news;
 
 
-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.os.Bundle;
 
 
-public class NewsActivity extends AppCompatActivity {
+import com.github.mzule.activityrouter.annotation.Router;
+import com.guiying.common.base.BaseActivity;
+
+@Router("news")
+public class NewsActivity extends BaseActivity {
 
 
     @Override
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {

+ 0 - 4
News/src/main/res/layout/activity_news.xml

@@ -2,10 +2,6 @@
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_news"
     xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_news"
     android:layout_width="match_parent" android:layout_height="match_parent"
     android:layout_width="match_parent" android:layout_height="match_parent"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="com.guiying.news.NewsActivity">
     tools:context="com.guiying.news.NewsActivity">
 
 
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
     <TextView android:layout_width="wrap_content" android:layout_height="wrap_content"

+ 0 - 6
News/src/main/res/values-w820dp/dimens.xml

@@ -1,6 +0,0 @@
-<resources>
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
-         (such as screen margins) for screens with more than 820dp of available width. This
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
-    <dimen name="activity_horizontal_margin">64dp</dimen>
-</resources>

+ 1 - 3
News/src/main/res/values/colors.xml

@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <resources>
-    <color name="colorPrimary">#3F51B5</color>
-    <color name="colorPrimaryDark">#303F9F</color>
-    <color name="colorAccent">#FF4081</color>
+
 </resources>
 </resources>

+ 1 - 2
News/src/main/res/values/dimens.xml

@@ -1,5 +1,4 @@
 <resources>
 <resources>
     <!-- Default screen margins, per the Android Design guidelines. -->
     <!-- Default screen margins, per the Android Design guidelines. -->
-    <dimen name="activity_horizontal_margin">16dp</dimen>
-    <dimen name="activity_vertical_margin">16dp</dimen>
+
 </resources>
 </resources>

+ 0 - 11
News/src/main/res/values/styles.xml

@@ -1,11 +0,0 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
-        <!-- Customize your theme here. -->
-        <item name="colorPrimary">@color/colorPrimary</item>
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
-        <item name="colorAccent">@color/colorAccent</item>
-    </style>
-
-</resources>

+ 13 - 0
app/src/main/AndroidManifest.xml

@@ -9,6 +9,19 @@
         android:label="@string/app_name"
         android:label="@string/app_name"
         android:supportsRtl="true"
         android:supportsRtl="true"
         android:theme="@style/AppTheme">
         android:theme="@style/AppTheme">
+        <activity
+            android:name="com.github.mzule.activityrouter.router.RouterActivity"
+            android:theme="@android:style/Theme.NoDisplay">
+            <intent-filter>
+                <action android:name="android.intent.action.VIEW" />
+
+                <category android:name="android.intent.category.DEFAULT" />
+                <category android:name="android.intent.category.BROWSABLE" />
+
+                <data android:scheme="@string/global_scheme" /> <!-- 改成自己的scheme -->
+            </intent-filter>
+        </activity>
+
         <activity android:name=".MainActivity">
         <activity android:name=".MainActivity">
             <intent-filter>
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <action android:name="android.intent.action.MAIN" />

+ 15 - 0
app/src/main/java/com/guiying/androidmodulepattern/AppModule.java

@@ -0,0 +1,15 @@
+package com.guiying.androidmodulepattern;
+
+import com.github.mzule.activityrouter.annotation.Module;
+
+/**
+ * <p>类说明</p>
+ *
+ * @author 张华洋 2017/2/15 20:42
+ * @version V1.2.0
+ * @name AppModule
+ */
+
+@Module("app")
+public class AppModule {
+}

+ 23 - 2
app/src/main/java/com/guiying/androidmodulepattern/MainActivity.java

@@ -1,13 +1,34 @@
 package com.guiying.androidmodulepattern;
 package com.guiying.androidmodulepattern;
 
 
-import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
 
 
-public class MainActivity extends AppCompatActivity {
+import com.github.mzule.activityrouter.router.Routers;
+import com.guiying.common.base.BaseActivity;
+
+public class MainActivity extends BaseActivity implements View.OnClickListener {
+
+    protected Button newsButton;
+    protected Button girlsButton;
 
 
     @Override
     @Override
     protected void onCreate(Bundle savedInstanceState) {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
         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");
+        }
     }
     }
+
 }
 }

+ 2 - 0
app/src/main/java/com/guiying/androidmodulepattern/MyApplication.java

@@ -1,5 +1,6 @@
 package com.guiying.androidmodulepattern;
 package com.guiying.androidmodulepattern;
 
 
+import com.github.mzule.activityrouter.annotation.Modules;
 import com.guiying.common.base.BaseApplication;
 import com.guiying.common.base.BaseApplication;
 
 
 /**
 /**
@@ -9,6 +10,7 @@ import com.guiying.common.base.BaseApplication;
  * @version V1.2.0
  * @version V1.2.0
  * @name MyApplication
  * @name MyApplication
  */
  */
+@Modules({"app", "girls", "news"})
 public class MyApplication extends BaseApplication {
 public class MyApplication extends BaseApplication {
 
 
     @Override
     @Override

+ 13 - 5
app/src/main/res/layout/activity_main.xml

@@ -1,17 +1,25 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/activity_main"
     android:id="@+id/activity_main"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
+    android:orientation="vertical"
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="com.guiying.androidmodulepattern.MainActivity">
     tools:context="com.guiying.androidmodulepattern.MainActivity">
 
 
-    <TextView
-        android:layout_width="wrap_content"
+    <Button
+        android:id="@+id/news_button"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
-        android:text="Hello World!" />
-</RelativeLayout>
+        android:text="News" />
+
+    <Button
+        android:id="@+id/girls_button"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Girls" />
+</LinearLayout>

+ 0 - 6
app/src/main/res/values-w820dp/dimens.xml

@@ -1,6 +0,0 @@
-<resources>
-    <!-- Example customization of dimensions originally defined in res/values/dimens.xml
-         (such as screen margins) for screens with more than 820dp of available width. This
-         would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
-    <dimen name="activity_horizontal_margin">64dp</dimen>
-</resources>

+ 1 - 3
app/src/main/res/values/colors.xml

@@ -1,6 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
 <resources>
-    <color name="colorPrimary">#3F51B5</color>
-    <color name="colorPrimaryDark">#303F9F</color>
-    <color name="colorAccent">#FF4081</color>
+
 </resources>
 </resources>

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -1,3 +1,5 @@
 <resources>
 <resources>
     <string name="app_name">AndroidModulePattern</string>
     <string name="app_name">AndroidModulePattern</string>
+
+    <string name="global_scheme">module</string>
 </resources>
 </resources>

+ 0 - 11
app/src/main/res/values/styles.xml

@@ -1,11 +0,0 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
-        <!-- Customize your theme here. -->
-        <item name="colorPrimary">@color/colorPrimary</item>
-        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
-        <item name="colorAccent">@color/colorAccent</item>
-    </style>
-
-</resources>