问题
I am playing around with square up android Motor & Flow library . I tried to pass the data from Screen A to Screen B and I am able to successfully retrieve data at Screen B . The problem araise while I try to call Screen B from Screen B (Re creation of same screen again).
Screen A
@Override
public Object createComponent(MainActivity.Component parent) {
return DaggerScreenA_Component.builder().component(parent).fingerPrintModule(new FingerPrintModule()).moduleDependencies(new ModuleDependencies()).build();
}
@dagger.Component(dependencies = MainActivity.Component.class,modules = {ModuleDependencies.class, FingerPrintModule.class})
@DaggerScope(Component.class)
public interface Component extends AppDependencies {
void inject(ViewA view);
SharedPreferences sharedPreferences();
FingerprintManager fingerprintManager();
KeyguardManager keyguardManager();
}
@DaggerScope(Component.class)
public static class Presenter extends ViewPresenter<ViewA> {
@Inject
RestClient restClient;
@Inject
ResponseCache responseCache;
@Inject
SharedPreferences sharedPreferences;
@Inject
FingerprintManager fingerprintManager;
@Inject
KeyguardManager keyguardManager;
Context context;
public Callback<WeatherResponse> configServiceCallback = new Callback<WeatherResponse>() {
@Override
public void onResponse(Call<WeatherResponse> call, Response<WeatherResponse> response) {
Log.d("ScreenA","Response data -->"+response.body().toString());
responseCache.setWeatherResponse(response.body());
Flow.get(context).setHistory(History.single(new ScreenB("Value Passed from previous Screen")), Flow.Direction.FORWARD);
}
@Override
public void onFailure(Call<WeatherResponse> call, Throwable t) {
}
};
private String errorMessage = "";
@Inject
Presenter() {
}
@Override
protected void onLoad(Bundle savedInstanceState) {
super.onLoad(savedInstanceState);
context = getView().getContext();
Log.e("Screen A","shared preferences-->"+sharedPreferences.getBoolean("HARI",false));
Log.e("Screen A","fingerprintManager-->"+fingerprintManager);
restClient.getService(WeatherService.class).getConfiguration().enqueue(configServiceCallback);
}
}
Screen B:
private static String value = "";
public ScreenB(String value) {
this.value = value;
}
@Override
public Object createComponent(MainActivity.Component parent) {
return DaggerScreenB_Component.builder().component(parent).fingerPrintModule(new FingerPrintModule()).module(new Module()).build();
}
@dagger.Component(dependencies = MainActivity.Component.class,modules = {FingerPrintModule.class,Module.class})
@DaggerScope(Component.class)
public interface Component extends AppDependencies {
void inject(ViewB view);
FingerprintManager fingerprintManager();
KeyguardManager keyguardManager();
}
@DaggerScope(Component.class)
public static class Presenter extends ViewPresenter<ViewB> {
Context context;
@Inject
FingerprintManager fingerprintManager;
private String errorMessage = "";
@Inject
ResponseCache responseCache;
String value = "";
@Inject
Presenter(String value) {
this.value= value;
}
@Override
protected void onLoad(Bundle savedInstanceState) {
super.onLoad(savedInstanceState);
context = getView().getContext();
Log.d("ScreenB","Entered Value-->"+value);
getView().textView.setText(value);
}
public void moveToNext(){
Flow.get(context).setHistory(History.single(new ScreenB(getView().editText.getText().toString())), Flow.Direction.FORWARD);
}
}
@dagger.Module
public static class Module {
@Provides
@DaggerScope(Component.class)
public String provideValue() {
return value;
}
}
I have added this project it to Github also.Any one faced this issue ? Please share your comments and suggestions. Thanks in Advance.
来源:https://stackoverflow.com/questions/39535781/data-parsing-issue-at-android-while-using-flow-path-to-create-the-same-screen-ag