Skip to content

Commit

Permalink
see 10/11 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Oct 11, 2017
1 parent c5fc08b commit 21e683f
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 104 deletions.
32 changes: 17 additions & 15 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,21 @@ getReplaceAll : 替换所有正则匹配的部分

* ### 屏幕相关→[ScreenUtils.java][screen.java]
```
getScreenWidth : 获取屏幕的宽度(单位:px)
getScreenHeight : 获取屏幕的高度(单位:px)
setFullScreen : 设置屏幕为全屏
setLandscape : 设置屏幕为横屏
setPortrait : 设置屏幕为竖屏
isLandscape : 判断是否横屏
isPortrait : 判断是否竖屏
getScreenRotation: 获取屏幕旋转角度
screenShot : 截屏
isScreenLock : 判断是否锁屏
setSleepDuration : 设置进入休眠时长
getSleepDuration : 获取进入休眠时长
isTablet : 判断是否是平板
getScreenWidth : 获取屏幕的宽度(单位:px)
getScreenHeight : 获取屏幕的高度(单位:px)
getScreenDensity : 获取屏幕密度
getScreenDensityDpi: 获取屏幕密度DPI
setFullScreen : 设置屏幕为全屏
setLandscape : 设置屏幕为横屏
setPortrait : 设置屏幕为竖屏
isLandscape : 判断是否横屏
isPortrait : 判断是否竖屏
getScreenRotation : 获取屏幕旋转角度
screenShot : 截屏
isScreenLock : 判断是否锁屏
setSleepDuration : 设置进入休眠时长
getSleepDuration : 获取进入休眠时长
isTablet : 判断是否是平板
```

* ### SD卡相关→[SDCardUtils.java][sdcard.java][Demo][sdcard.demo]
Expand Down Expand Up @@ -610,7 +612,7 @@ getComments : 获取压缩文件中的注释链表

Gradle:
``` groovy
compile 'com.blankj:utilcode:1.9.2'
compile 'com.blankj:utilcode:1.9.3'
```


Expand All @@ -633,7 +635,7 @@ Utils.init(application);

