Browse Source

Modify download notifications. Load thumbnails when scrolling (not flying)

develop
Tommy Chen 8 years ago
parent
commit
e2d79bc507
  1. 4
      DaoGenerator/build.gradle
  2. 2
      android-stackblur
  3. 2
      cropper
  4. 29
      ehreader/src/tw/skyarrow/ehreader/activity/GalleryActivity.java
  5. 6
      ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentBase.java
  6. 6
      ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentDownload.java
  7. 6
      ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentWeb.java
  8. 4
      ehreader/src/tw/skyarrow/ehreader/activity/PhotoActivity.java
  9. 1
      ehreader/src/tw/skyarrow/ehreader/adapter/DownloadListAdapter.java
  10. 1
      ehreader/src/tw/skyarrow/ehreader/adapter/GalleryListAdapter.java
  11. 6
      ehreader/src/tw/skyarrow/ehreader/service/GalleryDownloadService.java
  12. 9
      ehreader/tests/AndroidManifest.xml

4
DaoGenerator/build.gradle

@ -9,9 +9,7 @@ dependencies {
sourceSets {
main {
java {
srcDir 'src'
}
java.srcDir 'src'
}
}

2
android-stackblur

@ -1 +1 @@
Subproject commit 618bebb3040259cc6c188bee76f29749433cb70e
Subproject commit aed2d79957759ce04e2e424d970af72618c2c92f

2
cropper

@ -1 +1 @@
Subproject commit 6f34786ee9a46661438bc7a3cc0263dc01471ae8
Subproject commit 1cd62c034aa4b2cf4a58c30bff543b8f8be86a6c

29
ehreader/src/tw/skyarrow/ehreader/activity/GalleryActivity.java

@ -242,12 +242,7 @@ public class GalleryActivity extends ActionBarActivity {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
// http://www.sherif.mobi/2013/01/how-to-get-widthheight-of-view.html
coverArea.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int coverWidth = coverArea.getMeasuredWidth();
int coverHeight = coverArea.getMeasuredHeight();
new Thread(new BlurCoverRunnable(loadedImage, coverWidth, coverHeight)).start();
new Thread(new BlurCoverRunnable(loadedImage)).start();
}
@Override
@ -268,24 +263,15 @@ public class GalleryActivity extends ActionBarActivity {
private class BlurCoverRunnable implements Runnable {
private Bitmap bitmap;
private int coverWidth;
private int coverHeight;
public BlurCoverRunnable(Bitmap bitmap, int coverWidth, int coverHeight) {
public BlurCoverRunnable(Bitmap bitmap) {
this.bitmap = bitmap;
this.coverWidth = coverWidth;
this.coverHeight = coverHeight;
}
@Override
public void run() {
int bmWidth = bitmap.getWidth();
int bmHeight= bitmap.getHeight();
float scale = getScale(bmWidth, bmHeight, coverWidth, coverHeight);
StackBlurManager blurManager = new StackBlurManager(bitmap);
Bitmap bg = Bitmap.createScaledBitmap(blurManager.processNatively(10), (int) (bmWidth * scale), (int) (bmHeight * scale), true);
runOnUiThread(new UpdateCoverRunnable(bitmap, bg));
runOnUiThread(new UpdateCoverRunnable(bitmap, blurManager.processNatively(10)));
}
};
@ -300,7 +286,16 @@ public class GalleryActivity extends ActionBarActivity {
@Override
public void run() {
// http://www.sherif.mobi/2013/01/how-to-get-widthheight-of-view.html
coverArea.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int coverWidth = coverArea.getMeasuredWidth();
int coverHeight = coverArea.getMeasuredHeight();
int bmWidth = bitmap.getWidth();
int bmHeight = bitmap.getHeight();
float scale = getScale(bmWidth, bmHeight, coverWidth, coverHeight);
Animation fadeIn = AnimationUtils.loadAnimation(GalleryActivity.this, R.anim.cover_fade_in);
Bitmap bg = Bitmap.createScaledBitmap(background, (int) (bmWidth * scale), (int) (bmHeight * scale), true);
coverForeground.setImageBitmap(bitmap);
coverForeground.startAnimation(fadeIn);

6
ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentBase.java

@ -101,11 +101,11 @@ public class MainFragmentBase extends Fragment implements AdapterView.OnItemClic
@Override
public void onScrollStateChanged(AbsListView absListView, int state) {
if (state == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
if (state == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
adapter.setScrolling(true);
} else {
adapter.setScrolling(false);
adapter.notifyDataSetChanged();
} else {
adapter.setScrolling(true);
}
}

6
ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentDownload.java

@ -223,11 +223,11 @@ public class MainFragmentDownload extends Fragment implements AbsListView.OnScro
@Override
public void onScrollStateChanged(AbsListView absListView, int state) {
if (state == InfiniteScrollListener.SCROLL_STATE_IDLE) {
if (state == InfiniteScrollListener.SCROLL_STATE_FLING) {
adapter.setScrolling(true);
} else {
adapter.setScrolling(false);
adapter.notifyDataSetChanged();
} else {
adapter.setScrolling(true);
}
}

6
ehreader/src/tw/skyarrow/ehreader/activity/MainFragmentWeb.java

@ -291,11 +291,11 @@ public class MainFragmentWeb extends Fragment implements InfiniteScrollListener.
@Override
public void onScrollStateChanged(int state) {
if (state == InfiniteScrollListener.SCROLL_STATE_IDLE) {
if (state == InfiniteScrollListener.SCROLL_STATE_FLING) {
adapter.setScrolling(true);
} else {
adapter.setScrolling(false);
adapter.notifyDataSetChanged();
} else {
adapter.setScrolling(true);
}
}

4
ehreader/src/tw/skyarrow/ehreader/activity/PhotoActivity.java

@ -147,10 +147,6 @@ public class PhotoActivity extends ActionBarActivity implements View.OnSystemUiV
public void onPageSelected(int i) {
seekBar.setProgress(i);
actionBar.setTitle(String.format("%s / %s", i + 1, total));
BaseApplication.getTracker().send(MapBuilder.createEvent(
"UI", "transition", "view pager", (long) i
).build());
}
@Override

1
ehreader/src/tw/skyarrow/ehreader/adapter/DownloadListAdapter.java

@ -39,6 +39,7 @@ public class DownloadListAdapter extends BaseListAdapter<Download> {
displayOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisc(true)
.resetViewBeforeLoading(true)
.build();
}

1
ehreader/src/tw/skyarrow/ehreader/adapter/GalleryListAdapter.java

@ -31,6 +31,7 @@ public class GalleryListAdapter extends BaseListAdapter<Gallery> {
displayOptions = new DisplayImageOptions.Builder()
.cacheInMemory(true)
.cacheOnDisc(true)
.resetViewBeforeLoading(true)
.build();
}

6
ehreader/src/tw/skyarrow/ehreader/service/GalleryDownloadService.java

@ -298,7 +298,8 @@ public class GalleryDownloadService extends IntentService {
.setContentTitle(gallery.getTitle())
.setContentIntent(pendingIntent)
.setProgress(0, 0, true)
.setContentText(getString(R.string.download_in_progress));
.setContentText(getString(R.string.download_in_progress))
.setTicker(getString(R.string.download_in_progress));
sendNotification();
@ -410,6 +411,7 @@ public class GalleryDownloadService extends IntentService {
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentText(getString(R.string.download_success))
.setTicker(getString(R.string.download_success))
.setProgress(0, 0, false)
.setAutoCancel(true)
.setContentIntent(pendingIntent);
@ -426,6 +428,7 @@ public class GalleryDownloadService extends IntentService {
isTerminated = true;
builder.setContentText(getString(R.string.download_failed))
.setTicker(getString(R.string.download_failed))
.setProgress(0, 0, false)
.setAutoCancel(true);
@ -457,6 +460,7 @@ public class GalleryDownloadService extends IntentService {
isTerminated = true;
builder.setContentText(getString(R.string.download_paused))
.setTicker(getString(R.string.download_paused))
.setProgress(0, 0, false)
.setAutoCancel(true);

9
ehreader/tests/AndroidManifest.xml

@ -1,11 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tw.skyarrow.ehreader.tests">
package="tw.skyarrow.ehreader.test">
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="tw.skyarrow.ehreader.test"/>
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="tw.skyarrow.ehreader"
android:label="Tests for tw.skyarrow.ehreader"/>
</manifest>
Loading…
Cancel
Save