From 085c16c84b03a3a5d52efea0bd1a698801cdc859 Mon Sep 17 00:00:00 2001 From: Claudia Brito Date: Tue, 17 Apr 2018 21:01:56 +0200 Subject: [PATCH 1/3] fix: issue 104 --- .../gorbin/asne/twitter/TwitterSocialNetwork.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/twitter/src/main/java/com/github/gorbin/asne/twitter/TwitterSocialNetwork.java b/twitter/src/main/java/com/github/gorbin/asne/twitter/TwitterSocialNetwork.java index 613cb7c..d4f4aec 100644 --- a/twitter/src/main/java/com/github/gorbin/asne/twitter/TwitterSocialNetwork.java +++ b/twitter/src/main/java/com/github/gorbin/asne/twitter/TwitterSocialNetwork.java @@ -27,7 +27,6 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.TextUtils; - import com.github.gorbin.asne.core.AccessToken; import com.github.gorbin.asne.core.OAuthActivity; import com.github.gorbin.asne.core.OAuthSocialNetwork; @@ -44,13 +43,12 @@ import com.github.gorbin.asne.core.listener.OnRequestSocialPersonCompleteListener; import com.github.gorbin.asne.core.listener.OnRequestSocialPersonsCompleteListener; import com.github.gorbin.asne.core.persons.SocialPerson; - import java.io.File; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.UUID; - import twitter4j.PagableResponseList; import twitter4j.Relationship; import twitter4j.StatusUpdate; @@ -508,9 +506,11 @@ protected Bundle doInBackground(Bundle... params) { @Override protected void onPostExecute(Bundle result) { if (!handleRequestResult(result, REQUEST_LOGIN)) return; + if (mSocialNetworkManager == null) return; - if (result.containsKey(RESULT_OAUTH_LOGIN)) { - Intent intent = new Intent(mSocialNetworkManager.getActivity(), OAuthActivity.class) + WeakReference contextReference = new WeakReference(mSocialNetworkManager.getActivity()); + if (result.containsKey(RESULT_OAUTH_LOGIN) && contextReference.get() != null) { + Intent intent = new Intent(contextReference.get(), OAuthActivity.class) .putExtra(OAuthActivity.PARAM_CALLBACK, mRedirectURL) .putExtra(OAuthActivity.PARAM_URL_TO_LOAD, result.getString(RESULT_OAUTH_LOGIN)); From ec00831dcfca5002cb7267db9bd46ec7ac4e2c41 Mon Sep 17 00:00:00 2001 From: Claudia Brito Date: Tue, 17 Apr 2018 21:19:25 +0200 Subject: [PATCH 2/3] task: publish Android library by Jitpack --- ASNECore/build.gradle | 3 +++ build.gradle | 1 + facebook/build.gradle | 3 +++ googleplus/build.gradle | 3 +++ instagram/build.gradle | 3 +++ linkedin/build.gradle | 3 +++ odnoklassniki/build.gradle | 3 +++ twitter/build.gradle | 3 +++ vk/build.gradle | 2 ++ 9 files changed, 24 insertions(+) diff --git a/ASNECore/build.gradle b/ASNECore/build.gradle index 548812c..94933a4 100644 --- a/ASNECore/build.gradle +++ b/ASNECore/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/build.gradle b/build.gradle index 3306e56..6a74226 100644 --- a/build.gradle +++ b/build.gradle @@ -5,6 +5,7 @@ buildscript { } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } diff --git a/facebook/build.gradle b/facebook/build.gradle index 5d2f84a..3c9c752 100644 --- a/facebook/build.gradle +++ b/facebook/build.gradle @@ -1,5 +1,8 @@ apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/googleplus/build.gradle b/googleplus/build.gradle index e0a5d33..24e7985 100644 --- a/googleplus/build.gradle +++ b/googleplus/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/instagram/build.gradle b/instagram/build.gradle index 1251e8a..3ec6875 100644 --- a/instagram/build.gradle +++ b/instagram/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/linkedin/build.gradle b/linkedin/build.gradle index 1dbce8f..56f5ed7 100644 --- a/linkedin/build.gradle +++ b/linkedin/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/odnoklassniki/build.gradle b/odnoklassniki/build.gradle index 47bd6d6..9178dfa 100644 --- a/odnoklassniki/build.gradle +++ b/odnoklassniki/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/twitter/build.gradle b/twitter/build.gradle index 992f2a5..10a258f 100644 --- a/twitter/build.gradle +++ b/twitter/build.gradle @@ -1,6 +1,9 @@ apply plugin: 'com.android.library' apply from: '../maven_push.gradle' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' + android { compileSdkVersion 23 buildToolsVersion '25.0.0' diff --git a/vk/build.gradle b/vk/build.gradle index 91b4488..c3c3051 100644 --- a/vk/build.gradle +++ b/vk/build.gradle @@ -1,5 +1,7 @@ apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' +group='com.github.claudiabrito' android { compileSdkVersion 23 From 84b07dc1f22710dc6e439aaa5294ae03674fe62b Mon Sep 17 00:00:00 2001 From: Claudia Brito Date: Tue, 17 Apr 2018 21:27:24 +0200 Subject: [PATCH 3/3] fix: remove boilerplate code --- .../googleplus/GooglePlusSocialNetwork.java | 17 +---- .../gorbin/asne/googleplus/MomentUtil.java | 63 ------------------- 2 files changed, 3 insertions(+), 77 deletions(-) diff --git a/googleplus/src/main/java/com/github/gorbin/asne/googleplus/GooglePlusSocialNetwork.java b/googleplus/src/main/java/com/github/gorbin/asne/googleplus/GooglePlusSocialNetwork.java index 10410e7..cfa15d4 100644 --- a/googleplus/src/main/java/com/github/gorbin/asne/googleplus/GooglePlusSocialNetwork.java +++ b/googleplus/src/main/java/com/github/gorbin/asne/googleplus/GooglePlusSocialNetwork.java @@ -21,15 +21,14 @@ *******************************************************************************/ package com.github.gorbin.asne.googleplus; -import android.content.Context; import android.app.Activity; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; - import com.github.gorbin.asne.core.AccessToken; import com.github.gorbin.asne.core.SocialNetwork; import com.github.gorbin.asne.core.SocialNetworkException; @@ -45,9 +44,8 @@ import com.github.gorbin.asne.core.listener.OnRequestSocialPersonsCompleteListener; import com.github.gorbin.asne.core.persons.SocialPerson; import com.google.android.gms.auth.GoogleAuthUtil; +import com.google.android.gms.auth.UserRecoverableAuthException; import com.google.android.gms.common.ConnectionResult; -import com.google.android.gms.common.GooglePlayServicesClient; -import com.google.android.gms.common.Scopes; import com.google.android.gms.common.api.CommonStatusCodes; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.ResultCallback; @@ -56,7 +54,6 @@ import com.google.android.gms.plus.PlusShare; import com.google.android.gms.plus.model.people.Person; import com.google.android.gms.plus.model.people.PersonBuffer; - import java.io.File; import java.util.ArrayList; import java.util.List; @@ -68,7 +65,7 @@ * @author Anton Krasov * @author Evgeny Gorbin (gorbin.e.o@gmail.com) */ -public class GooglePlusSocialNetwork extends SocialNetwork implements GooglePlayServicesClient.ConnectionCallbacks, GooglePlayServicesClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { +public class GooglePlusSocialNetwork extends SocialNetwork implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { /*** Social network ID in asne modules, should be unique*/ public static final int ID = 3; @@ -637,14 +634,6 @@ public void onConnectionSuspended(int i) { mConnectRequested = false; } - /** - * Called when the client is disconnected. - */ - @Override - public void onDisconnected() { - mConnectRequested = false; - } - /** * Called when there was an error connecting the client to the service. * @param connectionResult A ConnectionResult that can be used for resolving the error, and deciding what sort of error occurred. diff --git a/googleplus/src/main/java/com/github/gorbin/asne/googleplus/MomentUtil.java b/googleplus/src/main/java/com/github/gorbin/asne/googleplus/MomentUtil.java index d1aa98c..dba7c4b 100644 --- a/googleplus/src/main/java/com/github/gorbin/asne/googleplus/MomentUtil.java +++ b/googleplus/src/main/java/com/github/gorbin/asne/googleplus/MomentUtil.java @@ -16,8 +16,6 @@ package com.github.gorbin.asne.googleplus; -import com.google.android.gms.plus.model.moments.ItemScope; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -67,65 +65,4 @@ public class MomentUtil { ACTIONS[i] = "http://schemas.google.com/" + ACTIONS[i]; } } - - /** - * Generates the "result" JSON object for select moments. - * - * @param momentType The type of the moment. - */ - public static ItemScope getResultFor(String momentType) { - if (momentType.equals("CommentActivity")) { - return getCommentActivityResult(); - } - if (momentType.equals("ReserveActivity")) { - return getReserveActivityResult(); - } - if (momentType.equals("ReviewActivity")) { - return getReviewActivityResult(); - } - return null; - } - - /** - * Generates the "result" JSON object for CommentActivity moment. - */ - private static ItemScope getCommentActivityResult() { - return new ItemScope.Builder() - .setType("http://schema.org/Comment") - .setUrl("https://developers.google.com/+/plugins/snippet/examples/blog-entry#comment-1") - .setName("This is amazing!") - .setText("I can't wait to use it on my site!") - .build(); - } - - /** - * Generates the "result" JSON object for ReserveActivity moment. - */ - private static ItemScope getReserveActivityResult() { - return new ItemScope.Builder() - .setType("http://schemas.google.com/Reservation") - .setStartDate("2012-06-28T19:00:00-08:00") - .setAttendeeCount(3) - .build(); - } - - /** - * Generates the "result" JSON object for ReviewActivity moment. - */ - private static ItemScope getReviewActivityResult() { - ItemScope rating = new ItemScope.Builder() - .setType("http://schema.org/Rating") - .setRatingValue("100") - .setBestRating("100") - .setWorstRating("0") - .build(); - - return new ItemScope.Builder() - .setType("http://schema.org/Review") - .setName("A Humble Review of Widget") - .setUrl("https://developers.google.com/+/plugins/snippet/examples/review") - .setText("It is amazingly effective") - .setReviewRating(rating) - .build(); - } }