mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
Merge pull request #116 from passsy/bugfix/process_death_repo_detail
Survive process death and reload data after process death
This commit is contained in:
commit
f630029c58
@ -34,8 +34,8 @@ class RepoPagerPresenter extends BasePresenter<RepoPagerMvp.View> implements Rep
|
||||
private boolean isWatched;
|
||||
private boolean isStarred;
|
||||
private boolean isForked;
|
||||
private String login;
|
||||
private String repoId;
|
||||
private final String login;
|
||||
private final String repoId;
|
||||
private RepoModel repo;
|
||||
|
||||
@Override public void onError(@NonNull Throwable throwable) {
|
||||
@ -43,27 +43,38 @@ class RepoPagerPresenter extends BasePresenter<RepoPagerMvp.View> implements Rep
|
||||
super.onError(throwable);
|
||||
}
|
||||
|
||||
@Override public void onActivityCreated(@Nullable Intent intent) {
|
||||
if (intent != null && intent.getExtras() != null) {
|
||||
Bundle bundle = intent.getExtras();
|
||||
repoId = bundle.getString(BundleConstant.ID);
|
||||
login = bundle.getString(BundleConstant.EXTRA_TWO);
|
||||
if (!InputHelper.isEmpty(login()) && !InputHelper.isEmpty(repoId())) {
|
||||
makeRestCall(RestProvider.getRepoService().getRepo(login(), repoId()),
|
||||
repoModel -> {
|
||||
this.repo = repoModel;
|
||||
manageSubscription(this.repo.persist().observe().subscribe());
|
||||
sendToView(view -> {
|
||||
view.onInitRepo();
|
||||
view.onNavigationChanged(RepoPagerMvp.CODE);
|
||||
});
|
||||
onCheckStarring();
|
||||
onCheckWatching();
|
||||
});
|
||||
return;
|
||||
}
|
||||
public RepoPagerPresenter(final String repoId, final String login) {
|
||||
if (!InputHelper.isEmpty(login) && !InputHelper.isEmpty(repoId())) {
|
||||
throw new IllegalArgumentException("aruments cannot be empty");
|
||||
}
|
||||
sendToView(RepoPagerMvp.View::onFinishActivity);
|
||||
this.repoId = repoId;
|
||||
this.login = login;
|
||||
|
||||
makeRestCall(RestProvider.getRepoService().getRepo(login(), repoId()),
|
||||
repoModel -> {
|
||||
this.repo = repoModel;
|
||||
manageSubscription(this.repo.persist().observe().subscribe());
|
||||
sendToView(view -> {
|
||||
view.onInitRepo();
|
||||
view.onNavigationChanged(RepoPagerMvp.CODE);
|
||||
});
|
||||
onCheckStarring();
|
||||
onCheckWatching();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachView(@NonNull final RepoPagerMvp.View view) {
|
||||
super.onAttachView(view);
|
||||
|
||||
if (getRepo() != null) {
|
||||
view.onInitRepo();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable final Intent intent) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@NonNull @Override public String repoId() {
|
||||
|
||||
@ -137,8 +137,21 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
|
||||
return false;
|
||||
}
|
||||
|
||||
@NonNull @Override public RepoPagerPresenter providePresenter() {
|
||||
return new RepoPagerPresenter();
|
||||
@NonNull
|
||||
@Override
|
||||
public RepoPagerPresenter providePresenter() {
|
||||
|
||||
if (getIntent() == null) {
|
||||
throw new IllegalArgumentException("intent is null, WTF");
|
||||
}
|
||||
if (getIntent().getExtras() == null) {
|
||||
throw new IllegalArgumentException("no intent extras provided");
|
||||
}
|
||||
|
||||
final Bundle extras = getIntent().getExtras();
|
||||
final String repoId = extras.getString(BundleConstant.ID);
|
||||
final String login = extras.getString(BundleConstant.EXTRA_TWO);
|
||||
return new RepoPagerPresenter(repoId, login);
|
||||
}
|
||||
|
||||
@Override protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -146,14 +159,8 @@ public class RepoPagerView extends BaseActivity<RepoPagerMvp.View, RepoPagerPres
|
||||
setTitle("");
|
||||
Typeface myTypeface = TypeFaceHelper.getTypeface();
|
||||
bottomNavigation.setDefaultTypeface(myTypeface);
|
||||
if (savedInstanceState == null) {
|
||||
getPresenter().onActivityCreated(getIntent());
|
||||
bottomNavigation.setDefaultSelectedIndex(0);
|
||||
} else {
|
||||
if (getPresenter().getRepo() != null) {
|
||||
onInitRepo();
|
||||
}
|
||||
}
|
||||
bottomNavigation.setDefaultSelectedIndex(0);
|
||||
|
||||
fab.setImageResource(R.drawable.ic_add);
|
||||
fab.setImageTintList(ColorStateList.valueOf(Color.WHITE));
|
||||
showHideFab();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user