richk / courserademoapp Goto Github PK
View Code? Open in Web Editor NEWDemo app to demonstrate creating Android app based on VIPER + MVVM
License: Apache License 2.0
Demo app to demonstrate creating Android app based on VIPER + MVVM
License: Apache License 2.0
I just across your repo which is very good appreciate by Open Source Community (Stars: 255)
Seeing the repo I could not get an overview of the project so I think need info so it will easy to understand.
Also, it will be good to adding screenshots of applications.
I cant find demo.catalog.coursera.org.courserademoapp.di.DaggerApplicationComponent class.
Error 'Cannot resolve' in CourseraDemoApplication for line:
import demo.catalog.coursera.org.courserademoapp.di.DaggerApplicationComponent;
I'm trying to reproduce this architecture in my app. But I'm using Fragments instead Activity.
I've created same approach and it worked fine in an Activity, but when I try to convert to Fragment, the presenter is never injected by dagger. Why?
MyComponent
@FragmentScope
@Component(dependencies = ApplicationComponent.class, modules = {MyModule.class})
public interface MyComponent {
void inject(Fragment activity);
}
MyModule.java
@Module
public class MyModule {
private final Fragment fragment;
public MyModule(Fragment fragment) {
this.fragment = fragment;
}
@Provides
@Named("fragment")
@FragmentScope
Context provideFragmentContext(){
return fragment.getContext();
}
@Provides
@FragmentScope
RedePresenter providePresenter(UserInteractor interactor){
return new MyPresenter(interactor);
}
@Provides
@FragmentScope
UserInteractor provideInteractor(VeekerNetworkService networkService){
return new UserInteractor(networkService);
}
@Provides
@FragmentScope
NetworkUsersAdapter providesNetworkAdapter(){
return new NetworkUsersAdapter(fragment.getContext());
}
}
MyFragment.java
public class MyFragment extends Fragment {
@Inject
NetworkUsersAdapter mAdapter;
@Inject
MyPresenter mPresenter;
private MyComponent mComponent;
private Subscription mViewModelSubscription;
public MyFragment() {
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mComponent = DaggerMyComponent.builder()
.applicationComponent(((MyApplication) getActivity().getApplication()).getAppComponent())
.myModule(new MyModule(this))
.build();
mComponent.inject(this);
mPresenter.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_layou container, false);
return rootView;
}
@Override
public void onResume() {
super.onResume();
mViewModelSubscription = mPresenter.onResume(new Action1<NetworkParceableViewModel>() {
@Override
public void call(NetworkParceableViewModel viewModel) {
final List<User> users = viewModel.userList();
mAdapter.setNewData(users);
mAdapter.notifyDataSetChanged();
}
});
}
@Override
public void onPause() {
super.onPause();
mViewModelSubscription.unsubscribe();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mPresenter.onPause(outState);
}
I think there is a problem when rotating screen while background task is running. When I start the screen for the first time and interactor starts network request and I rotate the screen 2 requests are triggerred. How should we fix this in order to make interactor requests survive orientation and just delivere results like with Nucleus mvp implementation.
Retrofit giving error 404 for URLs provided in app. Please update URLs.
06-11 02:34:57.490 20630-20658/demo.catalog.coursera.org.courserademoapp D/Retrofit: ---> HTTP GET https://api.coursera.org/api/catalog.v1/courses?fields=smallIcon
06-11 02:34:57.490 20630-20658/demo.catalog.coursera.org.courserademoapp D/Retrofit: ---> END HTTP (no body)
06-11 02:34:57.491 20630-20658/demo.catalog.coursera.org.courserademoapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
06-11 02:34:57.716 20630-20650/demo.catalog.coursera.org.courserademoapp D/EGL_emulation: eglMakeCurrent: 0xa92050c0: ver 2 0 (tinfo 0xa92031f0)
06-11 02:34:59.110 20630-20658/demo.catalog.coursera.org.courserademoapp D/Retrofit: <--- HTTP 404 https://api.coursera.org/api/catalog.v1/courses?fields=smallIcon (1619ms)
06-11 02:34:59.110 20630-20658/demo.catalog.coursera.org.courserademoapp D/Retrofit: : HTTP/1.1 404 Not Found
Hi,
I am trying to implement the architecture for my new project. It was working fine for simple cases like showing list and inflating data in views.
Now, I want to try few more simpler events like Toast or showing error messages from viewmodel.
Please share how do you solve this problem.
Thanks
Hi, I saw you talk in youtube and was looking in your code, so I wonder why you navigate to the CatalogActivity in the MainActivity onCreate?
Is MainActivity even necessary?
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FlowController.launchCatalogActivity(this); }
Great talk by the way!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.