Skip to content

Instantly share code, notes, and snippets.

View orhanobut's full-sized avatar

Orhan Obut orhanobut

View GitHub Profile
final class DiskPersistence {
private final static DiskPersistence instance = new DiskPersistence();
public static DiskPersistence getInstance() {
return instance;
}
private DiskPersistence() {
// prevents to create a new instance
interface Persistence {
void delete();
void add(String value);
String get();
}
static class EmptyPersistence implements Persistence {
private static Persistence persistence;
interface Persistence {
void delete();
void add(String value);
String get();
}
static class EmptyPersistence implements Persistence {
@Override void delete(){
}
interface Persistence {
void delete();
void add(String value);
String get();
}
class FooBar {
private Persistence persistence;
void persistence(Persistence persistence) {
public class LoginFragment extends Fragment {
void onLoginClicked(){}
void makeLoginRequest(){}
void displayHome(){}
void onRegisterClicked(){}
void displayRegistrationFragment(){}
}
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
user = User.newUser(response.userResponse);
}
}
public class User {
private final String id;
private final String name;
public User(UserResponse response) {
if (response != null) {
id = response.id;
name = response.name;
}
}
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
UserResponse userResponse = response.userResponse;
if (userResponse != null) {
user = new User(response.userResponse);
}
public class Account {
private final User user;
private final String id;
public Account(AccountResponse response) {
id = response.id;
user = new User(response.userResponse);
}
}
public class MyFragment extends Fragment {
private static final String KEY_NAME = "KEY_NAME";
public static Fragment newFragment(String name) {
Fragment fragment = new MyFragment();
Bundle bundle = new Bundle();
bundle.putExtra(KEY_NAME, name);
fragment.setArguments(bundle);
return fragment;
}