Skip to content

Commit 6f88a50

Browse files
committed
Remove tabs and add @OverRide tags
1 parent c0e3ee9 commit 6f88a50

File tree

11 files changed

+718
-714
lines changed

11 files changed

+718
-714
lines changed

‎10/MicroJobs/src/com/oreilly/demo/pa/ch10/MicroJobsDatabase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ public int getJobsCount(){
443443

444444
Cursor c = null;
445445
try {
446-
c = getReadableDatabase().rawQuery("SELECT count(*) FROM jobs",
447-
null);
446+
c = getReadableDatabase().rawQuery(
447+
"SELECT count(*) FROM jobs",
448+
null);
448449
if (0 >= c.getCount()) { return 0; }
449450
c.moveToFirst();
450451
return c.getInt(0);

‎12/FinchVideo/src/com/oreilly/demo/pa/finchvideo/FinchVideoActivity.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,29 @@ public void onCreate(Bundle savedInstanceState) {
4343

4444
final ListView searchList = (ListView) findViewById(R.id.video_list);
4545
Cursor videoCursor =
46-
managedQuery(FinchVideo.Videos.CONTENT_URI, null,
47-
null, null, null);
46+
managedQuery(FinchVideo.Videos.CONTENT_URI, null,
47+
null, null, null);
4848

4949
// have to reset this on a new search
5050

5151
// Maps video entries from the database to views
5252
mAdapter = new SimpleCursorAdapter(this,
53-
R.layout.video_list_item,
54-
videoCursor,
55-
new String[] {
56-
FinchVideo.Videos.TITLE,
57-
FinchVideo.Videos.THUMB_URI_NAME
58-
},
59-
new int[] { R.id.video_text, R.id.video_thumb_icon });
53+
R.layout.video_list_item,
54+
videoCursor,
55+
new String[] {
56+
FinchVideo.Videos.TITLE,
57+
FinchVideo.Videos.THUMB_URI_NAME
58+
},
59+
new int[] { R.id.video_text, R.id.video_thumb_icon });
6060

6161
SimpleCursorAdapter.ViewBinder savb =
62-
new SimpleCursorAdapter.ViewBinder() {
62+
new SimpleCursorAdapter.ViewBinder() {
63+
@Override
6364
public boolean setViewValue(View view, Cursor cursor, int i) {
6465
switch (i) {
6566
case FinchVideo.TITLE_COLUMN:
6667
TextView tv = (TextView)
67-
view.findViewById(R.id.video_text);
68+
view.findViewById(R.id.video_text);
6869
String videoText = cursor.getString(i);
6970
tv.setText(videoText);
7071

@@ -86,6 +87,7 @@ public boolean setViewValue(View view, Cursor cursor, int i) {
8687
mSearchText.setMesgText(r.getString(R.string.finch_video_search));
8788
mSearchText.setOnEditorActionListener(
8889
new EditText.OnEditorActionListener() {
90+
@Override
8991
public boolean onEditorAction(TextView textView,
9092
int actionId,
9193
KeyEvent keyEvent)
@@ -111,14 +113,12 @@ public boolean onEditorAction(TextView textView,
111113
final ImageButton refreshButton = (ImageButton)
112114
findViewById(R.id.video_update_button);
113115
refreshButton.setOnClickListener(new View.OnClickListener() {
114-
public void onClick(View view) {
115-
query();
116-
}
116+
@Override public void onClick(View view) { query(); }
117117
});
118118
refreshButton.setFocusable(true);
119119
}
120120

121-
private void setThumbResource(View view, Cursor cursor) {
121+
void setThumbResource(View view, Cursor cursor) {
122122
Uri thumbUri = ContentUris.
123123
withAppendedId(FinchVideo.Videos.THUMB_URI,
124124
cursor.getLong(FinchVideo.ID_COLUMN));
@@ -136,7 +136,7 @@ private void setThumbResource(View view, Cursor cursor) {
136136
}
137137

138138
// sends the query to the finch video content provider
139-
private void query() {
139+
void query() {
140140
if (!mSearchText.searchEmpty()) {
141141
String queryString =
142142
FinchVideo.Videos.QUERY_PARAM_NAME + "=" +

‎12/FinchVideo/src/com/oreilly/demo/pa/finchvideo/SimpleFinchVideoActivity.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,33 @@ public void onCreate(Bundle savedInstanceState) {
4343

4444
// Maps video entries from the database to views
4545
mAdapter = new SimpleCursorAdapter(this,
46-
R.layout.simple_video_list_item,
47-
videoCursor,
48-
new String[] {
49-
FinchVideo.SimpleVideos.TITLE_NAME,
50-
FinchVideo.SimpleVideos.DESCRIPTION_NAME
51-
},
52-
new int[] { R.id.simple_video_title_text });
46+
R.layout.simple_video_list_item,
47+
videoCursor,
48+
new String[] {
49+
FinchVideo.SimpleVideos.TITLE_NAME,
50+
FinchVideo.SimpleVideos.DESCRIPTION_NAME
51+
},
52+
new int[] { R.id.simple_video_title_text });
5353

5454
SimpleCursorAdapter.ViewBinder savb =
55-
new SimpleCursorAdapter.ViewBinder() {
56-
public boolean setViewValue(View view,
57-
Cursor cursor, int i)
58-
{
59-
switch (i) {
60-
case FinchVideo.TITLE_COLUMN:
61-
TextView tv = (TextView)
62-
view.findViewById(
63-
R.id.simple_video_title_text);
64-
String videoText = cursor.getString(i);
65-
tv.setText(videoText);
66-
break;
67-
}
68-
69-
return true;
70-
}
71-
};
55+
new SimpleCursorAdapter.ViewBinder() {
56+
@Override public boolean setViewValue(
57+
View view,
58+
Cursor cursor, int i)
59+
{
60+
switch (i) {
61+
case FinchVideo.TITLE_COLUMN:
62+
TextView tv = (TextView)
63+
view.findViewById(
64+
R.id.simple_video_title_text);
65+
String videoText = cursor.getString(i);
66+
tv.setText(videoText);
67+
break;
68+
}
69+
70+
return true;
71+
}
72+
};
7273

7374
mAdapter.setViewBinder(savb);
7475

@@ -84,13 +85,11 @@ public boolean setViewValue(View view,
8485
mInsertButton = (Button)
8586
findViewById(R.id.simple_video_insert_button);
8687
mInsertButton.setOnClickListener(new View.OnClickListener() {
87-
public void onClick(View view) {
88-
insert();
89-
}
88+
@Override public void onClick(View view) { insert(); }
9089
});
9190
}
9291

93-
private void insert() {
92+
void insert() {
9493
ContentValues values = new ContentValues();
9594
String title = mTitleEditText.getText().toString();
9695
values.put(FinchVideo.SimpleVideos.TITLE_NAME, title);

‎12/FinchVideo/src/com/oreilly/demo/pa/finchvideo/provider/FinchVideoContentProvider.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.database.sqlite.SQLiteOpenHelper;
1111
import android.net.Uri;
1212
import android.os.ParcelFileDescriptor;
13+
import android.provider.BaseColumns;
1314
import android.text.TextUtils;
1415
import com.finchframework.finch.rest.FileHandlerFactory;
1516
import com.finchframework.finch.rest.RESTfulContentProvider;
@@ -26,7 +27,7 @@
2627
public class FinchVideoContentProvider extends RESTfulContentProvider {
2728
public static final String VIDEO = "video";
2829
public static final String DATABASE_NAME = VIDEO + ".db";
29-
private static int DATABASE_VERSION = 2;
30+
static int DATABASE_VERSION = 2;
3031

3132
public static final String VIDEOS_TABLE_NAME = "video";
3233

@@ -81,7 +82,7 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
8182
private void createTable(SQLiteDatabase sqLiteDatabase) {
8283
String createvideoTable =
8384
"CREATE TABLE " + VIDEOS_TABLE_NAME + " (" +
84-
FinchVideo.Videos._ID +
85+
BaseColumns._ID +
8586
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
8687
FinchVideo.Videos.TITLE + " TEXT, " +
8788
FinchVideo.Videos.DESCRIPTION + " TEXT, " +
@@ -129,6 +130,7 @@ private void init() {
129130
mFileHandlerFactory = new FileHandlerFactory(FILE_CACHE_DIR);
130131
}
131132

133+
@Override
132134
public SQLiteDatabase getDatabase() {
133135
return mDb;
134136
}
@@ -212,7 +214,7 @@ public Cursor query(Uri uri, String[] projection, String where,
212214
long videoID = ContentUris.parseId(uri);
213215
queryCursor =
214216
mDb.query(VIDEOS_TABLE_NAME, projection,
215-
FinchVideo.Videos._ID + " = " + videoID,
217+
BaseColumns._ID + " = " + videoID,
216218
whereArgs, null, null, null);
217219
queryCursor.setNotificationUri(
218220
getContext().getContentResolver(), uri);
@@ -353,6 +355,7 @@ private void verifyValues(ContentValues values)
353355
* The delegate insert method, which also takes a database parameter. Note
354356
* that this method is a direct implementation of a content provider method.
355357
*/
358+
@Override
356359
public Uri insert(Uri uri, ContentValues values, SQLiteDatabase db) {
357360
verifyValues(values);
358361

@@ -377,10 +380,10 @@ public Uri insert(Uri uri, ContentValues values, SQLiteDatabase db) {
377380
FinchVideo.Videos.CONTENT_URI, rowId);
378381
getContext().getContentResolver().notifyChange(insertUri, null);
379382
return insertUri;
380-
} else {
381-
throw new IllegalStateException("could not insert " +
382-
"content values: " + values);
383383
}
384+
385+
throw new IllegalStateException("could not insert " +
386+
"content values: " + values);
384387
}
385388

386389
return ContentUris.withAppendedId(FinchVideo.Videos.CONTENT_URI, rowID);
@@ -420,7 +423,7 @@ public int delete(Uri uri, String where, String[] whereArgs) {
420423
case VIDEO_ID:
421424
long videoId = ContentUris.parseId(uri);
422425
affected = db.delete(VIDEOS_TABLE_NAME,
423-
FinchVideo.Videos._ID + "=" + videoId
426+
BaseColumns._ID + "=" + videoId
424427
+ (!TextUtils.isEmpty(where) ?
425428
" AND (" + where + ')' : ""),
426429
whereArgs);
@@ -451,7 +454,7 @@ public int update(Uri uri, ContentValues values, String where,
451454
case VIDEO_ID:
452455
String videoId = uri.getPathSegments().get(1);
453456
count = db.update(VIDEOS_TABLE_NAME, values,
454-
FinchVideo.Videos._ID + "=" + videoId
457+
BaseColumns._ID + "=" + videoId
455458
+ (!TextUtils.isEmpty(where) ?
456459
" AND (" + where + ')' : ""),
457460
whereArgs);

‎12/FinchVideo/src/com/oreilly/demo/pa/finchvideo/provider/SimpleFinchVideoContentProvider.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import android.database.sqlite.SQLiteDatabase;
1212
import android.database.sqlite.SQLiteOpenHelper;
1313
import android.net.Uri;
14+
import android.provider.BaseColumns;
1415
import android.text.TextUtils;
1516

1617
import java.util.HashMap;
@@ -42,8 +43,8 @@ public class SimpleFinchVideoContentProvider extends ContentProvider {
4243

4344
// example projection map, not actually used in this application
4445
sVideosProjectionMap = new HashMap<String, String>();
45-
sVideosProjectionMap.put(FinchVideo.Videos._ID,
46-
FinchVideo.Videos._ID);
46+
sVideosProjectionMap.put(BaseColumns._ID,
47+
BaseColumns._ID);
4748
sVideosProjectionMap.put(FinchVideo.Videos.TITLE,
4849
FinchVideo.Videos.TITLE);
4950
sVideosProjectionMap.put(FinchVideo.Videos.VIDEO,
@@ -55,7 +56,7 @@ public class SimpleFinchVideoContentProvider extends ContentProvider {
5556
public static final String VIDEO_TABLE_NAME = "videos";
5657

5758
public static final String DATABASE_NAME = SIMPLE_VIDEO + ".db";
58-
private static int DATABASE_VERSION = 2;
59+
static int DATABASE_VERSION = 2;
5960

6061
private static class SimpleVideoDbHelper extends SQLiteOpenHelper {
6162
private SimpleVideoDbHelper(Context context, String name,
@@ -71,7 +72,7 @@ public void onCreate(SQLiteDatabase sqLiteDatabase) {
7172

7273
private void createTable(SQLiteDatabase sqLiteDatabase) {
7374
String qs = "CREATE TABLE " + VIDEO_TABLE_NAME + " (" +
74-
FinchVideo.SimpleVideos._ID +
75+
BaseColumns._ID +
7576
" INTEGER PRIMARY KEY AUTOINCREMENT, " +
7677
FinchVideo.SimpleVideos.TITLE_NAME + " TEXT, " +
7778
FinchVideo.SimpleVideos.DESCRIPTION_NAME + " TEXT, " +
@@ -145,7 +146,7 @@ public Cursor query(Uri uri, String[] projection, String where,
145146
// query the database for a specific video
146147
long videoID = ContentUris.parseId(uri);
147148
c = mDb.query(VIDEO_TABLE_NAME, projection,
148-
FinchVideo.Videos._ID + " = " + videoID +
149+
BaseColumns._ID + " = " + videoID +
149150
(!TextUtils.isEmpty(where) ?
150151
" AND (" + where + ')' : ""),
151152
whereArgs, null, null, sortOrder);
@@ -237,7 +238,7 @@ public int delete(Uri uri, String where, String[] whereArgs) {
237238
case VIDEO_ID:
238239
long videoId = ContentUris.parseId(uri);
239240
affected = mDb.delete(VIDEO_TABLE_NAME,
240-
FinchVideo.SimpleVideos._ID + "=" + videoId
241+
BaseColumns._ID + "=" + videoId
241242
+ (!TextUtils.isEmpty(where) ?
242243
" AND (" + where + ')' : ""),
243244
whereArgs);
@@ -269,7 +270,7 @@ public int update(Uri uri, ContentValues values, String where,
269270
case VIDEO_ID:
270271
String videoId = uri.getPathSegments().get(1);
271272
affected = db.update(VIDEO_TABLE_NAME, values,
272-
FinchVideo.SimpleVideos._ID + "=" + videoId
273+
BaseColumns._ID + "=" + videoId
273274
+ (!TextUtils.isEmpty(where) ?
274275
" AND (" + where + ')' : ""),
275276
whereArgs);

‎12/FinchVideo/src/com/oreilly/demo/pa/finchvideo/provider/YouTubeHandler.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.database.Cursor;
55
import android.database.sqlite.SQLiteDatabase;
66
import android.net.Uri;
7+
import android.provider.BaseColumns;
78
import android.util.Log;
89
import com.finchframework.finch.Finch;
910
import com.finchframework.finch.rest.RESTfulContentProvider;
@@ -64,9 +65,8 @@ public YouTubeHandler(RESTfulContentProvider restfulProvider,
6465
* Handles the response from the YouTube gdata server, which is in the form
6566
* of an RSS feed containing references to YouTube videos.
6667
*/
67-
public void handleResponse(HttpResponse response, Uri uri)
68-
throws IOException
69-
{
68+
@Override
69+
public void handleResponse(HttpResponse response, Uri uri) {
7070
try {
7171
int newCount = parseYoutubeEntity(response.getEntity());
7272

@@ -103,7 +103,7 @@ private void deleteOld() {
103103
if (old.moveToNext()) {
104104
do {
105105
String ID = old.getString(FinchVideo.ID_COLUMN);
106-
sb.append(FinchVideo.Videos._ID);
106+
sb.append(BaseColumns._ID);
107107
sb.append(" = ");
108108
sb.append(ID);
109109

0 commit comments

Comments
 (0)