Ejemplo n.º 1
0
 @Override
 protected void onDestroy() {
   realmDBManager.close();
   if (EventBus.getDefault().isRegistered(this)) EventBus.getDefault().unregister(this);
   Runtime.getRuntime().gc();
   super.onDestroy();
 }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_matchday_detail);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new MatchdayPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    // By using this method the tabs will be populated according to viewPager's count and
    // with the name from the pagerAdapter getPageTitle()
    tabLayout.setTabsFromPagerAdapter(mSectionsPagerAdapter);
    tabLayout.setupWithViewPager(mViewPager);
    realmDBManager = new ZappRealmDBManager();

    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            createMatchday();
          }
        });

    RealmResults<Matchday> list = realmDBManager.list_all_matchdays();

    setMatchday(new Matchday());
    DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
    String date = df.format(Calendar.getInstance().getTime());
    getMatchday().setDatum(date);

    EventBus.getDefault().register(this);
  }
Ejemplo n.º 3
0
 @Override
 public int getCount() {
   return realmDBManager.list_all_members().size();
 }
Ejemplo n.º 4
0
 public MatchdayPagerAdapter(FragmentManager fm) {
   super(fm);
   //            dbManager = ZappDBManager.getInstance();
   realmDBManager = new ZappRealmDBManager();
   memberlist = realmDBManager.list_all_members();
 }
Ejemplo n.º 5
0
 @Override
 public boolean onNavigateUp() {
   realmDBManager.close();
   Runtime.getRuntime().gc();
   return super.onNavigateUp();
 }
Ejemplo n.º 6
0
 private void createMatchday() {
   realmDBManager.insertRealmObject(getMatchday());
   EventBus.getDefault().post(new SaveEvent());
 }