[feedhenry-dev] New fh-sync-android initialization

Vojtech Sazel vsazel at redhat.com
Fri Sep 8 19:07:35 UTC 2017


ad 4)
Then you can implement your sync activity by implementing
*SyncableActivity *interface where you implement onBindSyncListener() where
sync listner is created and bound. Such activity doesn't need to call
pauseSync()
and resumeSync().It's done automatically by watching activities lifecycle.

public class ListOfItemsActivity extends AppCompatActivity implements
SyncableActivity {
:
:
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_of_items_activity);

       // Start the sync process        try {

FHSyncClient.getInstance().manage(DATA_ID, null, new JSONObject());
} catch (Exception e) { Log.e(TAG, e.getMessage(), e); } } : :

    @Override
    public FHSyncListener onBindSyncListener() {
        FHSyncListener.Builder builder=new FHSyncListener.Builder();
        builder.onSyncCompleted(pMessage -> {
           :
           :
        }).onLocalUpdateApplied(pMessage -> {           :
           :

        });        return builder.build();

}

}


Pull request:
https://github.com/feedhenry/fh-sync-android/pull/3

You can see new initialization in modified *sync-cloud-app:*
https://github.com/wojta/sync-android-app/pull/1/files

There are still changes to be made and wrapper to old sync needs to be
written.
It also needs review of unit tests and other tasks we have in SDK team:
https://issues.jboss.org/browse/FH-3855

Please feel free to comment here and to the PRs. You may want to contact me
on Slack/RocketChat but I'm *not* *available* on Monday and all afternoons
next week (12:00 GMT and after).

Vojtech

On Fri, Sep 8, 2017 at 8:49 PM, Vojtech Sazel <vsazel at redhat.com> wrote:

> Sorry, I accidentally sent the mail unfinished.
> Follow up.
>
> On Fri, Sep 8, 2017 at 8:48 PM, Vojtech Sazel <vsazel at redhat.com> wrote:
>
>> Hi,
>>
>> I followed up the work started by Wojciech and made decoupled Android
>> fh-sync-android working.
>>
>> Changes done:
>> 1) Network calls are not static, but done through NetworkClient is now
>> interface, with NetworkClientImpl having implementation with OkHttp
>> Android.
>> 2) Dataset storage is written against FileStorage with implementation
>> FileStorageImpl that uses internal Android storage in files (as was in old
>> sync)
>> 3) Client unique Id generator was added in ClientIdGenerator an ClientIdGeneratorImpl,
>> this is needed by cloud app to properly sync (done the same way as in old
>> sync)
>> 4) FHSyncListener and  FHSyncConfig improved, with new initialization
>> for Android apps
>>
>> For Android initialization it's now needed to use Sync.init(Application
>> application, FHSyncConfig config, String cloudUrl) method
>> in your Application object like this:
>>
>> public class SyncApplication extends Application {
>>
>>     @Override
>>     public void onCreate() {
>>         super.onCreate();
>>         Sync.init(SyncApplication.this, (new FHSyncConfig.Builder()).useCustomSync(false).syncFrequencySeconds(10).notifyEnableAll().build(), "http://192.168.13.14:3000/sync");
>>
>>     }
>> }
>>
>>
>> When fh-android-sdk wrapper is written it should be still backwards
>> compatibile with current old sync.
>>
>>
>> --
>>
>> VOJTĚCH SÁZEL
>>
>> SENIOR QUALITY ENGINEER, MOBILE QE
>>
>> Red Hat
>>
>> <https://www.redhat.com/>
>>
>> Remote Czech Republic
>>
>> vsazel at redhat.com    IM: vsazel
>> <https://red.ht/sig>
>>
>
>
>
> --
>
> VOJTĚCH SÁZEL
>
> SENIOR QUALITY ENGINEER, MOBILE QE
>
> Red Hat
>
> <https://www.redhat.com/>
>
> Remote Czech Republic
>
> vsazel at redhat.com    IM: vsazel
> <https://red.ht/sig>
>



-- 

VOJTĚCH SÁZEL

SENIOR QUALITY ENGINEER, MOBILE QE

Red Hat

<https://www.redhat.com/>

Remote Czech Republic

vsazel at redhat.com    IM: vsazel
<https://red.ht/sig>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/feedhenry-dev/attachments/20170908/74935229/attachment.htm>


More information about the feedhenry-dev mailing list