Kaydet (Commit) 76c5f6fd authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

More 2.3 styling + fix for flickering bug on multi-slide change.

Change-Id: Iae19e9d44f1a437737c943c06356a99957c6991e
üst 61c94cbe
...@@ -51,4 +51,22 @@ ...@@ -51,4 +51,22 @@
android:text="www.libreoffice.org" android:text="www.libreoffice.org"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView
android:id="@+id/about_licence"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip"
android:gravity="center_horizontal"
android:text="@string/about_licence" />
<TextView
android:id="@+id/about_libraries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="10dip"
android:text="@string/about_libraries" />
</LinearLayout> </LinearLayout>
\ No newline at end of file
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
<string name="about_close">Close</string> <string name="about_close">Close</string>
<string name="about_versionstring">Version: {0} (Build ID: {1})</string> <string name="about_versionstring">Version: {0} (Build ID: {1})</string>
<string name="about_copyright">Copyright \u00A9 2012 LibreOffice Contributors and/or their affiliates.</string> <string name="about_copyright">Copyright \u00A9 2012 LibreOffice Contributors and/or their affiliates.</string>
<string name="about_licence">This app is release under the Mozilla Public License, v. 2.0.</string>
<string name="about_libraries">This app uses android-coverflow\n\tCopyright © 2011, Polidea\n\tAll rights reserved.\n\nThis app uses ActionBarSherlock:\n\tCopyright 2012 Jake Wharton\n\tLicensed under the Apache License, Version 2.0 (the "License")</string>
<string name="addserver">Add Server</string> <string name="addserver">Add Server</string>
<string name="addserver_entername">Server name:</string> <string name="addserver_entername">Server name:</string>
<string name="addserver_enteraddress">Server address as IP or hostname:</string> <string name="addserver_enteraddress">Server address as IP or hostname:</string>
...@@ -40,5 +42,6 @@ ...@@ -40,5 +42,6 @@
<string name="addserver_add">Add</string> <string name="addserver_add">Add</string>
<string name="addserver_cancel">Cancel</string> <string name="addserver_cancel">Cancel</string>
<string name="reconnect_description1">Your connection has been dropped.</string> <string name="reconnect_description1">Your connection has been dropped.</string>
<string name="reconnect_description2">Attempting to reconnect…</string> <string name="reconnect_description2">Attempting to reconnect…</string>
</resources> </resources>
\ No newline at end of file
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<item name="android:titleTextStyle">@style/Theme.ImpressRemote.ActionBar.Title</item> <item name="android:titleTextStyle">@style/Theme.ImpressRemote.ActionBar.Title</item>
<item name="titleTextStyle">@style/Theme.ImpressRemote.ActionBar.Title</item> <item name="titleTextStyle">@style/Theme.ImpressRemote.ActionBar.Title</item>
<item name="backgroundSplit">@color/text_grey</item> <item name="backgroundSplit">@color/text_grey</item>
<item name="android:backgroundSplit">@color/text_grey</item> <item name="android:backgroundSplit">@color/text_grey</item>
</style> </style>
<style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light"> <style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light">
...@@ -41,11 +41,24 @@ ...@@ -41,11 +41,24 @@
<style name="Theme.ImpressRemote.ActionBarMenuItem" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar"> <style name="Theme.ImpressRemote.ActionBarMenuItem" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
<item name="android:background">@color/grey</item> <item name="android:background">@color/grey</item>
<item name="android:textColor">@color/white</item> <item name="android:textColor">@color/white</item>
<item name="android:textSize">16dp</item> <item name="android:textSize">16dp</item>
</style> </style>
<style name="Theme.ImpressRemote.Dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@color/light_grey</item>
<item name="android:fullDark">@color/light_grey</item>
<item name="android:topDark">@color/light_grey</item>
<item name="android:centerDark">@color/light_grey</item>
<item name="android:bottomDark">@color/light_grey</item>
<item name="android:fullBright">@color/light_grey</item>
<item name="android:centerBright">@color/light_grey</item>
<item name="android:bottomBright">@color/light_grey</item>
<item name="android:bottomMedium">@color/light_grey</item>
<item name="android:centerMedium">@color/light_grey</item>
<item name="android:textColor">@color/grey</item>
</style>
<style name="Theme.ImpressRemote" parent="Theme.Sherlock.Light.DarkActionBar"> <style name="Theme.ImpressRemote" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item> <item name="android:actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item>
<item name="actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item> <item name="actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item>
...@@ -56,7 +69,7 @@ ...@@ -56,7 +69,7 @@
<item name="android:windowBackground">@color/light_grey</item> <item name="android:windowBackground">@color/light_grey</item>
<item name="android:homeAsUpIndicator">@drawable/up_indicator_white</item> <item name="android:homeAsUpIndicator">@drawable/up_indicator_white</item>
<item name="android:textColor">@color/text_grey</item> <item name="android:textColor">@color/text_grey</item>
<item name="android:alertDialogStyle">@style/Theme.ImpressRemote.Dialog</item>
</style> </style>
</resources> </resources>
\ No newline at end of file
...@@ -39,7 +39,7 @@ public class AboutDialogBuilder extends AlertDialog.Builder { ...@@ -39,7 +39,7 @@ public class AboutDialogBuilder extends AlertDialog.Builder {
PackageInfo aInfo = aContext.getPackageManager().getPackageInfo( PackageInfo aInfo = aContext.getPackageManager().getPackageInfo(
aContext.getPackageName(), 0); aContext.getPackageName(), 0);
String aVersionString = MessageFormat.format( String aVersionString = MessageFormat.format(
getContext().getResources().getString( aContext.getResources().getString(
R.string.about_versionstring), R.string.about_versionstring),
aInfo.versionName, aInfo.versionCode); aInfo.versionName, aInfo.versionCode);
mVersionLabel.setText(aVersionString); mVersionLabel.setText(aVersionString);
......
...@@ -49,6 +49,8 @@ public class PresentationFragment extends SherlockFragment { ...@@ -49,6 +49,8 @@ public class PresentationFragment extends SherlockFragment {
private float mNewCoverflowWidth = 0; private float mNewCoverflowWidth = 0;
private float mNewCoverflowHeight = 0; private float mNewCoverflowHeight = 0;
private long lastUpdateTime = 0;
private ServiceConnection mConnection = new ServiceConnection() { private ServiceConnection mConnection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName aClassName, public void onServiceConnected(ComponentName aClassName,
...@@ -64,7 +66,8 @@ public class PresentationFragment extends SherlockFragment { ...@@ -64,7 +66,8 @@ public class PresentationFragment extends SherlockFragment {
mTopView.setOnItemSelectedListener(new ClickListener()); mTopView.setOnItemSelectedListener(new ClickListener());
} }
updateSlideNumberDisplay(); updateSlideNumberDisplay(mCommunicationService.getSlideShow()
.getCurrentSlide());
} }
...@@ -138,12 +141,12 @@ public class PresentationFragment extends SherlockFragment { ...@@ -138,12 +141,12 @@ public class PresentationFragment extends SherlockFragment {
} }
private void updateSlideNumberDisplay() { private void updateSlideNumberDisplay(int aPosition) {
int aSlide = mCommunicationService.getSlideShow().getCurrentSlide(); // int aSlide = mCommunicationService.getSlideShow().getCurrentSlide();
mNumberText.setText((aSlide + 1) + "/" mNumberText.setText((aPosition + 1) + "/"
+ mCommunicationService.getSlideShow().getSize()); + mCommunicationService.getSlideShow().getSize());
mNotes.loadData(mCommunicationService.getSlideShow().getNotes(aSlide), mNotes.loadData(mCommunicationService.getSlideShow()
"text/html", null); .getNotes(aPosition), "text/html", null);
} }
// -------------------------------------------------- RESIZING LISTENER ---- // -------------------------------------------------- RESIZING LISTENER ----
...@@ -232,6 +235,8 @@ public class PresentationFragment extends SherlockFragment { ...@@ -232,6 +235,8 @@ public class PresentationFragment extends SherlockFragment {
int aPosition, long arg3) { int aPosition, long arg3) {
if (mCommunicationService != null) if (mCommunicationService != null)
mCommunicationService.getTransmitter().gotoSlide(aPosition); mCommunicationService.getTransmitter().gotoSlide(aPosition);
lastUpdateTime = System.currentTimeMillis();
updateSlideNumberDisplay(aPosition);
} }
@Override @Override
...@@ -247,8 +252,13 @@ public class PresentationFragment extends SherlockFragment { ...@@ -247,8 +252,13 @@ public class PresentationFragment extends SherlockFragment {
if (aIntent.getAction().equals( if (aIntent.getAction().equals(
CommunicationService.MSG_SLIDE_CHANGED)) { CommunicationService.MSG_SLIDE_CHANGED)) {
int aSlide = aIntent.getExtras().getInt("slide_number"); int aSlide = aIntent.getExtras().getInt("slide_number");
if (aSlide == mTopView.getSelectedItemPosition())
return;
if ((System.currentTimeMillis() - lastUpdateTime) < 5000) {
return;
}
mTopView.setSelection(aSlide, true); mTopView.setSelection(aSlide, true);
updateSlideNumberDisplay();
} else if (aIntent.getAction().equals( } else if (aIntent.getAction().equals(
CommunicationService.MSG_SLIDE_PREVIEW)) { CommunicationService.MSG_SLIDE_PREVIEW)) {
// int aNSlide = aIntent.getExtras().getInt("slide_number"); // int aNSlide = aIntent.getExtras().getInt("slide_number");
......
/*
* Copyright (c) 2011, Polidea
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the distribution.
* Neither the name of the Polidea nor the names of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package pl.polidea.coverflow; package pl.polidea.coverflow;
import android.content.Context; import android.content.Context;
......
/*
* Copyright (c) 2011, Polidea
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the distribution.
* Neither the name of the Polidea nor the names of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package pl.polidea.coverflow; package pl.polidea.coverflow;
import android.R.color; import android.R.color;
...@@ -19,111 +38,111 @@ import android.graphics.Shader.TileMode; ...@@ -19,111 +38,111 @@ import android.graphics.Shader.TileMode;
*/ */
public class ReflectingImageAdapter extends AbstractCoverFlowImageAdapter { public class ReflectingImageAdapter extends AbstractCoverFlowImageAdapter {
/** The linked adapter. */ /** The linked adapter. */
private final AbstractCoverFlowImageAdapter linkedAdapter; private final AbstractCoverFlowImageAdapter linkedAdapter;
/** /**
* Gap between the image and its reflection. * Gap between the image and its reflection.
*/ */
private float reflectionGap; private float reflectionGap;
/** The image reflection ratio. */ /** The image reflection ratio. */
private float imageReflectionRatio; private float imageReflectionRatio;
/** /**
* Sets the width ratio. * Sets the width ratio.
* *
* @param imageReflectionRatio * @param imageReflectionRatio
* the new width ratio * the new width ratio
*/ */
public void setWidthRatio(final float imageReflectionRatio) { public void setWidthRatio(final float imageReflectionRatio) {
this.imageReflectionRatio = imageReflectionRatio; this.imageReflectionRatio = imageReflectionRatio;
} }
/** /**
* Creates reflecting adapter. * Creates reflecting adapter.
* *
* @param linkedAdapter * @param linkedAdapter
* adapter that provides images to get reflections * adapter that provides images to get reflections
*/ */
public ReflectingImageAdapter( public ReflectingImageAdapter(
final AbstractCoverFlowImageAdapter linkedAdapter) { final AbstractCoverFlowImageAdapter linkedAdapter) {
super(); super();
this.linkedAdapter = linkedAdapter; this.linkedAdapter = linkedAdapter;
} }
/** /**
* Sets the reflection gap. * Sets the reflection gap.
* *
* @param reflectionGap * @param reflectionGap
* the new reflection gap * the new reflection gap
*/ */
public void setReflectionGap(final float reflectionGap) { public void setReflectionGap(final float reflectionGap) {
this.reflectionGap = reflectionGap; this.reflectionGap = reflectionGap;
} }
/** /**
* Gets the reflection gap. * Gets the reflection gap.
* *
* @return the reflection gap * @return the reflection gap
*/ */
public float getReflectionGap() { public float getReflectionGap() {
return reflectionGap; return reflectionGap;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see pl.polidea.coverflow.AbstractCoverFlowImageAdapter#createBitmap(int) * @see pl.polidea.coverflow.AbstractCoverFlowImageAdapter#createBitmap(int)
*/ */
@Override @Override
protected Bitmap createBitmap(final int position) { protected Bitmap createBitmap(final int position) {
return createReflectedImages(linkedAdapter.getItem(position)); return createReflectedImages(linkedAdapter.getItem(position));
} }
/** /**
* Creates the reflected images. * Creates the reflected images.
* *
* @param originalImage * @param originalImage
* the original image * the original image
* @return true, if successful * @return true, if successful
*/ */
public Bitmap createReflectedImages(final Bitmap originalImage) { public Bitmap createReflectedImages(final Bitmap originalImage) {
final int width = originalImage.getWidth(); final int width = originalImage.getWidth();
final int height = originalImage.getHeight(); final int height = originalImage.getHeight();
final Matrix matrix = new Matrix(); final Matrix matrix = new Matrix();
matrix.preScale(1, -1); matrix.preScale(1, -1);
final Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, final Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0,
(int) (height * imageReflectionRatio), width, (int) (height * imageReflectionRatio), width,
(int) (height - height * imageReflectionRatio), matrix, (int) (height - height * imageReflectionRatio), matrix,
false); false);
final Bitmap bitmapWithReflection = Bitmap.createBitmap(width, final Bitmap bitmapWithReflection = Bitmap.createBitmap(width,
(int) (height + height * imageReflectionRatio), (int) (height + height * imageReflectionRatio),
Config.ARGB_8888); Config.ARGB_8888);
final Canvas canvas = new Canvas(bitmapWithReflection); final Canvas canvas = new Canvas(bitmapWithReflection);
canvas.drawBitmap(originalImage, 0, 0, null); canvas.drawBitmap(originalImage, 0, 0, null);
final Paint deafaultPaint = new Paint(); final Paint deafaultPaint = new Paint();
deafaultPaint.setColor(color.transparent); deafaultPaint.setColor(color.transparent);
canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null); canvas.drawBitmap(reflectionImage, 0, height + reflectionGap, null);
final Paint paint = new Paint(); final Paint paint = new Paint();
final LinearGradient shader = new LinearGradient(0, final LinearGradient shader = new LinearGradient(0,
originalImage.getHeight(), 0, originalImage.getHeight(), 0,
bitmapWithReflection.getHeight() + reflectionGap, bitmapWithReflection.getHeight() + reflectionGap,
0x70ffffff, 0x00ffffff, TileMode.CLAMP); 0x70ffffff, 0x00ffffff, TileMode.CLAMP);
paint.setShader(shader); paint.setShader(shader);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
canvas.drawRect(0, height, width, bitmapWithReflection.getHeight() canvas.drawRect(0, height, width, bitmapWithReflection.getHeight()
+ reflectionGap, paint); + reflectionGap, paint);
return bitmapWithReflection; return bitmapWithReflection;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see android.widget.Adapter#getCount() * @see android.widget.Adapter#getCount()
*/ */
@Override @Override
public int getCount() { public int getCount() {
return linkedAdapter.getCount(); return linkedAdapter.getCount();
} }
} }
/*
* Copyright (c) 2011, Polidea
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the distribution.
* Neither the name of the Polidea nor the names of its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package pl.polidea.coverflow; package pl.polidea.coverflow;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -19,72 +38,72 @@ import android.util.Log; ...@@ -19,72 +38,72 @@ import android.util.Log;
*/ */
public class ResourceImageAdapter extends AbstractCoverFlowImageAdapter { public class ResourceImageAdapter extends AbstractCoverFlowImageAdapter {
/** The Constant TAG. */ /** The Constant TAG. */
private static final String TAG = ResourceImageAdapter.class private static final String TAG = ResourceImageAdapter.class
.getSimpleName(); .getSimpleName();
/** The Constant DEFAULT_LIST_SIZE. */ /** The Constant DEFAULT_LIST_SIZE. */
private static final int DEFAULT_LIST_SIZE = 20; private static final int DEFAULT_LIST_SIZE = 20;
/** The Constant IMAGE_RESOURCE_IDS. */ /** The Constant IMAGE_RESOURCE_IDS. */
private static final List<Integer> IMAGE_RESOURCE_IDS = new ArrayList<Integer>( private static final List<Integer> IMAGE_RESOURCE_IDS = new ArrayList<Integer>(
DEFAULT_LIST_SIZE); DEFAULT_LIST_SIZE);
/** The Constant DEFAULT_RESOURCE_LIST. */ /** The Constant DEFAULT_RESOURCE_LIST. */
private static final int[] DEFAULT_RESOURCE_LIST = {}; private static final int[] DEFAULT_RESOURCE_LIST = {};
/** The bitmap map. */ /** The bitmap map. */
private final Map<Integer, WeakReference<Bitmap>> bitmapMap = new HashMap<Integer, WeakReference<Bitmap>>(); private final Map<Integer, WeakReference<Bitmap>> bitmapMap = new HashMap<Integer, WeakReference<Bitmap>>();
private final Context context; private final Context context;
/** /**
* Creates the adapter with default set of resource images. * Creates the adapter with default set of resource images.
* *
* @param context * @param context
* context * context
*/ */
public ResourceImageAdapter(final Context context) { public ResourceImageAdapter(final Context context) {
super(); super();
this.context = context; this.context = context;
setResources(DEFAULT_RESOURCE_LIST); setResources(DEFAULT_RESOURCE_LIST);
} }
/** /**
* Replaces resources with those specified. * Replaces resources with those specified.
* *
* @param resourceIds * @param resourceIds
* array of ids of resources. * array of ids of resources.
*/ */
public final synchronized void setResources(final int[] resourceIds) { public final synchronized void setResources(final int[] resourceIds) {
IMAGE_RESOURCE_IDS.clear(); IMAGE_RESOURCE_IDS.clear();
for (final int resourceId : resourceIds) { for (final int resourceId : resourceIds) {
IMAGE_RESOURCE_IDS.add(resourceId); IMAGE_RESOURCE_IDS.add(resourceId);
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see android.widget.Adapter#getCount() * @see android.widget.Adapter#getCount()
*/ */
@Override @Override
public synchronized int getCount() { public synchronized int getCount() {
return IMAGE_RESOURCE_IDS.size(); return IMAGE_RESOURCE_IDS.size();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see pl.polidea.coverflow.AbstractCoverFlowImageAdapter#createBitmap(int) * @see pl.polidea.coverflow.AbstractCoverFlowImageAdapter#createBitmap(int)
*/ */
@Override @Override
protected Bitmap createBitmap(final int position) { protected Bitmap createBitmap(final int position) {
Log.v(TAG, "creating item " + position); Log.v(TAG, "creating item " + position);
final Bitmap bitmap = ((BitmapDrawable) context.getResources() final Bitmap bitmap = ((BitmapDrawable) context.getResources()
.getDrawable(IMAGE_RESOURCE_IDS.get(position))) .getDrawable(IMAGE_RESOURCE_IDS.get(position)))
.getBitmap(); .getBitmap();
bitmapMap.put(position, new WeakReference<Bitmap>(bitmap)); bitmapMap.put(position, new WeakReference<Bitmap>(bitmap));
return bitmap; return bitmap;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment