chrisspeck.com

Chris' random ramblings

Archive for July, 2011

Steps to create a Content Provider in Android

1. Define strings for provider mime type, item mime type & for authority

    <string name="[OBJECT]_CONTENT_TYPE">vnd.android.cursor.item/vnd.[initials].[object]</string>
    <string name="[OBJECT]_CONTENT_TYPE_DIR">vnd.android.cursor.dir/vnd.[initials].[object]</string>
    <string name="[OBJECT]_CONTENT_COMMENT_DIR_URI">"content://com.[initials].[object]Provider/[object]"</string>
    <string name="[OBJECT]_CONTENT_COMMENT_AUTHORITY">"com.[initials].[object]Provider"</string>

2. Create metadata class

3. Create authority and sql helper private class

4. Define authority in androidmanifest.xml

<provider android:name="[Object]Provider" android:label="@string/app_name"                      android:authorities="@string/[OBJECT]_CONTENT_COMMENT_AUTHORITY"></provider>

5. profit

That is all.

Tags:
posted by specky in Programming and have Comment (1)

Troubleshooting Gallery2 HTTP Status 500 Internal Server Errors

If you are receiving a “HTTP Status 500 Internal Server Error” when trying to Edit or view a Gallery2 setup, you would ought to check whether your choice of graphics toolkit is the cause of the error.

In a gallery I was setting this morning, the “Gd” graphics toolkit was causing the site to crash because of a time-out which arose when Gallery2 attempted to use Gd to generate a thumbnail.

The fix is to fight your way to the Admin/Plugins page, configure and activate the ImageMagick plugin, and deactivate (& delete) the Gd plugin.

Incidentally, the only way to trouble-shoot Gallery2 when it is in this condition is to:

  1. Check your host’s error log for any errors generated by the PHP scripts and/or Apache; and
  2. Activate Gallery2′s immediate debug mode.

Immediate debug mode should at least generate output, the last line of which should indicate where/why Gallery2 has died.

Finally, if you are running on a Linux Host / LAMP stack and you want to use a local php.ini, you must put the following line in the  .htaccess file:

SetEnv PHPRC /path/to/httpdocs/
posted by specky in IT,Programming and have No Comments

Conditional Gallery2 Shopping Cart Block

I am in the process of developing a photography website, and for that purpose I am combining WordPress + Gallery2.

Gallery2 has a very neat shopping cart feature, which lets a viewer select images, and then purchase/download, order prints, email etc in one go.

Gallery2 comes with a “Shopping Cart Info” block (a design element) which shows the contents of the cart. If selected, this block will display itself, whether or not there is actually anything within the cart.

I thought it looked a little tacky for the site to show a shopping cart on the gallery, and sub-gallery pages when there is nothing in it.

My solution to this issue was to create a new block, called “Conditional Cart Info”, which invokes the original “Shopping Cart Info”, only if the contents of the cart is greater than 0.

It requires a modification to the file /modules/cart/templates/blocks/blocks.inc and the creation of a new file /modules/cart/templates/blocks/ConditionalCart.tpl.

You can download my modified files here or click through below to read the source code:
blocks.inc
ConditionalCart.tpl

 

Read more…

posted by specky in Downloads,Programming and have No Comments