Merge pull request #477 from dosiecki/master

Android: Bugfixes
This commit is contained in:
Samuel Clay 2014-01-24 17:32:51 -08:00
commit 5243ff8896
8 changed files with 26 additions and 14 deletions

View file

@ -144,7 +144,6 @@ public class Main extends NbFragmentActivity implements StateChangedListener, Sy
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
Log.d(this.getClass().getName(), "onActivityResult:RESULT_OK" );
folderFeedList.hasUpdated();
}
}
@ -165,7 +164,8 @@ public class Main extends NbFragmentActivity implements StateChangedListener, Sy
*/
@Override
public void updatePartialSync() {
folderFeedList.hasUpdated();
// TODO: move 2-step sync to new async lib and remove this method entirely
// folderFeedList.hasUpdated();
}
@Override

View file

@ -214,24 +214,22 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (pager == null) return false;
int currentItem = pager.getCurrentItem();
Story story = readingAdapter.getStory(currentItem);
if (story == null) return false;
if (item.getItemId() == android.R.id.home) {
finish();
return true;
} else if (item.getItemId() == R.id.menu_reading_original) {
if (story != null) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(story.permalink));
startActivity(i);
}
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(story.permalink));
startActivity(i);
return true;
} else if (item.getItemId() == R.id.menu_reading_sharenewsblur) {
if (story != null) {
DialogFragment newFragment = ShareDialogFragment.newInstance(getReadingFragment(), story, getReadingFragment().previouslySavedShareText);
newFragment.show(getSupportFragmentManager(), "dialog");
}
DialogFragment newFragment = ShareDialogFragment.newInstance(getReadingFragment(), story, getReadingFragment().previouslySavedShareText);
newFragment.show(getSupportFragmentManager(), "dialog");
return true;
} else if (item.getItemId() == R.id.menu_shared) {
FeedUtils.shareStory(story, this);
@ -378,7 +376,7 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
*/
private void checkStoryCount(int position) {
// if the pager is at or near the number of stories loaded, check for more unless we know we are at the end of the list
if (((position + 2) >= stories.getCount()) && !noMoreApiPages && !requestedPage && !stopLoading) {
if (((position + AppConstants.READING_STORY_PRELOAD) >= stories.getCount()) && !noMoreApiPages && !requestedPage && !stopLoading) {
currentApiPage += 1;
requestedPage = true;
enableMainProgress(true);
@ -584,6 +582,7 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
public void overlayText(View v) {
ReadingItemFragment item = getReadingFragment();
if (item == null) return;
item.switchSelectedFeedView();
updateOverlayText();
}

View file

@ -61,6 +61,7 @@ public class AllSharedStoriesItemListFragment extends ItemListFragment implement
groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS, DatabaseConstants.FEED_TITLE };
groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar, R.id.row_item_feedtitle };
// TODO: defer creation of the adapter until the loader's first callback so we don't leak this first cursor
Cursor cursor = contentResolver.query(FeedProvider.ALL_SHARED_STORIES_URI, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder));
adapter = new MultipleFeedItemsAdapter(getActivity(), R.layout.row_socialitem, cursor, groupFrom, groupTo, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
adapter.setViewBinder(new SocialItemViewBinder(getActivity()));

View file

@ -68,6 +68,7 @@ public class FeedItemListFragment extends StoryItemListFragment implements Loade
itemList.setEmptyView(v.findViewById(R.id.empty_view));
ContentResolver contentResolver = getActivity().getContentResolver();
// TODO: defer creation of the adapter until the loader's first callback so we don't leak this first stories cursor
Uri storiesUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
Cursor storiesCursor = contentResolver.query(storiesUri, null, DatabaseConstants.getStorySelectionFromState(currentState), null, DatabaseConstants.getStorySortOrder(storyOrder));
Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
@ -85,6 +86,7 @@ public class FeedItemListFragment extends StoryItemListFragment implements Loade
feedCursor.moveToFirst();
Feed feed = Feed.fromCursor(feedCursor);
feedCursor.close();
String[] groupFrom = new String[] { DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_AUTHORS, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS };
int[] groupTo = new int[] { R.id.row_item_title, R.id.row_item_author, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar };

View file

@ -57,7 +57,7 @@ public abstract class ItemListFragment extends Fragment implements OnScrollListe
@Override
public synchronized void onScroll(AbsListView view, int firstVisible, int visibleCount, int totalCount) {
// load an extra page worth of stories past the viewport
if (totalCount != 0 && (firstVisible + visibleCount + visibleCount - 1 >= totalCount) && !requestedPage) {
if (totalCount != 0 && (firstVisible + (visibleCount*2) >= totalCount) && !requestedPage) {
currentPage += 1;
requestedPage = true;
triggerRefresh(currentPage);

View file

@ -409,7 +409,7 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
float currentSize = PrefsUtils.getTextSize(getActivity());
StringBuilder builder = new StringBuilder();
builder.append("<html><head><meta name=\"viewport\" content=\"width=device-width; initial-scale=1; maximum-scale=1; minimum-scale=1; user-scalable=0; target-densityDpi=medium-dpi\" />");
builder.append("<html><head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=0\" />");
builder.append("<style style=\"text/css\">");
builder.append(String.format("body { font-size: %sem; } ", Float.toString(currentSize)));
builder.append("</style>");

View file

@ -110,6 +110,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
Cursor userCursor = resolver.query(FeedProvider.USERS_URI, null, DatabaseConstants.USER_USERID + " IN (?)", new String[] { id }, null);
UserProfile user = UserProfile.fromCursor(userCursor);
userCursor.close();
imageLoader.displayImage(user.photoUrl, favouriteImage, 10f);
favouriteImage.setTag(id);
@ -135,6 +136,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
if (story != null) {
Cursor userCursor = resolver.query(FeedProvider.USERS_URI, null, DatabaseConstants.USER_USERID + " IN (?)", new String[] { comment.userId }, null);
UserProfile user = UserProfile.fromCursor(userCursor);
userCursor.close();
DialogFragment newFragment = ReplyDialogFragment.newInstance(story, comment.userId, user.username);
newFragment.show(manager, "dialog");
@ -171,15 +173,18 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
TextView replyUsername = (TextView) replyView.findViewById(R.id.reply_username);
replyUsername.setText(R.string.unknown_user);
}
replyCursor.close();
TextView replySharedDate = (TextView) replyView.findViewById(R.id.reply_shareddate);
replySharedDate.setText(reply.shortDate + " ago");
((LinearLayout) commentView.findViewById(R.id.comment_replies_container)).addView(replyView);
}
replies.close();
Cursor userCursor = resolver.query(FeedProvider.USERS_URI, null, DatabaseConstants.USER_USERID + " IN (?)", new String[] { comment.userId }, null);
UserProfile commentUser = UserProfile.fromCursor(userCursor);
userCursor.close();
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
commentUsername.setText(commentUser.username);
@ -209,6 +214,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
imageLoader.displayImage(sourceUser.photoUrl, sourceUserImage, 10f);
imageLoader.displayImage(userPhoto, usershareImage, 10f);
}
sourceUserCursor.close();
} else {
imageLoader.displayImage(userPhoto, commentImage, 10f);
}
@ -260,6 +266,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
ImageView image = ViewUtils.createSharebarImage(context, imageLoader, user.photoUrl, user.userId);
sharedGrid.addView(image);
}
userCursor.close();
}
}

View file

@ -41,4 +41,7 @@ public class AppConstants {
// when generating a request for multiple feeds, limit the total number requested to prevent
// unworkably long URLs
public static final int MAX_FEED_LIST_SIZE = 250;
// when reading stories, how many stories worth of buffer to keep loaded ahead of the user
public static final int READING_STORY_PRELOAD = 5;
}