Skip to content

Commit 822d031

Browse files
authored
Merge pull request #15602 from wordpress-mobile/fix/lint-issues-on-develop
Fix/lint issues on develop
2 parents e0a7d6d + f073ade commit 822d031

17 files changed

+174
-200
lines changed

WordPress/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<uses-sdk tools:overrideLibrary="org.m4m.android" />
88

99
<!-- Normal permissions, access automatically granted to app -->
10+
<uses-permission android:name="android.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS" />
1011
<uses-permission android:name="android.permission.VIBRATE" />
1112
<uses-permission android:name="android.permission.INTERNET" />
1213
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

WordPress/src/main/java/org/wordpress/android/datasets/PeopleTable.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,29 +305,29 @@ private static Person getPerson(String table, long personId, int localTableBlogI
305305
}
306306

307307
private static Person getPersonFromCursor(Cursor c, String table, int localTableBlogId) {
308-
long personId = c.getInt(c.getColumnIndex("person_id"));
308+
long personId = c.getInt(c.getColumnIndexOrThrow("person_id"));
309309

310310
Person person = new Person(personId, localTableBlogId);
311-
person.setDisplayName(c.getString(c.getColumnIndex("display_name")));
312-
person.setAvatarUrl(c.getString(c.getColumnIndex("avatar_url")));
311+
person.setDisplayName(c.getString(c.getColumnIndexOrThrow("display_name")));
312+
person.setAvatarUrl(c.getString(c.getColumnIndexOrThrow("avatar_url")));
313313
switch (table) {
314314
case TEAM_TABLE:
315-
person.setUsername(c.getString(c.getColumnIndex("user_name")));
316-
String role = c.getString(c.getColumnIndex("role"));
315+
person.setUsername(c.getString(c.getColumnIndexOrThrow("user_name")));
316+
String role = c.getString(c.getColumnIndexOrThrow("role"));
317317
person.setRole(role);
318318
person.setPersonType(Person.PersonType.USER);
319319
break;
320320
case FOLLOWERS_TABLE:
321-
person.setUsername(c.getString(c.getColumnIndex("user_name")));
322-
person.setSubscribed(c.getString(c.getColumnIndex("subscribed")));
321+
person.setUsername(c.getString(c.getColumnIndexOrThrow("user_name")));
322+
person.setSubscribed(c.getString(c.getColumnIndexOrThrow("subscribed")));
323323
person.setPersonType(Person.PersonType.FOLLOWER);
324324
break;
325325
case EMAIL_FOLLOWERS_TABLE:
326-
person.setSubscribed(c.getString(c.getColumnIndex("subscribed")));
326+
person.setSubscribed(c.getString(c.getColumnIndexOrThrow("subscribed")));
327327
person.setPersonType(Person.PersonType.EMAIL_FOLLOWER);
328328
break;
329329
case VIEWERS_TABLE:
330-
person.setUsername(c.getString(c.getColumnIndex("user_name")));
330+
person.setUsername(c.getString(c.getColumnIndexOrThrow("user_name")));
331331
person.setPersonType(Person.PersonType.VIEWER);
332332
break;
333333
}

WordPress/src/main/java/org/wordpress/android/datasets/PublicizeTable.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ private static boolean getBooleanFromCursor(Cursor cursor, String columnName) {
138138
private static PublicizeService getServiceFromCursor(Cursor c) {
139139
PublicizeService service = new PublicizeService();
140140

141-
service.setId(c.getString(c.getColumnIndex("id")));
142-
service.setLabel(c.getString(c.getColumnIndex("label")));
143-
service.setDescription(c.getString(c.getColumnIndex("description")));
144-
service.setGenericon(c.getString(c.getColumnIndex("genericon")));
145-
service.setIconUrl(c.getString(c.getColumnIndex("icon_url")));
146-
service.setConnectUrl(c.getString(c.getColumnIndex("connect_url")));
141+
service.setId(c.getString(c.getColumnIndexOrThrow("id")));
142+
service.setLabel(c.getString(c.getColumnIndexOrThrow("label")));
143+
service.setDescription(c.getString(c.getColumnIndexOrThrow("description")));
144+
service.setGenericon(c.getString(c.getColumnIndexOrThrow("genericon")));
145+
service.setIconUrl(c.getString(c.getColumnIndexOrThrow("icon_url")));
146+
service.setConnectUrl(c.getString(c.getColumnIndexOrThrow("connect_url")));
147147
service.setIsJetpackSupported(getBooleanFromCursor(c, "is_jetpack_supported"));
148148
service.setIsMultiExternalUserIdSupported(getBooleanFromCursor(c, "is_multi_user_id_supported"));
149149
service.setIsExternalUsersOnly(getBooleanFromCursor(c, "is_external_users_only"));
@@ -295,22 +295,22 @@ public static void setConnectionsForSite(long siteId, PublicizeConnectionList co
295295
private static PublicizeConnection getConnectionFromCursor(Cursor c) {
296296
PublicizeConnection connection = new PublicizeConnection();
297297

298-
connection.siteId = c.getLong(c.getColumnIndex("site_id"));
299-
connection.connectionId = c.getInt(c.getColumnIndex("id"));
300-
connection.userId = c.getInt(c.getColumnIndex("user_id"));
301-
connection.keyringConnectionId = c.getInt(c.getColumnIndex("keyring_connection_id"));
302-
connection.keyringConnectionUserId = c.getInt(c.getColumnIndex("keyring_connection_user_id"));
303-
304-
connection.isShared = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_shared")));
305-
306-
connection.setService(c.getString(c.getColumnIndex("service")));
307-
connection.setLabel(c.getString(c.getColumnIndex("label")));
308-
connection.setExternalId(c.getString(c.getColumnIndex("external_id")));
309-
connection.setExternalName(c.getString(c.getColumnIndex("external_name")));
310-
connection.setExternalDisplayName(c.getString(c.getColumnIndex("external_display")));
311-
connection.setExternalProfilePictureUrl(c.getString(c.getColumnIndex("external_profile_picture")));
312-
connection.setRefreshUrl(c.getString(c.getColumnIndex("refresh_url")));
313-
connection.setStatus(c.getString(c.getColumnIndex("status")));
298+
connection.siteId = c.getLong(c.getColumnIndexOrThrow("site_id"));
299+
connection.connectionId = c.getInt(c.getColumnIndexOrThrow("id"));
300+
connection.userId = c.getInt(c.getColumnIndexOrThrow("user_id"));
301+
connection.keyringConnectionId = c.getInt(c.getColumnIndexOrThrow("keyring_connection_id"));
302+
connection.keyringConnectionUserId = c.getInt(c.getColumnIndexOrThrow("keyring_connection_user_id"));
303+
304+
connection.isShared = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow("is_shared")));
305+
306+
connection.setService(c.getString(c.getColumnIndexOrThrow("service")));
307+
connection.setLabel(c.getString(c.getColumnIndexOrThrow("label")));
308+
connection.setExternalId(c.getString(c.getColumnIndexOrThrow("external_id")));
309+
connection.setExternalName(c.getString(c.getColumnIndexOrThrow("external_name")));
310+
connection.setExternalDisplayName(c.getString(c.getColumnIndexOrThrow("external_display")));
311+
connection.setExternalProfilePictureUrl(c.getString(c.getColumnIndexOrThrow("external_profile_picture")));
312+
connection.setRefreshUrl(c.getString(c.getColumnIndexOrThrow("refresh_url")));
313+
connection.setStatus(c.getString(c.getColumnIndexOrThrow("status")));
314314

315315
return connection;
316316
}

WordPress/src/main/java/org/wordpress/android/datasets/ReaderBlogTable.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,21 @@ private static ReaderBlog getBlogInfoFromCursor(Cursor c) {
104104
}
105105

106106
ReaderBlog blogInfo = new ReaderBlog();
107-
blogInfo.blogId = c.getLong(c.getColumnIndex("blog_id"));
108-
blogInfo.feedId = c.getLong(c.getColumnIndex("feed_id"));
109-
blogInfo.setUrl(c.getString(c.getColumnIndex("blog_url")));
110-
blogInfo.setImageUrl(c.getString(c.getColumnIndex("image_url")));
111-
blogInfo.setFeedUrl(c.getString(c.getColumnIndex("feed_url")));
112-
blogInfo.setName(c.getString(c.getColumnIndex("name")));
113-
blogInfo.setDescription(c.getString(c.getColumnIndex("description")));
114-
blogInfo.isPrivate = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_private")));
115-
blogInfo.isJetpack = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_jetpack")));
116-
blogInfo.isFollowing = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_following")));
117-
blogInfo.isNotificationsEnabled = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_notifications_enabled")));
118-
blogInfo.numSubscribers = c.getInt(c.getColumnIndex("num_followers"));
119-
blogInfo.organizationId = c.getInt(c.getColumnIndex("organization_id"));
120-
blogInfo.numUnseenPosts = c.getInt(c.getColumnIndex("unseen_count"));
107+
blogInfo.blogId = c.getLong(c.getColumnIndexOrThrow("blog_id"));
108+
blogInfo.feedId = c.getLong(c.getColumnIndexOrThrow("feed_id"));
109+
blogInfo.setUrl(c.getString(c.getColumnIndexOrThrow("blog_url")));
110+
blogInfo.setImageUrl(c.getString(c.getColumnIndexOrThrow("image_url")));
111+
blogInfo.setFeedUrl(c.getString(c.getColumnIndexOrThrow("feed_url")));
112+
blogInfo.setName(c.getString(c.getColumnIndexOrThrow("name")));
113+
blogInfo.setDescription(c.getString(c.getColumnIndexOrThrow("description")));
114+
blogInfo.isPrivate = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow("is_private")));
115+
blogInfo.isJetpack = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow("is_jetpack")));
116+
blogInfo.isFollowing = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow("is_following")));
117+
blogInfo.isNotificationsEnabled = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow(
118+
"is_notifications_enabled")));
119+
blogInfo.numSubscribers = c.getInt(c.getColumnIndexOrThrow("num_followers"));
120+
blogInfo.organizationId = c.getInt(c.getColumnIndexOrThrow("organization_id"));
121+
blogInfo.numUnseenPosts = c.getInt(c.getColumnIndexOrThrow("unseen_count"));
121122

