Home | History | Annotate | Download | only in ui
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *        http://www.apache.org/licenses/LICENSE-2.0
      9  * Unless required by applicable law or agreed to in writing, software
     10  * distributed under the License is distributed on an "AS IS" BASIS,
     11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12  * See the License for the specific language governing permissions and limitations under the
     13  * License.
     14  *
     15  */
     16 
     17 package com.android.benchmark.ui;
     18 
     19 import android.app.ActionBar;
     20 import android.os.Bundle;
     21 import android.support.v4.app.FragmentManager;
     22 import android.support.v4.app.ListFragment;
     23 import android.support.v7.app.AppCompatActivity;
     24 import android.view.Window;
     25 import android.widget.ListAdapter;
     26 
     27 import com.android.benchmark.R;
     28 
     29 /**
     30  * Simple list activity base class
     31  */
     32 public abstract class ListActivityBase extends AppCompatActivity {
     33 
     34     @Override
     35     public void onCreate(Bundle savedInstanceState) {
     36         super.onCreate(savedInstanceState);
     37         setContentView(R.layout.activity_list_fragment);
     38 
     39         ActionBar actionBar = getActionBar();
     40         if (actionBar != null) {
     41             actionBar.setTitle(getName());
     42         }
     43 
     44         if (findViewById(R.id.list_fragment_container) != null) {
     45             FragmentManager fm = getSupportFragmentManager();
     46             ListFragment listView = new ListFragment();
     47             listView.setListAdapter(createListAdapter());
     48             fm.beginTransaction().add(R.id.list_fragment_container, listView).commit();
     49         }
     50     }
     51 
     52     protected abstract ListAdapter createListAdapter();
     53     protected abstract String getName();
     54 }
     55 
     56