tagList = mTagKeyMap.get(mActivityName);
1208 | if (tagList != null && tagList.size() > 0) {
1209 | for (String tag : tagList) {
1210 | mTagMap.remove(tag);
1211 | }
1212 | mTagKeyMap.remove(mActivityName);
1213 | }
1214 | if (mFragmentList.size() > 0) {
1215 | for (String name : mFragmentList) {
1216 | if (name.contains(mActivityName))
1217 | mMap.remove(name);
1218 | }
1219 | }
1220 | mMap.remove(mActivityName);
1221 | }
1222 | }
1223 |
1224 | /**
1225 | * 初始化状态栏和导航栏
1226 | */
1227 | private void initBar() {
1228 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1229 | int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE; //防止系统栏隐藏时内容区域大小发生变化
1230 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !OSUtils.isEMUI3_1()) {
1231 | uiFlags = initBarAboveLOLLIPOP(uiFlags); //初始化5.0以上,包含5.0
1232 | uiFlags = setStatusBarDarkFont(uiFlags); //android 6.0以上设置状态栏字体为暗色
1233 | supportActionBar();
1234 | } else {
1235 | initBarBelowLOLLIPOP(); //初始化5.0以下,4.4以上沉浸式
1236 | solveNavigation(); //解决android4.4有导航栏的情况下,activity底部被导航栏遮挡的问题和android 5.0以下解决状态栏和布局重叠问题
1237 | }
1238 | uiFlags = hideBar(uiFlags); //隐藏状态栏或者导航栏
1239 | mWindow.getDecorView().setSystemUiVisibility(uiFlags);
1240 | }
1241 | if (OSUtils.isMIUI6More())
1242 | setMIUIStatusBarDarkFont(mWindow, mBarParams.darkFont); //修改miui状态栏字体颜色
1243 | if (OSUtils.isFlymeOS4More()) { // 修改Flyme OS状态栏字体颜色
1244 | if (mBarParams.flymeOSStatusBarFontColor != 0) {
1245 | FlymeOSStatusBarFontUtils.setStatusBarDarkIcon(mActivity, mBarParams.flymeOSStatusBarFontColor);
1246 | } else {
1247 | FlymeOSStatusBarFontUtils.setStatusBarDarkIcon(mActivity, mBarParams.darkFont);
1248 | }
1249 | }
1250 | }
1251 |
1252 | /**
1253 | * 初始化android 5.0以上状态栏和导航栏
1254 | *
1255 | * @param uiFlags the ui flags
1256 | * @return the int
1257 | */
1258 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
1259 | private int initBarAboveLOLLIPOP(int uiFlags) {
1260 | uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; //Activity全屏显示,但状态栏不会被隐藏覆盖,状态栏依然可见,Activity顶端布局部分会被状态栏遮住。
1261 | if (mBarParams.fullScreen && mBarParams.navigationBarEnable) {
1262 | uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; //Activity全屏显示,但导航栏不会被隐藏覆盖,导航栏依然可见,Activity底部布局部分会被导航栏遮住。
1263 | }
1264 | mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
1265 | if (mConfig.hasNavigtionBar()) { //判断是否存在导航栏
1266 | mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
1267 | }
1268 | mWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //需要设置这个才能设置状态栏颜色
1269 | if (mBarParams.statusBarFlag)
1270 | mWindow.setStatusBarColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
1271 | mBarParams.statusBarColorTransform, mBarParams.statusBarAlpha)); //设置状态栏颜色
1272 | else
1273 | mWindow.setStatusBarColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
1274 | Color.TRANSPARENT, mBarParams.statusBarAlpha)); //设置状态栏颜色
1275 | if (mBarParams.navigationBarEnable)
1276 | mWindow.setNavigationBarColor(ColorUtils.blendARGB(mBarParams.navigationBarColor,
1277 | mBarParams.navigationBarColorTransform, mBarParams.navigationBarAlpha)); //设置导航栏颜色
1278 | return uiFlags;
1279 | }
1280 |
1281 | /**
1282 | * 初始化android 4.4和emui3.1状态栏和导航栏
1283 | */
1284 | private void initBarBelowLOLLIPOP() {
1285 | mWindow.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);//透明状态栏
1286 | setupStatusBarView(); //创建一个假的状态栏
1287 | if (mConfig.hasNavigtionBar()) { //判断是否存在导航栏,是否禁止设置导航栏
1288 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable)
1289 | mWindow.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);//透明导航栏,设置这个,如果有导航栏,底部布局会被导航栏遮住
1290 | else
1291 | mWindow.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
1292 | setupNavBarView(); //创建一个假的导航栏
1293 | }
1294 | }
1295 |
1296 | /**
1297 | * 设置一个可以自定义颜色的状态栏
1298 | */
1299 | private void setupStatusBarView() {
1300 | if (mBarParams.statusBarView == null) {
1301 | mBarParams.statusBarView = new View(mActivity);
1302 | }
1303 | FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mConfig.getStatusBarHeight());
1304 | params.gravity = Gravity.TOP;
1305 | mBarParams.statusBarView.setLayoutParams(params);
1306 | if (mBarParams.statusBarFlag)
1307 | mBarParams.statusBarView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
1308 | mBarParams.statusBarColorTransform, mBarParams.statusBarAlpha));
1309 | else
1310 | mBarParams.statusBarView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.statusBarColor,
1311 | Color.TRANSPARENT, mBarParams.statusBarAlpha));
1312 | mBarParams.statusBarView.setVisibility(View.VISIBLE);
1313 | ViewGroup viewGroup = (ViewGroup) mBarParams.statusBarView.getParent();
1314 | if (viewGroup != null)
1315 | viewGroup.removeView(mBarParams.statusBarView);
1316 | mViewGroup.addView(mBarParams.statusBarView);
1317 | }
1318 |
1319 | /**
1320 | * 设置一个可以自定义颜色的导航栏
1321 | */
1322 | private void setupNavBarView() {
1323 | if (mBarParams.navigationBarView == null) {
1324 | mBarParams.navigationBarView = new View(mActivity);
1325 | }
1326 | FrameLayout.LayoutParams params;
1327 | if (mConfig.isNavigationAtBottom()) {
1328 | params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, mConfig.getNavigationBarHeight());
1329 | params.gravity = Gravity.BOTTOM;
1330 | } else {
1331 | params = new FrameLayout.LayoutParams(mConfig.getNavigationBarWidth(), FrameLayout.LayoutParams.MATCH_PARENT);
1332 | params.gravity = Gravity.END;
1333 | }
1334 | mBarParams.navigationBarView.setLayoutParams(params);
1335 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
1336 | if (!mBarParams.fullScreen && (mBarParams.navigationBarColorTransform == Color.TRANSPARENT)) {
1337 | mBarParams.navigationBarView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.navigationBarColor,
1338 | Color.BLACK, mBarParams.navigationBarAlpha));
1339 | } else {
1340 | mBarParams.navigationBarView.setBackgroundColor(ColorUtils.blendARGB(mBarParams.navigationBarColor,
1341 | mBarParams.navigationBarColorTransform, mBarParams.navigationBarAlpha));
1342 | }
1343 | } else
1344 | mBarParams.navigationBarView.setBackgroundColor(Color.TRANSPARENT);
1345 | mBarParams.navigationBarView.setVisibility(View.VISIBLE);
1346 | ViewGroup viewGroup = (ViewGroup) mBarParams.navigationBarView.getParent();
1347 | if (viewGroup != null)
1348 | viewGroup.removeView(mBarParams.navigationBarView);
1349 | mViewGroup.addView(mBarParams.navigationBarView);
1350 | }
1351 |
1352 | /**
1353 | * 解决安卓4.4和EMUI3.1导航栏与状态栏的问题,以及系统属性fitsSystemWindows的坑
1354 | */
1355 | private void solveNavigation() {
1356 | boolean systemWindows = false;
1357 | if (mContentView.getChildCount() != 0) {
1358 | //判断当前布局根节点是否使用android:fitsSystemWindows="true"属性
1359 | //但是目前发现如果根节点是DrawerLayout不起作用,所以系统fitsSystemWindows属性还是慎用吧
1360 | systemWindows = mContentView.getChildAt(0).getFitsSystemWindows();
1361 | }
1362 | if (systemWindows || mBarParams.fixMarginAtBottom)
1363 | mContentView.setPadding(0, 0, 0, 0);
1364 | else {
1365 | // 解决android4.4有导航栏的情况下,activity底部被导航栏遮挡的问题
1366 | if (mConfig.hasNavigtionBar() && !mBarParams.fullScreenTemp && !mBarParams.fullScreen) {
1367 | if (mConfig.isNavigationAtBottom()) { //判断导航栏是否在底部
1368 | if (!mBarParams.isSupportActionBar) { //判断是否支持actionBar
1369 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
1370 | if (mBarParams.fits)
1371 | mContentView.setPadding(0, mConfig.getStatusBarHeight(),
1372 | 0, mConfig.getNavigationBarHeight()); //有导航栏,获得rootView的根节点,然后设置距离底部的padding值为导航栏的高度值
1373 | else
1374 | mContentView.setPadding(0, 0, 0, mConfig.getNavigationBarHeight());
1375 | } else {
1376 | if (mBarParams.fits)
1377 | mContentView.setPadding(0, mConfig.getStatusBarHeight(),
1378 | 0, 0);
1379 | else
1380 | mContentView.setPadding(0, 0, 0, 0);
1381 | }
1382 | } else {
1383 | //支持有actionBar的界面
1384 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable)
1385 | mContentView.setPadding(0, mConfig.getStatusBarHeight() +
1386 | mConfig.getActionBarHeight() + 10, 0, mConfig.getNavigationBarHeight());
1387 | else
1388 | mContentView.setPadding(0, mConfig.getStatusBarHeight() +
1389 | mConfig.getActionBarHeight() + 10, 0, 0);
1390 | }
1391 | } else {
1392 | if (!mBarParams.isSupportActionBar) {
1393 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable) {
1394 | if (mBarParams.fits)
1395 | mContentView.setPadding(0, mConfig.getStatusBarHeight(),
1396 | mConfig.getNavigationBarWidth(), 0); //不在底部,设置距离右边的padding值为导航栏的宽度值
1397 | else
1398 | mContentView.setPadding(0, 0, mConfig.getNavigationBarWidth(), 0);
1399 | } else {
1400 | if (mBarParams.fits)
1401 | mContentView.setPadding(0, mConfig.getStatusBarHeight(),
1402 | 0, 0);
1403 | else
1404 | mContentView.setPadding(0, 0, 0, 0);
1405 | }
1406 | } else {
1407 | //支持有actionBar的界面
1408 | if (mBarParams.navigationBarEnable && mBarParams.navigationBarWithKitkatEnable)
1409 | mContentView.setPadding(0, mConfig.getStatusBarHeight() +
1410 | mConfig.getActionBarHeight() + 10, mConfig.getNavigationBarWidth(), 0);
1411 | else
1412 | mContentView.setPadding(0, mConfig.getStatusBarHeight() +
1413 | mConfig.getActionBarHeight() + 10, 0, 0);
1414 | }
1415 | }
1416 | } else {
1417 | if (!mBarParams.isSupportActionBar) {
1418 | if (mBarParams.fits)
1419 | mContentView.setPadding(0, mConfig.getStatusBarHeight(), 0, 0);
1420 | else
1421 | mContentView.setPadding(0, 0, 0, 0);
1422 | } else {
1423 | //支持有actionBar的界面
1424 | mContentView.setPadding(0, mConfig.getStatusBarHeight() + mConfig.getActionBarHeight() + 10, 0, 0);
1425 | }
1426 | }
1427 | }
1428 | }
1429 |
1430 | /**
1431 | * Hide bar.
1432 | * 隐藏或显示状态栏和导航栏。
1433 | *
1434 | * @param uiFlags the ui flags
1435 | * @return the int
1436 | */
1437 |
1438 | private int hideBar(int uiFlags) {
1439 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
1440 | switch (mBarParams.barHide) {
1441 | case FLAG_HIDE_BAR:
1442 | uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
1443 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
1444 | | View.INVISIBLE;
1445 | break;
1446 | case FLAG_HIDE_STATUS_BAR:
1447 | uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.INVISIBLE;
1448 | break;
1449 | case FLAG_HIDE_NAVIGATION_BAR:
1450 | uiFlags |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
1451 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
1452 | break;
1453 | case FLAG_SHOW_BAR:
1454 | uiFlags |= View.SYSTEM_UI_FLAG_VISIBLE;
1455 | break;
1456 | }
1457 | }
1458 | return uiFlags | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
1459 | }
1460 |
1461 | /**
1462 | * Sets status bar dark font.
1463 | * 设置状态栏字体颜色,android6.0以上
1464 | */
1465 | private int setStatusBarDarkFont(int uiFlags) {
1466 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && mBarParams.darkFont) {
1467 | return uiFlags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
1468 | } else {
1469 | return uiFlags;
1470 | }
1471 | }
1472 |
1473 | /**
1474 | * 变色view
1475 | *
1476 | * Transform view.
1477 | */
1478 | private void transformView() {
1479 | if (mBarParams.viewMap.size() != 0) {
1480 | Set>> entrySet = mBarParams.viewMap.entrySet();
1481 | for (Map.Entry> entry : entrySet) {
1482 | View view = entry.getKey();
1483 | Map map = entry.getValue();
1484 | Integer colorBefore = mBarParams.statusBarColor;
1485 | Integer colorAfter = mBarParams.statusBarColorTransform;
1486 | for (Map.Entry integerEntry : map.entrySet()) {
1487 | colorBefore = integerEntry.getKey();
1488 | colorAfter = integerEntry.getValue();
1489 | }
1490 | if (view != null) {
1491 | if (Math.abs(mBarParams.viewAlpha - 0.0f) == 0)
1492 | view.setBackgroundColor(ColorUtils.blendARGB(colorBefore, colorAfter, mBarParams.statusBarAlpha));
1493 | else
1494 | view.setBackgroundColor(ColorUtils.blendARGB(colorBefore, colorAfter, mBarParams.viewAlpha));
1495 | }
1496 | }
1497 | }
1498 | }
1499 |
1500 |
1501 | /**
1502 | * 通过状态栏高度动态设置状态栏布局
1503 | */
1504 | private void setStatusBarView() {
1505 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && mBarParams.statusBarViewByHeight != null) {
1506 | ViewGroup.LayoutParams params = mBarParams.statusBarViewByHeight.getLayoutParams();
1507 | params.height = mConfig.getStatusBarHeight();
1508 | mBarParams.statusBarViewByHeight.setLayoutParams(params);
1509 | }
1510 | }
1511 |
1512 | /**
1513 | * 重新绘制标题栏高度,解决状态栏与顶部重叠问题
1514 | * Sets title bar.
1515 | */
1516 | private void setTitleBar() {
1517 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && mBarParams.titleBarView != null) {
1518 | ViewGroup.LayoutParams layoutParams = mBarParams.titleBarView.getLayoutParams();
1519 | if (mBarParams.titleBarHeight == 0)
1520 | mBarParams.titleBarHeight = layoutParams.height + mConfig.getStatusBarHeight();
1521 | if (mBarParams.titleBarPaddingTopHeight == 0)
1522 | mBarParams.titleBarPaddingTopHeight = mBarParams.titleBarView.getPaddingTop()
1523 | + mConfig.getStatusBarHeight();
1524 | layoutParams.height = mBarParams.titleBarHeight;
1525 | mBarParams.titleBarView.setPadding(mBarParams.titleBarView.getPaddingLeft(),
1526 | mBarParams.titleBarPaddingTopHeight,
1527 | mBarParams.titleBarView.getPaddingRight(),
1528 | mBarParams.titleBarView.getPaddingBottom());
1529 | mBarParams.titleBarView.setLayoutParams(layoutParams);
1530 | }
1531 | }
1532 |
1533 | /**
1534 | * 支持actionBar的界面
1535 | * Support action bar.
1536 | */
1537 | private void supportActionBar() {
1538 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !OSUtils.isEMUI3_1()) {
1539 | if (mBarParams.isSupportActionBar) {
1540 | mContentView.setPadding(0, mConfig.getStatusBarHeight() + mConfig.getActionBarHeight(), 0, 0);
1541 | } else {
1542 | if (mBarParams.fits)
1543 | mContentView.setPadding(0, mConfig.getStatusBarHeight(), 0, 0);
1544 | else
1545 | mContentView.setPadding(0, 0, 0, 0);
1546 | }
1547 | }
1548 | }
1549 |
1550 | /**
1551 | * 解决底部输入框与软键盘问题
1552 | * Keyboard enable.
1553 | */
1554 | private void keyboardEnable() {
1555 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1556 | if (mBarParams.keyboardEnable) { //解决软键盘与底部输入框冲突问题
1557 | KeyboardPatch.patch(mActivity).enable(mBarParams.keyboardMode);
1558 | } else {
1559 | KeyboardPatch.patch(mActivity).disable(mBarParams.keyboardMode);
1560 | }
1561 | }
1562 | }
1563 |
1564 | /**
1565 | * 设置状态栏字体图标为深色,需要MIUIV6以上
1566 | *
1567 | * @return boolean 成功执行返回true
1568 | */
1569 | private static void setMIUIStatusBarDarkFont(Window window, boolean darkFont) {
1570 | if (window != null) {
1571 | Class clazz = window.getClass();
1572 | try {
1573 | int darkModeFlag;
1574 | Class layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
1575 | Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
1576 | darkModeFlag = field.getInt(layoutParams);
1577 | Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
1578 | if (darkFont) {
1579 | extraFlagField.invoke(window, darkModeFlag, darkModeFlag);//状态栏透明且黑色字体
1580 | } else {
1581 | extraFlagField.invoke(window, 0, darkModeFlag);//清除黑色字体
1582 | }
1583 | } catch (Exception e) {
1584 | e.printStackTrace();
1585 | }
1586 | }
1587 | }
1588 |
1589 | /**
1590 | * Has navigtion bar boolean.
1591 | * 判断是否存在导航栏
1592 | *
1593 | * @param activity the activity
1594 | * @return the boolean
1595 | */
1596 | @TargetApi(14)
1597 | public static boolean hasNavigationBar(Activity activity) {
1598 | BarConfig config = new BarConfig(activity);
1599 | return config.hasNavigtionBar();
1600 | }
1601 |
1602 | /**
1603 | * Gets navigation bar height.
1604 | * 获得导航栏的高度
1605 | *
1606 | * @param activity the activity
1607 | * @return the navigation bar height
1608 | */
1609 | @TargetApi(14)
1610 | public static int getNavigationBarHeight(Activity activity) {
1611 | BarConfig config = new BarConfig(activity);
1612 | return config.getNavigationBarHeight();
1613 | }
1614 |
1615 | /**
1616 | * Gets navigation bar width.
1617 | * 获得导航栏的宽度
1618 | *
1619 | * @param activity the activity
1620 | * @return the navigation bar width
1621 | */
1622 | @TargetApi(14)
1623 | public static int getNavigationBarWidth(Activity activity) {
1624 | BarConfig config = new BarConfig(activity);
1625 | return config.getNavigationBarWidth();
1626 | }
1627 |
1628 | /**
1629 | * Is navigation at bottom boolean.
1630 | * 判断导航栏是否在底部
1631 | *
1632 | * @param activity the activity
1633 | * @return the boolean
1634 | */
1635 | @TargetApi(14)
1636 | public static boolean isNavigationAtBottom(Activity activity) {
1637 | BarConfig config = new BarConfig(activity);
1638 | return config.isNavigationAtBottom();
1639 | }
1640 |
1641 | /**
1642 | * Gets status bar height.
1643 | * 或得状态栏的高度
1644 | *
1645 | * @param activity the activity
1646 | * @return the status bar height
1647 | */
1648 | @TargetApi(14)
1649 | public static int getStatusBarHeight(Activity activity) {
1650 | BarConfig config = new BarConfig(activity);
1651 | return config.getStatusBarHeight();
1652 | }
1653 |
1654 | /**
1655 | * Gets action bar height.
1656 | * 或得ActionBar得高度
1657 | *
1658 | * @param activity the activity
1659 | * @return the action bar height
1660 | */
1661 | @TargetApi(14)
1662 | public static int getActionBarHeight(Activity activity) {
1663 | BarConfig config = new BarConfig(activity);
1664 | return config.getActionBarHeight();
1665 | }
1666 |
1667 | /**
1668 | * 判断手机支不支持状态栏字体变色
1669 | * Is support status bar dark font boolean.
1670 | *
1671 | * @return the boolean
1672 | */
1673 | public static boolean isSupportStatusBarDarkFont() {
1674 | if (OSUtils.isMIUI6More() || OSUtils.isFlymeOS4More()
1675 | || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)) {
1676 | return true;
1677 | } else
1678 | return false;
1679 | }
1680 |
1681 | /**
1682 | * 单独设置标题栏的高度
1683 | * Sets title bar.
1684 | *
1685 | * @param activity the activity
1686 | * @param view the view
1687 | */
1688 | public static void setTitleBar(Activity activity, View view) {
1689 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1690 | ViewGroup.LayoutParams lp = view.getLayoutParams();
1691 | lp.height += getStatusBarHeight(activity);
1692 | view.setPadding(view.getPaddingLeft(), view.getPaddingTop() + getStatusBarHeight(activity),
1693 | view.getPaddingRight(), view.getPaddingBottom());
1694 | }
1695 | }
1696 |
1697 | /**
1698 | * Sets status bar view.
1699 | *
1700 | * @param activity the activity
1701 | * @param view the view
1702 | */
1703 | public static void setStatusBarView(Activity activity, View view) {
1704 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
1705 | ViewGroup.LayoutParams params = view.getLayoutParams();
1706 | params.height = getStatusBarHeight(activity);
1707 | view.setLayoutParams(params);
1708 | }
1709 | }
1710 |
1711 | /**
1712 | * Gets bar params.
1713 | *
1714 | * @return the bar params
1715 | */
1716 | public BarParams getBarParams() {
1717 | return mBarParams;
1718 | }
1719 |
1720 | public BarParams getTagBarParams(String tag) {
1721 | BarParams barParams = null;
1722 | if (!isEmpty(tag)) {
1723 | barParams = mTagMap.get(mActivityName + "_TAG_" + tag);
1724 | }
1725 | return barParams;
1726 | }
1727 |
1728 | private boolean isEmpty(String str) {
1729 | return str == null || str.trim().length() == 0;
1730 | }
1731 | }
1732 |
--------------------------------------------------------------------------------
/barlibrary/src/main/java/com/gyf/barlibrary/ImmersionFragment.java:
--------------------------------------------------------------------------------
1 | package com.gyf.barlibrary;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | /**
6 | * ImmersionFragment沉浸式基类,因为fragment是基于activity之上的,
7 | * 为了能够在fragment使用沉浸式而fragment之间又相互不影响,必须实现immersionInit方法,
8 | * 原理是当用户可见才执行沉浸式初始化
9 | * 已过时,当配合vieapager使用时,请自行使用懒加载方式实现,或者参看我的demo里的BaseLazyFragment
10 | * Created by geyifeng on 2017/5/12.
11 | */
12 | @Deprecated
13 | public abstract class ImmersionFragment extends Fragment {
14 | @Override
15 | public void setUserVisibleHint(boolean isVisibleToUser) {
16 | super.setUserVisibleHint(isVisibleToUser);
17 | if ((isVisibleToUser && isResumed())) {
18 | onResume();
19 | }
20 | }
21 |
22 | @Override
23 | public void onResume() {
24 | super.onResume();
25 | if (getUserVisibleHint() && immersionEnabled()) {
26 | immersionInit();
27 | }
28 | }
29 |
30 | /**
31 | * 当前页面Fragment支持沉浸式初始化。子类可以重写返回false,设置不支持沉浸式初始化
32 | * Immersion bar enabled boolean.
33 | *
34 | * @return the boolean
35 | */
36 | @Deprecated
37 | protected boolean immersionEnabled() {
38 | return true;
39 | }
40 |
41 | @Deprecated
42 | protected abstract void immersionInit();
43 | }
44 |
--------------------------------------------------------------------------------
/barlibrary/src/main/java/com/gyf/barlibrary/KeyboardPatch.java:
--------------------------------------------------------------------------------
1 | package com.gyf.barlibrary;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Rect;
5 | import android.os.Build;
6 | import android.util.DisplayMetrics;
7 | import android.view.View;
8 | import android.view.ViewTreeObserver;
9 | import android.view.WindowManager;
10 |
11 | /**
12 | * 解决底部输入框和软键盘的问题
13 | * Created by geyifeng on 2017/5/17.
14 | */
15 | public class KeyboardPatch {
16 | private Activity mActivity;
17 | private View mDecorView;
18 | private View mContentView;
19 | private boolean flag = false;
20 | private BarParams mBarParams;
21 |
22 | private KeyboardPatch(Activity activity) {
23 | this(activity, activity.findViewById(android.R.id.content));
24 | }
25 |
26 | private KeyboardPatch(Activity activity, View contentView) {
27 | this.mActivity = activity;
28 | this.mDecorView = activity.getWindow().getDecorView();
29 | this.mContentView = contentView;
30 | mBarParams = ImmersionBar.with(mActivity).getBarParams();
31 | if (contentView.equals(activity.findViewById(android.R.id.content))) {
32 | this.flag = false;
33 | } else {
34 | this.flag = true;
35 | }
36 | }
37 |
38 | /**
39 | * Patch keyboard patch.
40 | *
41 | * @param activity the activity
42 | * @return the keyboard patch
43 | */
44 | public static KeyboardPatch patch(Activity activity) {
45 | return new KeyboardPatch(activity);
46 | }
47 |
48 | /**
49 | * Patch keyboard patch.
50 | *
51 | * @param activity the activity
52 | * @param contentView 界面容器,指定布局的根节点
53 | * @return the keyboard patch
54 | */
55 | public static KeyboardPatch patch(Activity activity, View contentView) {
56 | return new KeyboardPatch(activity, contentView);
57 | }
58 |
59 | /**
60 | * 监听layout变化
61 | */
62 | public void enable() {
63 | enable(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
64 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
65 | }
66 |
67 | public void enable(int mode) {
68 | mActivity.getWindow().setSoftInputMode(mode);
69 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
70 | mDecorView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener);//当在一个视图树中全局布局发生改变或者视图树中的某个视图的可视状态发生改变时,所要调用的回调函数的接口类
71 | }
72 | }
73 |
74 | /**
75 | * 取消监听
76 | */
77 | public void disable() {
78 | disable(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
79 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
80 | }
81 |
82 | public void disable(int mode) {
83 | mActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
84 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
85 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
86 | mDecorView.getViewTreeObserver().removeOnGlobalLayoutListener(onGlobalLayoutListener);
87 | }
88 | }
89 |
90 | private ViewTreeObserver.OnGlobalLayoutListener onGlobalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {
91 | @Override
92 | public void onGlobalLayout() {
93 | Rect r = new Rect();
94 | mDecorView.getWindowVisibleDisplayFrame(r); //获取当前窗口可视区域大小的
95 | int height = mDecorView.getContext().getResources().getDisplayMetrics().heightPixels; //获取屏幕密度,不包含导航栏
96 | int diff = height - r.bottom;
97 | if (diff > 0) {
98 | if (mContentView.getPaddingBottom() != diff) {
99 | if (flag || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !OSUtils.isEMUI3_1())
100 | || !mBarParams.navigationBarEnable) {
101 | if (mBarParams.fits)
102 | mContentView.setPadding(0, ImmersionBar.getStatusBarHeight(mActivity), 0, diff);
103 | else
104 | mContentView.setPadding(0, 0, 0, diff);
105 | } else {
106 | if (mBarParams.fits)
107 | mContentView.setPadding(0, ImmersionBar.getStatusBarHeight(mActivity),
108 | 0, diff + ImmersionBar.getNavigationBarHeight(mActivity));
109 | else
110 | mContentView.setPadding(0, 0, 0, diff + ImmersionBar.getNavigationBarHeight(mActivity));
111 | }
112 | }
113 | } else {
114 | if (mContentView.getPaddingBottom() != 0) {
115 | if (flag || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !OSUtils.isEMUI3_1())
116 | || !mBarParams.navigationBarEnable) {
117 | if (mBarParams.fits)
118 | mContentView.setPadding(0, ImmersionBar.getStatusBarHeight(mActivity), 0, 0);
119 | else
120 | mContentView.setPadding(0, 0, 0, 0);
121 | } else {
122 | if (mBarParams.fits)
123 | mContentView.setPadding(0, ImmersionBar.getStatusBarHeight(mActivity),
124 | 0, ImmersionBar.getNavigationBarHeight(mActivity));
125 | else
126 | mContentView.setPadding(0, 0, 0, ImmersionBar.getNavigationBarHeight(mActivity));
127 | }
128 | }
129 | }
130 | }
131 | };
132 | }
133 |
--------------------------------------------------------------------------------
/barlibrary/src/main/java/com/gyf/barlibrary/OSUtils.java:
--------------------------------------------------------------------------------
1 | package com.gyf.barlibrary;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.lang.reflect.Method;
6 |
7 | /**
8 | * 手机系统判断
9 | * Created by geyifeng on 2017/4/18.
10 | */
11 | public class OSUtils {
12 |
13 | private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
14 | private static final String KEY_EMUI_VERSION_NAME = "ro.build.version.emui";
15 | private static final String KEY_DISPLAY = "ro.build.display.id";
16 |
17 | /**
18 | * 判断是否为miui
19 | * Is miui boolean.
20 | *
21 | * @return the boolean
22 | */
23 | public static boolean isMIUI() {
24 | String property = getSystemProperty(KEY_MIUI_VERSION_NAME, "");
25 | return !TextUtils.isEmpty(property);
26 | }
27 |
28 | /**
29 | * 判断miui版本是否大于等于6
30 | * Is miui 6 more boolean.
31 | *
32 | * @return the boolean
33 | */
34 | public static boolean isMIUI6More() {
35 | String version = getMIUIVersion();
36 | if ((!version.isEmpty() && Integer.valueOf(version.substring(1)) >= 6)) {
37 | return true;
38 | } else
39 | return false;
40 | }
41 |
42 | /**
43 | * 获得miui的版本
44 | * Gets miui version.
45 | *
46 | * @return the miui version
47 | */
48 | public static String getMIUIVersion() {
49 | return isMIUI() ? getSystemProperty(KEY_MIUI_VERSION_NAME, "") : "";
50 | }
51 |
52 | /**
53 | * 判断是否为emui
54 | * Is emui boolean.
55 | *
56 | * @return the boolean
57 | */
58 | public static boolean isEMUI() {
59 | String property = getSystemProperty(KEY_EMUI_VERSION_NAME, "");
60 | return !TextUtils.isEmpty(property);
61 | }
62 |
63 | /**
64 | * 得到emui的版本
65 | * Gets emui version.
66 | *
67 | * @return the emui version
68 | */
69 | public static String getEMUIVersion() {
70 | return isEMUI() ? getSystemProperty(KEY_EMUI_VERSION_NAME, "") : "";
71 | }
72 |
73 | /**
74 | * 判断是否为emui3.1版本
75 | * Is emui 3 1 boolean.
76 | *
77 | * @return the boolean
78 | */
79 | public static boolean isEMUI3_1() {
80 | String property = getEMUIVersion();
81 | if ("EmotionUI 3".equals(property) || property.contains("EmotionUI_3.1")) {
82 | return true;
83 | }
84 | return false;
85 | }
86 |
87 | /**
88 | * 判断是否为flymeOS
89 | * Is flyme os boolean.
90 | *
91 | * @return the boolean
92 | */
93 | public static boolean isFlymeOS() {
94 | return getFlymeOSFlag().toLowerCase().contains("flyme");
95 | }
96 |
97 | /**
98 | * 判断flymeOS的版本是否大于等于4
99 | * Is flyme os 4 more boolean.
100 | *
101 | * @return the boolean
102 | */
103 | public static boolean isFlymeOS4More() {
104 | String version = getFlymeOSVersion();
105 | int num;
106 | if (!version.isEmpty()) {
107 | if (version.toLowerCase().contains("os")) {
108 | num = Integer.valueOf(version.substring(9, 10));
109 | } else {
110 | num = Integer.valueOf(version.substring(6, 7));
111 | }
112 | if (num >= 4) {
113 | return true;
114 | }
115 | }
116 | return false;
117 | }
118 |
119 | /**
120 | * 判断flymeOS的版本是否等于5
121 | * Is flyme os 5 boolean.
122 | *
123 | * @return the boolean
124 | */
125 | public static boolean isFlymeOS5() {
126 | String version = getFlymeOSVersion();
127 | int num;
128 | if (!version.isEmpty()) {
129 | if (version.toLowerCase().contains("os")) {
130 | num = Integer.valueOf(version.substring(9, 10));
131 | } else {
132 | num = Integer.valueOf(version.substring(6, 7));
133 | }
134 | if (num == 5) {
135 | return true;
136 | }
137 | }
138 | return false;
139 | }
140 |
141 |
142 | /**
143 | * 得到flymeOS的版本
144 | * Gets flyme os version.
145 | *
146 | * @return the flyme os version
147 | */
148 | public static String getFlymeOSVersion() {
149 | return isFlymeOS() ? getSystemProperty(KEY_DISPLAY, "") : "";
150 | }
151 |
152 | private static String getFlymeOSFlag() {
153 | return getSystemProperty(KEY_DISPLAY, "");
154 | }
155 |
156 | private static String getSystemProperty(String key, String defaultValue) {
157 | try {
158 | Class> clz = Class.forName("android.os.SystemProperties");
159 | Method get = clz.getMethod("get", String.class, String.class);
160 | return (String) get.invoke(clz, key, defaultValue);
161 | } catch (Exception e) {
162 | e.printStackTrace();
163 | }
164 | return defaultValue;
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/barlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | BarLibrary
3 |
4 |
--------------------------------------------------------------------------------
/barlibrary/src/test/java/com/gyf/barlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.gyf.barlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.2'
9 | classpath 'com.novoda:bintray-release:0.3.4'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codeGoogler/MyStausBarFacoryTest/750524b46525f96bbf0b5a6d5565df4006fbd978/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Jul 30 13:40:01 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':barlibrary'
2 |
--------------------------------------------------------------------------------