[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png

[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.2-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.3-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,8 @@ getReplaceAll
```
getScreenWidth
getScreenHeight
getScreenDensity
getScreenDensityDpi
setFullScreen
setLandscape
setPortrait
Expand Down Expand Up @@ -610,7 +612,7 @@ getComments

Gradle:
``` groovy
compile 'com.blankj:utilcode:1.9.2'
compile 'com.blankj:utilcode:1.9.3'
```


Expand All @@ -633,7 +635,7 @@ Utils.init(application);

[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png

[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.2-brightgreen.svg
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.9.3-brightgreen.svg
[auc]: https://github.com/Blankj/AndroidUtilCode

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void initView(Bundle savedInstanceState, View view) {
navigation = (BottomNavigationView) findViewById(R.id.navigation_fragment);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

mFragments[0] = RootFragment.newInstance();
mFragments[1] = RootFragment.newInstance();
mFragments[2] = RootFragment.newInstance();
mFragments[0] = Root0Fragment.newInstance();
mFragments[1] = Root1Fragment.newInstance();
mFragments[2] = Root2Fragment.newInstance();
FragmentUtils.add(getSupportFragmentManager(), mFragments, R.id.fragment_container, curIndex);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
package com.blankj.androidutilcode.core.fragment;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.transition.Fade;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.base.BaseFragment;
import com.blankj.utilcode.util.FragmentUtils;

import java.util.Random;

/**
* <pre>
* author: Blankj
* blog : http://blankj.com
* time : 17/02/02
* desc :
* </pre>
*/
public class Root0Fragment extends BaseFragment
implements FragmentUtils.OnBackClickListener {

ImageView ivSharedElement;
TextView tvAboutFragment;

public static Root0Fragment newInstance() {
Bundle args = new Bundle();
Root0Fragment fragment = new Root0Fragment();
fragment.setArguments(args);
return fragment;
}

@Override
public void initData(Bundle bundle) {

}

@Override
public int bindLayout() {
return R.layout.fragment_root;
}

@Override
public void initView(Bundle savedInstanceState, View view) {
Random random = new Random();
FragmentUtils.setBackgroundColor(this, Color.rgb(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
view.findViewById(R.id.btn_show_about_fragment).setOnClickListener(this);
view.findViewById(R.id.btn_add).setOnClickListener(this);
view.findViewById(R.id.btn_add_hide).setOnClickListener(this);
view.findViewById(R.id.btn_add_hide_stack).setOnClickListener(this);
view.findViewById(R.id.btn_add).setOnClickListener(this);
view.findViewById(R.id.btn_add_show).setOnClickListener(this);
view.findViewById(R.id.btn_add_child).setOnClickListener(this);
view.findViewById(R.id.btn_pop_to_root).setOnClickListener(this);
view.findViewById(R.id.btn_pop_add).setOnClickListener(this);
view.findViewById(R.id.btn_hide_show).setOnClickListener(this);
view.findViewById(R.id.btn_replace).setOnClickListener(this);
ivSharedElement = (ImageView) view.findViewById(R.id.iv_shared_element);
tvAboutFragment = (TextView) view.findViewById(R.id.tv_about_fragment);
}

@Override
public void doBusiness() {

}

@Override
public void onWidgetClick(View view) {
tvAboutFragment.setText("");
switch (view.getId()) {
case R.id.btn_show_about_fragment:
tvAboutFragment.setText("top: " + FragmentUtils.getSimpleName(FragmentUtils.getTop(getFragmentManager()))
+ "\ntopInStack: " + FragmentUtils.getSimpleName(FragmentUtils.getTopInStack(getFragmentManager()))
+ "\ntopShow: " + FragmentUtils.getSimpleName(FragmentUtils.getTopShow(getFragmentManager()))
+ "\ntopShowInStack: " + FragmentUtils.getSimpleName(FragmentUtils.getTopShowInStack(getFragmentManager()))
+ "\n---all of fragments---\n"
+ FragmentUtils.getAllFragments(getFragmentManager()).toString()
+ "\n----------------------\n\n"
+ "---stack top---\n"
+ FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString()
+ "\n---stack bottom---\n\n"
);
break;
case R.id.btn_add:
FragmentUtils.add(getFragmentManager(),
ChildFragment.newInstance(),
R.id.child_fragment_container,
false,
true);
break;
case R.id.btn_add_hide:
FragmentUtils.add(getFragmentManager(),
ChildFragment.newInstance(),
R.id.fragment_container,
true);
break;
case R.id.btn_add_hide_stack:
FragmentUtils.add(getFragmentManager(),
ChildFragment.newInstance(),
R.id.fragment_container,
true,
true);
break;
// case R.id.btn_add_show:
// FragmentUtils.add(getFragmentManager(),
// addSharedElement(Demo1Fragment.newInstance()),
// R.id.fragment_container,
// false,
// false,
// sharedElement);
// break;
// case R.id.btn_add_child:
// FragmentUtils.add(getChildFragmentManager(),
// ChildFragment.newInstance(),
// R.id.child_fragment_container,
// false,
// true);
// break;
// case R.id.btn_pop_to_root:
// FragmentUtils.popToFragment(getFragmentManager(),
// Demo1Fragment.class,
// true);
// break;
// case R.id.btn_pop_add:
// FragmentUtils.popAddFragment(getFragmentManager(),
// addSharedElement(ChildFragment.newInstance()),
// R.id.fragment_container,
// true,
// sharedElement);
// break;
// case R.id.btn_hide_show:
// Fragment fragment1 = FragmentUtils.findFragment(getFragmentManager(), Demo1Fragment.class);
// if (fragment1 != null) {
// FragmentUtils.showHideFragment(this, fragment1);
// } else {
// ToastUtils.showLong("please add demo1 first!");
// }
// break;
// case R.id.btn_replace:
// ((FragmentActivity) getActivity()).rootFragment = FragmentUtils.replaceFragment(this, addSharedElement(Demo3Fragment.newInstance()), false, sharedElement);
// break;
}
}

private Fragment addSharedElement(Fragment fragment) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fragment.setSharedElementEnterTransition(new DetailTransition());
fragment.setEnterTransition(new Fade());
fragment.setSharedElementReturnTransition(new DetailTransition());
}
return fragment;
}

@Override
public boolean onBackClick() {
// FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
* desc :
* </pre>
*/
public class RootFragment extends BaseFragment
public class Root1Fragment extends BaseFragment
implements FragmentUtils.OnBackClickListener {

ImageView ivSharedElement;
TextView tvAboutFragment;

public static RootFragment newInstance() {
public static Root1Fragment newInstance() {
Bundle args = new Bundle();
RootFragment fragment = new RootFragment();
Root1Fragment fragment = new Root1Fragment();
fragment.setArguments(args);
return fragment;
}
Expand Down
Loading

0 comments on commit 21e683f

Please sign in to comment.