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

483/Remove PlusClient dependencies #589

Merged
merged 13 commits into from
Mar 18, 2016
Merged

483/Remove PlusClient dependencies #589

merged 13 commits into from
Mar 18, 2016

Conversation

friedger
Copy link
Contributor

This PR removes the dependency to the Google Plus Client (json/java) and removes the dependencies.

Now the app is below 65k methods and is used without multidex.

This PR includes also the changes of #587

import okhttp3.Request;
import okhttp3.Response;

public class PlusImageResizer implements Interceptor {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what is left from the PlusPersonDownloader

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives size to the api but the intention of this is not to resize the image. It gets the image from Google+ URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. What about PlusImageFetcher?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or PlusImageUrlConverter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah actually it is not a downloader. Converter makes really sense.

@tasomaniac
Copy link
Member

Oh man, this is huge. I will review this later tonight. This is great!

import java.io.OutputStream;
import java.net.HttpURLConnection;

public class GapiOkHttpRequest extends LowLevelHttpRequest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally! 😄

@tasomaniac
Copy link
Member

I thought this would be much much more difficult. I thought we would have to refactor whole NewsFeed parsing etc.

This is really awesome. I just have couple of comments and that's all.

@tasomaniac
Copy link
Member

BTW, this PR also includes the changes in #588
Sorry for re-opning it. :) I think that why you closed it before. I will close it now

+ "nextPageToken,"
+ "items(id,published,url,object/content,verb,"
+ "object/attachments,annotation,object(plusoners,replies,resharers))"
+ "&key=" + BuildConfig.IP_SIMPLE_API_ACCESS_KEY)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using key here (instead of in an interceptor) makes it more explicit where the authentication takes place. I prefer this solution of a

public class ApiKeyAdder implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();

        HttpUrl newUrl = original.url().newBuilder()
            .addQueryParameter("key", BuildConfig.IP_SIMPLE_API_ACCESS_KEY).build();
        Request.Builder requestBuilder = original.newBuilder().url(newUrl);

        Request request = requestBuilder.build();
        return chain.proceed(request);
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this interceptor. API keys and Auth related things usually done in interceptor anyways. That's what Square does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is added now.

public static final String CACHE_KEY_PERSON = "person_";
public static final String CACHE_KEY_NEWS = "news_";
public static final String CACHE_KEY_PERSON = "person2_";
public static final String CACHE_KEY_NEWS = "news2_";
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new model classes -> new cache keys

@friedger
Copy link
Contributor Author

We are hitting now User Rate limits for the people api on g+ in the infofragment on chapters with more than 5 organizers. Organizers are shown as "Name not known"

We should move to Plus.PeopleApi.load that allows to retrieve all organizers in one call. @tasomaniac Do you agree? Even though you don't like that api.

Change is out of scope for this PR, though.

@@ -407,7 +407,7 @@ public void onNotFound(final String key) {
@Override
public void success(Person person) {
if (person != null) {
App.getInstance().getModelCache().put(key, person);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 We should look into the usages of put and make all of them async. The ModelCache causes a lot of issues in strict mode.

@@ -124,28 +93,38 @@ public void onActivityCreated(Bundle savedInstanceState) {

final String chapterPlusId = getArguments().getString(Const.EXTRA_PLUS_ID);
if (Utils.isOnline(getActivity())) {
new Builder<>(String.class, Person.class)
.setOnBackgroundExecuteListener(new CommonAsyncTask.OnBackgroundExecuteListener<String, Person>() {
App.getInstance().getModelCache().getAsync(Const.CACHE_KEY_PERSON + chapterPlusId,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line now exists in the else statement as well here

I don't think this isOnline check is helpful. Because of that we have a hell of indentation here. I think shouldn't have getAsync from model 2 times.

What we can do is that, we can first try to get it online, if that is unsuccesful, we can try to get from the cache, if that fails, we can use setIsloading(false)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's refactor this in a new PR.

@tasomaniac
Copy link
Member

LGTM

tasomaniac added a commit that referenced this pull request Mar 18, 2016
483/Remove PlusClient dependencies
@tasomaniac tasomaniac merged commit 51c5458 into develop Mar 18, 2016
@tasomaniac tasomaniac deleted the 483/activities branch March 18, 2016 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants