Droidcon London. How it was



    The other day in London, the droidcon conference took place. She was not spared such fashionable themes as Redux, MVI, assembly speed optimization and Gradle features. The event was opened by a report by Chet Haase and Romain Guy about the fragmentation of memory and differences between the Android version of the Garbage Collector, and Jake Wharton made a presentation about Dagger.

    In this review I want to share my impressions of the conference and the details of these reports.

    I have heard a lot about the London droidcon, but so far I have not been able to attend it, since it is much more expensive than, for example, droidcon Berlin, not to mention Moscow conferences. At the same time, the level of Russian conferences, such as droidcon, Mobius, AppsConf, has greatly increased in recent years, and I wanted to compare the atmosphere, the level of organization and reports with foreign counterparts.

    But first things first.


    Tickets


    If you buy a ticket in advance, you can take it for 230 pounds + VAT. The final price was about 700 pounds, including VAT. Quite expensive when compared with tickets to Russian conferences, but on average for Europe this is an adequate price. The flight will cost about 30 thousand rubles, but there is an opportunity to save money, as now the Victory is flying there, and you can buy a ticket for about 6000 rubles one way.


    Accommodation


    We lived in a 15-minute walk from the venue. Hotel average, about 150 pounds per day. In fact, if you are not too demanding, then you can live in a hostel in the city center for 20 pounds a day.




    Organization

    In terms of organization, the conference was at a fairly high level. I liked the playground itself: a spacious hall for communication and moral relaxation, comfortable audiences in which reports were read. In the lobby there were many stands of various companies where you could take a pair of pens and t-shirts. In the evening of the first day, the organizers organized a party. There were free drinks and music, we went for a walk around London.






    Reports

    The schedule, in my opinion, was drawn up very well, since at any time there were interesting reports. In addition, workshops were constantly held.


    But I expected more from the level of reports. Many of them were without any practical component, for example, just a description of some kind of API or functionality. The level of reports at Moscow conferences is at least not lower. There were some pretty strong and relevant speeches. Next, I will write about those that seemed to me the most interesting.


    Read more about

    Keynote
    reports - Trash Talk: The Evolution of Garbage Collection on Android Chet Haase and Romain Guy, Google
    The conference began with a very good report on the Android memory model. The guys told how it changed from version to version, for what reasons it happened. I will not disclose the details here, but I recommend viewing thevideo.

    Modularization - How Hard Can It Be?
    Elin Nilsson, Spotify

    Not exactly technical, but more motivational, but no less interesting report. Elin spoke about the reasons that made them think about dividing a monolithic application into modules, how hard it went and what came of it in terms of the amount of code, processes and build speed. Link to the report .



    Redux on Android
    Nish Tahir, WillowTree

    Not to say that this report somehow opened my eyes to Redux, but, in my opinion, the author well revealed the essence of this decision, spoke about the problems and whether Redux should be chosen the main architectural pattern and in which cases it is justified. Link to the Modern Data Binding report by Yigit Boyar and Jose Alcerreca, Google





    It was interesting to hear a report about the tools from Google from the mouths of the developers themselves. In principle, they didn’t say anything new, the desire to use Data Binding didn’t appear either, but thanks for the attempt. Link to the report

    Deep Dive into the Android Gradle Plugin
    John Rodriguez, Square Cash

    This report was one of the last at the conference, and I was not ready to accept interesting and informative information, but then John came out and did a good and rather hardcore A report about the interesting nuances of the Android Gradle Plugin. I also recommend it for viewing .

    Helping Dagger Help You
    Jake Wharton, Google

    A good report came from Jack Wharton. Together with Square, they made several convenient libraries for use with Dagger, which solve a number of developer problems.

    First, a lot of attention is now being paid to the problem of assembly speed. This is especially true for Dagger and ButterKnife, as they use the annotation processor and kapt. Square presented a solution in which Dagger and ButterKnife implementations work on reflection instead of code generation. This slightly reduces the speed of the runtime application, but it saves time on the compile time, and within the dev-builds it is quite justified, since for the latest Pixel and Samsung models this is barely perceptible work.


    This is how Binder implementations look in the ButterKnife version with reflection
    @NonNull@UiThreadpublicstatic Unbinder bind(@NonNull Object target, @NonNull View source){
        List<Unbinder> unbinders = new ArrayList<>();
        Class<?> targetClass = target.getClass();
        if ((targetClass.getModifiers() & PRIVATE) != 0) {
            thrownew IllegalArgumentException(targetClass.getName() + " must not be private.");
        }
        while (true) {
            for (Field field : targetClass.getDeclaredFields()) {
                int unbinderStartingSize = unbinders.size();
                Unbinder unbinder;
                unbinder = parseBindView(target, field, source);
                if (unbinder != null) unbinders.add(unbinder);
                unbinder = parseBindViews(target, field, source);
                if (unbinder != null) unbinders.add(unbinder);
                unbinder = parseBindDrawable(target, field, source);
                if (unbinder != null) unbinders.add(unbinder);
                unbinder = parseBindString(target, field, source);
                if (unbinder != null) unbinders.add(unbinder);
                ...
            }
            for (Method method : targetClass.getDeclaredMethods()) {
                Unbinder unbinder;
                unbinder = parseOnCheckedChanged(target, method, source);
                if (unbinder != null) unbinders.add(unbinder);
                unbinder = parseOnClick(target, method, source);
                if (unbinder != null) unbinders.add(unbinder);
                ...
            }
            targetClass = targetClass.getSuperclass();
        }
        returnnew CompositeUnbinder(unbinders);
    }

    The library for ButterKnife can be found at this link. The version for Dagger is around here .


    Secondly, sometimes it becomes necessary to inject dependencies into custom views that are declared in XML. Previously, I had to inject them through set-methods and throw them through classes from the outside, for example, in a presenter, when he attaches to the view. Now there is a convenient way to do this: dependencies can be prokidyd through the constructor immediately after the required parameters, and the custom LayoutInfater can create a twist with these complex constructors.


    How it looks in code:


    MainActivity.java
    publicfinalclassMainActivityextendsActivity{
        @OverrideprotectedvoidonCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            MainComponent component = DaggerMainActivity_MainComponent.create();
            InflationInjectFactory factory = component.getInjectFactory();
            getLayoutInflater().setFactory(factory);
            setContentView(R.layout.main_activity);
            GalleryPresenter presenter = component.getGalleryPresenter();
            GalleryView view = findViewById(R.id.gallery);
            presenter.attach(view);
        }
        @Component(modules = ViewModule.class)
        interfaceMainComponent{
            InflationInjectFactory getInjectFactory();
            GalleryPresenter getGalleryPresenter();
        }
    }

    GalleryView is written in xml.


    Galleryview
    publicfinalclassGalleryViewextendsLinearLayout{
        privatefinal ViewUpdater mViewUpdater;
        @InflationInjectpublicGalleryView(@Assisted Context context, @Assisted AttributeSet attrs, ViewUpdater viewUpdater){
            super(context, attrs);
            mViewUpdater = viewUpdater;
        }
    }

    Third, in Square, they approached in their own way the problem that AutoValue solves, namely the creation of factories for classes with heavy designers. Only this solution is maximally integrated into the Dagger logic.


    Example of use:


    UserPresenter.java
    publicfinalclassUserPresenter{
        privatefinal LoadUserInteractor mLoadUserInteractor;
        privatefinal String mUserId;
        @AssistedInject
        UserPresenter(@Assisted LoadUserInteractor loadUserInteractor, @Exclamation String userid) {
            mLoadUserInteractor = loadUserInteractor;
            mUserId = userid;
        }
        @AssistedInject.Factory
        publicinterfaceFactory{
            UserPresenter create(String greeting);
        }
        ...
    }

    UserActivity.java
    publicfinalclassUserActivityextendsActivity{
        @OverrideprotectedvoidonCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main_view);
            UserPresenter.Factory factory = DaggerUserActivity_ UserComponent.create().getUserPresenterFctory();
            UserPresenter presenter = factory.create(getIntent().getStringExtra("user_id"));
            presenter.attach();
            ...
        }
        @Component(modules = UserModule.class)
        interfaceUserComponent{
            UserPresenter.Factory getUserPresenterFctory();
        }
    }

    I liked how easy the implementation of these topical solutions look like. I also advise to view .


    Undoubtedly, I learned something interesting for myself from the reports of the conference, talked to colleagues from different companies, which is a great advantage of an international conference, and it is for networking that you should go for them. As a bonus, this time was a visit to London. If we talk about reports, it is easier to watch them online or attend one of the many Russian conferences.


    Also popular now: