Skip to content

Commit

Permalink
修复兼容性问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hss committed May 12, 2020
1 parent 5f91345 commit f65105f
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,23 @@ public void onStop() {
startWaitingResult = true;
}

@Override
public void onStart() {
super.onStart();
if(startWaitingResult){
onStartOfResultBack();
startWaitingResult = false;
}
}


/**
* 如果真有,那么比onStart()先执行
* @param requestCode
* @param resultCode
* @param data
*/
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(startWaitingResult){
consumed = true;
listener.onActivityResult(requestCode,resultCode,data);
if (StartActivityUtil.debugable) {
Log.i("onActivityResult", "req:" + requestCode + ",result:" + resultCode + ",data:" + data);
}
onStartOfResultBack(requestCode,resultCode,data);

//不会在回来时回调,而是一跳出去就回调,resultcode是cancel,所以这个方法不能用
}
//consumed = true;
Expand All @@ -70,8 +68,17 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d

}

protected void onStartOfResultBack() {
listener.onActivityResult(requestCode,66,null);
@Override
public void onStart() {
super.onStart();
if(startWaitingResult && !consumed){
onStartOfResultBack(requestCode,66,null);
startWaitingResult = false;
}
}

protected void onStartOfResultBack(int requestCode, int resultCode, @Nullable Intent data) {
listener.onActivityResult(requestCode,resultCode,data);
if (StartActivityUtil.debugable) {
Log.i("onActivityResult2", "req:" + requestCode + ",result:onStartOfResultBack,data:null" );
}
Expand Down

0 comments on commit f65105f

Please sign in to comment.