DetailsNormal.java revision 21143c86b2764adf18bb502adf32d536dcb18ae5
1/*
2 * Copyright (C) 2010 Google Inc.
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.loaderapp;
18
19import com.android.loaderapp.model.ContactLoader;
20import com.android.loaderapp.model.ContactLoader.ContactData;
21
22import android.app.patterns.Loader;
23import android.app.patterns.LoaderActivity;
24import android.net.Uri;
25import android.os.Bundle;
26
27public class DetailsNormal extends LoaderActivity<ContactData> {
28    static final int LOADER_DETAILS = 1;
29
30    ContactDetailsView mDetails;
31    Uri mUri;
32
33    @Override
34    public void onCreate(Bundle savedState) {
35        super.onCreate(savedState);
36
37        setContentView(R.layout.contact_details);
38        mDetails = (ContactDetailsView) findViewById(R.id.contact_details);
39        mDetails.setCallbacks(new ContactDetailsView.DefaultCallbacks(this));
40
41        mUri = getIntent().getData();
42    }
43
44    @Override
45    public void onInitializeLoaders() {
46        Bundle args = new Bundle();
47        args.putParcelable("uri", getIntent().getData());
48        startLoading(LOADER_DETAILS, args);
49    }
50
51    @Override
52    protected Loader onCreateLoader(int id, Bundle args) {
53        switch (id) {
54            case LOADER_DETAILS: {
55                Uri uri = args.getParcelable("uri");
56                return new ContactLoader(this, uri);
57            }
58        }
59        return null;
60    }
61
62    @Override
63    public void onLoadComplete(Loader loader, ContactData data) {
64        switch (loader.getId()) {
65            case LOADER_DETAILS:
66                mDetails.setData(data);
67                break;
68        }
69    }
70}
71