This repository was archived by the owner on May 5, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
PowerUp/app/src/main/java/powerup/systers/com/ui Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -416,6 +416,11 @@ public void updateAvatarSkin(int skin) {
416416 skinAvatar .setImageResource (skin );
417417 }
418418
419+ @ Override
420+ public void updateAvatarAccessory (int accessory ) {
421+ accessoryImageView .setImageResource (accessory );
422+ }
423+
419424 @ Override
420425 public void updateScenarioFromDatabase (Scenario scenario ) {
421426 scene = scenario ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ interface IGameScreenView {
1111 void updateAvatarCloth (int cloth );
1212 void updateAvatarHair (int hair );
1313 void updateAvatarSkin (int skin );
14+ void updateAvatarAccessory (int accessory );
1415 void updateScenarioFromDatabase (Scenario scenario );
1516 void setScenarioBackground (int id );
1617 void updateQuestion (String question );
@@ -23,6 +24,7 @@ interface IGameScreenPresenter {
2324 void calculateHairValue (int value );
2425 void calculateSkinValue (int value );
2526 void calculateClothValue (int value );
27+ void calculateAccessoryValue (int value );
2628 void setValues ();
2729 void getScenarioBackground ();
2830 void loadQuestion ();
Original file line number Diff line number Diff line change @@ -83,12 +83,32 @@ public void calculateClothValue(int value) {
8383 }
8484 }
8585
86+ @ Override
87+ public void calculateAccessoryValue (int value ) {
88+ if (value > 0 ) {
89+ String accessoryImageName = context .getResources ().getString (R .string .accessories );
90+ accessoryImageName = accessoryImageName + value ;
91+ R .drawable ourRID = new R .drawable ();
92+ java .lang .reflect .Field photoNameField ;
93+ try {
94+ photoNameField = ourRID .getClass ().getField (accessoryImageName );
95+ view .updateAvatarAccessory (photoNameField .getInt (ourRID ));
96+ } catch (NoSuchFieldException | IllegalAccessException
97+ | IllegalArgumentException error ) {
98+ Log .e ("StorePresenter" , "Error due to :" + accessoryImageName );
99+ }
100+ }
101+
102+ }
103+
86104 @ Override
87105 public void setValues () {
88106 calculateEyeValue (source .getCurrentEyeValue ());
89107 calculateClothValue (source .getCurrentClothValue ());
90108 calculateHairValue (source .getCurrentHairValue ());
91109 calculateSkinValue (source .getCurrentSkinValue ());
110+ calculateAccessoryValue (source .getCurrentAccessoriesValue ());
111+
92112 }
93113
94114 @ Override
Original file line number Diff line number Diff line change @@ -411,6 +411,11 @@ public void updateAvatarSkin(int skin) {
411411 skinAvatar .setImageResource (skin );
412412 }
413413
414+ @ Override
415+ public void updateAvatarAccessory (int accessory ) {
416+ accessoryImageView .setImageResource (accessory );
417+ }
418+
414419 @ Override
415420 public void updateScenarioFromDatabase (Scenario scenario ) {
416421 scene = scenario ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ interface IGameScreenLevel2View {
1111 void updateAvatarCloth (int cloth );
1212 void updateAvatarHair (int hair );
1313 void updateAvatarSkin (int skin );
14+ void updateAvatarAccessory (int accessory );
1415 void updateScenarioFromDatabase (Scenario scenario );
1516 void setScenarioBackground (int id );
1617 void updateQuestion (String question );
@@ -23,6 +24,7 @@ interface IGameScreenLevel2Presenter {
2324 void calculateHairValue (int value );
2425 void calculateSkinValue (int value );
2526 void calculateClothValue (int value );
27+ void calculateAccessoryValue (int value );
2628 void setValues ();
2729 void getScenarioBackground ();
2830 void loadQuestion ();
Original file line number Diff line number Diff line change @@ -82,13 +82,31 @@ public void calculateClothValue(int value) {
8282 Log .e ("GameLevel2Presenter" , "Error due to :" + clothImageName );
8383 }
8484 }
85+ @ Override
86+ public void calculateAccessoryValue (int value ) {
87+ if (value > 0 ) {
88+ String accessoryImageName = context .getResources ().getString (R .string .accessories );
89+ accessoryImageName = accessoryImageName + value ;
90+ R .drawable ourRID = new R .drawable ();
91+ java .lang .reflect .Field photoNameField ;
92+ try {
93+ photoNameField = ourRID .getClass ().getField (accessoryImageName );
94+ view .updateAvatarAccessory (photoNameField .getInt (ourRID ));
95+ } catch (NoSuchFieldException | IllegalAccessException
96+ | IllegalArgumentException error ) {
97+ Log .e ("StorePresenter" , "Error due to :" + accessoryImageName );
98+ }
99+ }
85100
101+ }
86102 @ Override
87103 public void setValues () {
88104 calculateEyeValue (source .getCurrentEyeValue ());
89105 calculateClothValue (source .getCurrentClothValue ());
90106 calculateHairValue (source .getCurrentHairValue ());
91107 calculateSkinValue (source .getCurrentSkinValue ());
108+ calculateAccessoryValue (source .getCurrentAccessoriesValue ());
109+
92110 }
93111
94112 @ Override
You can’t perform that action at this time.
0 commit comments