Java Code Examples for android.app.Activity#setTitle()

The following examples show how to use android.app.Activity#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CareListBehaviorFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override public void onResume() {
    super.onResume();

    Activity activity = getActivity();
    String title = getTitle();
    if (activity != null && !TextUtils.isEmpty(title)) {
        activity.setTitle(title);
        activity.invalidateOptionsMenu();

        ImageManager.with(activity).setWallpaper(Wallpaper.ofCurrentPlace().lightend());
    }

    showProgressBar();
    listener = CareBehaviorTemplateListController.instance().setCallback(this);
    CareBehaviorTemplateListController.instance().listBehaviorTemplates();
}
 
Example 2
Source File: PluginActivityControl.java    From Neptune with Apache License 2.0 6 votes vote down vote up
/**
 * 设置更新Activity的标题
 */
private static void setActivityTitle(Activity activity, ActivityInfo actInfo) {
    if (actInfo.nonLocalizedLabel != null) {
        activity.setTitle(actInfo.nonLocalizedLabel);
    } else if (actInfo.labelRes != 0) {
        activity.setTitle(actInfo.labelRes);
    } else if (actInfo.applicationInfo != null) {
        if (actInfo.applicationInfo.nonLocalizedLabel != null) {
            activity.setTitle(actInfo.applicationInfo.nonLocalizedLabel);
        } else if (actInfo.applicationInfo.labelRes != 0) {
            activity.setTitle(actInfo.applicationInfo.labelRes);
        } else {
            activity.setTitle(actInfo.applicationInfo.name);
        }
    } else {
        activity.setTitle(actInfo.name);
    }
}
 
Example 3
Source File: PlaceServicePlanFragment.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    title.setVisibility(View.INVISIBLE);
    getController().getPrimaryPlaceServiceLevel(this);

    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            goNext();
        }
    });

    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }
}
 
Example 4
Source File: BreadcrumbBarFragment.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
private void attachBreadcrumbBar(Activity activity, ActionBar actionBar) {
    //make sure we're in the right mode
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    //We need to get the amount that each item should "bleed" over to the left, and move the whole widget that
    //many pixels. This replicates the "overlap" space that each piece of the bar has on the next piece for
    //the left-most element.
    int buffer = Math.round(activity.getResources().getDimension(R.dimen.title_round_bleed));
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    p.leftMargin = buffer;

    activity.setTitle("");
    actionBar.setDisplayShowHomeEnabled(false);
}
 
Example 5
Source File: CareAddEditBehaviorFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
protected void setActivityName(String name) {
    hideProgressBar();
    Activity activity = getActivity();
    if (activity != null) {
        if (!TextUtils.isEmpty(name)) {
            if (name.length() > MAX_LENGTH_NAME) {
                name = String.format("%s...", name.substring(0, MAX_LENGTH_NAME - 1));
            }
        }
        activity.setTitle(name);
        activity.invalidateOptionsMenu();
    }
}
 
Example 6
Source File: PlaceCongratsFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();

    message.setText(String.format(getString(R.string.place_congrats_message_title), getController().getNewPlaceNickname()));

    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }
}
 
Example 7
Source File: Sampler2dPropertiesFragment.java    From ShaderEditor with MIT License 5 votes vote down vote up
@Override
public View onCreateView(
		LayoutInflater inflater,
		ViewGroup container,
		Bundle state) {
	Activity activity = getActivity();
	activity.setTitle(R.string.texture_properties);

	Bundle args;
	View view;

	if ((args = getArguments()) == null ||
			(imageUri = args.getParcelable(
					IMAGE_URI)) == null ||
			(cropRect = args.getParcelable(
					CROP_RECT)) == null ||
			(view = initView(
					activity,
					inflater,
					container)) == null) {
		activity.finish();
		return null;
	}

	imageRotation = args.getFloat(ROTATION);

	return view;
}
 
Example 8
Source File: CareBehaviorNameEditorFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override public void editTemplate(final CareBehaviorModel editingModel, final CareBehaviorTemplateModel templateModel) {
    String title = editingModel.getName();
    if (TextUtils.isEmpty(title)) {
        title = StringUtils.EMPTY_STRING;
    }

    careBehaviorName.setText(title);
    Activity activity = getActivity();
    if (activity != null) {
        activity.invalidateOptionsMenu();
        if (title.length() > MAX_LENGTH_NAME) {
            title = String.format("%s...", title.substring(0, MAX_LENGTH_NAME - 1));
        }
        activity.setTitle(title);
    }

    careBehaviorSaveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!TextUtils.isEmpty(careBehaviorName.getText())) {
                editingModel.setName(careBehaviorName.getText().toString());
                BackstackManager.getInstance().navigateBack();
            }
            else {
                careBehaviorName.setError(getString(R.string.care_behavior_edit_name_error, careBehaviorName.getHint()));
            }
        }
    });
}
 
