Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version: 1.1.5
Allow remove preference key from SharedPreferenceService
Naming convention cleaning up

Version: 1.1.4
Fix the bug that navigation may crash the app when the app just resumes from other app such as facebook login

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ The library is currently release to jCenter and MavenCentral
<dependency>
<groupId>com.shipdream</groupId>
<artifactId>android-mvc</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
</dependency>
```

**Gradle:**
```groovy
compile "com.shipdream:android-mvc:1.1.4"
compile "com.shipdream:android-mvc:1.1.5"
```

## Dependency injection with reference count
Expand Down
15 changes: 14 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def jacocoCoveredProjects = [
]

allprojects {
tasks.withType(JavaCompile) {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}

repositories {
jcenter()
mavenLocal()
Expand All @@ -56,13 +61,21 @@ allprojects {
}
}

if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}

ext {
siteUrl = 'https://github.com/kejunxia/AndroidMvc' // Homepage URL of the library
gitUrl = 'https://github.com/kejunxia/AndroidMvc.git' // Git repository URL
version = [
major: 1,
minor: 1,
patch : 4
patch : 5
]
libGroup = 'com.shipdream'
libVersion = "${version.major}.${version.minor}.${version.patch}"
Expand Down
4 changes: 2 additions & 2 deletions documents/sites/Site-MarkDown.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ The library is currently release to jCenter and MavenCentral
<dependency>
<groupId>com.shipdream</groupId>
<artifactId>android-mvc</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
</dependency>
```

**Gradle:**
```groovy
compile "com.shipdream:android-mvc:1.1.4"
compile "com.shipdream:android-mvc:1.1.5"
```

## Samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void handleAsyncError(Object sender, Exception e, RetrofitErrorHandler r
}
} else{
if (nonRetrofitErrorHandler == null){
mLogger.warn("Unhandled exception detected: {}", e.getMessage(), e);
logger.warn("Unhandled exception detected: {}", e.getMessage(), e);
} else{
nonRetrofitErrorHandler.handleException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
*/
public abstract class AbstractRetrofitMultiEndpointsController<MODEL> extends AbstractRetrofitController<MODEL> {
@Inject
Client mClient;
Client client;

private Map<String, RetrofitServiceFactory> mHttpServiceFactoryCache = new HashMap<>();
private Map<String, RetrofitServiceFactory> httpServiceFactoryCache = new HashMap<>();

/**
* Get a service for a specific endpoint. A new service will be created if not cached yet, otherwise cached service
Expand All @@ -52,11 +52,11 @@ protected void onCreateNewHttpRetrofitServiceFactory(RetrofitServiceFactory fact

private RetrofitServiceFactory getHttpServiceFactory(String endpoint) {
//Cache service factory
if(mHttpServiceFactoryCache.get(endpoint) == null) {
RetrofitServiceFactory factory = new RetrofitServiceFactory(endpoint, mClient);
if(httpServiceFactoryCache.get(endpoint) == null) {
RetrofitServiceFactory factory = new RetrofitServiceFactory(endpoint, client);
onCreateNewHttpRetrofitServiceFactory(factory, endpoint);
mHttpServiceFactoryCache.put(endpoint, factory);
httpServiceFactoryCache.put(endpoint, factory);
}
return mHttpServiceFactoryCache.get(endpoint);
return httpServiceFactoryCache.get(endpoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ public void addEncodedQueryParam(String name, String value) {
}

public static class FlexibleConverter extends GsonConverter {
private Logger mLogger = LoggerFactory.getLogger(getClass());
private Gson mGson;
private List<OnSuccessListener> mOnSuccessListeners;
private String mEncoding = "UTF-8";
private Logger logger = LoggerFactory.getLogger(getClass());
private Gson gson;
private List<OnSuccessListener> onSuccessListeners;
private String encoding = "UTF-8";
public FlexibleConverter(Gson gson, String encoding, List<OnSuccessListener> onSuccessListeners) {
super(gson, encoding);
if(mEncoding != null) {
mEncoding = encoding;
if(this.encoding != null) {
this.encoding = encoding;
}
mOnSuccessListeners = onSuccessListeners;
mGson = gson;
this.onSuccessListeners = onSuccessListeners;
this.gson = gson;
}

@Override
Expand All @@ -180,9 +180,9 @@ public Object fromBody(TypedInput body, Type type) throws ConversionException {
//return raw response string
try {
String content = inputStreamToString(body.in(), charset);
mLogger.debug("Responding json to raw string : {}", content);
logger.debug("Responding json to raw string : {}", content);

for(OnSuccessListener listener : mOnSuccessListeners) {
for(OnSuccessListener listener : onSuccessListeners) {
listener.onSuccessfulResponse();
}

Expand All @@ -199,16 +199,16 @@ public Object fromBody(TypedInput body, Type type) throws ConversionException {
InputStreamReader isr = null;
try {
Object response = null;
if(mLogger.isDebugEnabled()) {
if(logger.isDebugEnabled()) {
String content = inputStreamToString(body.in(), charset);
mLogger.debug("Responding json to object: {}", content);
response = mGson.fromJson(content, type);
logger.debug("Responding json to object: {}", content);
response = gson.fromJson(content, type);
} else {
isr = new InputStreamReader(body.in(), charset);
response = mGson.fromJson(isr, type);
response = gson.fromJson(isr, type);
}

for(OnSuccessListener listener : mOnSuccessListeners) {
for(OnSuccessListener listener : onSuccessListeners) {
listener.onSuccessfulResponse();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ interface Editor{
Editor putFloat(String key, float value);
Editor putBoolean(String key, boolean value);
Editor putString(String key, String value);
Editor remove(String key);
Editor clear();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@
import java.io.InputStreamReader;

public class AssetServiceImpl implements AssetService {
private Context mContext;
private Context context;

public AssetServiceImpl(Context context){
mContext = context;
this.context = context;
}

@Override
public InputStream getAsset(String path) throws IOException {
return mContext.getAssets().open(path);
return context.getAssets().open(path);
}

@Override
public String getStringFromAssets(String assetPath) throws IOException {
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader = null;
try {
InputStream inputStream = mContext.getAssets().open(assetPath);
InputStream inputStream = context.getAssets().open(assetPath);
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String str;
while ((str = bufferedReader.readLine()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
*
*/
public class NetworkServiceImpl implements NetworkService {
private Context mContext;
private Context context;

public NetworkServiceImpl(Context context){
mContext = context;
this.context = context;
}

@Override
public NetworkStatus getCurrentNetworkStatus() {
ConnectivityManager cm = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
if (null != activeNetwork) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,92 +25,104 @@
* Wrapper to use real Android Preference
*/
public class PreferenceServiceImpl implements PreferenceService {
private SharedPreferences mPrefs;
private SharedPreferences sharedPreferences;


public PreferenceServiceImpl(Context context, String preferenceName, int mode){
mPrefs = context.getSharedPreferences(preferenceName, mode);
sharedPreferences = context.getSharedPreferences(preferenceName, mode);
}

@Override
public boolean contains(String key) {
return mPrefs.contains(key);
return sharedPreferences.contains(key);
}

@Override
public int getInt(String key, int defaultValue) {
return mPrefs.getInt(key, defaultValue);
return sharedPreferences.getInt(key, defaultValue);
}

@Override
public long getLong(String key, long defaultValue) {
return mPrefs.getLong(key, defaultValue);
return sharedPreferences.getLong(key, defaultValue);
}

@Override
public float getFloat(String key, float defaultValue) {
return mPrefs.getFloat(key, defaultValue);
return sharedPreferences.getFloat(key, defaultValue);
}

@Override
public boolean getBoolean(String key, boolean defaultValue) {
return mPrefs.getBoolean(key, defaultValue);
return sharedPreferences.getBoolean(key, defaultValue);
}

@Override
public String getString(String key, String defaultValue) {
return mPrefs.getString(key, defaultValue);
return sharedPreferences.getString(key, defaultValue);
}

@Override
public Editor edit() {
return new AndroidPreferenceEditor(mPrefs.edit());
return new AndroidPreferenceEditor(sharedPreferences.edit());
}

private static class AndroidPreferenceEditor implements Editor{
private SharedPreferences.Editor mEditor;
private SharedPreferences.Editor editor;
AndroidPreferenceEditor(SharedPreferences.Editor andEditor){
mEditor = andEditor;
editor = andEditor;
}

@Override
public Editor putInt(String key, int value) {
return new AndroidPreferenceEditor(mEditor.putInt(key, value));
editor.putInt(key, value);
return this;
}

@Override
public Editor putLong(String key, long value) {
return new AndroidPreferenceEditor(mEditor.putLong(key, value));
editor.putLong(key, value);
return this;
}

@Override
public Editor putFloat(String key, float value) {
return new AndroidPreferenceEditor(mEditor.putFloat(key, value));
editor.putFloat(key, value);
return this;
}

@Override
public Editor putBoolean(String key, boolean value) {
return new AndroidPreferenceEditor(mEditor.putBoolean(key, value));
editor.putBoolean(key, value);
return this;
}

@Override
public Editor putString(String key, String value) {
return new AndroidPreferenceEditor(mEditor.putString(key, value));
editor.putString(key, value);
return this;
}

@Override
public Editor remove(String key) {
editor.remove(key);
return this;
}

@Override
public Editor clear() {
return new AndroidPreferenceEditor(mEditor.clear());
editor.clear();
return this;
}

@Override
public boolean commit() {
return mEditor.commit();
return editor.commit();
}

@Override
public void apply() {
mEditor.apply();
editor.apply();
}
}
}
Loading