From a12c42c55c3dd49eb20c389d8eb50092bc9aec90 Mon Sep 17 00:00:00 2001
From: panqihua <1029559041@qq.com>
Date: Wed, 25 Mar 2020 02:02:01 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E8=8F=9C=E5=8D=95=E6=A1=86=E6=9E=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/build.gradle | 3 +-
app/src/main/AndroidManifest.xml | 1 +
.../com/community/pocket/ui/BaseFragment.java | 2 +-
.../pocket/ui/login/LoginActivity.java | 4 +-
.../pocket/ui/main/MainFragment.java | 39 +++++++++++++++++++
.../community/pocket/ui/main/MainMenu.java | 32 +++++++++++++++
.../main/ui/dashboard/DashboardFragment.java | 15 +++++++
.../main/ui/dashboard/DashboardViewModel.java | 19 +++++++++
.../pocket/ui/main/ui/home/HomeFragment.java | 15 +++++++
.../pocket/ui/main/ui/home/HomeViewModel.java | 19 +++++++++
.../pocket/ui/main/ui/info/InfoFragment.java | 17 ++++++++
.../pocket/ui/main/ui/info/InfoViewModel.java | 19 +++++++++
.../notifications/NotificationsFragment.java | 16 ++++++++
.../notifications/NotificationsViewModel.java | 19 +++++++++
.../res/drawable/ic_dashboard_black_24dp.xml | 9 +++++
.../main/res/drawable/ic_home_black_24dp.xml | 9 +++++
.../drawable/ic_notifications_black_24dp.xml | 9 +++++
.../layout/main/layout/activity_main_menu.xml | 36 +++++++++++++++++
.../layout/main/layout/fragment_dashboard.xml | 22 +++++++++++
.../res/layout/main/layout/fragment_home.xml | 22 +++++++++++
.../main/layout/fragment_notifications.xml | 22 +++++++++++
.../res/layout/main/layout/info_fragment.xml | 20 ++++++++++
app/src/main/res/menu/bottom_nav_menu.xml | 19 +++++++++
.../main/res/navigation/mobile_navigation.xml | 29 ++++++++++++++
app/src/main/res/values-en-rUS/strings.xml | 4 ++
app/src/main/res/values-zh-rCN/strings.xml | 4 ++
app/src/main/res/values/strings.xml | 4 ++
27 files changed, 426 insertions(+), 3 deletions(-)
create mode 100644 app/src/main/java/com/community/pocket/ui/main/MainFragment.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/MainMenu.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardFragment.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardViewModel.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/home/HomeFragment.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/home/HomeViewModel.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsFragment.java
create mode 100644 app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsViewModel.java
create mode 100644 app/src/main/res/drawable/ic_dashboard_black_24dp.xml
create mode 100644 app/src/main/res/drawable/ic_home_black_24dp.xml
create mode 100644 app/src/main/res/drawable/ic_notifications_black_24dp.xml
create mode 100644 app/src/main/res/layout/main/layout/activity_main_menu.xml
create mode 100644 app/src/main/res/layout/main/layout/fragment_dashboard.xml
create mode 100644 app/src/main/res/layout/main/layout/fragment_home.xml
create mode 100644 app/src/main/res/layout/main/layout/fragment_notifications.xml
create mode 100644 app/src/main/res/layout/main/layout/info_fragment.xml
create mode 100644 app/src/main/res/menu/bottom_nav_menu.xml
create mode 100644 app/src/main/res/navigation/mobile_navigation.xml
diff --git a/app/build.gradle b/app/build.gradle
index debf2a4..4082ecb 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -23,7 +23,7 @@ android {
sourceSets {
main {
res {
- srcDirs 'src/main/res', 'src/main/res/layout/resetpwd', 'src/main/res/layout/resetpwd/layout'
+ srcDirs 'src/main/res', 'src/main/res/layout/resetpwd', 'src/main/res/layout/resetpwd/layout', 'src/main/res/layout/main', 'src/main/res/layout/main/layout'
}
}
}
@@ -40,6 +40,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
+ implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4ef0eaf..e701d7f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -10,6 +10,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
+
diff --git a/app/src/main/java/com/community/pocket/ui/BaseFragment.java b/app/src/main/java/com/community/pocket/ui/BaseFragment.java
index cadb5ba..89ce581 100644
--- a/app/src/main/java/com/community/pocket/ui/BaseFragment.java
+++ b/app/src/main/java/com/community/pocket/ui/BaseFragment.java
@@ -15,7 +15,7 @@ import org.xutils.x;
* 封装初始化xutils逻辑
*/
public abstract class BaseFragment extends Fragment {
- @Nullable
+ @NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return x.view().inject(this, inflater, container);//fragment注解
diff --git a/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java b/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java
index cc6d552..b01d6ec 100644
--- a/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java
+++ b/app/src/main/java/com/community/pocket/ui/login/LoginActivity.java
@@ -21,6 +21,7 @@ import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
import com.community.pocket.ui.BaseActivity;
+import com.community.pocket.ui.main.MainMenu;
import com.community.pocket.ui.register.RegisterActivity;
import com.community.pocket.ui.resetpwd.ResetPwdActivity;
import com.community.pocket.util.PropertiesUtil;
@@ -93,8 +94,9 @@ public class LoginActivity extends BaseActivity {
}
setResult(Activity.RESULT_OK);
+ startActivity(new Intent(getApplicationContext(), MainMenu.class));
//Complete and destroy login activity once successful
-// finish();
+ finish();
}
});
diff --git a/app/src/main/java/com/community/pocket/ui/main/MainFragment.java b/app/src/main/java/com/community/pocket/ui/main/MainFragment.java
new file mode 100644
index 0000000..019afff
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/MainFragment.java
@@ -0,0 +1,39 @@
+package com.community.pocket.ui.main;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.Observer;
+
+import com.community.pocket.ui.BaseFragment;
+
+import org.jetbrains.annotations.NotNull;
+
+public abstract class MainFragment extends BaseFragment {
+
+ @NotNull
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+
+ View root = super.onCreateView(inflater, container, savedInstanceState);
+ final TextView textView = root.findViewById(viewId());
+ MutableLiveData mText = new MutableLiveData<>();
+ mText.setValue(this.getClass().getName());
+ mText.observe(getViewLifecycleOwner(), new Observer() {
+ @Override
+ public void onChanged(@Nullable String s) {
+ textView.setText(s);
+ }
+ });
+
+ return root;
+ }
+
+ protected abstract int viewId();
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/MainMenu.java b/app/src/main/java/com/community/pocket/ui/main/MainMenu.java
new file mode 100644
index 0000000..92b585c
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/MainMenu.java
@@ -0,0 +1,32 @@
+package com.community.pocket.ui.main;
+
+import android.os.Bundle;
+
+import androidx.navigation.NavController;
+import androidx.navigation.Navigation;
+import androidx.navigation.ui.NavigationUI;
+
+import com.community.pocket.R;
+import com.community.pocket.ui.BaseActivity;
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+
+import org.xutils.view.annotation.ContentView;
+import org.xutils.view.annotation.ViewInject;
+
+@ContentView((R.layout.activity_main_menu))
+public class MainMenu extends BaseActivity {
+
+ @ViewInject(R.id.nav_view)
+ private BottomNavigationView navView;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+
+ NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
+ NavigationUI.setupWithNavController(navView, navController);
+ }
+
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardFragment.java
new file mode 100644
index 0000000..7840edc
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardFragment.java
@@ -0,0 +1,15 @@
+package com.community.pocket.ui.main.ui.dashboard;
+
+import com.community.pocket.R;
+import com.community.pocket.ui.main.MainFragment;
+
+import org.xutils.view.annotation.ContentView;
+
+
+@ContentView(R.layout.fragment_dashboard)
+public class DashboardFragment extends MainFragment {
+ @Override
+ protected int viewId() {
+ return R.id.text_dashboard;
+ }
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardViewModel.java
new file mode 100644
index 0000000..f644580
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/dashboard/DashboardViewModel.java
@@ -0,0 +1,19 @@
+package com.community.pocket.ui.main.ui.dashboard;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class DashboardViewModel extends ViewModel {
+
+ private MutableLiveData mText;
+
+ public DashboardViewModel() {
+ mText = new MutableLiveData<>();
+ mText.setValue("This is dashboard fragment");
+ }
+
+ LiveData getText() {
+ return mText;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeFragment.java
new file mode 100644
index 0000000..152cb7d
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeFragment.java
@@ -0,0 +1,15 @@
+package com.community.pocket.ui.main.ui.home;
+
+import com.community.pocket.R;
+import com.community.pocket.ui.main.MainFragment;
+
+import org.xutils.view.annotation.ContentView;
+
+@ContentView(R.layout.fragment_home)
+public class HomeFragment extends MainFragment {
+
+ @Override
+ protected int viewId() {
+ return R.id.text_home;
+ }
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeViewModel.java
new file mode 100644
index 0000000..b92a438
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/home/HomeViewModel.java
@@ -0,0 +1,19 @@
+package com.community.pocket.ui.main.ui.home;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class HomeViewModel extends ViewModel {
+
+ private MutableLiveData mText;
+
+ public HomeViewModel() {
+ mText = new MutableLiveData<>();
+ mText.setValue("This is home fragment");
+ }
+
+ LiveData getText() {
+ return mText;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
new file mode 100644
index 0000000..f5d2aab
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
@@ -0,0 +1,17 @@
+package com.community.pocket.ui.main.ui.info;
+
+import com.community.pocket.R;
+import com.community.pocket.ui.main.MainFragment;
+
+import org.xutils.view.annotation.ContentView;
+
+@ContentView(R.layout.info_fragment)
+public class InfoFragment extends MainFragment {
+
+ @Override
+ protected int viewId() {
+ return R.id.text_info;
+ }
+
+
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java
new file mode 100644
index 0000000..4e7bc2b
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/info/InfoViewModel.java
@@ -0,0 +1,19 @@
+package com.community.pocket.ui.main.ui.info;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+class InfoViewModel extends ViewModel {
+
+ private MutableLiveData mText;
+
+ public InfoViewModel() {
+ mText = new MutableLiveData<>();
+ mText.setValue("This is info fragment");
+ }
+
+ LiveData getText() {
+ return mText;
+ }
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsFragment.java b/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsFragment.java
new file mode 100644
index 0000000..3dba6d2
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsFragment.java
@@ -0,0 +1,16 @@
+package com.community.pocket.ui.main.ui.notifications;
+
+import com.community.pocket.R;
+import com.community.pocket.ui.main.MainFragment;
+
+import org.xutils.view.annotation.ContentView;
+
+
+@ContentView(R.layout.fragment_notifications)
+public class NotificationsFragment extends MainFragment {
+
+ @Override
+ protected int viewId() {
+ return R.id.text_notifications;
+ }
+}
diff --git a/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsViewModel.java b/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsViewModel.java
new file mode 100644
index 0000000..c0c8023
--- /dev/null
+++ b/app/src/main/java/com/community/pocket/ui/main/ui/notifications/NotificationsViewModel.java
@@ -0,0 +1,19 @@
+package com.community.pocket.ui.main.ui.notifications;
+
+import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
+import androidx.lifecycle.ViewModel;
+
+public class NotificationsViewModel extends ViewModel {
+
+ private MutableLiveData mText;
+
+ public NotificationsViewModel() {
+ mText = new MutableLiveData<>();
+ mText.setValue("This is notifications fragment");
+ }
+
+ LiveData getText() {
+ return mText;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_dashboard_black_24dp.xml b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml
new file mode 100644
index 0000000..46fc8de
--- /dev/null
+++ b/app/src/main/res/drawable/ic_dashboard_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_home_black_24dp.xml b/app/src/main/res/drawable/ic_home_black_24dp.xml
new file mode 100644
index 0000000..f8bb0b5
--- /dev/null
+++ b/app/src/main/res/drawable/ic_home_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/ic_notifications_black_24dp.xml b/app/src/main/res/drawable/ic_notifications_black_24dp.xml
new file mode 100644
index 0000000..78b75c3
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notifications_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/main/layout/activity_main_menu.xml b/app/src/main/res/layout/main/layout/activity_main_menu.xml
new file mode 100644
index 0000000..1555ee6
--- /dev/null
+++ b/app/src/main/res/layout/main/layout/activity_main_menu.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/main/layout/fragment_dashboard.xml b/app/src/main/res/layout/main/layout/fragment_dashboard.xml
new file mode 100644
index 0000000..1bfbe37
--- /dev/null
+++ b/app/src/main/res/layout/main/layout/fragment_dashboard.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/main/layout/fragment_home.xml b/app/src/main/res/layout/main/layout/fragment_home.xml
new file mode 100644
index 0000000..e4bb13e
--- /dev/null
+++ b/app/src/main/res/layout/main/layout/fragment_home.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/main/layout/fragment_notifications.xml b/app/src/main/res/layout/main/layout/fragment_notifications.xml
new file mode 100644
index 0000000..1719248
--- /dev/null
+++ b/app/src/main/res/layout/main/layout/fragment_notifications.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/main/layout/info_fragment.xml b/app/src/main/res/layout/main/layout/info_fragment.xml
new file mode 100644
index 0000000..46f0c0b
--- /dev/null
+++ b/app/src/main/res/layout/main/layout/info_fragment.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml
new file mode 100644
index 0000000..8511171
--- /dev/null
+++ b/app/src/main/res/menu/bottom_nav_menu.xml
@@ -0,0 +1,19 @@
+
+
diff --git a/app/src/main/res/navigation/mobile_navigation.xml b/app/src/main/res/navigation/mobile_navigation.xml
new file mode 100644
index 0000000..f9442df
--- /dev/null
+++ b/app/src/main/res/navigation/mobile_navigation.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml
index 25d931c..4f4d7dc 100644
--- a/app/src/main/res/values-en-rUS/strings.xml
+++ b/app/src/main/res/values-en-rUS/strings.xml
@@ -26,4 +26,8 @@
Next
Previous
send code
+ Forum
+ Visitor
+ Recycle
+ MyInformation
\ No newline at end of file
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 60fb858..9864195 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -26,4 +26,8 @@
下一步
上一步
发送验证码
+ 论坛
+ 访客管理
+ 垃圾上门回收
+ 我的信息
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a8f3b83..7259d32 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -27,6 +27,10 @@
Next
Previous
send code
+ Forum
+ Visitor
+ Recycle
+ MyInformation