Example 9
Source File: WeatherAlertCategorySelection.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume () {
    super.onResume();
    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }
}
 
Example 10
Source File: HaloTestDeviceFragment.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
@Override
public void onResume () {
    super.onResume();
    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }
}
 
Example 11
Source File: CategoriesFragment.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    activity.setTitle(R.string.title_categories);
}
 
Example 12
Source File: TextureParametersFragment.java    From ShaderEditor with MIT License 4 votes vote down vote up
@Override
public View onCreateView(
		LayoutInflater inflater,
		ViewGroup container,
		Bundle state) {
	Activity activity = getActivity();
	activity.setTitle(R.string.texture_parameters);

	Bundle args = getArguments();
	if (args == null ||
			(samplerType = args.getString(TYPE)) == null ||
			(textureName = args.getString(NAME)) == null) {
		throw new IllegalArgumentException(
				"Missing type and name arguments");
	}

	isBackBuffer = ShaderRenderer.UNIFORM_BACKBUFFER.equals(textureName);

	int layout;
	if (isBackBuffer) {
		textureParameters = new BackBufferParameters();
		layout = R.layout.fragment_backbuffer_parameters;
	} else {
		textureParameters = new TextureParameters();
		layout = R.layout.fragment_texture_parameters;
	}

	View view = inflater.inflate(layout, container, false);

	textureParameterView = view.findViewById(R.id.texture_parameters);
	textureParameterView.setDefaults(textureParameters);

	if (isBackBuffer) {
		backBufferParametersView = view.findViewById(
				R.id.backbuffer_parameters);
	}

	view.findViewById(R.id.insert_code).setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			insertUniform();
		}
	});

	return view;
}
 
Example 13
Source File: Api8Adapter.java    From mytracks with Apache License 2.0 4 votes vote down vote up
@Override
public void setTitleAndSubtitle(Activity activity, String title, String subtitle) {
  activity.setTitle(title + " " + subtitle);
}
 
Example 14
Source File: HaloRoomFragment.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Override
public void onResume () {
    super.onResume();

    frag = this;

    nextButton.setColorScheme(isEditMode() ? Version1ButtonColor.WHITE : Version1ButtonColor.BLACK);
    listTitle.setTextColor(isEditMode() ? Color.WHITE : Color.BLACK);
    listSubTitle.setTextColor(isEditMode() ? Color.WHITE : Color.BLACK);
    nextButton.setText(isEditMode() ? getString(R.string.save_text) : getString(R.string.pairing_next));
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(adapter.getSelectedItem() == -1) {
                AlertPopup alertPopup = AlertPopup.newInstance(
                        getString(R.string.halo_post_pairing_room_error_title),
                        getString(R.string.halo_post_pairing_room_error_body),
                        null,
                        null,
                        new AlertPopup.AlertButtonCallback() {
                            @Override public boolean topAlertButtonClicked() { return false; }
                            @Override public boolean bottomAlertButtonClicked() { return false; }
                            @Override public boolean errorButtonClicked() { return false; }

                            @Override public void close() {
                                BackstackManager.getInstance().navigateBack();
                            }
                        }
                );
                alertPopup.setCloseButtonVisible(true);
                BackstackManager.getInstance().navigateToFloatingFragment(alertPopup, alertPopup.getClass().getCanonicalName(), true);
                return;
            }
        }
    });

    String deviceAddress = getArguments().getString(DEVICE_ADDRESS);

    haloController = new HaloController(
            DeviceModelProvider.instance().getModel(deviceAddress == null ? "DRIV:dev:" : deviceAddress),
            CorneaClientFactory.getClient(),
            null
    );
    haloController.setCallback(this);

    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }

}
 
Example 15
Source File: NamesFragment.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 4 votes vote down vote up
private void updateActivityTitle() {
    Activity activity = getActivity();
    if (names != -1 && activity != null && isVisible())
        activity.setTitle(getString(R.string.playersLabel) + " (" + names + ") - " + getString(R.string.app_name));
}
 
