-
Notifications
You must be signed in to change notification settings - Fork 0
Add main functionality with out dagger2 nor data manager #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ghazy The sample is actually impressive. Most of the comments I left are minor.
Here are some points I believe you need to consider IMHO:
- Consider having a good commit history with descriptive name [The same comment was left on Quiz1]
- The Project structure needs to be improved a little to follow MVP pattern:
= No need foradapterpackage, we can move the adapter to the concerned feature package.
= No need toactivitypackage, check how this sample handled it.
= No need forviewHolderspackage, we should rather move it the feature package.
= All feature packages can be enclosed in anther package. check how this sample handled it.
=apiInterfaceandnetworkspackages should be nested into data package. Check the above sample.
= All package names should be lowercase without underscores. Check (this)[https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html]
CC @ayman
| */ | ||
|
|
||
| public abstract class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { | ||
| protected abstract Fragment createFragment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @BindView(R.id.nav_view) NavigationView navigationView; | ||
|
|
||
| @Override | ||
| protected void onCreate(@Nullable Bundle savedInstanceState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy I suggest breaking this method into smaller ones. [Check similar comment on Quiz1 PR].
|
|
||
| for(NavigationItemEnum item: NavigationItemEnum.values()) { | ||
| if(item.getId() == menuItem.getItemId()) { | ||
| Intent i = new Intent(getApplicationContext(), item.getClassToLaunch()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy Intent iI vote for using descriptive good names rather than very short ones. What do you think? [minor comment]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also why getApplicationContext(), this or getActivity in case of fragment should be enough
| interface View extends BaseView<Presenter> { | ||
|
|
||
| String getTitle(); | ||
| String getDescription(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy I suggest leaving blank lines between different methods.
| "title": "Buy grocery", | ||
| "details": "Go to the market to buy carrots", | ||
| "done": false | ||
| "done": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy +1 For making a virtual back-end server 👍
|
|
||
| implementation 'io.reactivex:rxandroid:1.2.1' | ||
| implementation 'io.reactivex:rxjava:1.3.0' | ||
| implementation 'io.reactivex.rxjava2:rxandroid:2.0.2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy +1 For using RxJava
| * Created by ahmedghazy on 7/25/18. | ||
| */ | ||
|
|
||
| public interface BasePresenter extends LifecycleObserver{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy +1 for using LifecycleObserver
| } | ||
|
|
||
| @Override | ||
| @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) public void stop() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| android:padding="20dp" | ||
| > | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy I vote for removing these many blank lines.
|
|
||
| interface Presenter extends BasePresenter { | ||
|
|
||
| void getTodos(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy +1 for nice contract method names.
| public void getTodos() { | ||
|
|
||
| mView.showWait(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy avoid too many blank lines
| @Override | ||
| public void getTodos() { | ||
|
|
||
| mView.showWait(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy Always check that views are available before calling them, the callbacks may be received after the view is closed or killed by the OS
| mTitle.setText(todo.getTitle()); | ||
| mDescription.setText(todo.getDetails()); | ||
| mDone.setChecked(todo.isDone()); | ||
| mDone.setOnClickListener(new View.OnClickListener() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy Butterknife it
|
|
||
| DisposableObserver<Todo> disposableObserver = mTodosSubscriber.updateTodo(new TodosSubscriber.Callback<Todo>() { | ||
| @Override | ||
| public void onSuccess(Todo todo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy It is good to give the user feedback of success/failure of updating requests
|
|
||
| for(NavigationItemEnum item: NavigationItemEnum.values()) { | ||
| if(item.getId() == menuItem.getItemId()) { | ||
| Intent i = new Intent(getApplicationContext(), item.getClassToLaunch()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also why getApplicationContext(), this or getActivity in case of fragment should be enough
| private CompositeDisposable mCompositeDisposable; | ||
|
|
||
| public static NewTodoPresenter getInstance(TodosSubscriber todosSubscriber, NewTodoContract.View view) { | ||
| return sNewTodoPresenter == null ? new NewTodoPresenter(todosSubscriber, view) : sNewTodoPresenter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AFGhazy I believe this line needs a little modification, as sNewTodoPresenter will be null forever. Please let me know if I missed something.
It could be fixed as shown below. but I vote for implementing it as here.
return sNewTodoPresenter == null ? sNewTodoPresenter = new NewTodoPresenter(todosSubscriber, view) : sNewTodoPresenter;
Kindly let me know what you think.
No description provided.