1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

separate icon fo 'downloading' status

This commit is contained in:
Nikolay Pultsin 2013-02-18 00:44:34 +04:00
parent 0084c1f78d
commit 31f4c630f2
7 changed files with 27 additions and 16 deletions

View file

@ -28,7 +28,7 @@
<data android:scheme="ExceptionInInitializerError"/> <data android:scheme="ExceptionInInitializerError"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="org.geometerplus.android.fbreader.api.ApiService"> <service android:name="org.geometerplus.android.fbreader.api.ApiService" android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="android.fbreader.action.API"/> <action android:name="android.fbreader.action.API"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
@ -170,7 +170,7 @@
<data android:host="*" android:scheme="epub"/> <data android:host="*" android:scheme="epub"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="org.geometerplus.android.fbreader.network.BookDownloaderService" android:process=":networkLibrary"/> <service android:name="org.geometerplus.android.fbreader.network.BookDownloaderService" android:launchMode="singleTask" android:process=":networkLibrary"/>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkSearchActivity" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay"> <activity android:name="org.geometerplus.android.fbreader.network.NetworkSearchActivity" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH"/> <action android:name="android.intent.action.SEARCH"/>

View file

@ -28,7 +28,7 @@
<data android:scheme="ExceptionInInitializerError"/> <data android:scheme="ExceptionInInitializerError"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="org.geometerplus.android.fbreader.api.ApiService"> <service android:name="org.geometerplus.android.fbreader.api.ApiService" android:launchMode="singleTask">
<intent-filter> <intent-filter>
<action android:name="android.fbreader.action.API"/> <action android:name="android.fbreader.action.API"/>
<category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/>
@ -170,7 +170,7 @@
<data android:host="*" android:scheme="epub"/> <data android:host="*" android:scheme="epub"/>
</intent-filter> </intent-filter>
</activity> </activity>
<service android:name="org.geometerplus.android.fbreader.network.BookDownloaderService" android:process=":networkLibrary"/> <service android:name="org.geometerplus.android.fbreader.network.BookDownloaderService" android:launchMode="singleTask" android:process=":networkLibrary"/>
<activity android:name="org.geometerplus.android.fbreader.network.NetworkSearchActivity" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay"> <activity android:name="org.geometerplus.android.fbreader.network.NetworkSearchActivity" android:process=":networkLibrary" android:theme="@android:style/Theme.NoDisplay">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH"/> <action android:name="android.intent.action.SEARCH"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

View file

@ -24,11 +24,13 @@ import android.os.IBinder;
public class BookDownloaderServiceConnection implements ServiceConnection { public class BookDownloaderServiceConnection implements ServiceConnection {
private volatile Runnable myAction; private volatile Runnable myAction;
private BookDownloaderInterface myInterface; private volatile BookDownloaderInterface myInterface;
synchronized void bindToService(Context context, Runnable action) { synchronized void bindToService(Context context, Runnable action) {
if (myInterface != null) { if (myInterface != null) {
action.run(); if (action != null) {
action.run();
}
} else { } else {
myAction = action; myAction = action;
context.bindService( context.bindService(
@ -41,7 +43,10 @@ public class BookDownloaderServiceConnection implements ServiceConnection {
synchronized void unbind(Context context) { synchronized void unbind(Context context) {
myAction = null; myAction = null;
context.unbindService(this); if (myInterface != null) {
context.unbindService(this);
myInterface = null;
}
} }
public synchronized void onServiceConnected(ComponentName className, IBinder service) { public synchronized void onServiceConnected(ComponentName className, IBinder service) {

View file

@ -95,11 +95,7 @@ public abstract class NetworkLibraryActivity extends TreeActivity<NetworkTree> i
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
bindService( Connection.bindToService(this, null);
new Intent(getApplicationContext(), BookDownloaderService.class),
Connection,
BIND_AUTO_CREATE
);
NetworkLibrary.Instance().addChangeListener(this); NetworkLibrary.Instance().addChangeListener(this);
} }
@ -115,7 +111,7 @@ public abstract class NetworkLibraryActivity extends TreeActivity<NetworkTree> i
protected void onStop() { protected void onStop() {
NetworkLibrary.Instance().removeChangeListener(this); NetworkLibrary.Instance().removeChangeListener(this);
unbindService(Connection); Connection.unbind(this);
super.onStop(); super.onStop();
} }
@ -147,6 +143,15 @@ public abstract class NetworkLibraryActivity extends TreeActivity<NetworkTree> i
} }
} }
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Connection.bindToService(this, new Runnable() {
public void run() {
getListView().invalidateViews();
}
});
}
@Override @Override
public boolean onSearchRequested() { public boolean onSearchRequested() {
final NetworkTree tree = getCurrentTree(); final NetworkTree tree = getCurrentTree();

View file

@ -91,7 +91,7 @@ public abstract class NetworkBookActions {
final BookUrlInfo reference = book.reference(UrlInfo.Type.Book); final BookUrlInfo reference = book.reference(UrlInfo.Type.Book);
if (reference != null if (reference != null
&& connection != null && connection.isBeingDownloaded(reference.Url)) { && connection != null && connection.isBeingDownloaded(reference.Url)) {
return R.drawable.ic_list_download; return R.drawable.ic_list_downloading;
} else if (book.localCopyFileName() != null) { } else if (book.localCopyFileName() != null) {
return R.drawable.ic_list_flag; return R.drawable.ic_list_flag;
} else if (reference != null) { } else if (reference != null) {

View file

@ -61,10 +61,11 @@ public class ShowBookInfoAction extends BookAction {
} }
private void showBookInfo(NetworkTree tree) { private void showBookInfo(NetworkTree tree) {
OrientationUtil.startActivity( OrientationUtil.startActivityForResult(
myActivity, myActivity,
new Intent(myActivity, NetworkBookInfoActivity.class) new Intent(myActivity, NetworkBookInfoActivity.class)
.putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey()) .putExtra(NetworkLibraryActivity.TREE_KEY_KEY, tree.getUniqueKey()),
1
); );
} }
} }