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 SQLSchema { | |
private Map<String, TypeHandler> fields = new HashMap<String, TypeHandler>(); | |
private Class<? extends Storable> clazz; | |
public SQLSchema(Class<? extends Storable> clazz) { | |
this.clazz = clazz; | |
Field[] fields = SQLHelper.getFields(clazz); | |
for (Field field : fields) { | |
fields.put(field.getName(), TypeHandler.getHandler(field.getType())); |
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
DelegatingRequest<JSONObject> tokenRequest = new DelegatingRequest<JSONObject>( | |
Method.POST, TOKEN_URL, NewtorkResponseParser.jsonObjectParser, | |
new Listener<JSONObject>() { | |
@Override | |
public void onResponse(JSONObject response) { | |
ACCESS_TOKEN = response.optString("access_token"); | |
// Do the rest of the treatment | |
} | |
}, new ErrorListener() { |
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
ImageLoader imageLoader = new ExtendedImageLoader(queue, new BitmapLru(64000), new ImageRequestFactory() { | |
@Override | |
public Request<?> getImageRequest(String url, Listener<Bitmap> listener, | |
int maxWidth, int maxHeight, Config config, | |
ErrorListener errorListener) { | |
return new MyImageRequest(url, listener, maxWidth, maxHeight, config, errorListener); | |
} | |
}); |
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 StringParser implements NewtorkResponseParser<String> { | |
@Override | |
public Response<String> parseResponse(NetworkResponse response) { | |
String parsed; | |
try { | |
parsed = new String(response.data, | |
HttpHeaderParser.parseCharset(response.headers)); | |
} catch (UnsupportedEncodingException e) { | |
parsed = new String(response.data); |
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 DelegatingRequest<T> extends Request<T> { | |
Listener<T> listener; | |
NewtorkResponseParser<T> parser; | |
Map<String, String> headers = new HashMap<String, String>(); | |
byte[] customBody = null; | |
Map<String, String> params = new HashMap<String, String>(); | |
private String customBodyContentType = null; | |
public DelegatingRequest(int method, String url, NewtorkResponseParser<T> parser, Listener<T> listener, ErrorListener errorListener) { |
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
return new ImageRequest(url, listener, maxWidth, maxHeight, config, errorListener); |
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 interface ImageRequestFactory { | |
public Request<?> getImageRequest(String url, Listener<Bitmap> listener, | |
int maxWidth, int maxHeight, Config config, ErrorListener errorListener); | |
} |
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 ExtendedImageLoader extends ImageLoader { | |
/** ... */ | |
/** Creator of Image Requests */ | |
private ImageRequestFactory mImageRequestFactory; | |
/** ... */ |
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 { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_login); | |
} | |
public void login(View target) { | |
// 30% chances to be logged in ! |
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 RestrictedActivity extends LoginableActivity { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
if (!loggedIn) { | |
login(null); | |
} else { | |
startup(); |