Skip to content

Commit

Permalink
update : 简化接入
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhun committed Nov 30, 2018
1 parent 7b1cfc9 commit b38e5dc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 43 deletions.
14 changes: 1 addition & 13 deletions app/src/main/java/com/geek/notchtools/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,12 @@ public class BaseActivity extends AppCompatActivity {
public void setContentView(int layoutResID) {
super.setContentView(R.layout.activity_base);
mNotchContainer = findViewById(R.id.notch_container);
mNotchContainer.setTag(NotchTools.NOTCH_CONTAINER);
mContentContainer = findViewById(R.id.content_container);
onBindContentContainer(layoutResID);
}

private void onBindContentContainer(int layoutResID) {
LayoutInflater.from(this).inflate(layoutResID, mContentContainer, true);
}

/**
* 全屏SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN下刘海屏适配需要
*/
protected void setFakeNotchView() {
if (mNotchContainer == null) {
mNotchContainer = findViewById(R.id.notch_container);
}
View view = new View(this);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, NotchTools.getFullScreenTools().getNotchHeight(getWindow())));
view.setBackgroundColor(Color.BLACK);
mNotchContainer.addView(view);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.geek.notchtools;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import notchtools.geek.com.notchtools.NotchTools;
import notchtools.geek.com.notchtools.core.NotchProperty;
import notchtools.geek.com.notchtools.core.OnNotchCallBack;

public class FullScreenNoUseNotchActivity extends BaseActivity {

Expand All @@ -24,18 +21,7 @@ public void onClick(View v) {
finish();
}
});
NotchTools.getFullScreenTools().fullScreenDontUseStatus(this, new OnNotchCallBack() {
@Override
public void onNotchPropertyCallback(NotchProperty notchProperty) {

}

@Override
public void onNeedAddNotchStatusBar(boolean needAddNocth) {
if (needAddNocth) {
setFakeNotchView();
}
}
});
NotchTools.getFullScreenTools().fullScreenDontUseStatusForPortrait(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import notchtools.geek.com.notchtools.core.NotchProperty;
import notchtools.geek.com.notchtools.core.OnNotchCallBack;

public class FullScreenUseNotchActivity extends BaseActivity {
public class FullScreenUseNotchActivity extends BaseActivity implements OnNotchCallBack {

private ImageView mBackView;

Expand All @@ -25,19 +25,15 @@ public void onClick(View v) {
finish();
}
});
NotchTools.getFullScreenTools().fullScreenUseStatus(this, new OnNotchCallBack() {
@Override
public void onNotchPropertyCallback(NotchProperty notchProperty) {
int marginTop = notchProperty.getMarginTop();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mBackView.getLayoutParams();
layoutParams.topMargin += marginTop;
mBackView.setLayoutParams(layoutParams);
}

@Override
public void onNeedAddNotchStatusBar(boolean needAddNocth) {
NotchTools.getFullScreenTools().fullScreenUseStatus(this, this);
}

}
});
@Override
public void onNotchPropertyCallback(NotchProperty notchProperty) {
int marginTop = notchProperty.getMarginTop();
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mBackView.getLayoutParams();
layoutParams.topMargin += marginTop;
mBackView.setLayoutParams(layoutParams);
}

}

0 comments on commit b38e5dc

Please sign in to comment.