Skip to content

Commit a35d022

Browse files
committed
Add new division and menu icons, refactor most layouts. Save latest data version in shared preferences
1 parent a9569b8 commit a35d022

File tree

184 files changed

+176
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+176
-106
lines changed

app/src/main/java/de/g00fy2/justdoit/app/controllers/ImageLoaderController.java

+2
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ public interface ImageLoaderController {
1515
void loadChampionIcon(String championKey, ImageView imageView, Boolean circleCrop);
1616

1717
void loadSpellIcon(String spellKey, ImageView imageView, Boolean circleCrop);
18+
19+
void loadDivisionIcon(String tier, int rank, ImageView imageView);
1820
}

app/src/main/java/de/g00fy2/justdoit/app/controllers/ImageLoaderControllerImpl.java

+22
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package de.g00fy2.justdoit.app.controllers;
22

3+
import android.content.res.Resources;
34
import android.graphics.drawable.Drawable;
45
import android.widget.ImageView;
56
import com.bumptech.glide.Glide;
67
import com.bumptech.glide.RequestBuilder;
78
import com.bumptech.glide.request.RequestOptions;
89
import de.g00fy2.justdoit.app.activities.BaseActivity;
910
import de.g00fy2.model.utils.Constants;
11+
import de.g00fy2.model.utils.LeagueAPIUtils;
1012
import javax.inject.Inject;
1113

1214
/**
@@ -62,6 +64,13 @@ public void loadChampionIcon(String championKey, ImageView imageView, Boolean ci
6264
}
6365
}
6466

67+
@Override public void loadDivisionIcon(String tier, int rank, ImageView imageView) {
68+
int drawableId = getIconRessourceForPosition(tier, rank);
69+
if (imageView != null && drawableId != 0) {
70+
Glide.with(baseActivity).load(drawableId).into(imageView);
71+
}
72+
}
73+
6574
private RequestBuilder<Drawable> load(String url) {
6675
return Glide.with(baseActivity).load(url);
6776
}
@@ -84,4 +93,17 @@ private String generateSpellImageUrl(String name) {
8493
String url = BASE_URL + latestVersion + "/img/spell/";
8594
return url + name + ".png";
8695
}
96+
97+
private int getIconRessourceForPosition(String tier, int rank) {
98+
tier = tier.toLowerCase();
99+
String imagename = tier + "_" + LeagueAPIUtils.transformRankToString(rank).toLowerCase();
100+
Resources res = baseActivity.getResources();
101+
int resId = res.getIdentifier(imagename, "drawable", baseActivity.getPackageName());
102+
103+
if (resId != 0) {
104+
return resId;
105+
} else {
106+
return res.getIdentifier(tier, "drawable", baseActivity.getPackageName());
107+
}
108+
}
87109
}

app/src/main/java/de/g00fy2/justdoit/app/fragments/league_position/LeaguePositionFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ public class LeaguePositionFragment extends BaseFragment
7777

7878
@Override public void setSummonerData(Summoner summoner) {
7979
if (summoner != null) {
80-
imageLoaderController.loadProfileIcon(summoner.profileIconId, leaguePositionProfileImageView,
81-
true);
8280
leaguePositionProfileTextView.setText(summoner.name);
8381
}
8482
}
8583

8684
@Override public void setLeagueData(LeaguePosition leaguePosition) {
8785
if (leaguePosition != null) {
86+
imageLoaderController.loadDivisionIcon(leaguePosition.tier, leaguePosition.rank,
87+
leaguePositionProfileImageView);
8888
leaguePositionLeagueTextView.setText(
8989
leaguePosition.tier + " " + LeagueAPIUtils.transformRankToString(leaguePosition.rank));
9090
leaguePositionNameTextView.setText(leaguePosition.leagueName);

app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/SettingsFragment.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@
3434

3535
@Override protected void initializeViews() {
3636
regionPreference = findPreference("region");
37-
regionPreference.setOnPreferenceClickListener(preference -> {
38-
presenter.showNotAvailableNotice();
39-
return true;
40-
});
37+
regionPreference.setEnabled(false);
4138
apikeyPreference = findPreference("apikey");
4239
apikeyPreference.setOnPreferenceChangeListener((preference, newValue) -> {
4340
presenter.changeAPIKey((String) newValue);

app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/SettingsModule.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import dagger.Module;
44
import dagger.Provides;
55
import de.g00fy2.justdoit.app.di.scopes.PerFragment;
6-
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetCurrentVersionInteractor;
7-
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetCurrentVersionInteractorImpl;
6+
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetDataVersionInteractor;
7+
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetDataVersionInteractorImpl;
88

99
/**
1010
* Created by Thomas Wirth on 08.12.2017.
@@ -29,8 +29,8 @@ public SettingsModule(SettingsContract.SetingsView view,
2929
return presenter;
3030
}
3131

32-
@Provides @PerFragment public GetCurrentVersionInteractor provideGetCurrentVersionInteractor(
33-
GetCurrentVersionInteractorImpl getCurrentVersionInteractorImpl) {
34-
return getCurrentVersionInteractorImpl;
32+
@Provides @PerFragment public GetDataVersionInteractor provideGetDataVersionInteractor(
33+
GetDataVersionInteractorImpl getDataVersionInteractorImpl) {
34+
return getDataVersionInteractorImpl;
3535
}
3636
}

app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/SettingsPresenterImpl.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import de.g00fy2.justdoit.app.controllers.ErrorController;
55
import de.g00fy2.justdoit.app.controllers.SnackbarController;
66
import de.g00fy2.justdoit.app.fragments.base.BasePresenterImpl;
7-
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetCurrentVersionInteractor;
7+
import de.g00fy2.justdoit.app.fragments.settings.interactors.GetDataVersionInteractor;
88
import de.g00fy2.justdoit.app.navigation.NavigationDrawer;
99
import de.g00fy2.model.api.APIKeyInterceptor;
1010
import javax.inject.Inject;
@@ -20,7 +20,7 @@ public class SettingsPresenterImpl extends BasePresenterImpl
2020

2121
@Inject APIKeyInterceptor apiKeyInterceptor;
2222
@Inject NavigationDrawer navigationDrawer;
23-
@Inject GetCurrentVersionInteractor getCurrentVersionInteractor;
23+
@Inject GetDataVersionInteractor getDataVersionInteractor;
2424
@Inject SnackbarController snackbarController;
2525
@Inject ErrorController errorController;
2626

@@ -31,7 +31,7 @@ public class SettingsPresenterImpl extends BasePresenterImpl
3131
@Override public void onResume() {
3232
super.onResume();
3333
navigationDrawer.setCheckedItem(R.id.settings);
34-
bind(getCurrentVersionInteractor.execute()
34+
bind(getDataVersionInteractor.execute()
3535
.subscribe(currentVersion -> view.setPatchversionPreference(currentVersion),
3636
errorController::onError));
3737
}

app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/interactors/GetCurrentVersionInteractor.java app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/interactors/GetDataVersionInteractor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Created by Thomas Wirth on 09.12.2017.
77
*/
88

9-
public interface GetCurrentVersionInteractor {
9+
public interface GetDataVersionInteractor {
1010

1111
Single<String> execute();
1212
}

app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/interactors/GetCurrentVersionInteractorImpl.java app/src/main/java/de/g00fy2/justdoit/app/fragments/settings/interactors/GetDataVersionInteractorImpl.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@
22

33
import de.g00fy2.justdoit.app.fragments.base.BaseInteractor;
44
import de.g00fy2.model.datastores.StaticDataDataStore;
5-
import io.reactivex.Observable;
65
import io.reactivex.Single;
76
import javax.inject.Inject;
87

98
/**
109
* Created by Thomas Wirth on 09.12.2017.
1110
*/
1211

13-
public class GetCurrentVersionInteractorImpl extends BaseInteractor
14-
implements GetCurrentVersionInteractor {
12+
public class GetDataVersionInteractorImpl extends BaseInteractor
13+
implements GetDataVersionInteractor {
1514

1615
@Inject public StaticDataDataStore staticDataDataStore;
1716

18-
@Inject GetCurrentVersionInteractorImpl() {
17+
@Inject GetDataVersionInteractorImpl() {
1918

2019
}
2120

2221
@Override public Single<String> execute() {
23-
return staticDataDataStore.getVersions()
24-
.flatMapObservable(Observable::fromIterable)
25-
.firstOrError()
26-
.compose(single());
22+
return staticDataDataStore.getDataVersion().compose(single());
2723
}
2824
}

app/src/main/java/de/g00fy2/justdoit/app/fragments/start/StartPresenterImpl.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@ public class StartPresenterImpl extends BasePresenterImpl implements StartContra
4343
navigationDrawer.setCheckedItem(R.id.home);
4444

4545
loadStoredSummoners();
46-
showLatestDataVersion();
46+
getLatestDataVersion();
4747
}
4848

4949
@Override public void searchSummoner(String summonerName) {
5050
bind(getSummonerByNameInteractor.execute(summonerName).subscribe(summoner -> {
51-
favouriteSummoners.add(summoner);
5251
view.setDefaultSummoner(summoner);
53-
view.notifyDataChanged();
5452
snackbarController.showSuccess(summoner.name + " was found!");
53+
loadStoredSummoners();
5554
}, throwable -> errorController.onError(throwable)));
5655
}
5756

@@ -84,7 +83,7 @@ private void loadStoredSummoners() {
8483
}, errorController::onError));
8584
}
8685

87-
private void showLatestDataVersion() {
86+
private void getLatestDataVersion() {
8887
bind(getVersionInteractor.execute().subscribe(latestVersion -> {
8988
view.showCurrentVersion(latestVersion);
9089
imageLoaderController.setLatestVersion(latestVersion);

app/src/main/java/de/g00fy2/justdoit/app/fragments/start/interactors/GetVersionInteractorImpl.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import de.g00fy2.justdoit.app.fragments.base.BaseInteractor;
44
import de.g00fy2.model.datastores.StaticDataDataStore;
5-
import io.reactivex.Observable;
65
import io.reactivex.Single;
76
import javax.inject.Inject;
87

@@ -18,9 +17,6 @@ public class GetVersionInteractorImpl extends BaseInteractor implements GetVersi
1817
}
1918

2019
@Override public Single<String> execute() {
21-
return staticDataDataStore.getVersions()
22-
.flatMapObservable(Observable::fromIterable)
23-
.firstOrError()
24-
.compose(single());
20+
return staticDataDataStore.getLatestDataVersionFromWeb().compose(single());
2521
}
2622
}
6.22 KB
6.13 KB
6.15 KB
6.15 KB
6.16 KB
10.7 KB
10 KB
9.99 KB
9.99 KB
10 KB
8.75 KB
8.68 KB
8.7 KB
8.69 KB
8.67 KB
9.1 KB
10.1 KB
10.1 KB
10.1 KB
10.1 KB
7.15 KB
7.1 KB
7.11 KB
7.08 KB
7.1 KB
1.94 KB
1.93 KB
1.91 KB
1.92 KB
1.92 KB
3.16 KB
2.94 KB
2.93 KB
2.94 KB
2.95 KB
2.94 KB
2.64 KB
2.62 KB
2.62 KB
2.62 KB
2.62 KB
2.76 KB
2.99 KB
2.23 KB
2.23 KB
2.23 KB
2.23 KB
2.23 KB
3.09 KB
3.07 KB
3.08 KB
3.06 KB
3.07 KB
5.25 KB
4.89 KB
4.87 KB
4.88 KB
4.86 KB
4.88 KB
4.3 KB
4.27 KB
4.28 KB
4.28 KB
4.28 KB
4.59 KB
4.96 KB
4.98 KB
4.99 KB
3.57 KB
3.53 KB
3.56 KB
3.55 KB
3.55 KB
10.2 KB
10 KB
10.1 KB
10.1 KB
10.2 KB
17.8 KB
16.6 KB
16.6 KB
16.6 KB
16.6 KB
16.6 KB
14.5 KB
14.4 KB
14.4 KB
14.4 KB
14.4 KB
15.1 KB
16.7 KB
16.6 KB
16.7 KB
16.7 KB
16.7 KB
11.6 KB
11.5 KB
11.6 KB
11.6 KB
11.6 KB
20.8 KB
20.5 KB
20.5 KB
20.6 KB
20.7 KB
36.7 KB
34.4 KB
34.4 KB
34.4 KB
34.5 KB
34.5 KB
29.8 KB
29.5 KB
29.6 KB
29.6 KB
29.6 KB
30.8 KB
33.7 KB
34.1 KB
23.5 KB
23.2 KB
23.4 KB
23.5 KB
23.5 KB
34.6 KB
34.2 KB
34.4 KB
34.4 KB
34.6 KB
61.1 KB
57.8 KB
57.9 KB
57.9 KB
58.2 KB
49.5 KB
48.9 KB
49.1 KB
49.1 KB
49.2 KB
52.1 KB
57.1 KB
57.3 KB
38.5 KB
38.8 KB
39.1 KB
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- drawable/account_multiple.xml -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path android:fillColor="#FFF" android:pathData="M16,13C15.71,13 15.38,13 15.03,13.05C16.19,13.89 17,15 17,16.5V19H23V16.5C23,14.17 18.33,13 16,13M8,13C5.67,13 1,14.17 1,16.5V19H15V16.5C15,14.17 10.33,13 8,13M8,11A3,3 0 0,0 11,8A3,3 0 0,0 8,5A3,3 0 0,0 5,8A3,3 0 0,0 8,11M16,11A3,3 0 0,0 19,8A3,3 0 0,0 16,5A3,3 0 0,0 13,8A3,3 0 0,0 16,11Z" />
8+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- drawable/finance.xml -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path android:fillColor="#FFF" android:pathData="M3,13H7V23H3V13M10,14H14V23H10V14M17,9H21V23H17V9M17,1H21V5H20V3.06L11.97,11.09L8,7.12L3.4,11.72L2.34,10.66L8,5L11.97,8.97L18.94,2H17V1Z" />
8+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- drawable/trophy.xml -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path android:fillColor="#FFF" android:pathData="M20.2,2H19.5H18C17.1,2 16,3 16,4H8C8,3 6.9,2 6,2H4.5H3.8H2V11C2,12 3,13 4,13H6.2C6.6,15 7.9,16.7 11,17V19.1C8.8,19.3 8,20.4 8,21.7V22H16V21.7C16,20.4 15.2,19.3 13,19.1V17C16.1,16.7 17.4,15 17.8,13H20C21,13 22,12 22,11V2H20.2M4,11V4H6V6V11C5.1,11 4.3,11 4,11M20,11C19.7,11 18.9,11 18,11V6V4H20V11Z" />
8+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- drawable/settings.xml -->
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path android:fillColor="#FFF" android:pathData="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z" />
8+
</vector>

app/src/main/res/layout/fragment_league_position.xml

+26-35
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,48 @@
99
>
1010

1111
<LinearLayout
12-
android:layout_width="wrap_content"
12+
android:layout_width="match_parent"
1313
android:layout_height="wrap_content"
14-
android:layout_marginBottom="8dp"
15-
android:layout_marginStart="16dp"
16-
android:layout_marginTop="16dp"
14+
android:layout_margin="8dp"
1715
android:orientation="horizontal"
1816
>
1917
<ImageView
2018
android:id="@+id/league_position_profile_imageview"
21-
android:layout_width="56dp"
22-
android:layout_height="56dp"
19+
android:layout_width="112dp"
20+
android:layout_height="112dp"
2321
/>
2422
<LinearLayout
25-
android:layout_width="match_parent"
26-
android:layout_height="match_parent"
27-
android:gravity="center"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:layout_marginEnd="16dp"
26+
android:layout_marginStart="16dp"
27+
android:layout_marginTop="8dp"
28+
android:orientation="vertical"
2829
>
2930
<TextView
3031
android:id="@+id/league_position_profile_textview"
3132
android:layout_width="wrap_content"
3233
android:layout_height="wrap_content"
33-
android:layout_marginStart="8dp"
34+
android:layout_marginBottom="8dp"
3435
android:text="Summoner"
3536
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
3637
/>
37-
</LinearLayout>
38-
</LinearLayout>
39-
40-
<LinearLayout
41-
android:layout_width="wrap_content"
42-
android:layout_height="wrap_content"
43-
android:layout_marginBottom="4dp"
44-
android:layout_marginStart="16dp"
45-
android:orientation="vertical"
46-
>
47-
48-
<TextView
49-
android:id="@+id/league_position_league_textview"
50-
android:layout_width="wrap_content"
51-
android:layout_height="wrap_content"
52-
android:layout_marginBottom="8dp"
53-
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
54-
tools:text="Gold"
55-
/>
56-
<TextView
57-
android:id="@+id/league_position_league_name_textview"
58-
android:layout_width="wrap_content"
59-
android:layout_height="wrap_content"
60-
tools:text="Vis Orakel"
61-
/>
38+
<TextView
39+
android:id="@+id/league_position_league_textview"
40+
android:layout_width="wrap_content"
41+
android:layout_height="wrap_content"
42+
android:layout_marginBottom="8dp"
43+
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
44+
tools:text="Gold"
45+
/>
46+
<TextView
47+
android:id="@+id/league_position_league_name_textview"
48+
android:layout_width="wrap_content"
49+
android:layout_height="wrap_content"
50+
tools:text="Vis Orakel"
51+
/>
6252

53+
</LinearLayout>
6354
</LinearLayout>
6455

6556
<LinearLayout

0 commit comments

Comments
 (0)