Skip to content

Conversation

@AFGhazy
Copy link
Owner

@AFGhazy AFGhazy commented Jul 28, 2018

No description provided.

@AFGhazy AFGhazy changed the title No dagger2 nor data manager Add main functionality with out dagger2 nor data manager Jul 28, 2018
Copy link

@IslamSalah IslamSalah left a 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 for adapter package, we can move the adapter to the concerned feature package.
    = No need to activity package, check how this sample handled it.
    = No need for viewHolders package, we should rather move it the feature package.
    = All feature packages can be enclosed in anther package. check how this sample handled it.
    = apiInterface and networks packages 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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AFGhazy Kindly check this for best practices for class member ordering.

@BindView(R.id.nav_view) NavigationView navigationView;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {

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());

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]

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();

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,

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'

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{

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() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AFGhazy I suggest putting the annotations in a separate line abovew the method signature as you did in NewTodoPresenter Check this

android:padding="20dp"
>


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();

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();

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();

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() {

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) {

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());

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;

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants