-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit
- Loading branch information
Showing
123 changed files
with
1,142 additions
and
446 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/src/main/java/com/goldze/component/ui/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.goldze.component.ui; | ||
|
||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.app.FragmentTransaction; | ||
import android.support.v4.content.ContextCompat; | ||
|
||
import com.alibaba.android.arouter.facade.annotation.Route; | ||
import com.alibaba.android.arouter.launcher.ARouter; | ||
import com.goldze.base.router.RouterActivityPath; | ||
import com.goldze.base.router.RouterFragmentPath; | ||
import com.goldze.component.R; | ||
import com.goldze.component.BR; | ||
import com.goldze.component.databinding.ActivityMainBinding; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import me.goldze.mvvmhabit.base.BaseActivity; | ||
import me.goldze.mvvmhabit.base.BaseViewModel; | ||
import me.majiajie.pagerbottomtabstrip.NavigationController; | ||
import me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener; | ||
|
||
/** | ||
* Created by goldze on 2018/6/21 | ||
*/ | ||
@Route(path = RouterActivityPath.App.APP_MAIN) | ||
public class MainActivity extends BaseActivity<ActivityMainBinding, BaseViewModel> { | ||
private List<Fragment> mFragments; | ||
|
||
@Override | ||
public int initContentView(Bundle savedInstanceState) { | ||
return R.layout.activity_main; | ||
} | ||
|
||
@Override | ||
public int initVariableId() { | ||
return BR.viewModel; | ||
} | ||
|
||
@Override | ||
public void initData() { | ||
//初始化Fragment | ||
initFragment(); | ||
//初始化底部Button | ||
initBottomTab(); | ||
} | ||
|
||
private void initFragment() { | ||
//ARouter拿到多Fragment(这里需要通过ARouter获取,不能直接new,因为在组件独立运行时,宿主app是没有依赖其他组件,所以new不到其他组件的Fragment) | ||
Fragment homeFragment = (Fragment) ARouter.getInstance().build(RouterFragmentPath.Home.HOME_HOME).navigation(); | ||
Fragment workFragment = (Fragment) ARouter.getInstance().build(RouterFragmentPath.Work.WORK_WORK).navigation(); | ||
Fragment msgFragment = (Fragment) ARouter.getInstance().build(RouterFragmentPath.Msg.MSG_MSG).navigation(); | ||
Fragment meFragment = (Fragment) ARouter.getInstance().build(RouterFragmentPath.User.USER_ME).navigation(); | ||
mFragments = new ArrayList<>(); | ||
mFragments.add(homeFragment); | ||
mFragments.add(workFragment); | ||
mFragments.add(msgFragment); | ||
mFragments.add(meFragment); | ||
if (homeFragment != null) { | ||
//默认选中第一个 | ||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); | ||
transaction.add(R.id.frameLayout, homeFragment); | ||
transaction.commitAllowingStateLoss(); | ||
} | ||
} | ||
|
||
private void initBottomTab() { | ||
NavigationController navigationController = binding.pagerBottomTab.material() | ||
.addItem(R.mipmap.yingyong, "首页") | ||
.addItem(R.mipmap.huanzhe, "工作") | ||
.addItem(R.mipmap.xiaoxi_select, "消息") | ||
.addItem(R.mipmap.wode_select, "我的") | ||
.setDefaultColor(ContextCompat.getColor(this, R.color.textColorVice)) | ||
.build(); | ||
//底部按钮的点击事件监听 | ||
navigationController.addTabItemSelectedListener(new OnTabItemSelectedListener() { | ||
@Override | ||
public void onSelected(int index, int old) { | ||
Fragment currentFragment = mFragments.get(index); | ||
if (currentFragment != null) { | ||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); | ||
transaction.replace(R.id.frameLayout, currentFragment); | ||
transaction.commitAllowingStateLoss(); | ||
} | ||
} | ||
|
||
@Override | ||
public void onRepeat(int index) { | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
library-base/src/main/java/com/goldze/base/contract/_Login.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.goldze.base.contract; | ||
|
||
/** | ||
* 登录完成后,组件间通信的契约类 | ||
* Created by goldze on 2018/6/21. | ||
*/ | ||
|
||
public class _Login { | ||
private String userName; | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
|
||
public void setUserName(String userName) { | ||
this.userName = userName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
library-base/src/main/java/com/goldze/base/global/SPKeyGlobal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.goldze.base.global; | ||
|
||
/** | ||
* 全局SharedPreferences Key 统一存放在这里,单个组件中的key可以另外在组件中定义 | ||
* Created by goldze on 2018/6/21 0021. | ||
*/ | ||
public class SPKeyGlobal { | ||
public static final String USER_INFO = "user_info"; | ||
} |
33 changes: 33 additions & 0 deletions
33
library-base/src/main/java/com/goldze/base/router/RouterActivityPath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.goldze.base.router; | ||
|
||
/** | ||
* 用于组件开发中,ARouter单Activity跳转的统一路径注册 | ||
* 在这里注册添加路由路径,需要清楚的写好注释,标明功能界面 | ||
* Created by goldze on 2018/6/21 | ||
*/ | ||
|
||
public class RouterActivityPath { | ||
/** | ||
* 宿主组件 | ||
*/ | ||
public static class App { | ||
/*主界面*/ | ||
public static final String APP_MAIN = "/app/Main"; | ||
} | ||
|
||
/** | ||
* 身份验证组件 | ||
*/ | ||
public static class Sign { | ||
/*登录界面*/ | ||
public static final String SIGN_LOGIN = "/sign/Login"; | ||
} | ||
|
||
/** | ||
* 用户组件 | ||
*/ | ||
public static class User { | ||
/*用户详情*/ | ||
public static final String USER_USERDETAIL = "/user/UserDetail"; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
library-base/src/main/java/com/goldze/base/router/RouterFragmentPath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.goldze.base.router; | ||
|
||
/** | ||
* 用于组件开发中,ARouter多Fragment跳转的统一路径注册 | ||
* 在这里注册添加路由路径,需要清楚的写好注释,标明功能界面 | ||
* Created by goldze on 2018/6/21 | ||
*/ | ||
|
||
public class RouterFragmentPath { | ||
/** | ||
* 首页组件 | ||
*/ | ||
public static class Home { | ||
/*首页*/ | ||
public static final String HOME_HOME = "/home/Home"; | ||
} | ||
|
||
/** | ||
* 工作组件 | ||
*/ | ||
public static class Work { | ||
/*工作*/ | ||
public static final String WORK_WORK = "/work/Work"; | ||
} | ||
/** | ||
* 消息组件 | ||
*/ | ||
public static class Msg { | ||
/*消息*/ | ||
public static final String MSG_MSG = "/msg/Msg"; | ||
} | ||
/** | ||
* 用户组件 | ||
*/ | ||
public static class User { | ||
/*我的*/ | ||
public static final String USER_ME = "/user/Me"; | ||
} | ||
} |
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.