Giter Club home page Giter Club logo

Comments (9)

eRGoon avatar eRGoon commented on August 28, 2024

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);
        }

in ArticleDetailActivity:

        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.

davidedesio avatar davidedesio commented on August 28, 2024

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.

eRGoon avatar eRGoon commented on August 28, 2024

Hi BeDave,

are you sure about this? I cannot find such line in ArticleDetailFragment.

from androidrssreader.

davidedesio avatar davidedesio commented on August 28, 2024

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.

koesie10 avatar koesie10 commented on August 28, 2024

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.

bgupta55 avatar bgupta55 commented on August 28, 2024

@eRGoon Solution worked for me, Thank You !!

from androidrssreader.

randhika avatar randhika commented on August 28, 2024

not working buddy..

from androidrssreader.

andrejonn31 avatar andrejonn31 commented on August 28, 2024

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.

pengjfcn avatar pengjfcn commented on August 28, 2024

while after loading about 15sec , the app has stopped,why ?

from androidrssreader.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.