1/*
2 * Copyright (C) 2009 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 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settings.fuelgauge;
18
19import android.app.Fragment;
20import android.os.Bundle;
21import android.os.Parcel;
22import android.view.LayoutInflater;
23import android.view.View;
24import android.view.ViewGroup;
25
26import com.android.internal.os.BatteryStatsImpl;
27import com.android.settings.R;
28
29public class BatteryHistoryDetail extends Fragment {
30    public static final String EXTRA_STATS = "stats";
31
32    private BatteryStatsImpl mStats;
33
34    @Override
35    public void onCreate(Bundle icicle) {
36        super.onCreate(icicle);
37        byte[] data = getArguments().getByteArray(EXTRA_STATS);
38        Parcel parcel = Parcel.obtain();
39        parcel.unmarshall(data, 0, data.length);
40        parcel.setDataPosition(0);
41        mStats = com.android.internal.os.BatteryStatsImpl.CREATOR
42                .createFromParcel(parcel);
43    }
44
45    @Override
46    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
47        View view = inflater.inflate(R.layout.preference_batteryhistory, null);
48        BatteryHistoryChart chart = (BatteryHistoryChart)view.findViewById(
49                R.id.battery_history_chart);
50        chart.setStats(mStats);
51        return view;
52    }
53}
54