Example 16
Source File: CropImageFragment.java    From ShaderEditor with MIT License 4 votes vote down vote up
@Override
public View onCreateView(
		LayoutInflater inflater,
		ViewGroup container,
		Bundle state) {
	Activity activity = getActivity();
	activity.setTitle(R.string.crop_image);

	try {
		cropImageView = ((CropImageViewProvider) activity)
				.getCropImageView();
	} catch (ClassCastException e) {
		throw new ClassCastException(activity.toString() +
				" must implement " +
				"CropImageFragment.CropImageViewProvider");
	}

	Bundle args = getArguments();
	if (args == null ||
			(imageUri = args.getParcelable(IMAGE_URI)) == null) {
		abort(activity);
		return null;
	}

	View view = inflater.inflate(
			R.layout.fragment_crop_image,
			container,
			false);
	progressView = view.findViewById(R.id.progress_view);

	// make cropImageView in activity visible (again)
	cropImageView.setVisibility(View.VISIBLE);

	view.findViewById(R.id.crop).setOnClickListener(new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			cropImage();
		}
	});

	return view;
}
 
Example 17
Source File: CareStatusFragment.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Override public void showAlerting(CareStatus careStatus) {
    hideProgressBar();
    if(adapter == null) {
        adapter = new SecurityFragmentRecyclerAdapter(new ArrayList<SimpleDividerCard>());
    }
    adapter.removeAll();
    isAlert = true;
    logger.debug("Should show {}", careStatus);
    AlertTrigger trigger = careStatus.getAlertTriggeredBy();
    if (trigger == null) {
        return;
    }
    if (!isClosed) { // Currently being viewed.
        hideTabs();
    }

    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getString(R.string.care_alarm_triggered));
        activity.invalidateOptionsMenu();
    }
    mListView.setBackgroundColor(Color.WHITE);
    mTopCard.setAlarmState(AlarmTopCard.AlarmState.ALERT);
    mTopCard.setCenterTopText(getStringSpan(trigger.getTriggerDescription().toUpperCase()));
    mTopCard.setDeviceImage(getImageRes(trigger.getTriggerType()));
    mTopCard.setAlarmType(AlarmTopCard.AlarmType.CARE);

    mStatusCard.setAlarmState(AlarmStatusCard.AlarmState.ALERT);
    mStatusCard.setSinceDate(trigger.getTriggerTime());
    mStatusCard.setAlarmType(AlarmStatusCard.AlarmType.CARE);
    mStatusCard.setLeftButtonListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CareStatusController.instance().disarm();
        }
    });

    adapter.add(mTopCard);
    adapter.add(mStatusCard);

    List<AlertTrigger> allTriggers = careStatus.getAllAlertTriggers();
    if (allTriggers == null || allTriggers.isEmpty()) {
        return;
    }

    SimpleDateFormat sdf = new SimpleDateFormat("h:mm a", Locale.getDefault());
    Iterator<AlertTrigger> triggerIterator = allTriggers.iterator();
    int i = 0;
    while (triggerIterator.hasNext()) {
        AlertTrigger currentTrigger = triggerIterator.next();
        if(i!=0){
            mAlarmActiveCard.showDivider();
        }
        mAlarmActiveCard = new AlarmActiveCard(getActivity());
        mAlarmActiveCard.setImageResource(getImageRes(currentTrigger.getTriggerType()));
        mAlarmActiveCard.setTitle(currentTrigger.getTriggerTitle());
        mAlarmActiveCard.setDescription(currentTrigger.getTriggerDescription());
        mAlarmActiveCard.setAlertTime(sdf.format(currentTrigger.getTriggerTime()));
        mAlarmActiveCard.setIconRes(getImageRes(currentTrigger.getTriggerType()));
        adapter.add(mAlarmActiveCard);
        i++;
    }

    mListView.setAdapter(adapter);
    adapter.notifyDataSetChanged();
}
 
Example 18
Source File: PluginInjector.java    From PluginLoader with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
static void injectActivityContext(Activity activity) {
	Intent intent = activity.getIntent();
	FragmentContainer fragmentContainer = AnnotationProcessor.getFragmentContainer(activity.getClass());
	// 如果是打开插件中的activity, 或者是打开的用来显示插件fragment的宿主activity
	if (fragmentContainer != null || (intent.getComponent() != null
			&& (intent.getComponent().getClassName().startsWith(PluginStubBinding.STUB_ACTIVITY_PRE)))) {
		// 为了不需要重写插件Activity的attachBaseContext方法为:
		// 我们在activityoncreate之前去完成attachBaseContext的事情

		Context pluginContext = null;
		PluginDescriptor pd = null;

		//是打开的用来显示插件fragment的宿主activity
		if (fragmentContainer != null) {
			// 为了能够在宿主中的Activiy里面展示来自插件的普通Fragment,
			// 我们将宿主程序中用来展示插件普通Fragment的Activity的Context也替换掉

			if (!TextUtils.isEmpty(fragmentContainer.pluginId())) {

				pd = PluginLoader.getPluginDescriptorByPluginId(fragmentContainer.pluginId());
				pluginContext = PluginLoader.getNewPluginComponentContext(pd.getPluginContext(), activity.getBaseContext());

			} else if (!TextUtils.isEmpty(fragmentContainer.fragmentId())) {
				String classId = null;
				try {
					classId = activity.getIntent().getStringExtra(fragmentContainer.fragmentId());
				} catch (Exception e) {
					PaLog.printException("这里的Intent如果包含来自插件的VO对象实例," +
							"会产生ClassNotFound异常", e);
				}
				if (classId != null) {
					@SuppressWarnings("rawtypes")
					Class clazz = PluginLoader.loadPluginFragmentClassById(classId);

					pd = PluginLoader.getPluginDescriptorByClassName(clazz.getName());
					pluginContext = PluginLoader.getNewPluginComponentContext(pd.getPluginContext(), activity.getBaseContext());

				} else {
					return;
				}
			} else {
				PaLog.e("FragmentContainer注解至少配置一个参数:pluginId, fragmentId");
				return;
			}

		} else {

			//是打开插件中的activity
			pd = PluginLoader.getPluginDescriptorByClassName(activity.getClass().getName());
			pluginContext = PluginLoader.getNewPluginContext(activity.getClass());

		}

		PluginActivityInfo pluginActivityInfo = pd.getActivityInfos().get(activity.getClass().getName());
		ActivityInfo activityInfo = (ActivityInfo) RefInvoker.getFieldObject(activity, Activity.class.getName(),
				android_app_Activity_mActivityInfo);
		int pluginAppTheme = getPluginTheme(activityInfo, pluginActivityInfo, pd);

		resetActivityContext(pluginContext, activity, pluginAppTheme);

		resetWindowConfig(pluginContext, pd, activity, activityInfo, pluginActivityInfo);

		activity.setTitle(activity.getClass().getName());

	} else {
		// 如果是打开宿主程序的activity,注入一个无害的Context,用来在宿主程序中startService和sendBroadcast时检查打开的对象是否是插件中的对象
		// 插入Context
		Context mainContext = new PluginBaseContextWrapper(activity.getBaseContext());
		RefInvoker.setFieldObject(activity, ContextWrapper.class.getName(), android_content_ContextWrapper_mBase, null);
		RefInvoker.invokeMethod(activity, ContextThemeWrapper.class.getName(), android_content_ContextThemeWrapper_attachBaseContext,
				new Class[]{Context.class}, new Object[]{mainContext});
	}
}
 
Example 19
Source File: BaseFragment.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected void setParentActivityTitle(CharSequence title) {
    Activity activity = getParentActivity();
    if (activity != null) {
        activity.setTitle(title);
    }
}
 
Example 20
Source File: HaloStationSelectionFragment.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@Override
public void onResume () {
    super.onResume();

    String deviceAddress = getArguments().getString(DEVICE_ADDRESS);

    setListViewEnabled(true);
    if (nextButton != null) {
        nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BackstackManager.getInstance().navigateBack();
            }
        });
    }

    if(rescanButton != null) {
        rescanButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showProgressBar();
                haloController.getStationList(loadStationList, failureListener);
            }
        });
    }

    if(stations != null) {
        stations.clear();
        stations = null;
    }

    haloController = new HaloController(
            DeviceModelProvider.instance().getModel(deviceAddress == null ? "DRIV:dev:" : deviceAddress),
            CorneaClientFactory.getClient(),
            UPDATE_ON
    );
    haloController.setCallback(this);

    Activity activity = getActivity();
    if (activity != null) {
        activity.setTitle(getTitle());
    }

}