1 /* 2 * Copyright (C) 2013 Square, 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 package com.example.dagger.activitygraphs.ui; 17 18 import android.app.Activity; 19 import com.example.dagger.activitygraphs.PerActivity; 20 import javax.inject.Inject; 21 22 /** 23 * A simple abstraction which provides the ability to set the title on an activity. 24 * <p> 25 * Fragments should not directly modify any part of an activity outside of the view or dialog that 26 * it creates. This class provides a way for fragments to inject a controller that will allow for 27 * control of the activity title. While not exceedingly useful in practice, this concept could be 28 * expanded to things like facilitating control over the action bar, dialogs, notifications, etc. 29 */ 30 @PerActivity 31 public class ActivityTitleController { 32 private final Activity activity; 33 34 @Inject public ActivityTitleController(Activity activity) { 35 this.activity = activity; 36 } 37 38 public void setTitle(CharSequence title) { 39 activity.setTitle(title); 40 } 41 } 42