This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginActivity extends Activity implements LoginListener { | |
@Override | |
public void onLogin() {} | |
@Override | |
public void onRegister() {} | |
@Override | |
public void onUsernameTextChanged() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginFragment extends Fragment { | |
... | |
public interface LoginListener { | |
void onLogin(); | |
void onRegister(); | |
// new added | |
void onUsernameTextChanged(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AccountActivity extends Activity implements LoginFragment.LoginListener { | |
@Override | |
public void onLogin() { | |
makeLoginRequest(); | |
} | |
@Override | |
public void onRegister() { | |
makeRegisterRequest(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginFragment extends Fragment { | |
private LoginListener loginListener; | |
//optional | |
private TextListener textListener; | |
public void setTextListener(TextListener listener) { | |
this.textListener = listener; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LoginActivity extends Activity | |
implements LoginFragment.LoginListener, LoginFragment.TextListener { | |
public void displayLoginFragment() { | |
LoginFragment fragment = LoginFragment.newInstance(); | |
fragment.setTextListener(this); | |
... | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApiManager implements ApiService { | |
private final Parser parser = new GsonParser(); | |
@Override | |
public void login(Callback callback) { | |
... | |
User user = parser.fromBody(body, User.class); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApiManager implements ApiService { | |
private final Parser parser; | |
public ApiManager(Parser parser) { | |
this.parser = parser; | |
} | |
@Override | |
public void login(Callback callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseActivity extends Activity { | |
ApiService apiService = new ApiManager(new GsonParser()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyView extends View { | |
private boolean editMode; | |
public MyView(Context context, boolean editMode){ | |
super(context); | |
this.editMode = editMode; | |
} | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyView extends View { | |
private boolean editMode; | |
public MyView(Context context, boolean editMode){ | |
super(context); | |
this.editMode = editMode; | |
} | |
//a new method |