Comments (9)
I did the following:
In ArticleListActivity:
//load article details to main panel
Bundle arguments = new Bundle();
arguments.putSerializable (Article.KEY, selected);
if (mTwoPane) {
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
.replace(R.id.article_detail_container, fragment)
.commit();
} else {
Intent detailIntent = new Intent(this, ArticleDetailActivity.class);
detailIntent.putExtra("arguments", arguments);
startActivity(detailIntent);
}
if (savedInstanceState == null) {
Bundle arguments = getIntent().getBundleExtra("arguments");
ArticleDetailFragment fragment = new ArticleDetailFragment();
fragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction()
.add(R.id.article_detail_container, fragment)
.commit();
}
from androidrssreader.
Dear eRGoon,
your code create another issue in ArticleDetailFragment pointing out a NullPointerException on line:
ArticleListFragment fragment = (ArticleListFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.article_list);
Any idea to solve this?
from androidrssreader.
Hi BeDave,
are you sure about this? I cannot find such line in ArticleDetailFragment.
from androidrssreader.
Yep, i'm pretty sure about this.
Search for "onOptionsItemSelected(MenuItem item)" method and look in
"else if (id == R.id.actionbar_markunread)" statement.
It controls the behavior of mark as unread button in article detail
view.
from androidrssreader.
Indeed, the fragment cannot be found. If I just get the fragment it already returns null.
ArticleListFragment fragment = (ArticleListFragment) getActivity().getSupportFragmentManager().findFragmentById(R.id.article_list);
However, it only does so when running in a one pane layout. If you are on a tablet, it doesn't happen when you mark it as unread. Unfortunately, I've not been able to fix it, so my solution is removing the menu item on one-pane layouts using this:
In ArticleListActivity:
private static boolean mTwoPane; // change to static
public static boolean isTwoPane() {
return mTwoPane;
}
In ArticleDetailFragment:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.detailmenu, menu);
if (!ArticleListActivity.isTwoPane()) { // add this
menu.removeItem(R.id.actionbar_markunread);
}
}
// if you want extra security
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.actionbar_saveoffline) {
Toast.makeText(getActivity().getApplicationContext(),
R.string.saved_for_offline, Toast.LENGTH_LONG).show();
return true;
} else if (id == R.id.actionbar_markunread) {
db.openToWrite();
db.markAsUnread(displayedArticle.getGuid());
db.close();
displayedArticle.setRead(false);
try {
ArticleListAdapter adapter = (ArticleListAdapter) ((ArticleListFragment) getActivity()
.getSupportFragmentManager().findFragmentById(
R.id.article_list)).getListAdapter();
adapter.notifyDataSetChanged();
} catch (NullPointerException e) {
}
return true;
} else {
return super.onOptionsItemSelected(item);
}
}
from androidrssreader.
@eRGoon Solution worked for me, Thank You !!
from androidrssreader.
not working buddy..
from androidrssreader.
As for me, i didnt get any feeds in the list view at all even after leaving it for a few minutes. i have used the rss feeds of NYT, http://rss.nytimes.com/services/xml/rss/nyt/World.xml, Aljazeera: http://www.aljazeera.com/xml/rss/all.xml, still the samething. i am stuck here
from androidrssreader.
while after loading about 15sec , the app has stopped,why ?
from androidrssreader.
Related Issues (8)
- RssService Error HOT 11
- error HOT 8
- Article content empty in phones. HOT 2
- errors..
- ArticleListActivity error HOT 1
- Rss Feed not showing HOT 5
- Unable to instantiate activity component info HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidrssreader.