Skip to content

Commit

Permalink
Reduce amount of scrolling needed to load more information
Browse files Browse the repository at this point in the history
Closes #217
  • Loading branch information
grote committed Sep 30, 2016
1 parent a917d3d commit 8931338
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions res/xml/changelog_master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<release version="1.1.5" versioncode="41">
<change>Added France North West (Thanks Patrick!)</change>
<change>Reduce amount of scrolling needed to load more information</change>
<change>Added help screens</change>
<change>Reduced size of the app</change>
</release>
Expand Down
5 changes: 5 additions & 0 deletions src/de/grobox/liberario/activities/TripsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -54,6 +55,8 @@
import de.schildbach.pte.dto.QueryTripsResult;
import de.schildbach.pte.dto.Trip;

import static de.grobox.liberario.utils.TransportrUtils.getDragDistance;

public class TripsActivity extends TransportrActivity {
private QueryTripsResult start_context;
private QueryTripsResult end_context;
Expand Down Expand Up @@ -96,6 +99,8 @@ protected void onCreate(Bundle savedInstanceState) {

swipeRefresh = (SwipyRefreshLayout) findViewById(R.id.swipe_refresh_layout);
swipeRefresh.setColorSchemeResources(R.color.accent);
swipeRefresh.setDistanceToTriggerSync(getDragDistance(this));


mRecyclerView = (RecyclerView) findViewById(R.id.trips_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
Expand Down
3 changes: 3 additions & 0 deletions src/de/grobox/liberario/fragments/DeparturesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import de.schildbach.pte.dto.QueryDeparturesResult;
import de.schildbach.pte.dto.StationDepartures;

import static de.grobox.liberario.utils.TransportrUtils.getDragDistance;

public class DeparturesFragment extends TransportrFragment {

public static final String TAG = "de.grobox.liberario.departures";
Expand Down Expand Up @@ -92,6 +94,7 @@ public void onClick(View v) {
// Swipe to Refresh
ui.swipe_refresh.setColorSchemeResources(R.color.accent);
ui.swipe_refresh.setDirection(SwipyRefreshLayoutDirection.BOTH);
ui.swipe_refresh.setDistanceToTriggerSync(getDragDistance(getContext()));
ui.swipe_refresh.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh(final SwipyRefreshLayoutDirection direction) {
Expand Down
3 changes: 3 additions & 0 deletions src/de/grobox/liberario/fragments/NearbyStationsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
import de.schildbach.pte.dto.LocationType;
import de.schildbach.pte.dto.NearbyLocationsResult;

import static de.grobox.liberario.utils.TransportrUtils.getDragDistance;

public class NearbyStationsFragment extends TransportrFragment {

public static final String TAG = "de.grobox.liberario.nearby_locations";
Expand Down Expand Up @@ -127,6 +129,7 @@ public void onLocationChanged(Location location) {

ui.swipe_refresh.setColorSchemeResources(R.color.accent);
ui.swipe_refresh.setDirection(SwipyRefreshLayoutDirection.BOTTOM);
ui.swipe_refresh.setDistanceToTriggerSync(getDragDistance(getContext()));
ui.swipe_refresh.setOnRefreshListener(new SwipyRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh(final SwipyRefreshLayoutDirection direction) {
Expand Down
6 changes: 6 additions & 0 deletions src/de/grobox/liberario/utils/TransportrUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.support.v4.content.ContextCompat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -588,4 +589,9 @@ static public NetworkProvider.WalkSpeed getWalkSpeed(Context context) {
return NetworkProvider.WalkSpeed.valueOf(walkString);
}

static public int getDragDistance(Context context) {
final DisplayMetrics metrics = context.getResources().getDisplayMetrics();
return (int) (25 * metrics.density);
}

}

0 comments on commit 8931338

Please sign in to comment.