Search in sources :

Example 1 with NewsListFragment

use of io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment in project ZhihuDailyPurify by izzyleung.

the class SingleDayNewsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getIntent().getExtras();
    Fragment newFragment = new NewsListFragment();
    String dateString = bundle.getString(Constants.BundleKeys.DATE);
    Calendar calendar = Calendar.getInstance();
    try {
        Date date = Constants.Dates.simpleDateFormat.parse(dateString);
        calendar.setTime(date);
        calendar.add(Calendar.DAY_OF_YEAR, -1);
    } catch (ParseException ignored) {
    }
    //noinspection ConstantConditions
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(DateFormat.getDateInstance().format(calendar.getTime()));
    bundle.putString(Constants.BundleKeys.DATE, dateString);
    bundle.putBoolean(Constants.BundleKeys.IS_FIRST_PAGE, isSameDay(calendar, Calendar.getInstance()));
    bundle.putBoolean(Constants.BundleKeys.IS_SINGLE, true);
    newFragment.setArguments(bundle);
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_frame, newFragment).commit();
}
Also used : Bundle(android.os.Bundle) Calendar(java.util.Calendar) ParseException(java.text.ParseException) NewsListFragment(io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment) Fragment(android.support.v4.app.Fragment) Date(java.util.Date) NewsListFragment(io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment)

Aggregations

Bundle (android.os.Bundle)1 Fragment (android.support.v4.app.Fragment)1 NewsListFragment (io.github.izzyleung.zhihudailypurify.ui.fragment.NewsListFragment)1 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1