mobisocial.bento.ebento.ui.PeopleListActivity.java Source code

Java tutorial

Introduction

Here is the source code for mobisocial.bento.ebento.ui.PeopleListActivity.java

Source

/*
 * Copyright (C) 2012 Kazuya (Kaz) Yokoyama <kazuya.yokoyama@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package mobisocial.bento.ebento.ui;

import mobisocial.bento.ebento.io.EventManager;
import mobisocial.bento.ebento.io.EventManager.OnStateUpdatedListener;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ActionBar;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MenuItem;

import mobisocial.bento.ebento.R;

public class PeopleListActivity extends FragmentActivity {
    //private static final String TAG = "PeopleListActivity";

    private EventManager mManager = EventManager.getInstance();
    private PeopleListFragment mPeopleListFragment;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_people_list);

        final ActionBar actionBar = getSupportActionBar();
        // set defaults for logo & home up
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);

        FragmentManager fm = getSupportFragmentManager();
        mPeopleListFragment = (PeopleListFragment) fm.findFragmentById(R.id.fragment_people_list);
        mManager.addListener(mStateUpdatedListener);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mManager.removeListener(mStateUpdatedListener);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            finish();
            return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    }

    // EventManager > OnStateUpdatedListener
    private OnStateUpdatedListener mStateUpdatedListener = new OnStateUpdatedListener() {
        @Override
        public void onStateUpdated() {
            mPeopleListFragment.refreshView();
        }
    };
}