Refactor MainActivity.java