Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Noh.Jaechun
authored and
Noh.Jaechun
committed
Oct 12, 2017
1 parent
d2a9486
commit bba6a30
Showing
5 changed files
with
100 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.suribada.rxjavabook.weather; | ||
|
||
/** | ||
* Created by Naver on 2017. 10. 12.. | ||
*/ | ||
public class Area { | ||
|
||
public String code; | ||
} |
59 changes: 59 additions & 0 deletions
59
app/src/main/java/com/suribada/rxjavabook/weather/LegacyWeatherRepository.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,59 @@ | ||
package com.suribada.rxjavabook.weather; | ||
|
||
import android.location.Location; | ||
|
||
/** | ||
* 콜백 Hell 표현 | ||
* | ||
* Created by Naver on 2017. 10. 12.. | ||
*/ | ||
public class LegacyWeatherRepository { | ||
|
||
public interface AreaResultListener { | ||
void onResult(int code, Area area); | ||
void onFailure(Throwable e); | ||
} | ||
|
||
public interface WeatherResultListener { | ||
void onResult(int code, Weather weather); | ||
void onFail(Throwable e); | ||
} | ||
|
||
public void requestWeather(Location location) { | ||
requestLocationCode(location, new AreaResultListener() { | ||
@Override | ||
public void onResult(int code, Area area) { | ||
String areaCode = "1111"; // 디폴트 위치 | ||
if (code == 200) { | ||
areaCode = area.code; | ||
} | ||
requestWeather(areaCode, new WeatherResultListener() { | ||
|
||
@Override | ||
public void onResult(int code, Weather weather) { | ||
// 화면에 보여주기 | ||
} | ||
|
||
@Override | ||
public void onFail(Throwable e) { | ||
// 로그나 Toast | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onFailure(Throwable e) { | ||
// 로그나 Toast | ||
} | ||
}); | ||
} | ||
|
||
public void requestLocationCode(Location location, AreaResultListener listener) { | ||
|
||
} | ||
|
||
public void requestWeather(String areaCode, WeatherResultListener listener) { | ||
|
||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/suribada/rxjavabook/weather/Weather.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,8 @@ | ||
package com.suribada.rxjavabook.weather; | ||
|
||
/** | ||
* Created by Naver on 2017. 10. 12.. | ||
*/ | ||
|
||
public class Weather { | ||
} |
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