122123
return blogInfo;
123124
}

WordPress/src/main/java/org/wordpress/android/datasets/ReaderCommentTable.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -314,26 +314,26 @@ private static ReaderComment getCommentFromCursor(Cursor c) {
314314

315315
ReaderComment comment = new ReaderComment();
316316

317-
comment.commentId = c.getLong(c.getColumnIndex("comment_id"));
318-
comment.blogId = c.getLong(c.getColumnIndex("blog_id"));
319-
comment.postId = c.getLong(c.getColumnIndex("post_id"));
320-
comment.parentId = c.getLong(c.getColumnIndex("parent_id"));
321-
322-
comment.setPublished(c.getString(c.getColumnIndex("published")));
323-
comment.timestamp = c.getLong(c.getColumnIndex("timestamp"));
324-
325-
comment.setAuthorAvatar(c.getString(c.getColumnIndex("author_avatar")));
326-
comment.setAuthorName(c.getString(c.getColumnIndex("author_name")));
327-
comment.setAuthorUrl(c.getString(c.getColumnIndex("author_url")));
328-
comment.authorId = c.getLong(c.getColumnIndex("author_id"));
329-
comment.authorBlogId = c.getLong(c.getColumnIndex("author_blog_id"));
330-
331-
comment.setStatus(c.getString(c.getColumnIndex("status")));
332-
comment.setText(c.getString(c.getColumnIndex("text")));
333-
334-
comment.numLikes = c.getInt(c.getColumnIndex("num_likes"));
335-
comment.isLikedByCurrentUser = SqlUtils.sqlToBool(c.getInt(c.getColumnIndex("is_liked")));
336-
comment.pageNumber = c.getInt(c.getColumnIndex("page_number"));
317+
comment.commentId = c.getLong(c.getColumnIndexOrThrow("comment_id"));
318+
comment.blogId = c.getLong(c.getColumnIndexOrThrow("blog_id"));
319+
comment.postId = c.getLong(c.getColumnIndexOrThrow("post_id"));
320+
comment.parentId = c.getLong(c.getColumnIndexOrThrow("parent_id"));
321+
322+
comment.setPublished(c.getString(c.getColumnIndexOrThrow("published")));
323+
comment.timestamp = c.getLong(c.getColumnIndexOrThrow("timestamp"));
324+
325+
comment.setAuthorAvatar(c.getString(c.getColumnIndexOrThrow("author_avatar")));
326+
comment.setAuthorName(c.getString(c.getColumnIndexOrThrow("author_name")));
327+
comment.setAuthorUrl(c.getString(c.getColumnIndexOrThrow("author_url")));
328+
comment.authorId = c.getLong(c.getColumnIndexOrThrow("author_id"));
329+
comment.authorBlogId = c.getLong(c.getColumnIndexOrThrow("author_blog_id"));
330+
331+
comment.setStatus(c.getString(c.getColumnIndexOrThrow("status")));
332+
comment.setText(c.getString(c.getColumnIndexOrThrow("text")));
333+
334+
comment.numLikes = c.getInt(c.getColumnIndexOrThrow("num_likes"));
335+
comment.isLikedByCurrentUser = SqlUtils.sqlToBool(c.getInt(c.getColumnIndexOrThrow("is_liked")));
336+
comment.pageNumber = c.getInt(c.getColumnIndexOrThrow("page_number"));
337337

338338
return comment;
339339
}

WordPress/src/main/java/org/wordpress/android/datasets/ReaderDiscoverCardsTable.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object ReaderDiscoverCardsTable {
4848
try {
4949
if (c.moveToFirst()) {
5050
do {
51-
val cardJson = c.getString(c.getColumnIndex(CARDS_JSON_COLUMN))
51+
val cardJson = c.getString(c.getColumnIndexOrThrow(CARDS_JSON_COLUMN))
5252
cardJsonList.add(cardJson)
5353
} while (c.moveToNext())
5454
}

0 commit comments

Comments
 (0)