Do not scroll to top on timeline refresh (#681)

* Do not scroll to top on timeline refresh

* Use dp for shifting timeline
This commit is contained in:
Ivan Kupalov 2018-06-24 10:53:19 +02:00 committed by Konrad Pozniak
parent e8d1b16b39
commit 570d7e3597
1 changed files with 3 additions and 5 deletions

View File

@ -78,6 +78,7 @@ import java.util.regex.Pattern;
import javax.inject.Inject; import javax.inject.Inject;
import at.connyduck.sparkbutton.helpers.Utils;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
@ -1065,11 +1066,8 @@ public class TimelineFragment extends SFragment implements
@Override @Override
public void onInserted(int position, int count) { public void onInserted(int position, int count) {
adapter.notifyItemRangeInserted(position, count); adapter.notifyItemRangeInserted(position, count);
if (position == 0 if (position == 0) {
&& layoutManager.findFirstVisibleItemPosition() == 0 recyclerView.scrollBy(0, Utils.dpToPx(Objects.requireNonNull(getContext()), -30));
&& (swipeRefreshLayout.getVisibility() == View.VISIBLE
|| progressBar.getVisibility() == View.VISIBLE)) {
recyclerView.post(() -> layoutManager.scrollToPosition(0));
} }
} }