Merge pull request #1197 from k0shk0sh/development_local

show message when search results are incomplete
This commit is contained in:
Kosh Sergani 2017-10-28 20:26:03 +02:00 committed by GitHub
commit e65f89db88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 37 deletions

View File

@ -33,7 +33,6 @@ import com.fastaccess.helper.AppHelper;
import com.fastaccess.helper.BundleConstant;
import com.fastaccess.helper.Bundler;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.RxHelper;
import com.fastaccess.helper.ViewHelper;
@ -270,6 +269,9 @@ public abstract class BaseActivity<V extends BaseMvp.FAView, P extends BasePrese
@Override public void onOpenUrlInBrowser() {
if (!InputHelper.isEmpty(schemeUrl)) {
ActivityHelper.startCustomTab(this, schemeUrl);
try {
finish();
} catch (Exception ignored) {}// fragment might be committed and calling finish will crash the app.
}
}

View File

@ -10,7 +10,6 @@ import android.support.v4.widget.DrawerLayout;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.Login;
import com.fastaccess.data.dao.model.Notification;
import com.fastaccess.helper.Logger;
import com.fastaccess.helper.ParseDateFormat;
import com.fastaccess.helper.PrefGetter;
import com.fastaccess.helper.RxHelper;
@ -19,12 +18,6 @@ import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
import com.fastaccess.ui.modules.feeds.FeedsFragment;
import com.fastaccess.ui.modules.main.issues.pager.MyIssuesPagerFragment;
import com.fastaccess.ui.modules.main.pullrequests.pager.MyPullsPagerFragment;
import com.github.b3er.rxfirebase.database.RxFirebaseDatabase;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.GenericTypeIndicator;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.Single;
@ -38,7 +31,6 @@ import static com.fastaccess.helper.AppHelper.getFragmentByTag;
public class MainPresenter extends BasePresenter<MainMvp.View> implements MainMvp.Presenter {
MainPresenter() {
checkBlackListed();
setEnterprise(PrefGetter.isEnterprise());
manageDisposable(RxHelper.getObservable(RestProvider.getUserService(isEnterprise()).getUser())
.flatMap(login -> {
@ -141,28 +133,4 @@ public class MainPresenter extends BasePresenter<MainMvp.View> implements MainMv
}
@Override public void onMenuItemReselect(@IdRes int id, int position, boolean fromUser) {}
private void checkBlackListed() {
manageDisposable(RxHelper.getSingle(RxFirebaseDatabase
.data(FirebaseDatabase.getInstance().getReference().child("black_listed")))
.map(dataSnapshot -> {
boolean exists = false;
Login login = Login.getUser();
Logger.e(dataSnapshot);
if (login != null) {
if (dataSnapshot != null && dataSnapshot.exists()) {
List<String> values = dataSnapshot.getValue(new GenericTypeIndicator<ArrayList<String>>() {});
if (values != null && !values.isEmpty()) {
exists = values.contains(Login.getUser().getLogin());
}
}
}
return exists;
})
.subscribe(exists -> {
if (exists) {
sendToView(MainMvp.View::onUserIsBlackListed);
}
}, Throwable::printStackTrace));
}
}

View File

@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.fastaccess.R;
import com.fastaccess.data.dao.SearchCodeModel;
import com.fastaccess.provider.rest.RestProvider;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
@ -52,7 +53,12 @@ class SearchCodePresenter extends BasePresenter<SearchCodeMvp.View> implements S
lastPage = response.getLast();
sendToView(view -> {
view.onNotifyAdapter(response.isIncompleteResults() ? null : response.getItems(), page);
view.onSetTabCount(response.getTotalCount());
if (!response.isIncompleteResults()) {
view.onSetTabCount(response.getTotalCount());
} else {
view.onSetTabCount(0);
view.showMessage(R.string.error, R.string.search_results_warning);
}
});
});
return true;

View File

@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.Issue;
import com.fastaccess.provider.rest.RestProvider;
import com.fastaccess.provider.scheme.SchemeParser;
@ -53,7 +54,12 @@ class SearchIssuesPresenter extends BasePresenter<SearchIssuesMvp.View> implemen
lastPage = response.getLast();
sendToView(view -> {
view.onNotifyAdapter(response.isIncompleteResults() ? null : response.getItems(), page);
view.onSetTabCount(response.getTotalCount());
if (!response.isIncompleteResults()) {
view.onSetTabCount(response.getTotalCount());
} else {
view.onSetTabCount(0);
view.showMessage(R.string.error, R.string.search_results_warning);
}
});
});
return true;

View File

@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.Repo;
import com.fastaccess.provider.rest.RestProvider;
import com.fastaccess.provider.scheme.SchemeParser;
@ -53,7 +54,12 @@ class SearchReposPresenter extends BasePresenter<SearchReposMvp.View> implements
lastPage = response.getLast();
sendToView(view -> {
view.onNotifyAdapter(response.isIncompleteResults() ? null : response.getItems(), page);
view.onSetTabCount(response.getTotalCount());
if (!response.isIncompleteResults()) {
view.onSetTabCount(response.getTotalCount());
} else {
view.onSetTabCount(0);
view.showMessage(R.string.error, R.string.search_results_warning);
}
});
});
return true;

View File

@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
import com.fastaccess.R;
import com.fastaccess.data.dao.model.User;
import com.fastaccess.provider.rest.RestProvider;
import com.fastaccess.ui.base.mvp.presenter.BasePresenter;
@ -52,7 +53,12 @@ class SearchUsersPresenter extends BasePresenter<SearchUsersMvp.View> implements
lastPage = response.getLast();
sendToView(view -> {
view.onNotifyAdapter(response.isIncompleteResults() ? null : response.getItems(), page);
view.onSetTabCount(response.getTotalCount());
if (!response.isIncompleteResults()) {
view.onSetTabCount(response.getTotalCount());
} else {
view.onSetTabCount(0);
view.showMessage(R.string.error, R.string.search_results_warning);
}
});
});
return true;

View File

@ -612,4 +612,5 @@
<string name="restore_purchases">Restore Purchases</string>
<string name="include_forks">Include Forks</string>
<string name="comment_is_too_far_to_paginate">The comment is too far to paginate</string>
<string name="search_results_warning">Please be more specific with your search</string>
</resources>