-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
Order regions by continents #395
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a30eff0
pick network order following continents and countries
ialokim f4efb0e
added continent contour lines and improved the list (items) design
ialokim 47a075f
update to FastAdapter 3.2.3 and introduce type parameters
ialokim 8711af3
fix PickTransportNetworkActivityTest and transport_network logo width
ialokim 067f08d
simplified svg and xml continent contour lines
ialokim f3db4f1
removed unused translations to satisfy lint
ialokim 121a8db
addressed some requested changes
ialokim 969ac57
add subRegions right away to parentRegions, fix AndroidLiveTest
ialokim 3f8d44d
make the Nicaraguan provider work again
ialokim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/src/main/java/de/grobox/transportr/networks/Continent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Transportr | ||
* | ||
* Copyright (c) 2013 - 2017 Torsten Grote | ||
* | ||
* This program is Free Software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.grobox.transportr.networks; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.DrawableRes; | ||
import android.support.annotation.Nullable; | ||
import android.support.annotation.StringRes; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import de.grobox.transportr.R; | ||
|
||
@ParametersAreNonnullByDefault | ||
enum Continent implements ParentRegion { | ||
|
||
EUROPE(R.string.np_continent_europe, R.drawable.continent_europe), | ||
AFRICA(R.string.np_continent_africa, R.drawable.continent_africa), | ||
NORTH_AMERICA(R.string.np_continent_north_america, R.drawable.continent_north_america), | ||
CENTRAL_AMERICA(R.string.np_continent_central_america, R.drawable.continent_central_america), | ||
SOUTH_AMERICA(R.string.np_continent_south_america, R.drawable.continent_south_america), | ||
ASIA(R.string.np_continent_asia, R.drawable.continent_asia), | ||
OCEANIA(R.string.np_continent_oceania, R.drawable.continent_oceania); | ||
|
||
|
||
private final @StringRes int name; | ||
private final @DrawableRes int contour; | ||
private List<Region> subRegions; | ||
|
||
Continent(@StringRes int name, @DrawableRes int contour) { | ||
this.name = name; | ||
this.contour = contour; | ||
this.subRegions = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
@StringRes | ||
public int getName() { | ||
return name; | ||
} | ||
|
||
@DrawableRes | ||
public int getContour() { | ||
return contour; | ||
} | ||
|
||
@Override | ||
public String getName(Context context) { | ||
return context.getString(name); | ||
} | ||
|
||
@Override | ||
public void addSubRegion(Region subRegion) { | ||
subRegions.add(subRegion); | ||
} | ||
|
||
@Override | ||
public List<Region> getSubRegions() { | ||
return subRegions; | ||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
app/src/main/java/de/grobox/transportr/networks/ContinentItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Transportr | ||
* | ||
* Copyright (c) 2013 - 2017 Torsten Grote | ||
* | ||
* This program is Free Software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.grobox.transportr.networks; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.IdRes; | ||
import android.support.annotation.LayoutRes; | ||
import android.view.View; | ||
|
||
import java.util.List; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import de.grobox.transportr.R; | ||
|
||
@ParametersAreNonnullByDefault | ||
class ContinentItem extends ParentRegionItem<ParentRegionItem, ContinentViewHolder, RegionItem> { | ||
|
||
private final Continent continent; | ||
|
||
ContinentItem(Continent continent) { | ||
super(); | ||
this.continent = continent; | ||
} | ||
|
||
@Override | ||
protected String getName(Context context) { | ||
return continent.getName(context); | ||
} | ||
|
||
@IdRes | ||
@Override | ||
public int getType() { | ||
return R.id.list_item_transport_continent; | ||
} | ||
|
||
@Override | ||
@LayoutRes | ||
public int getLayoutRes() { | ||
return R.layout.list_item_transport_continent; | ||
} | ||
|
||
@Override | ||
public void bindView(ContinentViewHolder ui, List<Object> payloads) { | ||
super.bindView(ui, payloads); | ||
ui.bind(continent, isExpanded()); | ||
} | ||
|
||
@Override | ||
public ContinentViewHolder getViewHolder(View view) { | ||
return new ContinentViewHolder(view); | ||
} | ||
|
||
@Override | ||
public long getIdentifier() { | ||
return continent.getName(); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/de/grobox/transportr/networks/ContinentViewHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Transportr | ||
* | ||
* Copyright (c) 2013 - 2017 Torsten Grote | ||
* | ||
* This program is Free Software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.grobox.transportr.networks; | ||
|
||
import android.os.Build; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import de.grobox.transportr.R; | ||
|
||
import static android.view.View.GONE; | ||
import static android.view.View.VISIBLE; | ||
|
||
class ContinentViewHolder extends ParentRegionViewHolder<Continent> { | ||
|
||
private final ImageView contour; | ||
|
||
ContinentViewHolder(View v) { | ||
super(v); | ||
contour = v.findViewById(R.id.contour); | ||
} | ||
|
||
@Override | ||
void bind(Continent continent, boolean expanded) { | ||
super.bind(continent, expanded); | ||
contour.setImageResource(continent.getContour()); | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
app/src/main/java/de/grobox/transportr/networks/Country.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Transportr | ||
* | ||
* Copyright (c) 2013 - 2017 Torsten Grote | ||
* | ||
* This program is Free Software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.grobox.transportr.networks; | ||
|
||
import android.content.Context; | ||
import android.support.annotation.Nullable; | ||
import android.support.annotation.StringRes; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import de.grobox.transportr.R; | ||
|
||
@ParametersAreNonnullByDefault | ||
enum Country implements ParentRegion { | ||
|
||
GERMANY(R.string.np_region_germany, "🇩🇪", Continent.EUROPE), | ||
AUSTRIA(R.string.np_region_austria, "🇦🇹", Continent.EUROPE), | ||
LIECHTENSTEIN(R.string.np_region_liechtenstein, "🇱🇮", Continent.EUROPE), | ||
SWITZERLAND(R.string.np_region_switzerland, "🇨🇭", Continent.EUROPE), | ||
LUXEMBOURG(R.string.np_region_luxembourg, "🇱🇺", Continent.EUROPE), | ||
NETHERLANDS(R.string.np_region_netherlands, "🇳🇱", Continent.EUROPE), | ||
DENMARK(R.string.np_region_denmark, "🇩🇰", Continent.EUROPE), | ||
SWEDEN(R.string.np_region_sweden, "🇸🇪", Continent.EUROPE), | ||
NORWAY(R.string.np_region_norway, "🇳🇴", Continent.EUROPE), | ||
FINLAND(R.string.np_region_finland, "🇫🇮", Continent.EUROPE), | ||
GREAT_BRITAIN(R.string.np_region_gb, "🇬🇧", Continent.EUROPE), | ||
IRELAND(R.string.np_region_ireland, "🇮🇪", Continent.EUROPE), | ||
POLAND(R.string.np_region_poland, "🇵🇱", Continent.EUROPE), | ||
UAE(R.string.np_region_uae, "🇦🇪", Continent.ASIA), | ||
USA(R.string.np_region_usa, "🇺🇸", Continent.NORTH_AMERICA), //TODO: it seems there's a problem with the flag | ||
AUSTRALIA(R.string.np_region_australia, "🇦🇺", Continent.OCEANIA), | ||
FRANCE(R.string.np_region_france, "🇫🇷", Continent.EUROPE), | ||
BRAZIL(R.string.np_region_br, "🇧🇷", Continent.SOUTH_AMERICA), | ||
CANADA(R.string.np_region_canada, "🇨🇦", Continent.NORTH_AMERICA); | ||
|
||
private final @StringRes int name; | ||
private final @Nullable String flag; | ||
private final Continent continent; | ||
private List<Region> subRegions; | ||
|
||
Country(@StringRes int name, @Nullable String flag, Continent continent) { | ||
this.name = name; | ||
this.flag = flag; | ||
this.continent = continent; | ||
this.continent.addSubRegion(this); | ||
this.subRegions = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
@StringRes | ||
public int getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String getName(Context context) { | ||
return context.getString(name); | ||
} | ||
|
||
@Nullable | ||
public String getFlag() { | ||
return flag; | ||
} | ||
|
||
public Continent getContinent() { | ||
return continent; | ||
} | ||
|
||
@Override | ||
public void addSubRegion(Region subRegion) { | ||
subRegions.add(subRegion); | ||
} | ||
|
||
@Override | ||
public List<Region> getSubRegions() { | ||
return subRegions; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind upgrading this to the latest
3.2.0
? The CI fails for3.0.5
for some reason.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, no problem. 😄 It's already at
3.2.2
🙊There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*
3.2.3
😆