• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 package com.android.dreams.phototable;
17 
18 import android.content.SharedPreferences;
19 import android.app.ListActivity;
20 import android.os.AsyncTask;
21 import android.os.Bundle;
22 import android.widget.ListAdapter;
23 
24 import java.util.LinkedList;
25 
26 /**
27  * Settings panel for photo flipping dream.
28  */
29 public class PhotoTableDreamSettings extends ListActivity {
30     private static final String TAG = "PhotoTableDreamSettings";
31     public static final String PREFS_NAME = PhotoTableDream.TAG;
32 
33     private PhotoSourcePlexor mPhotoSource;
34     private ListAdapter mAdapter;
35     private SharedPreferences mSettings;
36 
37     @Override
onCreate(Bundle savedInstanceState)38     protected void onCreate(Bundle savedInstanceState){
39         super.onCreate(savedInstanceState);
40 
41         mSettings = getSharedPreferences(PREFS_NAME, 0);
42         mPhotoSource = new PhotoSourcePlexor(this, mSettings);
43         setContentView(R.layout.settingslist);
44 
45         new AsyncTask<Void, Void, Void>() {
46             @Override
47             public Void doInBackground(Void... unused) {
48                 mAdapter = new SectionedAlbumDataAdapter(PhotoTableDreamSettings.this,
49                         mSettings,
50                         R.layout.header,
51                         R.layout.album,
52                         new LinkedList<PhotoSource.AlbumData>(mPhotoSource.findAlbums()));
53                 return null;
54             }
55 
56            @Override
57            public void onPostExecute(Void unused) {
58                setListAdapter(mAdapter);
59            }
60         }.execute();
61     }
62 }
63