Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

「update」v1.0.1 #2

Merged
merged 1 commit into from
Dec 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
Change Log
==========

Version 1.0.1 *(2016-12-28)*
----------------------------

* 增加 setSwipeBackEnable 方法,设置滑动返回是否可用
* 增加 setIsNeedShowShadow 方法,设置是否显示滑动返回的阴影效果
* 增加 setIsOnlyTrackingLeftEdge 方法,设置是否仅仅跟踪左侧边缘的滑动返回

Version 1.0.0 *(2016-12-27)*
----------------------------

Initial release.
* Initial release.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@

通过修改 support-v4 包中 SlidingPaneLayout 的源码来实现滑动返回布局

## 文档和 Demo 待完善
## 效果图与示例 apk

![BGASwipeBackLayoutDemo](https://cloud.githubusercontent.com/assets/8949716/21510933/b334a340-ccd4-11e6-9fce-94c2d783c73e.gif)

[点击下载 BGASwipeBackLayoutDemo.apk](http://fir.im/BGASwipeBackLayout) 或扫描下面的二维码安装

![BGABannerDemo apk文件二维](https://cloud.githubusercontent.com/assets/8949716/21510942/c8e9c9e0-ccd4-11e6-9757-bbc6653cccdb.png)


## 文档待完善,着急的猿友就先看 [demo](https://github.com/bingoogolapple/BGASwipeBackLayout-Android/tree/master/demo) 吧

## 代码是最好的老师,更多详细用法请查看 [demo](https://github.com/bingoogolapple/BGASwipeBackLayout-Android/tree/master/demo):feet:

Expand Down
12 changes: 9 additions & 3 deletions demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ android {
}

dependencies {
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
// compile 'cn.bingoogolapple:bga-swipebacklayout:1.0.1@aar'
// 上面的依赖是必须的

compile 'cn.bingoogolapple:bga-swipebacklayout:1.0.0@aar'
compile project(':library')

// compile project(':library')
// 下面的依赖不是必须的,只是为了方便演示 demo
compile 'cn.bingoogolapple:bga-adapter:1.1.5@aar'
compile 'com.android.support:palette-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.jaeger.statusbaruitl:library:1.3.1'
}
8 changes: 6 additions & 2 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:name=".activity.MainActivity"
android:theme="@style/AppTheme.Transparent.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand All @@ -19,7 +19,11 @@
</activity>

<activity
android:name=".DemoScrollViewActivity"
android:name=".activity.TestActivity"
android:theme="@style/AppTheme.Transparent"/>

<activity
android:name=".activity.TranslucentActivity"
android:theme="@style/AppTheme.Transparent"/>
</application>

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package cn.bingoogolapple.swipebacklayout.demo;
package cn.bingoogolapple.swipebacklayout.demo.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;

import cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout;
import cn.bingoogolapple.swipebacklayout.demo.R;
import cn.bingoogolapple.swipebacklayout.demo.util.KeyboardUtil;

/**
* 作者:王浩 邮件:[email protected]
* 创建时间:16/12/27 下午5:35
* 描述:
* 描述:开发者可将该类中的某些方法拷贝到自己的 BaseActivity 中封装成适合自己项目的滑动返回基类
*/
public class BaseActivity extends AppCompatActivity implements BGASwipeBackLayout.PanelSlideListener {
protected BGASwipeBackLayout mSwipeBackLayout;
Expand All @@ -23,15 +26,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}

/**
* 初始化滑动返回
*/
Expand All @@ -40,11 +34,14 @@ private void initSwipeBackFinish() {
mSwipeBackLayout = new BGASwipeBackLayout(this);
mSwipeBackLayout.attachToActivity(this);
mSwipeBackLayout.setPanelSlideListener(this);

mSwipeBackLayout.setIsOnlyTrackingLeftEdge(true);
mSwipeBackLayout.setIsNeedShowShadow(true);
}
}

/**
* 是否支持滑动返回
* 是否支持滑动返回。默认支持,如果某个界面不想支持滑动返回则重写该方法返回 false 即可
*
* @return
*/
Expand All @@ -53,7 +50,7 @@ protected boolean isSupportSwipeBack() {
}

/**
* 设置滑动返回是否可用
* 动态设置滑动返回是否可用。
*
* @param swipeBackEnable
*/
Expand All @@ -63,6 +60,7 @@ protected void setSwipeBackEnable(boolean swipeBackEnable) {
}
}


@Override
public void onPanelClosed(View view) {
}
Expand All @@ -76,6 +74,16 @@ public void onPanelOpened(View view) {
public void onPanelSlide(View view, float v) {
}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onBackPressed() {
backward();
Expand Down Expand Up @@ -173,4 +181,15 @@ public void executeBackwardAnim() {
public void executeSwipeBackAnim() {
overridePendingTransition(R.anim.activity_swipeback_enter, R.anim.activity_swipeback_exit);
}

/**
* 查找View
*
* @param id 控件的id
* @param <VT> View类型
* @return
*/
protected <VT extends View> VT getViewById(@IdRes int id) {
return (VT) findViewById(id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cn.bingoogolapple.swipebacklayout.demo.activity;

import android.os.Bundle;
import android.view.View;

import cn.bingoogolapple.swipebacklayout.demo.R;

/**
* 作者:王浩 邮件:[email protected]
* 创建时间:16/12/27 下午5:35
* 描述:示例项目主界面,改界面不需要支持滑动返回
*/
public class MainActivity extends BaseActivity {

/**
* 主界面不需要支持滑动返回,重写该方法永久禁用当前界面的滑动返回功能
*
* @return
*/
@Override
protected boolean isSupportSwipeBack() {
return false;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void onClick(View v) {
if (v.getId() == R.id.btn_main_test) {
forward(TestActivity.class);
}
}
}
Loading