DetailsNormal.java revision bc6f8fde3cfe4098c2c51a91f4b90522813c3f2b
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 ContactCoupler mCoupler; 31 Uri mUri; 32 33 @Override 34 public void onCreate(Bundle savedState) { 35 super.onCreate(savedState); 36 37 setContentView(R.layout.contact_details); 38 mCoupler = new ContactCoupler(this, findViewById(R.id.contact_details)); 39 mCoupler.setController(new ContactCoupler.DefaultController(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 mCoupler.setData(data); 67 break; 68 } 69 } 70} 71