luckybilly / luckybilly/SmartSwipe

Fragment中使用根布局作为View填入时遇到的崩溃情况,及目前的解决方案

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
2.1k
Forks
257
PR merge metrics
No merged PRs in 30d

Description

### 问题描述 DrawerConsumer在引用Fragment最外层布局作为View,加入至侧滑的Layout中,贴出来的代码rfq_root_view为Fragment的根布局,然后Fragment页面点击home键或者触发onHidden方法时会报空指针异常

请描述您遇到的问题: 解决方案就是在根布局在套一层布局 将rfq_root_view作为第二层布局然后放入SmartSwipe.wrap()方法中即可解决问题

- 预期行为:无崩溃现象

- 实际行为:出现了崩溃现象

### 出问题的代码

```java
//由于SmartSwipe中有较多的内置SwipeConsumer及较多的属性设置
// 为方便排查,请在这里将您出现问题的代码展示出来
mDrawerConsumer = SmartSwipe.wrap(rfq_root_view)
.addConsumer(DrawerConsumer())
.setRightDrawerView(horizontalMenu)
.setScrimColor(0x2F000000) //设置遮罩的颜色
.setShadowColor(0x80000000.toInt()) //设置边缘的阴影颜色
.addToExclusiveGroup(SwipeConsumerExclusiveGroup())

```

### 当前使用的SmartSwipe版本号:
implementation 'com.billy.android:smart-swipe:1.1.2'
implementation 'com.billy.android:smart-swipe-support:1.1.0'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the crash when SmartSwipe.wrap(rfq_root_view) is used in a Fragment and the home button or onHidden event is triggered. Compare that behavior with the reported workaround of wrapping rfq_root_view in another layout; done means the Fragment can undergo those events without a null-pointer crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.