Skip to content

【Bugfix】快速点击时,闪退( java.lang.IllegalStateException: Fragment already a… #41

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -57,6 +60,20 @@ private void initialize(PickerConfig pickerConfig) {
mPickerConfig = pickerConfig;
}

@Override
public void show(FragmentManager manager, String tag) {
Fragment fragment = manager.findFragmentByTag(tag);
FragmentTransaction ft = manager.beginTransaction();
if (fragment != null && fragment.isAdded()) {
ft.show(fragment);
} else {
if (fragment == null || !fragment.isAdded()) {
ft.add(this, tag);
}
}
ft.commitNow();
}

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Expand Down Expand Up @@ -205,27 +222,27 @@ public Builder setCurrentMillseconds(long millseconds) {
return this;
}

public Builder setYearText(String year){
public Builder setYearText(String year) {
mPickerConfig.mYear = year;
return this;
}

public Builder setMonthText(String month){
public Builder setMonthText(String month) {
mPickerConfig.mMonth = month;
return this;
}

public Builder setDayText(String day){
public Builder setDayText(String day) {
mPickerConfig.mDay = day;
return this;
}

public Builder setHourText(String hour){
public Builder setHourText(String hour) {
mPickerConfig.mHour = hour;
return this;
}

public Builder setMinuteText(String minute){
public Builder setMinuteText(String minute) {
mPickerConfig.mMinute = minute;
return this;
}
Expand Down