• 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.view.View;
23 import android.widget.ListAdapter;
24 
25 import java.util.LinkedList;
26 
27 /**
28  * Settings panel for photo flipping dream.
29  */
30 public class FlipperDreamSettings extends ListActivity {
31     private static final String TAG = "FlipperDreamSettings";
32     public static final String PREFS_NAME = FlipperDream.TAG;
33 
34     private PhotoSourcePlexor mPhotoSource;
35     private ListAdapter mAdapter;
36     private SharedPreferences mSettings;
37 
38     @Override
onCreate(Bundle savedInstanceState)39     protected void onCreate(Bundle savedInstanceState){
40         super.onCreate(savedInstanceState);
41 
42         mSettings = getSharedPreferences(PREFS_NAME, 0);
43         mPhotoSource = new PhotoSourcePlexor(this, mSettings);
44         setContentView(R.layout.settingslist);
45 
46         new AsyncTask<Void, Void, Void>() {
47             @Override
48             public Void doInBackground(Void... unused) {
49                 mAdapter = new SectionedAlbumDataAdapter(FlipperDreamSettings.this,
50                         mSettings,
51                         R.layout.header,
52                         R.layout.album,
53                         new LinkedList<PhotoSource.AlbumData>(mPhotoSource.findAlbums()));
54                 return null;
55             }
56 
57            @Override
58            public void onPostExecute(Void unused) {
59                setListAdapter(mAdapter);
60                if (mAdapter.getCount() == 0) {
61                    findViewById(android.R.id.empty).setVisibility(View.GONE);
62                }
63            }
64         }.execute();
65     }
66 }
67