mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
upgrade fragment/loader lib to support-provided version
This commit is contained in:
parent
acbe8b2d04
commit
97f95203de
63 changed files with 208 additions and 224 deletions
|
@ -5,7 +5,7 @@
|
|||
android:versionName="7.1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="19"
|
||||
android:minSdkVersion="21"
|
||||
android:targetSdkVersion="24" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.res.Resources;
|
||||
import android.support.v13.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.domain.UserDetails;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.app.DialogFragment;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class AddFeedExternal extends NbActivity implements AddFeedFragment.AddFe
|
|||
com.newsblur.util.Log.d(this, "intent filter caught feed-like URI: " + uri);
|
||||
|
||||
DialogFragment addFeedFragment = AddFeedFragment.newInstance(uri.toString(), uri.toString());
|
||||
addFeedFragment.show(getFragmentManager(), "dialog");
|
||||
addFeedFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.newsblur.activity;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
|
@ -22,7 +22,7 @@ public class AddSocial extends NbActivity {
|
|||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_addsocial);
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.findFragmentByTag(currentTag) == null) {
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
|
|
|
@ -15,9 +15,9 @@ public class AllSharedStoriesReading extends Reading {
|
|||
UIUtils.setCustomActionBar(this, R.drawable.ak_icon_blurblogs, getResources().getString(R.string.all_shared_stories_title));
|
||||
|
||||
// No sourceUserId since this is all shared stories. The sourceUsedId for each story will be used.
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class AllStoriesReading extends Reading {
|
|||
|
||||
UIUtils.setCustomActionBar(this, R.drawable.ak_icon_allstories, getResources().getString(R.string.all_stories_title));
|
||||
setTitle(getResources().getString(R.string.all_stories_row_title));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -32,7 +32,7 @@ public class FeedItemsList extends ItemsList {
|
|||
|
||||
public void deleteFeed() {
|
||||
DialogFragment deleteFeedFragment = DeleteFeedFragment.newInstance(feed, folderName);
|
||||
deleteFeedFragment.show(getFragmentManager(), "dialog");
|
||||
deleteFeedFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,7 +63,7 @@ public class FeedItemsList extends ItemsList {
|
|||
}
|
||||
if (item.getItemId() == R.id.menu_intel) {
|
||||
FeedIntelTrainerFragment intelFrag = FeedIntelTrainerFragment.newInstance(feed, fs);
|
||||
intelFrag.show(getFragmentManager(), FeedIntelTrainerFragment.class.getName());
|
||||
intelFrag.show(getSupportFragmentManager(), FeedIntelTrainerFragment.class.getName());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FeedReading extends Reading {
|
|||
|
||||
readingAdapter = new FeedReadingAdapter(fragmentManager, feed, classifier);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ public class FolderReading extends Reading {
|
|||
|
||||
UIUtils.setCustomActionBar(this, R.drawable.g_icn_folder_rss, fs.getFolderName());
|
||||
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ public class GlobalSharedStoriesReading extends Reading {
|
|||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
UIUtils.setCustomActionBar(this, R.drawable.ak_icon_global, getResources().getString(R.string.global_shared_stories_title));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,7 @@ public class InfrequentItemsList extends ItemsList implements InfrequentCutoffCh
|
|||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.menu_infrequent_cutoff) {
|
||||
InfrequentCutoffDialogFragment dialog = InfrequentCutoffDialogFragment.newInstance(PrefsUtils.getInfrequentCutoff(this));
|
||||
dialog.show(getFragmentManager(), InfrequentCutoffDialogFragment.class.getName());
|
||||
dialog.show(getSupportFragmentManager(), InfrequentCutoffDialogFragment.class.getName());
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
|
|
@ -13,8 +13,8 @@ public class InfrequentReading extends Reading {
|
|||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
UIUtils.setCustomActionBar(this, R.drawable.ak_icon_allstories, getResources().getString(R.string.infrequent_title));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -74,7 +74,7 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
setContentView(R.layout.activity_itemslist);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
itemSetFragment = (ItemSetFragment) fragmentManager.findFragmentByTag(ItemSetFragment.class.getName());
|
||||
if (itemSetFragment == null) {
|
||||
itemSetFragment = ItemSetFragment.newInstance();
|
||||
|
@ -232,16 +232,16 @@ public abstract class ItemsList extends NbActivity implements StoryOrderChangedL
|
|||
} else if (item.getItemId() == R.id.menu_story_order) {
|
||||
StoryOrder currentValue = getStoryOrder();
|
||||
StoryOrderDialogFragment storyOrder = StoryOrderDialogFragment.newInstance(currentValue);
|
||||
storyOrder.show(getFragmentManager(), STORY_ORDER);
|
||||
storyOrder.show(getSupportFragmentManager(), STORY_ORDER);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_read_filter) {
|
||||
ReadFilter currentValue = getReadFilter();
|
||||
ReadFilterDialogFragment readFilter = ReadFilterDialogFragment.newInstance(currentValue);
|
||||
readFilter.show(getFragmentManager(), READ_FILTER);
|
||||
readFilter.show(getSupportFragmentManager(), READ_FILTER);
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_textsize) {
|
||||
TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(PrefsUtils.getListTextSize(this), TextSizeDialogFragment.TextSizeType.ListText);
|
||||
textSize.show(getFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
textSize.show(getSupportFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_search_stories) {
|
||||
if (searchQueryInput.getVisibility() != View.VISIBLE) {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.Window;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.LoginRegisterFragment;
|
||||
|
||||
public class Login extends Activity {
|
||||
public class Login extends FragmentActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -17,7 +17,7 @@ public class Login extends Activity {
|
|||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_login);
|
||||
FragmentManager fragmentManager = getFragmentManager();
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.findFragmentByTag(LoginRegisterFragment.class.getName()) == null) {
|
||||
FragmentTransaction transaction = fragmentManager.beginTransaction();
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.Window;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.LoginProgressFragment;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
||||
public class LoginProgress extends Activity {
|
||||
public class LoginProgress extends FragmentActivity {
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private String currentTag = "fragment";
|
||||
private String TAG = "LoginProgressActivity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle bundle) {
|
||||
|
@ -25,7 +23,7 @@ public class LoginProgress extends Activity {
|
|||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setContentView(R.layout.activity_loginprogress);
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.findFragmentByTag(currentTag ) == null) {
|
||||
String username = getIntent().getStringExtra("username");
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.newsblur.activity;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -84,7 +84,7 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
swipeLayout.setProgressBackgroundColorSchemeResource(UIUtils.getThemedResource(this, R.attr.actionbarBackground, android.R.attr.background));
|
||||
swipeLayout.setOnRefreshListener(this);
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
folderFeedList = (FolderListFragment) fragmentManager.findFragmentByTag("folderFeedListFragment");
|
||||
folderFeedList.setRetainInstance(true);
|
||||
((FeedIntelligenceSelectorFragment) fragmentManager.findFragmentByTag("feedIntelligenceSelector")).setState(folderFeedList.currentState);
|
||||
|
@ -316,7 +316,7 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_logout) {
|
||||
DialogFragment newFragment = new LogoutDialogFragment();
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
} else if (item.getItemId() == R.id.menu_settings) {
|
||||
Intent settingsIntent = new Intent(this, Settings.class);
|
||||
startActivity(settingsIntent);
|
||||
|
@ -335,11 +335,11 @@ public class Main extends NbActivity implements StateChangedListener, SwipeRefre
|
|||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_textsize) {
|
||||
TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(PrefsUtils.getListTextSize(this), TextSizeDialogFragment.TextSizeType.ListText);
|
||||
textSize.show(getFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
textSize.show(getSupportFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_loginas) {
|
||||
DialogFragment newFragment = new LoginAsDialogFragment();
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_theme_light) {
|
||||
PrefsUtils.setSelectedTheme(this, ThemeValue.LIGHT);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -19,7 +19,7 @@ import java.util.ArrayList;
|
|||
* The base class for all Activities in the NewsBlur app. Handles enforcement of
|
||||
* login state and tracking of sync/update broadcasts.
|
||||
*/
|
||||
public class NbActivity extends Activity {
|
||||
public class NbActivity extends FragmentActivity {
|
||||
|
||||
public static final int UPDATE_DB_READY = (1<<0);
|
||||
public static final int UPDATE_METADATA = (1<<1);
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.newsblur.activity;
|
|||
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.MenuItem;
|
||||
|
@ -36,7 +36,7 @@ public class Profile extends NbActivity {
|
|||
userId = savedInstanceState.getString(USER_ID);
|
||||
}
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.findFragmentByTag(detailsTag) == null) {
|
||||
FragmentTransaction detailsTransaction = fragmentManager.beginTransaction();
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.content.Loader;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.database.MixedFeedsReadingAdapter;
|
||||
|
@ -15,13 +13,9 @@ public class ReadStoriesReading extends Reading {
|
|||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
UIUtils.setCustomActionBar(this, R.drawable.g_icn_unread, getResources().getString(R.string.read_stories_title));
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
|
||||
super.onLoadFinished(loader, cursor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Loader;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.ViewPager.OnPageChangeListener;
|
||||
import android.util.Log;
|
||||
|
@ -126,7 +126,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
setContentView(R.layout.activity_reading);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
try {
|
||||
fs = (FeedSet)getIntent().getSerializableExtra(EXTRA_FEEDSET);
|
||||
|
@ -215,9 +215,6 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
if (NBSyncService.isHousekeepingRunning()) finish();
|
||||
// this view shows stories, it is not safe to perform cleanup
|
||||
this.stopLoading = false;
|
||||
// onCreate() in our subclass should have called createLoader(), but sometimes the callback never makes it.
|
||||
// this ensures that at least one callback happens after activity re-create.
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
// this is not strictly necessary, since our first refresh with the fs will swap in
|
||||
// the correct session, but that can be delayed by sync backup, so we try here to
|
||||
// reduce UI lag, or in case somehow we got redisplayed in a zero-story state
|
||||
|
@ -243,7 +240,6 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
readingAdapter.swapCursor(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -305,24 +301,27 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
private void skipPagerToStoryHash() {
|
||||
// if we already started and found our target story, this will be unset
|
||||
if (storyHash == null) return;
|
||||
stories.moveToPosition(-1);
|
||||
while (stories.moveToNext()) {
|
||||
if (stopLoading) return;
|
||||
Story story = Story.fromCursor(stories);
|
||||
if ( (story.storyHash.equals(storyHash)) ||
|
||||
((storyHash.equals(FIND_FIRST_UNREAD)) && (!story.read))
|
||||
) {
|
||||
// see above note about re-setting the adapter to force the pager to reload fragments
|
||||
pager.setAdapter(readingAdapter);
|
||||
pager.setCurrentItem(stories.getPosition(), false);
|
||||
this.onPageSelected(stories.getPosition());
|
||||
// now that the pager is getting the right story, make it visible
|
||||
pager.setVisibility(View.VISIBLE);
|
||||
emptyViewText.setVisibility(View.INVISIBLE);
|
||||
storyHash = null;
|
||||
return;
|
||||
}
|
||||
int position = -1;
|
||||
if (storyHash.equals(FIND_FIRST_UNREAD)) {
|
||||
position = readingAdapter.findFirstUnread();
|
||||
} else {
|
||||
position = readingAdapter.findHash(storyHash);
|
||||
}
|
||||
|
||||
if (stopLoading) return;
|
||||
|
||||
if (position >= 0 ) {
|
||||
// see above note about re-setting the adapter to force the pager to reload fragments
|
||||
pager.setAdapter(readingAdapter);
|
||||
pager.setCurrentItem(position, false);
|
||||
this.onPageSelected(position);
|
||||
// now that the pager is getting the right story, make it visible
|
||||
pager.setVisibility(View.VISIBLE);
|
||||
emptyViewText.setVisibility(View.INVISIBLE);
|
||||
storyHash = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// if the story wasn't found, try to get more stories into the cursor
|
||||
this.checkStoryCount(readingAdapter.getCount()+1);
|
||||
}
|
||||
|
@ -415,7 +414,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_reading_sharenewsblur) {
|
||||
DialogFragment newFragment = ShareDialogFragment.newInstance(story, readingAdapter.getSourceUserId());
|
||||
newFragment.show(getFragmentManager(), "dialog");
|
||||
newFragment.show(getSupportFragmentManager(), "dialog");
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_send_story) {
|
||||
FeedUtils.sendStoryBrief(story, this);
|
||||
|
@ -425,11 +424,11 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_textsize) {
|
||||
TextSizeDialogFragment textSize = TextSizeDialogFragment.newInstance(PrefsUtils.getTextSize(this), TextSizeDialogFragment.TextSizeType.ReadingText);
|
||||
textSize.show(getFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
textSize.show(getSupportFragmentManager(), TextSizeDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_font) {
|
||||
ReadingFontDialogFragment storyFont = ReadingFontDialogFragment.newInstance(PrefsUtils.getFontString(this));
|
||||
storyFont.show(getFragmentManager(), ReadingFontDialogFragment.class.getName());
|
||||
storyFont.show(getSupportFragmentManager(), ReadingFontDialogFragment.class.getName());
|
||||
return true;
|
||||
} else if (item.getItemId() == R.id.menu_reading_save) {
|
||||
if (story.starred) {
|
||||
|
@ -459,7 +458,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
} else if (item.getItemId() == R.id.menu_intel) {
|
||||
if (story.feedId.equals("0")) return true; // cannot train on feedless stories
|
||||
StoryIntelTrainerFragment intelFrag = StoryIntelTrainerFragment.newInstance(story, fs);
|
||||
intelFrag.show(getFragmentManager(), StoryIntelTrainerFragment.class.getName());
|
||||
intelFrag.show(getSupportFragmentManager(), StoryIntelTrainerFragment.class.getName());
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
@ -500,7 +499,7 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
|
|||
private void updateCursor() {
|
||||
synchronized (STORIES_MUTEX) {
|
||||
try {
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
getSupportLoaderManager().restartLoader(0, null, this);
|
||||
} catch (IllegalStateException ise) {
|
||||
; // our heavy use of async can race loader calls, which it will gripe about, but this
|
||||
// is only a refresh call, so dropping a refresh during creation is perfectly fine.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.support.v13.app.FragmentStatePagerAdapter;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentStatePagerAdapter;
|
||||
import android.util.SparseArray;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
@ -61,9 +61,7 @@ public abstract class ReadingAdapter extends FragmentStatePagerAdapter {
|
|||
|
||||
public synchronized void swapCursor(Cursor cursor) {
|
||||
this.stories = cursor;
|
||||
if (cursor != null) {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
protected abstract ReadingItemFragment getReadingItemFragment(Story story);
|
||||
|
@ -89,6 +87,7 @@ public abstract class ReadingAdapter extends FragmentStatePagerAdapter {
|
|||
|
||||
public synchronized int getPosition(Story story) {
|
||||
if (stories == null) return -1;
|
||||
if (stories.isClosed()) return -1;
|
||||
int pos = 0;
|
||||
while (pos < stories.getCount()) {
|
||||
stories.moveToPosition(pos);
|
||||
|
@ -125,6 +124,7 @@ public abstract class ReadingAdapter extends FragmentStatePagerAdapter {
|
|||
|
||||
// go one step further than the default pageradapter and also refresh the
|
||||
// story object inside each fragment we have active
|
||||
if (stories == null) return;
|
||||
for (int i=0; i<stories.getCount(); i++) {
|
||||
WeakReference<ReadingItemFragment> frag = cachedFragments.get(i);
|
||||
if (frag == null) continue;
|
||||
|
@ -134,4 +134,22 @@ public abstract class ReadingAdapter extends FragmentStatePagerAdapter {
|
|||
rif.handleUpdate(NbActivity.UPDATE_STORY);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int findFirstUnread() {
|
||||
stories.moveToPosition(-1);
|
||||
while (stories.moveToNext()) {
|
||||
Story story = Story.fromCursor(stories);
|
||||
if (!story.read) return stories.getPosition();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public synchronized int findHash(String storyHash) {
|
||||
stories.moveToPosition(-1);
|
||||
while (stories.moveToNext()) {
|
||||
Story story = Story.fromCursor(stories);
|
||||
if (story.storyHash.equals(storyHash)) return stories.getPosition();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.os.Bundle;
|
||||
import android.app.FragmentManager;
|
||||
import android.app.FragmentTransaction;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.fragment.RegisterProgressFragment;
|
||||
|
@ -14,7 +14,7 @@ import com.newsblur.util.PrefsUtils;
|
|||
* Activity doesn't extend NbActivity because it is one of the few
|
||||
* Activities that will be shown while the user is still logged out.
|
||||
*/
|
||||
public class RegisterProgress extends Activity {
|
||||
public class RegisterProgress extends FragmentActivity {
|
||||
|
||||
private FragmentManager fragmentManager;
|
||||
private String currentTag = "fragment";
|
||||
|
@ -26,7 +26,7 @@ public class RegisterProgress extends Activity {
|
|||
super.onCreate(bundle);
|
||||
setContentView(R.layout.activity_loginprogress);
|
||||
|
||||
fragmentManager = getFragmentManager();
|
||||
fragmentManager = getSupportFragmentManager();
|
||||
|
||||
if (fragmentManager.findFragmentByTag(currentTag ) == null) {
|
||||
final String username = getIntent().getStringExtra("username");
|
||||
|
|
|
@ -17,9 +17,9 @@ public class SavedStoriesReading extends Reading {
|
|||
title = title + " - " + fs.getSingleSavedTag();
|
||||
}
|
||||
UIUtils.setCustomActionBar(this, R.drawable.clock, title);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), null);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), null);
|
||||
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import java.util.Set;
|
|||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.LoaderManager.LoaderCallbacks;
|
||||
import android.content.Loader;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -55,7 +55,7 @@ public class SearchForFeeds extends NbActivity implements LoaderCallbacks<Search
|
|||
resultsList.setEmptyView(emptyView);
|
||||
resultsList.setOnItemClickListener(this);
|
||||
resultsList.setItemsCanFocus(false);
|
||||
searchLoader = getLoaderManager().initLoader(0, new Bundle(), this);
|
||||
searchLoader = getSupportLoaderManager().initLoader(0, new Bundle(), this);
|
||||
|
||||
onSearchRequested();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class SearchForFeeds extends NbActivity implements LoaderCallbacks<Search
|
|||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(SearchAsyncTaskLoader.SEARCH_TERM, query);
|
||||
searchLoader = getLoaderManager().restartLoader(0, bundle, this);
|
||||
searchLoader = getSupportLoaderManager().restartLoader(0, bundle, this);
|
||||
|
||||
searchLoader.forceLoad();
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class SearchForFeeds extends NbActivity implements LoaderCallbacks<Search
|
|||
if ((u.getHost() == null) || (u.getHost().trim().isEmpty())) { return false; }
|
||||
|
||||
DialogFragment addFeedFragment = AddFeedFragment.newInstance(s, s);
|
||||
addFeedFragment.show(getFragmentManager(), "dialog");
|
||||
addFeedFragment.show(getSupportFragmentManager(), "dialog");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class SearchForFeeds extends NbActivity implements LoaderCallbacks<Search
|
|||
public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
|
||||
FeedResult result = adapter.getItem(position);
|
||||
DialogFragment addFeedFragment = AddFeedFragment.newInstance(result.url, result.label);
|
||||
addFeedFragment.show(getFragmentManager(), "dialog");
|
||||
addFeedFragment.show(getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
@ -10,7 +10,7 @@ import com.newsblur.util.PrefConstants;
|
|||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
public class Settings extends Activity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class Settings extends FragmentActivity implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
|
@ -15,8 +15,8 @@ public class SocialFeedReading extends Reading {
|
|||
SocialFeed socialFeed = FeedUtils.dbHelper.getSocialFeed(fs.getSingleSocialFeed().getKey());
|
||||
if (socialFeed == null) finish(); // don't open fatally stale intents
|
||||
UIUtils.setCustomActionBar(this, socialFeed.photoUrl, socialFeed.feedTitle);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getFragmentManager(), socialFeed.userId);
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
readingAdapter = new MixedFeedsReadingAdapter(getSupportFragmentManager(), socialFeed.userId);
|
||||
getSupportLoaderManager().initLoader(0, null, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package com.newsblur.database;
|
|||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.CancellationSignal;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.newsblur.database;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
||||
import com.newsblur.activity.ReadingAdapter;
|
||||
import com.newsblur.domain.Classifier;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.newsblur.database;
|
||||
|
||||
import android.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
|
||||
import com.newsblur.activity.ReadingAdapter;
|
||||
import com.newsblur.domain.Classifier;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.newsblur.database;
|
||||
|
||||
import android.content.AsyncTaskLoader;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.OperationCanceledException;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
import android.util.Log;
|
||||
|
||||
import com.newsblur.util.AppConstants;
|
||||
|
@ -78,16 +78,17 @@ public abstract class QueryCursorLoader extends AsyncTaskLoader<Cursor> {
|
|||
@Override
|
||||
public void deliverResult(Cursor cursor) {
|
||||
if (isReset()) {
|
||||
clearCursor();
|
||||
clearCursor();
|
||||
return;
|
||||
}
|
||||
if (this.cursor != cursor) {
|
||||
clearCursor();
|
||||
}
|
||||
Cursor oldCursor = this.cursor;
|
||||
this.cursor = cursor;
|
||||
if (isStarted()) {
|
||||
super.deliverResult(cursor);
|
||||
}
|
||||
if (oldCursor != null && oldCursor != this.cursor && !oldCursor.isClosed()) {
|
||||
oldCursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,8 +96,9 @@ public abstract class QueryCursorLoader extends AsyncTaskLoader<Cursor> {
|
|||
if (cursor != null) {
|
||||
// if we already have a cursor and haven't been reset, use it!
|
||||
deliverResult(cursor);
|
||||
} else {
|
||||
takeContentChanged();
|
||||
}
|
||||
// if we had nothing or have a pending change, reload
|
||||
if ((cursor == null) || takeContentChanged()) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
|
@ -110,21 +112,16 @@ public abstract class QueryCursorLoader extends AsyncTaskLoader<Cursor> {
|
|||
|
||||
@Override
|
||||
public void onCanceled(Cursor cursor) {
|
||||
// many some other loaders mysteriously deliver results when they are cancelled and
|
||||
// *very importantly*, some LoaderManager implementations rely upon this fact. do not
|
||||
// remove this seemingly incorrect side-effect without rigorously testing many combinations
|
||||
// of LoaderManager call patterns on all supported platforms.
|
||||
// not that this may also require double-checking that adapters close cursors to prevent
|
||||
// cursor leakage
|
||||
if (cursor != null) {
|
||||
deliverResult(cursor);
|
||||
}
|
||||
clearCursor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReset() {
|
||||
super.onReset();
|
||||
clearCursor();
|
||||
onStopLoading();
|
||||
// note that the stock CursorLoader here closes the cursor early rather than waiting for the
|
||||
// rest of the reset->stop->cancel->cancelled cycle, which can cause contexts to briefly have
|
||||
// a closed cursor but no replacement.
|
||||
}
|
||||
|
||||
private void clearCursor() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.newsblur.database;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
|
@ -29,6 +28,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserDetails;
|
||||
|
@ -65,7 +65,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
protected Cursor cursor;
|
||||
private boolean showNone = false;
|
||||
|
||||
private Activity context;
|
||||
private NbActivity context;
|
||||
private FeedSet fs;
|
||||
private StoryListStyle listStyle;
|
||||
private boolean ignoreReadStatus;
|
||||
|
@ -74,7 +74,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
private float textSize;
|
||||
private UserDetails user;
|
||||
|
||||
public StoryViewAdapter(Activity context, FeedSet fs, StoryListStyle listStyle) {
|
||||
public StoryViewAdapter(NbActivity context, FeedSet fs, StoryListStyle listStyle) {
|
||||
this.context = context;
|
||||
this.fs = fs;
|
||||
this.listStyle = listStyle;
|
||||
|
@ -115,7 +115,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
}
|
||||
|
||||
public int getStoryCount() {
|
||||
if (showNone || (cursor == null)) {
|
||||
if (showNone || isCursorBad()) {
|
||||
return 0;
|
||||
} else {
|
||||
return cursor.getCount();
|
||||
|
@ -138,27 +138,24 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
return (footerViews.get(position - getStoryCount()).hashCode());
|
||||
}
|
||||
|
||||
if (cursor == null || cursor.isClosed() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) return 0;
|
||||
if (isCursorBad() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) return 0;
|
||||
cursor.moveToPosition(position);
|
||||
return cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_HASH)).hashCode();
|
||||
}
|
||||
|
||||
public synchronized boolean isCursorValid() {
|
||||
if (cursor == null) return true;
|
||||
if (cursor.isClosed()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized void swapCursor(Cursor c) {
|
||||
this.cursor = c;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public synchronized void setShowNone(boolean showNone) {
|
||||
this.showNone = showNone;
|
||||
private boolean isCursorBad() {
|
||||
if (cursor == null) return true;
|
||||
if (cursor.isClosed()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized Story getStory(int position) {
|
||||
if (cursor == null || cursor.isClosed() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) {
|
||||
if (isCursorBad() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) {
|
||||
return null;
|
||||
} else {
|
||||
cursor.moveToPosition(position);
|
||||
|
@ -283,7 +280,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
case R.id.menu_intel:
|
||||
if (story.feedId.equals("0")) return true; // cannot train on feedless stories
|
||||
StoryIntelTrainerFragment intelFrag = StoryIntelTrainerFragment.newInstance(story, fs);
|
||||
intelFrag.show(context.getFragmentManager(), StoryIntelTrainerFragment.class.getName());
|
||||
intelFrag.show(context.getSupportFragmentManager(), StoryIntelTrainerFragment.class.getName());
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -355,7 +352,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||
if (viewHolder instanceof StoryViewHolder) {
|
||||
StoryViewHolder vh = (StoryViewHolder) viewHolder;
|
||||
|
||||
if (cursor == null || cursor.isClosed() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) return;
|
||||
if (isCursorBad() || cursor.getColumnCount() == 0 || position >= cursor.getCount() || position < 0) return;
|
||||
cursor.moveToPosition(position);
|
||||
|
||||
Story story = Story.fromCursor(cursor);
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.newsblur.R;
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.HashSet;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import com.newsblur.R;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import java.util.Set;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -13,7 +13,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
public class DeleteFeedFragment extends DialogFragment {
|
||||
private static final String FEED_TYPE = "feed_type";
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
|
|
@ -6,9 +6,9 @@ import java.util.Map;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
|
|
@ -4,13 +4,13 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Loader;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
|
@ -38,6 +38,7 @@ import com.newsblur.activity.GlobalSharedStoriesItemsList;
|
|||
import com.newsblur.activity.InfrequentItemsList;
|
||||
import com.newsblur.activity.ItemsList;
|
||||
import com.newsblur.activity.Main;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.activity.ReadStoriesItemsList;
|
||||
import com.newsblur.activity.SavedStoriesItemsList;
|
||||
import com.newsblur.activity.SocialFeedItemsList;
|
||||
|
@ -374,7 +375,7 @@ public class FolderListFragment extends NbFragment implements OnCreateContextMen
|
|||
}
|
||||
|
||||
private void markFeedsAsRead(FeedSet fs) {
|
||||
FeedUtils.markRead(getActivity(), fs, null, null, R.array.mark_all_read_options, false);
|
||||
FeedUtils.markRead(((NbActivity) getActivity()), fs, null, null, R.array.mark_all_read_options, false);
|
||||
adapter.lastFeedViewedId = fs.getSingleFeed();
|
||||
adapter.lastFolderViewed = fs.getFolderName();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.ContextMenu;
|
||||
|
@ -35,6 +35,7 @@ import butterknife.Bind;
|
|||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.ItemsList;
|
||||
import com.newsblur.activity.NbActivity;
|
||||
import com.newsblur.database.StoryViewAdapter;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.service.NBSyncService;
|
||||
|
@ -53,7 +54,6 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
|
||||
public static int ITEMLIST_LOADER = 0x01;
|
||||
|
||||
protected ItemsList activity;
|
||||
protected boolean cursorSeenYet = false;
|
||||
private boolean stopLoading = false;
|
||||
|
||||
|
@ -89,18 +89,10 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
activity = (ItemsList) getActivity();
|
||||
|
||||
if (getFeedSet() == null) {
|
||||
com.newsblur.util.Log.w(this.getClass().getName(), "item list started without FeedSet.");
|
||||
activity.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
// warm up the sync service as soon as possible since it will init the story session DB
|
||||
triggerRefresh(1, null);
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,10 +113,6 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if (!adapter.isCursorValid()) {
|
||||
com.newsblur.util.Log.e(this.getClass().getName(), "stale fragment loaded, falling back.");
|
||||
getActivity().finish();
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
@ -134,7 +122,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
ButterKnife.bind(this, v);
|
||||
|
||||
// disable the throbbers if animations are going to have a zero time scale
|
||||
boolean isDisableAnimations = ViewUtils.isPowerSaveMode(activity);
|
||||
boolean isDisableAnimations = ViewUtils.isPowerSaveMode(getActivity());
|
||||
|
||||
topProgressView.setEnabled(!isDisableAnimations);
|
||||
topProgressView.setColors(UIUtils.getColor(getActivity(), R.color.refresh_1),
|
||||
|
@ -157,7 +145,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
@Override
|
||||
public void onGlobalLayout() {
|
||||
itemGridWidthPx = itemGrid.getMeasuredWidth();
|
||||
itemGrid.getViewTreeObserver().removeGlobalOnLayoutListener(this);
|
||||
itemGrid.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
updateStyle();
|
||||
}
|
||||
});
|
||||
|
@ -176,7 +164,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
}
|
||||
});
|
||||
|
||||
adapter = new StoryViewAdapter(getActivity(), getFeedSet(), listStyle);
|
||||
adapter = new StoryViewAdapter(((NbActivity) getActivity()), getFeedSet(), listStyle);
|
||||
adapter.addFooterView(footerView);
|
||||
adapter.addFooterView(fleuronFooter);
|
||||
itemGrid.setAdapter(adapter);
|
||||
|
@ -226,7 +214,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
* Indicate that the DB was cleared.
|
||||
*/
|
||||
public void resetEmptyState() {
|
||||
setShowNone(true);
|
||||
updateAdapter(null);
|
||||
cursorSeenYet = false;
|
||||
}
|
||||
|
||||
|
@ -266,7 +254,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
emptyViewText.setTypeface(null, Typeface.NORMAL);
|
||||
emptyViewImage.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (NBSyncService.isFeedSetSyncing(getFeedSet(), activity) || (!cursorSeenYet)) {
|
||||
if (NBSyncService.isFeedSetSyncing(getFeedSet(), getActivity()) || (!cursorSeenYet)) {
|
||||
emptyViewText.setText(R.string.empty_list_view_loading);
|
||||
emptyViewText.setTypeface(null, Typeface.ITALIC);
|
||||
emptyViewImage.setVisibility(View.INVISIBLE);
|
||||
|
@ -288,7 +276,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
}
|
||||
|
||||
protected FeedSet getFeedSet() {
|
||||
return activity.getFeedSet();
|
||||
return ((ItemsList) getActivity()).getFeedSet();
|
||||
}
|
||||
|
||||
public void hasUpdated() {
|
||||
|
@ -324,18 +312,17 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
if (! NBSyncService.isFeedSetReady(getFeedSet())) {
|
||||
// the DB hasn't caught up yet from the last story list; don't display stale stories.
|
||||
com.newsblur.util.Log.i(this.getClass().getName(), "stale load");
|
||||
setShowNone(true);
|
||||
setLoading(true);
|
||||
updateAdapter(null);
|
||||
triggerRefresh(1, null);
|
||||
} else {
|
||||
cursorSeenYet = true;
|
||||
com.newsblur.util.Log.d(this.getClass().getName(), "loaded cursor with count: " + cursor.getCount());
|
||||
updateAdapter(cursor);
|
||||
if (cursor.getCount() < 1) {
|
||||
triggerRefresh(1, 0);
|
||||
}
|
||||
setShowNone(false);
|
||||
}
|
||||
updateAdapter(cursor);
|
||||
}
|
||||
updateLoadingMessage();
|
||||
}
|
||||
|
@ -343,8 +330,7 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
protected void updateAdapter(Cursor cursor) {
|
||||
adapter.swapCursor(cursor);
|
||||
adapter.updateFeedSet(getFeedSet());
|
||||
adapter.notifyDataSetChanged();
|
||||
if (cursor.getCount() > 0) {
|
||||
if ((cursor != null) && (cursor.getCount() > 0)) {
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
emptyView.setVisibility(View.VISIBLE);
|
||||
|
@ -354,13 +340,8 @@ public class ItemSetFragment extends NbFragment implements LoaderManager.LoaderC
|
|||
ensureSufficientStories();
|
||||
}
|
||||
|
||||
protected void setShowNone(boolean showNone) {
|
||||
adapter.setShowNone(showNone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
;
|
||||
}
|
||||
|
||||
public void updateStyle() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
@ -3,11 +3,11 @@ package com.newsblur.fragment;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
|
|
@ -4,8 +4,8 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.newsblur.fragment;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import com.newsblur.service.NBSyncService;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -4,8 +4,8 @@ import android.content.Context;
|
|||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -7,7 +7,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
public class ReadingActionConfirmationFragment extends DialogFragment {
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.app.DialogFragment;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.newsblur.fragment;
|
|||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.app.Fragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
|
|
|
@ -10,8 +10,8 @@ import java.util.Set;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.app.AlertDialog;
|
|||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -5,9 +5,9 @@ import java.util.Map;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.newsblur.fragment;
|
|||
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.DialogFragment;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.newsblur.network;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.AsyncTaskLoader;
|
||||
import android.support.v4.content.AsyncTaskLoader;
|
||||
|
||||
import com.newsblur.domain.FeedResult;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Collections;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -184,7 +183,7 @@ public class FeedUtils {
|
|||
/**
|
||||
* Marks some or all of the stories in a FeedSet as read for an activity, handling confirmation dialogues as necessary.
|
||||
*/
|
||||
public static void markRead(Activity activity, FeedSet fs, Long olderThan, Long newerThan, int choicesRid, boolean finishAfter) {
|
||||
public static void markRead(NbActivity activity, FeedSet fs, Long olderThan, Long newerThan, int choicesRid, boolean finishAfter) {
|
||||
ReadingAction ra = null;
|
||||
if (fs.isAllNormal() && (olderThan != null || newerThan != null)) {
|
||||
// the mark-all-read API doesn't support range bounding, so we need to pass each and every
|
||||
|
@ -247,7 +246,7 @@ public class FeedUtils {
|
|||
title = FeedUtils.getFeed(fs.getSingleFeed()).title;
|
||||
}
|
||||
ReadingActionConfirmationFragment dialog = ReadingActionConfirmationFragment.newInstance(ra, title, optionalOverrideMessage, choicesRid, finishAfter);
|
||||
dialog.show(activity.getFragmentManager(), "dialog");
|
||||
dialog.show(activity.getSupportFragmentManager(), "dialog");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue