Skip to content
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

Excercise 1 - 2016.10.27 - Balázs Ujlaki #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bujlaki
Copy link

@bujlaki bujlaki commented Oct 27, 2016

Please review

Added activities: NewTodoActivity (for mobile mode)
HomeActivity is used for tablet mode
@cristiantanas
Copy link
Owner

¡Muy buen trabajo! Sólo algunos comentarios:

  • Los ficheros del directorio .idea no se deberían incluir en el sistema de control de versiones. Son ficheros específicos de la instalación de Android Studio y generarían conflicto si alguien se intenta bajar los cambios. Simplemente habría que incluir el directorio en el fichero .git_ignore.
  • También es una buena práctica comprobar que las Activities realmente implementen las interfaces que definimos en los Fragments. Por ejemplo:
((NewTodoFragmentActionListener) activity).onSave();

Si la Activity no implementa la interfaz NewTodoFragmentActionListener tendremos una excepción no controlada. Podríamos resolver esto en el onAttach del Fragment:

@Override
public void onAttach(Context context) {
     super.onAttach(context);
     if(context instanceof Activity) {
          activity = (Activity) context;
         // Assumiendo que tenemos una variable de tipo NewTodoFragmentActionListener
         try { 
              this.listener = (NewTodoFragmentActionListener) activity; 
         } catch (ClassCastException exception) { 
              throw new ClassCastException("The activity does not implement the interface."); 
         }
     }
}

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.

2 participants