DetailsNormal.java revision 2aee0983597c8b0e65766c4b278d4b1c7d13605f
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 startLoading(LOADER_DETAILS, null); 47 } 48 49 @Override 50 protected Loader onCreateLoader(int id, Bundle args) { 51 switch (id) { 52 case LOADER_DETAILS: { 53 Uri uri = args.getParcelable("uri"); 54 return new ContactLoader(this, uri); 55 } 56 } 57 return null; 58 } 59 60 @Override 61 public void onLoadComplete(int id, ContactData data) { 62 switch (id) { 63 case LOADER_DETAILS: 64 mDetails.setData(data); 65 break; 66 } 67 } 68} 69