mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
introduced SynchroniserService
This commit is contained in:
parent
361c535c2c
commit
553b88dc70
4 changed files with 70 additions and 2 deletions
|
@ -136,6 +136,7 @@
|
|||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService" android:exported="false"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.synchroniser.SynchroniserService" android:launchMode="singleTask" android:process=":synchroniser" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library" android:configChanges="orientation|keyboardHidden|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.fbreader.action.BOOK_INFO"/>
|
||||
|
|
|
@ -136,6 +136,7 @@
|
|||
</intent-filter>
|
||||
</service>
|
||||
<service android:name="org.geometerplus.android.fbreader.config.ConfigService" android:launchMode="singleTask" android:process=":configService" android:exported="false"/>
|
||||
<service android:name="org.geometerplus.android.fbreader.synchroniser.SynchroniserService" android:launchMode="singleTask" android:process=":synchroniser" android:exported="false"/>
|
||||
<activity android:name="org.geometerplus.android.fbreader.library.BookInfoActivity" android:theme="@style/FBReader.Activity" android:process=":library" android:configChanges="orientation|keyboardHidden|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.fbreader.action.BOOK_INFO"/>
|
||||
|
|
|
@ -29,8 +29,7 @@ import android.app.SearchManager;
|
|||
import android.content.*;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.*;
|
||||
import android.view.*;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
|
@ -59,6 +58,7 @@ import org.geometerplus.android.fbreader.api.*;
|
|||
import org.geometerplus.android.fbreader.httpd.DataService;
|
||||
import org.geometerplus.android.fbreader.library.BookInfoActivity;
|
||||
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
|
||||
import org.geometerplus.android.fbreader.synchroniser.SynchroniserService;
|
||||
import org.geometerplus.android.fbreader.tips.TipsActivity;
|
||||
|
||||
import org.geometerplus.android.util.*;
|
||||
|
@ -95,6 +95,17 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
private String myMenuLanguage;
|
||||
|
||||
final DataService.Connection DataConnection = new DataService.Connection();
|
||||
private final ServiceConnection mySynchroniserConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder binder) {
|
||||
System.err.println("SynchroniserService CONNECTED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName componentName) {
|
||||
System.err.println("SynchroniserService DISCONNECTED");
|
||||
}
|
||||
};
|
||||
|
||||
private static final String PLUGIN_ACTION_PREFIX = "___";
|
||||
private final List<PluginApi.ActionInfo> myPluginActions =
|
||||
|
@ -450,6 +461,12 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
bindService(
|
||||
new Intent(this, SynchroniserService.class),
|
||||
mySynchroniserConnection,
|
||||
SynchroniserService.BIND_AUTO_CREATE
|
||||
);
|
||||
|
||||
myStartTimer = true;
|
||||
Config.Instance().runOnConnect(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -494,6 +511,7 @@ public final class FBReader extends Activity implements ZLApplicationWindow {
|
|||
setButtonLight(true);
|
||||
}
|
||||
myFBReaderApp.onWindowClosing();
|
||||
unbindService(mySynchroniserConnection);
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* Copyright (C) 2010-2014 Geometer Plus <contact@geometerplus.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package org.geometerplus.android.fbreader.synchroniser;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.geometerplus.android.fbreader.libraryService.BookCollectionShadow;
|
||||
|
||||
public class SynchroniserService extends Service implements Runnable {
|
||||
private final BookCollectionShadow myCollection = new BookCollectionShadow();
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
myCollection.bindToService(this, this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.err.println("SYNCHRONIZER BINDED TO LIBRARY");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
myCollection.unbind();
|
||||
System.err.println("SYNCHRONIZER UNBINDED FROM LIBRARY");
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue