diff --git a/.gitignore b/.gitignore
index 710f3f0..720f2a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,8 @@
.classpath
.project
.settings
+.metadata
bin
gen
lint.xml
-/.metadata
diff --git a/AIDLDemo/project.properties b/AIDLDemo/project.properties
index 730e911..8da376a 100644
--- a/AIDLDemo/project.properties
+++ b/AIDLDemo/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/AndroidUIDemo/project.properties b/AndroidUIDemo/project.properties
index 730e911..8da376a 100644
--- a/AndroidUIDemo/project.properties
+++ b/AndroidUIDemo/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/AndroidViewDemo/project.properties b/AndroidViewDemo/project.properties
index 730e911..8da376a 100644
--- a/AndroidViewDemo/project.properties
+++ b/AndroidViewDemo/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/AsyncTaskDemo/project.properties b/AsyncTaskDemo/project.properties
index 730e911..8da376a 100644
--- a/AsyncTaskDemo/project.properties
+++ b/AsyncTaskDemo/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/ClientDemo/project.properties b/ClientDemo/project.properties
index 730e911..8da376a 100644
--- a/ClientDemo/project.properties
+++ b/ClientDemo/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/ContactViewer/project.properties b/ContactViewer/project.properties
index 5a70945..8da376a 100644
--- a/ContactViewer/project.properties
+++ b/ContactViewer/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-7
+target=android-15
diff --git a/FinchChat/AndroidManifest.xml b/FinchChat/AndroidManifest.xml
index b740592..f9a2fe7 100644
--- a/FinchChat/AndroidManifest.xml
+++ b/FinchChat/AndroidManifest.xml
@@ -1,28 +1,35 @@
-
-
+ package="com.finchframework.finch"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+
+
+
-
-
+
+
+
-
+
-
+
+
\ No newline at end of file
diff --git a/FinchChat/project.properties b/FinchChat/project.properties
index 395d7de..b0439b1 100644
--- a/FinchChat/project.properties
+++ b/FinchChat/project.properties
@@ -8,5 +8,5 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
android.library=false
diff --git a/FinchFramework/AndroidManifest.xml b/FinchFramework/AndroidManifest.xml
index 18f0127..bc8df89 100644
--- a/FinchFramework/AndroidManifest.xml
+++ b/FinchFramework/AndroidManifest.xml
@@ -7,15 +7,15 @@
-
+
-
-
+
+
diff --git a/FinchFramework/project.properties b/FinchFramework/project.properties
index d525577..5fa344c 100644
--- a/FinchFramework/project.properties
+++ b/FinchFramework/project.properties
@@ -8,5 +8,5 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
android.library=true
diff --git a/FinchFramework/res/values/strings.xml b/FinchFramework/res/values/strings.xml
index 8d3bbaf..851c82e 100644
--- a/FinchFramework/res/values/strings.xml
+++ b/FinchFramework/res/values/strings.xml
@@ -2,7 +2,7 @@
FinchFramework
-
+
Connect a device
Make discoverable
@@ -11,4 +11,4 @@
Bluetooth tools
Animation
-
\ No newline at end of file
+
diff --git a/FinchFramework/src/com/finchframework/finch/FinchApplication.java b/FinchFramework/src/com/finchframework/finch/FinchApplication.java
index 26797ab..affad19 100644
--- a/FinchFramework/src/com/finchframework/finch/FinchApplication.java
+++ b/FinchFramework/src/com/finchframework/finch/FinchApplication.java
@@ -7,41 +7,41 @@
/**
* Provides the framework's Application subclass. This illustrates what
* you may need to do in an Application subclass.
- *
+ *
* To get this class instantiated, you must refer to it in the
* application tag of the manifest.
*/
public class FinchApplication extends Application {
- private final String TAG = this.getClass().getSimpleName();
-
- @Override
- public void onCreate() {
- // First, call the parent class
- super.onCreate();
-
- // This is a place to put code that must manage storage across
- // multiple activities, but it's better to keep most things in a
- // database, rather than in memory
- Log.i(TAG, "onCreate");
- }
-
- @Override
- public void onTerminate() {
- Log.i(TAG, "onTerminate");
-
- }
-
- @Override
- public void onLowMemory() {
- // In-memory caches should be thrown overboard here
- Log.i(TAG, "onLowMemory");
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- Log.i(TAG, "onConifgurationChanged");
- if (Log.isLoggable(TAG, Log.VERBOSE)) {
- Log.v(TAG, newConfig.toString());
- }
- }
+ private final String TAG = this.getClass().getSimpleName();
+
+ @Override
+ public void onCreate() {
+ // First, call the parent class
+ super.onCreate();
+
+ // This is a place to put code that must manage storage across
+ // multiple activities, but it's better to keep most things in a
+ // database, rather than in memory
+ Log.i(TAG, "onCreate");
+ }
+
+ @Override
+ public void onTerminate() {
+ Log.i(TAG, "onTerminate");
+
+ }
+
+ @Override
+ public void onLowMemory() {
+ // In-memory caches should be thrown overboard here
+ Log.i(TAG, "onLowMemory");
+ }
+
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ Log.i(TAG, "onConifgurationChanged");
+ if (Log.isLoggable(TAG, Log.VERBOSE)) {
+ Log.v(TAG, newConfig.toString());
+ }
+ }
}
diff --git a/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java b/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java
index 33f25c7..e6dbcdc 100644
--- a/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java
+++ b/FinchFramework/src/com/finchframework/finch/rest/FileHandler.java
@@ -14,26 +14,24 @@
*/
public class FileHandler implements ResponseHandler {
private String mId;
- private String mCacheDir;
+ private File mCacheDir;
- public FileHandler(String cacheDir, String id) {
+ public FileHandler(File cacheDir, String id) {
mCacheDir = cacheDir;
mId = id;
}
- public
- String getFileName(String ID) {
- return mCacheDir + "/" + ID;
+ public File getFile(String ID) {
+ return new File(mCacheDir, ID);
}
public void handleResponse(HttpResponse response, Uri uri)
- throws IOException
- {
+ throws IOException {
InputStream urlStream = response.getEntity().getContent();
FileOutputStream fout =
- new FileOutputStream(getFileName(mId));
+ new FileOutputStream(getFile(mId));
byte[] bytes = new byte[256];
- int r = 0;
+ int r;
do {
r = urlStream.read(bytes);
if (r >= 0) {
diff --git a/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java b/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java
index 2efb3f5..1f172b8 100644
--- a/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java
+++ b/FinchFramework/src/com/finchframework/finch/rest/FileHandlerFactory.java
@@ -7,17 +7,16 @@
* The cache directory is set in the constructor to the file handler factory.
*/
public class FileHandlerFactory {
- private String mCacheDir;
+ private File mCacheDir;
- public FileHandlerFactory(String cacheDir) {
+ public FileHandlerFactory(File cacheDir) {
mCacheDir = cacheDir;
init();
}
private void init() {
- File cacheDir = new File(mCacheDir);
- if (!cacheDir.exists()) {
- cacheDir.mkdir();
+ if (!mCacheDir.exists()) {
+ mCacheDir.mkdir();
}
}
@@ -25,27 +24,14 @@ public FileHandler newFileHandler(String id) {
return new FileHandler(mCacheDir, id);
}
- // not really used since ContentResolver uses _data field.
- public File getFile(String ID) {
- String cachePath = getFileName(ID);
-
- File cacheFile = new File(cachePath);
- if (cacheFile.exists()) {
- return cacheFile;
- }
- return null;
- }
-
public void delete(String ID) {
- String cachePath = mCacheDir + "/" + ID;
-
- File cacheFile = new File(cachePath);
+ File cacheFile = new File(mCacheDir, ID);
if (cacheFile.exists()) {
cacheFile.delete();
}
}
public String getFileName(String ID) {
- return mCacheDir + "/" + ID;
+ return new File(mCacheDir, ID).toString();
}
}
diff --git a/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java b/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java
index 9b67077..9b7d917 100644
--- a/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java
+++ b/FinchFramework/src/com/finchframework/finch/rest/RESTfulContentProvider.java
@@ -24,11 +24,14 @@ public abstract class RESTfulContentProvider extends ContentProvider {
private Map mRequestsInProgress =
new HashMap();
- public RESTfulContentProvider(FileHandlerFactory fileHandlerFactory) {
+ public RESTfulContentProvider() {
+ }
+
+ public void setFileHandlerFactory(FileHandlerFactory fileHandlerFactory) {
mFileHandlerFactory = fileHandlerFactory;
}
- public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);
+ public abstract Uri insert(Uri uri, ContentValues cv, SQLiteDatabase db);
private UriRequestTask getRequestTask(String queryText) {
return mRequestsInProgress.get(queryText);
@@ -53,10 +56,10 @@ public void requestComplete(String mQueryText) {
*
* @param requestTag unique tag identifying this request.
* @return The response handler created by a subclass used to parse the
- * request response.
+ * request response.
*/
protected abstract ResponseHandler newResponseHandler(String requestTag);
-
+
UriRequestTask newQueryTask(String requestTag, String url) {
UriRequestTask requestTask;
@@ -73,7 +76,6 @@ UriRequestTask newQueryTask(String requestTag, String url) {
* Creates a new worker thread to carry out a RESTful network invocation.
*
* @param queryTag unique tag that identifies this request.
- *
* @param queryUri the complete URI that should be access by this request.
*/
public void asyncQueryRequest(String queryTag, String queryUri) {
diff --git a/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java b/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java
index ea6b404..f7e3c1c 100644
--- a/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java
+++ b/FinchFramework/src/com/finchframework/finch/rest/RawResponse.java
@@ -29,75 +29,101 @@ public RawResponse(Context c, int rawResource) {
Log.d(Finch.LOG_TAG, "exception from raw input stream", e);
}
}
+
public StatusLine getStatusLine() {
return null;
}
+
public void setStatusLine(StatusLine statusLine) {
}
+
public void setStatusLine(ProtocolVersion protocolVersion,
int i) {
}
+
public void setStatusLine(ProtocolVersion protocolVersion,
int i, String s) {
}
+
public void setStatusCode(int i)
- throws IllegalStateException
- {
+ throws IllegalStateException {
}
+
public void setReasonPhrase(String s)
throws IllegalStateException {
}
+
public HttpEntity getEntity() {
return mDebugEntity;
}
+
public void setEntity(HttpEntity httpEntity) {
}
+
public Locale getLocale() {
return null;
}
+
public void setLocale(Locale locale) {
}
+
public ProtocolVersion getProtocolVersion() {
return null;
}
+
public boolean containsHeader(String s) {
return false;
}
+
public Header[] getHeaders(String s) {
return new Header[0];
}
+
public Header getFirstHeader(String s) {
return null;
}
+
public Header getLastHeader(String s) {
return null;
}
+
public Header[] getAllHeaders() {
return new Header[0];
}
+
public void addHeader(Header header) {
}
+
public void addHeader(String s, String s1) {
}
+
public void setHeader(Header header) {
}
+
public void setHeader(String s, String s1) {
}
+
public void setHeaders(Header[] headers) {
}
+
public void removeHeader(Header header) {
}
+
public void removeHeaders(String s) {
}
+
public HeaderIterator headerIterator() {
return null;
}
+
public HeaderIterator headerIterator(String s) {
return null;
}
+
public HttpParams getParams() {
return null;
}
+
public void setParams(HttpParams httpParams) {
}
};
diff --git a/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java b/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java
index 50865e3..79432f2 100644
--- a/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java
+++ b/FinchFramework/src/com/finchframework/finch/rest/UriRequestTask.java
@@ -24,21 +24,19 @@ public class UriRequestTask implements Runnable {
private RESTfulContentProvider mSiteProvider;
private String mRequestTag;
-
+
private int mRawResponse = -1;
// private int mRawResponse = R.raw.map_src;
public UriRequestTask(HttpUriRequest request,
- ResponseHandler handler, Context appContext)
- {
+ ResponseHandler handler, Context appContext) {
this(null, null, request, handler, appContext);
}
-
+
public UriRequestTask(String requestTag,
RESTfulContentProvider siteProvider,
HttpUriRequest request,
- ResponseHandler handler, Context appContext)
- {
+ ResponseHandler handler, Context appContext) {
mRequestTag = requestTag;
mSiteProvider = siteProvider;
mRequest = request;
diff --git a/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java b/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java
deleted file mode 100644
index 9bbd2d5..0000000
--- a/FinchFramework/src/com/finchframework/finch/views/MesgEditText.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package com.finchframework.finch.views;
-
-import android.content.Context;
-import android.graphics.Rect;
-import android.text.Editable;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.widget.EditText;
-
-/**
- * A text field that can display a default message until a user types in their
- * own text.
- */
-public class MesgEditText extends EditText {
- private String mMesgText;
-
- public MesgEditText(Context context) {
- super(context);
- }
-
- public MesgEditText(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public MesgEditText(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setMesgText(String messageText) {
- mMesgText = messageText;
- setText(messageText);
- }
-
- @Override
- public Editable getText() {
- CharSequence current = super.getText();
- if ((current != null) && mMesgText.equals(current)) {
- current = "";
- }
- return Editable.Factory.getInstance().newEditable(current);
- }
-
- @Override
- protected void onFocusChanged(boolean focused, int direction,
- Rect previouslyFocusedRect)
- {
- super.onFocusChanged(focused, direction, previouslyFocusedRect);
- userOverride();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
-// if (keyCode == KeyEvent.KEYCODE_ENTER) {
- userOverride();
-// }
- return super.onKeyDown(keyCode, keyEvent);
- }
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- boolean superResponse = super.onTouchEvent(event);
- String actualText = super.getText().toString();
- if (mMesgText.equals(actualText)) {
- super.setText("");
- }
- return superResponse;
- }
-
- private void userOverride() {
- String actualText = super.getText().toString();
- if (!hasFocus() && actualText.equals("")) {
- setText(mMesgText);
- }
- if (hasFocus() && actualText.equals(mMesgText)) {
- setText("");
- }
- }
-
- public boolean searchEmpty() {
- CharSequence actualText = super.getText();
-
- return ((actualText == null) ||
- mMesgText.equals(actualText.toString()) ||
- "".equals(actualText.toString()));
- }
-}
diff --git a/FinchLifecycle/project.properties b/FinchLifecycle/project.properties
index 730e911..8da376a 100644
--- a/FinchLifecycle/project.properties
+++ b/FinchLifecycle/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/FinchLifecycleBackport/project.properties b/FinchLifecycleBackport/project.properties
index 83afe56..67cc219 100644
--- a/FinchLifecycleBackport/project.properties
+++ b/FinchLifecycleBackport/project.properties
@@ -8,5 +8,5 @@
# project structure.
# Project target.
-target=android-7
+target=android-15
android.library.reference.1=../FinchFramework
diff --git a/FinchVideo/AndroidManifest.xml b/FinchVideo/AndroidManifest.xml
index 32ae55e..9a3ab35 100644
--- a/FinchVideo/AndroidManifest.xml
+++ b/FinchVideo/AndroidManifest.xml
@@ -1,32 +1,42 @@
-
-
-
-
+ package="com.oreilly.demo.android.pa.finchvideo"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
+
+
\ No newline at end of file
diff --git a/FinchVideo/README.txt b/FinchVideo/README.txt
index 9cab5e5..9b21279 100644
--- a/FinchVideo/README.txt
+++ b/FinchVideo/README.txt
@@ -1,15 +1,20 @@
+The simplest way to set up this project is to use the project and classpath
+files in the tools/ide/eclipse folders. To do this:
+1) copy project and classpath files for the FinchFramework project into the
+ project root as .project and .classpath, respectively.
+2) import the FinchFramework project into your eclipse workspace
+ (be sure to use "Import Existing Project into Workspace", not "Import
+ Existing Android Code into Workspace"!)
+3) repeat steps 1 and 2 for the FinchVideo project
-Probably the simplest way to set up this project is to use the project and
-classpath files in the tools/ide/eclipse folders. The more complete description
-is that need to set up the Finch Framework project
-($root/finch/framework/FinchFramework). You need to be sure that the directory
-lib-src is on the build path. You will also need to set up FinchWelcome as a library:
-1) import FinchWelcome into your workspace
-2) for FinchWelcome, check Properties > Android and verify that it is
- a library project (bottom half of the dialog)
-3) in the project, use Android > Properties to add that project
- to this one, as a library
+A more complete description is that you need to set up the FinchFramework
+project as an Android library:
+1) Set up this project. It will have compile errors.
+2) import the FinchFramework into your workspace
+3) verify that the FinchFramework project is a library project:
+ check Properties > Android and look in the bottom half of the dialog
+4) Use Android > Properties > Add... in the lower pane, to add the
+ FinchFramework project to this one, as a library
-Using the normal eclipse project dependency mechanism will not work.
-
+Using the normal eclipse project dependency mechanism will not work!
diff --git a/FinchVideo/project.properties b/FinchVideo/project.properties
index 817681e..67cc219 100644
--- a/FinchVideo/project.properties
+++ b/FinchVideo/project.properties
@@ -8,5 +8,5 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
android.library.reference.1=../FinchFramework
diff --git a/FinchVideo/res/layout/simple_video_activity.xml b/FinchVideo/res/layout/simple_video_activity.xml
index b82c882..a614877 100644
--- a/FinchVideo/res/layout/simple_video_activity.xml
+++ b/FinchVideo/res/layout/simple_video_activity.xml
@@ -7,85 +7,53 @@
android:id="@+id/video_layout"
android:orientation="vertical"
>
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:singleLine="true"
+ />
+
+
+
+
+
+
+
-
-
-
-
+ android:layout_height="?android:attr/listPreferredItemHeight"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:gravity="center_vertical"
+ android:paddingLeft="5dip"
+ android:singleLine="true"
+ android:layout_gravity="center_vertical"
+ />
diff --git a/FinchVideo/res/layout/video_list_item.xml b/FinchVideo/res/layout/video_list_item.xml
index df4341c..59e0885 100644
--- a/FinchVideo/res/layout/video_list_item.xml
+++ b/FinchVideo/res/layout/video_list_item.xml
@@ -7,7 +7,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:orientation="vertical"
>
-
-
Finch Video
Update Content
- Search Videos
- YouTube Video Example
+ FinchVideo
Insert
Title
diff --git a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/FinchVideoActivity.java b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/FinchVideoActivity.java
index 80a8107..c833dce 100644
--- a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/FinchVideoActivity.java
+++ b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/FinchVideoActivity.java
@@ -8,6 +8,7 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
+import android.text.Editable;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
@@ -18,7 +19,6 @@
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import com.finchframework.finch.Finch;
-import com.finchframework.finch.views.MesgEditText;
import com.oreilly.demo.android.pa.finchvideo.provider.FinchVideo;
import java.io.FileNotFoundException;
@@ -33,7 +33,7 @@
public class FinchVideoActivity extends Activity {
SimpleCursorAdapter mAdapter;
- private MesgEditText mSearchText;
+ private EditText mSearchText;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -43,75 +43,74 @@ public void onCreate(Bundle savedInstanceState) {
final ListView searchList = (ListView) findViewById(R.id.video_list);
Cursor videoCursor =
- managedQuery(FinchVideo.Videos.CONTENT_URI, null,
- null, null, null);
+ managedQuery(FinchVideo.Videos.CONTENT_URI, null,
+ null, null, null);
// have to reset this on a new search
// Maps video entries from the database to views
mAdapter = new SimpleCursorAdapter(this,
- R.layout.video_list_item,
- videoCursor,
- new String[] {
- FinchVideo.Videos.TITLE,
- FinchVideo.Videos.THUMB_URI_NAME
- },
- new int[] { R.id.video_text, R.id.video_thumb_icon });
+ R.layout.video_list_item,
+ videoCursor,
+ new String[] {
+ FinchVideo.Videos.TITLE,
+ FinchVideo.Videos.THUMB_URI_NAME
+ },
+ new int[] { R.id.video_text, R.id.video_thumb_icon });
SimpleCursorAdapter.ViewBinder savb =
- new SimpleCursorAdapter.ViewBinder() {
- @Override
- public boolean setViewValue(View view, Cursor cursor, int i) {
- switch (i) {
- case FinchVideo.TITLE_COLUMN:
- TextView tv = (TextView)
- view.findViewById(R.id.video_text);
- String videoText = cursor.getString(i);
- tv.setText(videoText);
-
- break;
- case FinchVideo.THUMB_URI_COLUMN:
- setThumbResource(view, cursor);
- break;
- }
-
- return true;
- }
- };
+ new SimpleCursorAdapter.ViewBinder() {
+ @Override
+ public boolean setViewValue(View view, Cursor cursor, int i) {
+ switch (i) {
+ case FinchVideo.TITLE_COLUMN:
+ TextView tv = (TextView)
+ view.findViewById(R.id.video_text);
+ String videoText = cursor.getString(i);
+ tv.setText(videoText);
+
+ break;
+ case FinchVideo.THUMB_URI_COLUMN:
+ setThumbResource(view, cursor);
+ break;
+ }
+
+ return true;
+ }
+ };
mAdapter.setViewBinder(savb);
searchList.setAdapter(mAdapter);
- mSearchText = (MesgEditText) findViewById(R.id.video_search_box);
- mSearchText.setMesgText(r.getString(R.string.finch_video_search));
+ mSearchText = (EditText) findViewById(R.id.video_search_box);
mSearchText.setOnEditorActionListener(
- new EditText.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView textView,
- int actionId,
- KeyEvent keyEvent)
- {
- // a null key event observed on some devices
- if (null != keyEvent) {
- int keyCode = keyEvent.getKeyCode();
- if ((keyCode == KeyEvent.KEYCODE_ENTER) &&
- (keyEvent.getAction() ==
- KeyEvent.ACTION_DOWN))
- {
- // action only causes the provider to ensure
- // the presence of some search results.
- query();
-
- return true;
+ new EditText.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView,
+ int actionId,
+ KeyEvent keyEvent)
+ {
+ // a null key event observed on some devices
+ if (null != keyEvent) {
+ int keyCode = keyEvent.getKeyCode();
+ if ((keyCode == KeyEvent.KEYCODE_ENTER) &&
+ (keyEvent.getAction() ==
+ KeyEvent.ACTION_DOWN))
+ {
+ // action only causes the provider to ensure
+ // the presence of some search results.
+ query();
+
+ return true;
+ }
}
+ return false;
}
- return false;
- }
- });
+ });
final ImageButton refreshButton = (ImageButton)
- findViewById(R.id.video_update_button);
+ findViewById(R.id.video_update_button);
refreshButton.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) { query(); }
});
@@ -120,32 +119,42 @@ public boolean onEditorAction(TextView textView,
void setThumbResource(View view, Cursor cursor) {
Uri thumbUri = ContentUris.
- withAppendedId(FinchVideo.Videos.THUMB_URI,
- cursor.getLong(FinchVideo.ID_COLUMN));
+ withAppendedId(FinchVideo.Videos.THUMB_URI,
+ cursor.getLong(FinchVideo.ID_COLUMN));
try {
InputStream thumbStream =
- getContentResolver().openInputStream(thumbUri);
+ getContentResolver().openInputStream(thumbUri);
ImageView iv = (ImageView)
- view.findViewById(R.id.video_thumb_icon);
+ view.findViewById(R.id.video_thumb_icon);
Bitmap bm = BitmapFactory.decodeStream(thumbStream);
iv.setImageBitmap(bm);
} catch (FileNotFoundException e) {
- Log.d(Finch.LOG_TAG, "could not open provider thumb: ", e);
+ // dont print because its possible the file was not downloaded yet.
+ Log.d(Finch.LOG_TAG, "Thumb not yet downloaded?");
}
}
// sends the query to the finch video content provider
void query() {
- if (!mSearchText.searchEmpty()) {
+ if (!searchEmpty()) {
String queryString =
- FinchVideo.Videos.QUERY_PARAM_NAME + "=" +
- Uri.encode(mSearchText.getText().toString());
+ FinchVideo.Videos.QUERY_PARAM_NAME + "=" +
+ Uri.encode(mSearchText.getText().toString());
Uri queryUri =
- Uri.parse(FinchVideo.Videos.CONTENT_URI + "?" +
- queryString);
+ Uri.parse(FinchVideo.Videos.CONTENT_URI + "?" +
+ queryString);
Cursor c = managedQuery(queryUri, null, null, null, null);
mAdapter.changeCursor(c);
}
}
+
+ private boolean searchEmpty() {
+ Editable text = mSearchText.getText();
+ if (text != null) {
+ String textString = text.toString();
+ return "".equals(textString);
+ }
+ return true;
+ }
}
diff --git a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideo.java b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideo.java
index c6d1b7f..e264b81 100644
--- a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideo.java
+++ b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideo.java
@@ -23,10 +23,10 @@ public class FinchVideo {
public static final int MEDIA_ID_COLUMN = 8;
public static final String AUTHORITY =
- "com.oreilly.demo.pa.finchvideo.FinchVideo";
+ "com.oreilly.demo.android.pa.finchvideo.FinchVideo";
public static final String SIMPLE_AUTHORITY =
- "com.oreilly.demo.pa.finchvideo.SimpleFinchVideo";
+ "com.oreilly.demo.android.pa.finchvideo.SimpleFinchVideo";
/**
* Simple Videos columns
*/
diff --git a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideoContentProvider.java b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideoContentProvider.java
index e7b9b4a..4aaf7a4 100644
--- a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideoContentProvider.java
+++ b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/FinchVideoContentProvider.java
@@ -16,6 +16,7 @@
import com.finchframework.finch.rest.RESTfulContentProvider;
import com.finchframework.finch.rest.ResponseHandler;
+import java.io.File;
import java.io.FileNotFoundException;
/**
@@ -31,8 +32,7 @@ public class FinchVideoContentProvider extends RESTfulContentProvider {
public static final String VIDEOS_TABLE_NAME = "video";
- private static final String FILE_CACHE_DIR =
- "/data/data/com.oreilly.demo.pa.finchvideo/file_cache";
+ private static final String FINCH_VIDEO_FILE_CACHE = "finch_video_file_cache";
private static final int VIDEOS = 1;
private static final int VIDEO_ID = 2;
@@ -65,7 +65,7 @@ public class FinchVideoContentProvider extends RESTfulContentProvider {
"max-results=15&format=1&q=";
private DatabaseHelper mOpenHelper;
- private SQLiteDatabase mDb;
+ private SQLiteDatabase mDb;
private static class DatabaseHelper extends SQLiteOpenHelper {
private DatabaseHelper(Context context, String name,
@@ -82,20 +82,20 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
private void createTable(SQLiteDatabase sqLiteDatabase) {
String createvideoTable =
"CREATE TABLE " + VIDEOS_TABLE_NAME + " (" +
- BaseColumns._ID +
+ BaseColumns._ID +
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
- FinchVideo.Videos.TITLE + " TEXT, " +
- FinchVideo.Videos.DESCRIPTION + " TEXT, " +
- FinchVideo.Videos.THUMB_URI_NAME + " TEXT," +
- FinchVideo.Videos.THUMB_WIDTH_NAME + " TEXT," +
- FinchVideo.Videos.THUMB_HEIGHT_NAME + " TEXT," +
- FinchVideo.Videos.TIMESTAMP + " TEXT, " +
- FinchVideo.Videos.QUERY_TEXT_NAME + " TEXT, " +
- FinchVideo.Videos.MEDIA_ID_NAME + " TEXT UNIQUE," +
- FinchVideo.Videos.THUMB_CONTENT_URI_NAME +
+ FinchVideo.Videos.TITLE + " TEXT, " +
+ FinchVideo.Videos.DESCRIPTION + " TEXT, " +
+ FinchVideo.Videos.THUMB_URI_NAME + " TEXT," +
+ FinchVideo.Videos.THUMB_WIDTH_NAME + " TEXT," +
+ FinchVideo.Videos.THUMB_HEIGHT_NAME + " TEXT," +
+ FinchVideo.Videos.TIMESTAMP + " TEXT, " +
+ FinchVideo.Videos.QUERY_TEXT_NAME + " TEXT, " +
+ FinchVideo.Videos.MEDIA_ID_NAME + " TEXT UNIQUE," +
+ FinchVideo.Videos.THUMB_CONTENT_URI_NAME +
" TEXT UNIQUE," +
- FinchVideo.Videos._DATA + " TEXT UNIQUE" +
- ");";
+ FinchVideo.Videos._DATA + " TEXT UNIQUE" +
+ ");";
sqLiteDatabase.execSQL(createvideoTable);
}
@@ -110,24 +110,22 @@ public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldv,
}
public FinchVideoContentProvider() {
- super(new FileHandlerFactory(FILE_CACHE_DIR));
}
public FinchVideoContentProvider(Context context) {
- super(new FileHandlerFactory(FILE_CACHE_DIR));
- init();
}
@Override
public boolean onCreate() {
- init();
- return true;
- }
+ FileHandlerFactory fileHandlerFactory =
+ new FileHandlerFactory(new File(getContext().getFilesDir(),
+ FINCH_VIDEO_FILE_CACHE));
+ setFileHandlerFactory(fileHandlerFactory);
- private void init() {
mOpenHelper = new DatabaseHelper(getContext(), DATABASE_NAME, null);
mDb = mOpenHelper.getWritableDatabase();
- mFileHandlerFactory = new FileHandlerFactory(FILE_CACHE_DIR);
+
+ return true;
}
@Override
@@ -135,111 +133,111 @@ public SQLiteDatabase getDatabase() {
return mDb;
}
-/**
- * Content provider query method that converts its parameters into a YouTube
- * RESTful search query.
- *
- * @param uri a reference to the query for videos, the query string can
- * contain, "q='key_words'". The keywords are sent to the google YouTube
- * API where they are used to search the YouTube video database.
- * @param projection
- * @param where not used in this provider.
- * @param whereArgs not used in this provider.
- * @param sortOrder not used in this provider.
- * @return a cursor containing the results of a YouTube search query.
- */
-@Override
-public Cursor query(Uri uri, String[] projection, String where,
- String[] whereArgs, String sortOrder)
-{
- Cursor queryCursor;
-
- int match = sUriMatcher.match(uri);
- switch (match) {
- case VIDEOS:
- // the query is passed out of band of other information passed
- // to this method -- its not an argument.
- String queryText = uri.
- getQueryParameter(FinchVideo.Videos.QUERY_PARAM_NAME);
-
- if (queryText == null) {
- // A null cursor is an acceptable argument to the method,
- // CursorAdapter.changeCursor(Cursor c), which interprets
- // the value by canceling all adapter state so that the
- // component for which the cursor is adapting data will
- // display no content.
- return null;
- }
+ /**
+ * Content provider query method that converts its parameters into a YouTube
+ * RESTful search query.
+ *
+ * @param uri a reference to the query for videos, the query string can
+ * contain, "q='key_words'". The keywords are sent to the google YouTube
+ * API where they are used to search the YouTube video database.
+ * @param projection
+ * @param where not used in this provider.
+ * @param whereArgs not used in this provider.
+ * @param sortOrder not used in this provider.
+ * @return a cursor containing the results of a YouTube search query.
+ */
+ @Override
+ public Cursor query(Uri uri, String[] projection, String where,
+ String[] whereArgs, String sortOrder)
+ {
+ Cursor queryCursor;
- String select = FinchVideo.Videos.QUERY_TEXT_NAME +
- " = '" + queryText + "'";
-
- // quickly return already matching data
- queryCursor =
- mDb.query(VIDEOS_TABLE_NAME, projection,
- select,
- whereArgs,
- null,
- null, sortOrder);
-
- // make the cursor observe the requested query
- queryCursor.setNotificationUri(
- getContext().getContentResolver(), uri);
-
- /**
- * Always try to update results with the latest data from the
- * network.
- *
- * Spawning an asynchronous load task thread, guarantees that
- * the load has no chance to block any content provider method,
- * and therefore no chance to block the UI thread.
- *
- * While the request loads, we return the cursor with existing
- * data to the client.
- *
- * If the existing cursor is empty, the UI will render no
- * content until it receives URI notification.
- *
- * Content updates that arrive when the asynchronous network
- * request completes will appear in the already returned cursor,
- * since that cursor query will match that of
- * newly arrived items.
- */
- if (!"".equals(queryText)) {
- asyncQueryRequest(queryText, QUERY_URI + encode(queryText));
- }
- break;
- case VIDEO_ID:
- case THUMB_VIDEO_ID:
- long videoID = ContentUris.parseId(uri);
- queryCursor =
- mDb.query(VIDEOS_TABLE_NAME, projection,
- BaseColumns._ID + " = " + videoID,
- whereArgs, null, null, null);
- queryCursor.setNotificationUri(
- getContext().getContentResolver(), uri);
- break;
- case THUMB_ID:
- String uriString = uri.toString();
- int lastSlash = uriString.lastIndexOf("/");
- String mediaID = uriString.substring(lastSlash + 1);
-
- queryCursor =
- mDb.query(VIDEOS_TABLE_NAME, projection,
- FinchVideo.Videos.MEDIA_ID_NAME + " = " +
- mediaID,
- whereArgs, null, null, null);
- queryCursor.setNotificationUri(
- getContext().getContentResolver(), uri);
- break;
-
- default:
- throw new IllegalArgumentException("unsupported uri: " +
- QUERY_URI);
- }
+ int match = sUriMatcher.match(uri);
+ switch (match) {
+ case VIDEOS:
+ // the query is passed out of band of other information passed
+ // to this method -- its not an argument.
+ String queryText = uri.
+ getQueryParameter(FinchVideo.Videos.QUERY_PARAM_NAME);
+
+ if (queryText == null) {
+ // A null cursor is an acceptable argument to the method,
+ // CursorAdapter.changeCursor(Cursor c), which interprets
+ // the value by canceling all adapter state so that the
+ // component for which the cursor is adapting data will
+ // display no content.
+ return null;
+ }
+
+ String select = FinchVideo.Videos.QUERY_TEXT_NAME +
+ " = '" + queryText + "'";
+
+ // quickly return already matching data
+ queryCursor =
+ mDb.query(VIDEOS_TABLE_NAME, projection,
+ select,
+ whereArgs,
+ null,
+ null, sortOrder);
+
+ // make the cursor observe the requested query
+ queryCursor.setNotificationUri(
+ getContext().getContentResolver(), uri);
+
+ /**
+ * Always try to update results with the latest data from the
+ * network.
+ *
+ * Spawning an asynchronous load task thread, guarantees that
+ * the load has no chance to block any content provider method,
+ * and therefore no chance to block the UI thread.
+ *
+ * While the request loads, we return the cursor with existing
+ * data to the client.
+ *
+ * If the existing cursor is empty, the UI will render no
+ * content until it receives URI notification.
+ *
+ * Content updates that arrive when the asynchronous network
+ * request completes will appear in the already returned cursor,
+ * since that cursor query will match that of
+ * newly arrived items.
+ */
+ if (!"".equals(queryText)) {
+ asyncQueryRequest(queryText, QUERY_URI + encode(queryText));
+ }
+ break;
+ case VIDEO_ID:
+ case THUMB_VIDEO_ID:
+ long videoID = ContentUris.parseId(uri);
+ queryCursor =
+ mDb.query(VIDEOS_TABLE_NAME, projection,
+ BaseColumns._ID + " = " + videoID,
+ whereArgs, null, null, null);
+ queryCursor.setNotificationUri(
+ getContext().getContentResolver(), uri);
+ break;
+ case THUMB_ID:
+ String uriString = uri.toString();
+ int lastSlash = uriString.lastIndexOf("/");
+ String mediaID = uriString.substring(lastSlash + 1);
+
+ queryCursor =
+ mDb.query(VIDEOS_TABLE_NAME, projection,
+ FinchVideo.Videos.MEDIA_ID_NAME + " = " +
+ mediaID,
+ whereArgs, null, null, null);
+ queryCursor.setNotificationUri(
+ getContext().getContentResolver(), uri);
+ break;
- return queryCursor;
-}
+ default:
+ throw new IllegalArgumentException("unsupported uri: " +
+ QUERY_URI);
+ }
+
+ return queryCursor;
+ }
/**
* Provides a handler that can parse YouTube gData RSS content.
@@ -383,7 +381,7 @@ public Uri insert(Uri uri, ContentValues values, SQLiteDatabase db) {
}
throw new IllegalStateException("could not insert " +
- "content values: " + values);
+ "content values: " + values);
}
return ContentUris.withAppendedId(FinchVideo.Videos.CONTENT_URI, rowID);
diff --git a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/SimpleFinchVideoContentProvider.java b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/SimpleFinchVideoContentProvider.java
index f33221b..3643ffe 100644
--- a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/SimpleFinchVideoContentProvider.java
+++ b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/SimpleFinchVideoContentProvider.java
@@ -21,48 +21,37 @@
* provider that stores basic video meta-data.
*/
public class SimpleFinchVideoContentProvider extends ContentProvider {
- public static final String AUTHORITY =
- "com.oreilly.demo.pa.finchvideo.SimpleFinchVideo";
-
public static final String SIMPLE_VIDEO = "simple_video";
+ public static final String VIDEO_TABLE_NAME = "videos";
private static final int VIDEOS = 1;
private static final int VIDEO_ID = 2;
-
private static UriMatcher sUriMatcher;
-
- private static HashMap sVideosProjectionMap;
-
static {
sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- sUriMatcher.addURI(AUTHORITY, FinchVideo.SimpleVideos.VIDEO_NAME,
- VIDEOS);
+ sUriMatcher.addURI(FinchVideo.SIMPLE_AUTHORITY, FinchVideo.SimpleVideos.VIDEO_NAME,
+ VIDEOS);
// use of the hash character indicates matching of an id
- sUriMatcher.addURI(AUTHORITY,
- FinchVideo.SimpleVideos.VIDEO_NAME + "/#", VIDEO_ID);
+ sUriMatcher.addURI(FinchVideo.SIMPLE_AUTHORITY,
+ FinchVideo.SimpleVideos.VIDEO_NAME + "/#", VIDEO_ID);
+ }
+ private static HashMap sVideosProjectionMap;
+ static {
// example projection map, not actually used in this application
sVideosProjectionMap = new HashMap();
- sVideosProjectionMap.put(BaseColumns._ID,
- BaseColumns._ID);
- sVideosProjectionMap.put(FinchVideo.Videos.TITLE,
- FinchVideo.Videos.TITLE);
- sVideosProjectionMap.put(FinchVideo.Videos.VIDEO,
- FinchVideo.Videos.VIDEO);
- sVideosProjectionMap.put(FinchVideo.Videos.DESCRIPTION,
- FinchVideo.Videos.DESCRIPTION);
+ sVideosProjectionMap.put(BaseColumns._ID, BaseColumns._ID);
+ sVideosProjectionMap.put(FinchVideo.Videos.TITLE, FinchVideo.Videos.TITLE);
+ sVideosProjectionMap.put(FinchVideo.Videos.VIDEO, FinchVideo.Videos.VIDEO);
+ sVideosProjectionMap.put(FinchVideo.Videos.DESCRIPTION, FinchVideo.Videos.DESCRIPTION);
}
- public static final String VIDEO_TABLE_NAME = "videos";
-
- public static final String DATABASE_NAME = SIMPLE_VIDEO + ".db";
- static int DATABASE_VERSION = 2;
-
private static class SimpleVideoDbHelper extends SQLiteOpenHelper {
- private SimpleVideoDbHelper(Context context, String name,
- SQLiteDatabase.CursorFactory factory)
- {
- super(context, name, factory, DATABASE_VERSION);
+ private static final String DATABASE_NAME = SIMPLE_VIDEO + ".db";
+ private static int DATABASE_VERSION = 2;
+
+ SimpleVideoDbHelper(Context context) {
+ super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
@@ -70,6 +59,15 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
createTable(sqLiteDatabase);
}
+ @Override
+ public void onUpgrade(SQLiteDatabase sqLiteDatabase,
+ int oldv, int newv)
+ {
+ sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " +
+ VIDEO_TABLE_NAME + ";");
+ createTable(sqLiteDatabase);
+ }
+
private void createTable(SQLiteDatabase sqLiteDatabase) {
String qs = "CREATE TABLE " + VIDEO_TABLE_NAME + " (" +
BaseColumns._ID +
@@ -79,41 +77,30 @@ private void createTable(SQLiteDatabase sqLiteDatabase) {
FinchVideo.SimpleVideos.URI_NAME + " TEXT);";
sqLiteDatabase.execSQL(qs);
}
-
- @Override
- public void onUpgrade(SQLiteDatabase sqLiteDatabase,
- int oldv, int newv)
- {
- sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " +
- VIDEO_TABLE_NAME + ";");
- createTable(sqLiteDatabase);
- }
}
- private Context mContext;
- private SimpleVideoDbHelper mOpenDbHelper;
-
- private SQLiteDatabase mDb;
- public SimpleFinchVideoContentProvider() {
- }
-
- public SimpleFinchVideoContentProvider(Context context) {
- mContext = context;
- init();
- }
+ private SimpleVideoDbHelper mOpenDbHelper;
@Override
public boolean onCreate() {
- init();
+ mOpenDbHelper = new SimpleVideoDbHelper(getContext());
return true;
}
- // allows object initialization to be reused.
- private void init() {
- mOpenDbHelper = new SimpleVideoDbHelper(getContext(),
- DATABASE_NAME, null);
- mDb = mOpenDbHelper.getWritableDatabase();
+ @Override
+ public String getType(Uri uri) {
+ switch (sUriMatcher.match(uri)) {
+ case VIDEOS:
+ return FinchVideo.SimpleVideos.CONTENT_TYPE;
+
+ case VIDEO_ID:
+ return FinchVideo.SimpleVideos.CONTENT_VIDEO_TYPE;
+
+ default:
+ throw new IllegalArgumentException("Unknown video type: " +
+ uri);
+ }
}
@Override
@@ -131,13 +118,12 @@ public Cursor query(Uri uri, String[] projection, String where,
int match = sUriMatcher.match(uri);
Cursor c;
-
switch (match) {
case VIDEOS:
// query the database for all videos
- c = mDb.query(VIDEO_TABLE_NAME, projection,
+ c = getDb().query(VIDEO_TABLE_NAME, projection,
where, whereArgs,
- null, null, sortOrder);
+ null, null, orderBy);
c.setNotificationUri(getContext().getContentResolver(),
FinchVideo.SimpleVideos.CONTENT_URI);
@@ -145,11 +131,11 @@ public Cursor query(Uri uri, String[] projection, String where,
case VIDEO_ID:
// query the database for a specific video
long videoID = ContentUris.parseId(uri);
- c = mDb.query(VIDEO_TABLE_NAME, projection,
+ c = getDb().query(VIDEO_TABLE_NAME, projection,
BaseColumns._ID + " = " + videoID +
(!TextUtils.isEmpty(where) ?
" AND (" + where + ')' : ""),
- whereArgs, null, null, sortOrder);
+ whereArgs, null, null, orderBy);
c.setNotificationUri(getContext().getContentResolver(),
FinchVideo.SimpleVideos.CONTENT_URI);
break;
@@ -160,21 +146,6 @@ public Cursor query(Uri uri, String[] projection, String where,
return c;
}
- @Override
- public String getType(Uri uri) {
- switch (sUriMatcher.match(uri)) {
- case VIDEOS:
- return FinchVideo.SimpleVideos.CONTENT_TYPE;
-
- case VIDEO_ID:
- return FinchVideo.SimpleVideos.CONTENT_VIDEO_TYPE;
-
- default:
- throw new IllegalArgumentException("Unknown video type: " +
- uri);
- }
- }
-
@Override
public Uri insert(Uri uri, ContentValues initialValues) {
// Validate the requested uri
@@ -196,9 +167,8 @@ public Uri insert(Uri uri, ContentValues initialValues) {
long rowId = db.insert(VIDEO_TABLE_NAME,
FinchVideo.SimpleVideos.VIDEO_NAME, values);
if (rowId > 0) {
- Uri videoURi =
- ContentUris.withAppendedId(
- FinchVideo.SimpleVideos.CONTENT_URI, rowId);
+ Uri videoURi = ContentUris.withAppendedId(
+ FinchVideo.SimpleVideos.CONTENT_URI, rowId);
getContext().getContentResolver().notifyChange(videoURi, null);
return videoURi;
}
@@ -210,12 +180,12 @@ private void verifyValues(ContentValues values) {
// Make sure that the fields are all set
if (!values.containsKey(FinchVideo.SimpleVideos.TITLE_NAME)) {
Resources r = Resources.getSystem();
- values.put(FinchVideo.SimpleVideos.URI_NAME,
+ values.put(FinchVideo.SimpleVideos.TITLE_NAME,
r.getString(android.R.string.untitled));
}
if (!values.containsKey(FinchVideo.SimpleVideos.DESCRIPTION_NAME)) {
- values.put(FinchVideo.SimpleVideos.URI_NAME, "");
+ values.put(FinchVideo.SimpleVideos.DESCRIPTION_NAME, "");
}
if (!values.containsKey(FinchVideo.SimpleVideos.URI_NAME)) {
@@ -230,28 +200,25 @@ public int delete(Uri uri, String where, String[] whereArgs) {
switch (match) {
case VIDEOS:
- affected = mDb.delete(VIDEO_TABLE_NAME,
+ affected = getDb().delete(VIDEO_TABLE_NAME,
(!TextUtils.isEmpty(where) ?
" AND (" + where + ')' : ""),
whereArgs);
break;
case VIDEO_ID:
long videoId = ContentUris.parseId(uri);
- affected = mDb.delete(VIDEO_TABLE_NAME,
+ affected = getDb().delete(VIDEO_TABLE_NAME,
BaseColumns._ID + "=" + videoId
+ (!TextUtils.isEmpty(where) ?
" AND (" + where + ')' : ""),
whereArgs);
-
- // the call to notify the uri after deletion is explicit
- getContext().getContentResolver().notifyChange(uri, null);
-
break;
default:
throw new IllegalArgumentException("unknown video element: " +
uri);
}
+ getContext().getContentResolver().notifyChange(uri, null);
return affected;
}
@@ -259,17 +226,17 @@ public int delete(Uri uri, String where, String[] whereArgs) {
public int update(Uri uri, ContentValues values, String where,
String[] whereArgs)
{
- SQLiteDatabase db = mOpenDbHelper.getWritableDatabase();
int affected;
+
switch (sUriMatcher.match(uri)) {
case VIDEOS:
- affected = db.update(VIDEO_TABLE_NAME, values,
+ affected = getDb().update(VIDEO_TABLE_NAME, values,
where, whereArgs);
break;
case VIDEO_ID:
String videoId = uri.getPathSegments().get(1);
- affected = db.update(VIDEO_TABLE_NAME, values,
+ affected = getDb().update(VIDEO_TABLE_NAME, values,
BaseColumns._ID + "=" + videoId
+ (!TextUtils.isEmpty(where) ?
" AND (" + where + ')' : ""),
@@ -281,6 +248,9 @@ public int update(Uri uri, ContentValues values, String where,
}
getContext().getContentResolver().notifyChange(uri, null);
+
return affected;
}
+
+ private SQLiteDatabase getDb() { return mOpenDbHelper.getWritableDatabase(); }
}
diff --git a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/YouTubeHandler.java b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/YouTubeHandler.java
index 7019ce8..b7ca0a3 100644
--- a/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/YouTubeHandler.java
+++ b/FinchVideo/src/com/oreilly/demo/android/pa/finchvideo/provider/YouTubeHandler.java
@@ -22,7 +22,7 @@
import java.io.InputStreamReader;
/**
- * Parses YouTube Entity data and and inserts it into the finch video content
+ * Parses YouTube entity data and and inserts it into the finch video content
* provider.
*/
public class YouTubeHandler implements ResponseHandler {
@@ -99,7 +99,7 @@ private void deleteOld() {
null, null, null, null);
int c = old.getCount();
if (old.getCount() > 0) {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
boolean next;
if (old.moveToNext()) {
do {
diff --git a/JSerializable/project.properties b/JSerializable/project.properties
index 730e911..8da376a 100644
--- a/JSerializable/project.properties
+++ b/JSerializable/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/LifecycleDemos/project.properties b/LifecycleDemos/project.properties
index 730e911..8da376a 100644
--- a/LifecycleDemos/project.properties
+++ b/LifecycleDemos/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/MicroJobs/project.properties b/MicroJobs/project.properties
index b00386b..9aa0dfa 100644
--- a/MicroJobs/project.properties
+++ b/MicroJobs/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=Google Inc.:Google APIs:8
+target=Google Inc.:Google APIs:15
diff --git a/SensorDemos/project.properties b/SensorDemos/project.properties
index 730e911..8da376a 100644
--- a/SensorDemos/project.properties
+++ b/SensorDemos/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15
diff --git a/SimpleFragment/project.properties b/SimpleFragment/project.properties
index 730e911..8da376a 100644
--- a/SimpleFragment/project.properties
+++ b/SimpleFragment/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-14
+target=android-15