Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mvp-with-dagger2 #2

Open
wants to merge 3 commits into
base: mvp-with-dagger2
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions autoupdate/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def _versionCode = 100 * majorNumber + 100 * minorNumber + patchNumber
def _versionName = "$majorNumber" + "." + "$minorNumber" + "." + "$patchNumber"

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
compileSdkVersion 25
buildToolsVersion '25.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 24
targetSdkVersion 25
versionCode _versionCode
versionName "$_versionName"
}
Expand Down Expand Up @@ -65,10 +65,10 @@ ext {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.google.dagger:dagger:2.+'
apt 'com.google.dagger:dagger-compiler:2.+'
compile 'com.google.dagger:dagger:2.7'
apt 'com.google.dagger:dagger-compiler:2.7'
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
Expand Down
37 changes: 23 additions & 14 deletions autoupdate/src/main/java/com/digigene/autoupdate/UpdateRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.net.HttpURLConnection;

import javax.inject.Inject;
Expand Down Expand Up @@ -60,31 +61,39 @@ public void update() {
new UpdateCommand().execute();
}

private class UpdateCommand extends AsyncTask<Void, Void, Void> {
private class UpdateCommand extends AsyncTask<Void, Void, Response> {
private Response response;
private HttpURLConnection httpURLConnection;

@Override
protected Void doInBackground(Void... aVoid) {
protected Response doInBackground(Void... aVoid) {
httpURLConnection = serverConnection.makeGetRequest();
response = new ResponseActionFactory(updateParams.getResUnsuccessful())
.makeResponse(httpURLConnection, context, activity);
if (httpURLConnection != null) {
try {
try {
response = new ResponseActionFactory(updateParams.getResUnsuccessful())
.makeResponse(httpURLConnection, context, activity);
if (httpURLConnection != null) {
httpURLConnection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
}
return response;
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
return null;
}

@Override
protected void onPostExecute(Void aVoid) {
if (ServerConnection.isResponseSuccessful(response.getResponseCode())) {
updateFileInfo.extractDataFromJson(response, updateParams.getJsonKeys());
updateDialogTextsAttrs();
updateAction.update();
protected void onPostExecute(Response response) {
if (response != null) {
if (ServerConnection.isResponseSuccessful(response.getResponseCode())) {
updateFileInfo.extractDataFromJson(response, updateParams.getJsonKeys());
updateDialogTextsAttrs();
updateAction.update();
} else {
return;
}
} else {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Response responseCodeIs2xx(HttpURLConnection httpURLConnection) {
}

public Response makeResponse(HttpURLConnection httpURLConnection, Context context, Activity
activity) {
activity) throws IOException {
int responseCode = 0;
try {
responseCode = httpURLConnection.getResponseCode();
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
Expand Down
6 changes: 3 additions & 3 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
compileSdkVersion 25
buildToolsVersion '25.0.3'

defaultConfig {
applicationId "com.digigene.autoupdatetest"
Expand All @@ -22,6 +22,6 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(':autoupdate')
}