• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.settings.fuelgauge;
18 
19 import android.app.Fragment;
20 import android.os.Bundle;
21 import android.os.Parcel;
22 import android.view.LayoutInflater;
23 import android.view.View;
24 import android.view.ViewGroup;
25 
26 import com.android.internal.os.BatteryStatsImpl;
27 import com.android.settings.R;
28 
29 public class BatteryHistoryDetail extends Fragment {
30     public static final String EXTRA_STATS = "stats";
31 
32     private BatteryStatsImpl mStats;
33 
34     @Override
onCreate(Bundle icicle)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
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)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