本文整理匯總了Java中android.transition.TransitionInflater.from方法的典型用法代碼示例。如果您正苦於以下問題:Java TransitionInflater.from方法的具體用法?Java TransitionInflater.from怎麽用?Java TransitionInflater.from使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.transition.TransitionInflater
的用法示例。
在下文中一共展示了TransitionInflater.from方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayDetails
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@Override
public void displayDetails(AnnouncementItem announcementItem) {
FullAnnouncement announcement = announcementItem.getAnnouncement();
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
AnnouncementDetailsFragment announcementDetailsFragment = AnnouncementDetailsFragment.newInstance(announcement);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
TransitionInflater transitionInflater = null;
transitionInflater = TransitionInflater.from(getContext());
Transition details_enter = transitionInflater.inflateTransition(R.transition.details_enter);
Transition details_exit = transitionInflater.inflateTransition(R.transition.details_exit);
setSharedElementEnterTransition(details_enter);
setSharedElementReturnTransition(details_exit);
setExitTransition(new Fade());
announcementDetailsFragment.setSharedElementEnterTransition(details_enter);
announcementDetailsFragment.setSharedElementReturnTransition(details_exit);
ft.addSharedElement(announcementItem.getBackgroundView(), announcementItem.getBackgroundView().getTransitionName());
}
ft.replace(R.id.content_main, announcementDetailsFragment, "Announcement details transition");
ft.addToBackStack(null);
ft.commitAllowingStateLoss();
}
示例2: onActivityCreated
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Transitionsを生成
TransitionInflater ti = TransitionInflater.from(getActivity());
// 指定されたタイプの Transitions を設定
int viewId = getArguments().getInt(EXTRA_TRANSITIONS_TYPE_VIEW_ID);
if (viewId == R.id.btn_add_fragment_explode) {
setEnterTransition(ti.inflateTransition(android.R.transition.explode));
setExitTransition(ti.inflateTransition(android.R.transition.explode));
} else if (viewId == R.id.btn_add_fragment_fade) {
setEnterTransition(ti.inflateTransition(android.R.transition.fade));
setExitTransition(ti.inflateTransition(android.R.transition.fade));
} else if (viewId == R.id.btn_add_fragment_slide) {
setEnterTransition(ti.inflateTransition(android.R.transition.slide_left));
setExitTransition(ti.inflateTransition(android.R.transition.slide_right));
} else {
// "NONE"押下時。この場合何もセットしない
}
}
示例3: onCreate
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transition);
mSceneRoot = (ViewGroup) findViewById(R.id.sceneRoot);
TransitionInflater inflater = TransitionInflater.from(this);
// Note that this is not the only way to create a Scene object, but that
// loading them from layout resources cooperates with the
// TransitionManager that we are also loading from resources, and which
// uses the same layout resource files to determine the scenes to transition
// from/to.
mScene1 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene1, this);
mScene2 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene2, this);
mScene3 = Scene.getSceneForLayout(mSceneRoot, R.layout.transition_scene3, this);
mTransitionManager = inflater.inflateTransitionManager(R.transition.transitions_mgr,
mSceneRoot);
}
示例4: initPushInAnim
import android.transition.TransitionInflater; //導入方法依賴的package包/類
private void initPushInAnim() {
Window window = getWindow();
window.requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
TransitionInflater inflater = TransitionInflater.from(mContext);
Transition pushDownIn = inflater.inflateTransition(R.transition.explode_in);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setEnterTransition(pushDownIn); // 第一次進入時使用
window.setReenterTransition(pushDownIn); // 再次進入時使用
window.setExitTransition(pushDownIn);
}
}
示例5: onCreate
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21) {
TransitionInflater inflater = TransitionInflater.from(this);
Transition transition = inflater.inflateTransition(R.transition.details_window_return_transition);
getWindow().setExitTransition(transition);
}
// setUpWindowAnimations();
setContentView(R.layout.activity_article_detail);
if (savedInstanceState == null) {
// Create the detail fragment and add it to the activity
// using a fragment transaction.
Bundle extras = getIntent().getExtras();
DetailsFragment fragment = new DetailsFragment();
extras.putBoolean(DetailsFragment.DETAIL_TRANSITION_ANIMATION, true);
fragment.setArguments(extras);
getSupportFragmentManager().beginTransaction()
.add(R.id.container, fragment)
.commit();
// Being here means we are in animation mode
supportPostponeEnterTransition();
}
}
示例6: newInstance
import android.transition.TransitionInflater; //導入方法依賴的package包/類
/**
* Create a new instance with details for a given {@link Gallery}.
*
* @param context The context this runs in.
* @param gallery The gallery of which the details should be displayed.
* @return A newly instantiated fragment.
*/
public static DetailFragment newInstance(@NonNull Context context, @NonNull Gallery gallery,
@NonNull CameraPosition cameraPosition) {
DetailFragment fragment = new DetailFragment();
Bundle args = new Bundle();
args.putParcelable(IntentKeys.GALLERY, gallery);
args.putParcelable(IntentKeys.CAMERA_POSITION, cameraPosition);
fragment.setArguments(args);
final TransitionInflater inflater = TransitionInflater.from(context);
fragment.setSharedElementEnterTransition(
inflater.inflateTransition(R.transition.detail_shared_enter));
fragment.setEnterTransition(new Fade());
return fragment;
}
示例7: onCheckedChanged
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
View square = sceneRoot.findViewById(R.id.transition_square);
switch (checkedId) {
case R.id.select_scene_1: {
square.setVisibility(View.VISIBLE);
// You can start an automatic transition with TransitionManager.go().
TransitionManager.go(mScene1);
break;
}
case R.id.select_scene_2: {
square.setVisibility(View.VISIBLE);
TransitionManager.go(mScene2);
break;
}
case R.id.select_scene_3: {
square.setVisibility(View.VISIBLE);
// You can also start a transition with a custom TransitionManager.
mTransitionManagerForScene3.transitionTo(mScene3);
break;
}
case R.id.select_scene_4: {
// Alternatively, transition can be invoked dynamically without a Scene.
// For this, we first call TransitionManager.beginDelayedTransition().
TransitionManager.beginDelayedTransition(sceneRoot);
// Then, we can just change view properties as usual.
square.setVisibility(View.VISIBLE);
ViewGroup.LayoutParams params = square.getLayoutParams();
int newSize = getResources().getDimensionPixelSize(R.dimen.square_size_expanded);
params.width = newSize;
params.height = newSize;
square.setLayoutParams(params);
break;
}
case R.id.select_scene_5: {
TransitionInflater transitionInflater = TransitionInflater.from(this);
Transition transition = transitionInflater.inflateTransition(R.transition.changebounds_fadeout_sequential);
TransitionManager.beginDelayedTransition(sceneRoot, transition);
square.setVisibility(View.GONE);
break;
}
}
}
示例8: getTransition
import android.transition.TransitionInflater; //導入方法依賴的package包/類
private Transition getTransition(@TransitionRes int transitionId) {
TransitionInflater inflater=TransitionInflater.from(this);
return inflater.inflateTransition(transitionId);
}
示例9: onCreate
import android.transition.TransitionInflater; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Declare a new thread to do a preference check. Library to invoke Intro slides
Thread t = new Thread(new Runnable() {
@Override
public void run() {
// Initialize SharedPreferences
SharedPreferences getPrefs = PreferenceManager
.getDefaultSharedPreferences(getBaseContext());
// Create a new boolean and preference and set it to true
boolean isFirstStart = getPrefs.getBoolean("firstStart", true);
// If the activity has never started before...
if (isFirstStart) {
// Launch app intro
Intent i = new Intent(HomeActivity.this, IntroActivity.class);
startActivity(i);
// Make a new preferences editor
SharedPreferences.Editor e = getPrefs.edit();
// Edit preference to make it false because we don't want this to run again
e.putBoolean("firstStart", false);
// Apply changes
e.apply();
}
else {
// Launch Mainactivity
// Intent intent = new Intent(getApplicationContext(), MainActivity.class);
// intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
// startActivity(intent);
// mActivity=true;
}
}
});
// Start the thread
t.start();
if (Build.VERSION.SDK_INT >= 21) {
TransitionInflater inflater = TransitionInflater.from(this);
Transition transition = inflater.inflateTransition(R.transition.details_window_enter_transition);
getWindow().setExitTransition(transition);
}
// setUpWindowAnimations();
setContentView(R.layout.activity_home);
ButterKnife.bind(this);
setupFind();
// Obtain the FirebaseAnalytics instance.
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
//Sets whether analytics collection is enabled for this app on this device.
mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
if (savedInstanceState == null) {
NewsFragment fragment = new NewsFragment();
fragment.setArguments(null);
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, fragment, "")
.commit();
}
NewsSyncUtils.initialize(this);
}
示例10: initIfNeeded
import android.transition.TransitionInflater; //導入方法依賴的package包/類
public void initIfNeeded() {
if (mInitialized) {
return;
}
mEnterAnimator = AnimatorInflater.loadAnimator(mMainActivity,
R.animator.channel_banner_enter);
mExitAnimator = AnimatorInflater.loadAnimator(mMainActivity,
R.animator.channel_banner_exit);
mEmptyScene = new Scene(mSceneContainer, (View) mEmptyView);
mEmptyScene.setEnterAction(new Runnable() {
@Override
public void run() {
FrameLayout.LayoutParams emptySceneLayoutParams =
(FrameLayout.LayoutParams) mEmptyView.getLayoutParams();
ViewGroup.MarginLayoutParams lp =
(ViewGroup.MarginLayoutParams) mCurrentSceneView.getLayoutParams();
emptySceneLayoutParams.topMargin = mCurrentSceneView.getTop();
emptySceneLayoutParams.setMarginStart(lp.getMarginStart());
emptySceneLayoutParams.height = mCurrentSceneView.getHeight();
emptySceneLayoutParams.width = mCurrentSceneView.getWidth();
mEmptyView.setLayoutParams(emptySceneLayoutParams);
setCurrentScene(mEmptyScene, mEmptyView);
}
});
mEmptyScene.setExitAction(new Runnable() {
@Override
public void run() {
removeAllViewsFromOverlay();
}
});
mChannelBannerScene = buildScene(mSceneContainer, mChannelBannerView);
mInputBannerScene = buildScene(mSceneContainer, mInputBannerView);
mKeypadChannelSwitchScene = buildScene(mSceneContainer, mKeypadChannelSwitchView);
mSelectInputScene = buildScene(mSceneContainer, mSelectInputView);
mCurrentScene = mEmptyScene;
// Enter transitions
TransitionSet enter = new TransitionSet()
.addTransition(new SceneTransition(SceneTransition.ENTER))
.addTransition(new Fade(Fade.IN));
setTransition(mEmptyScene, mChannelBannerScene, enter);
setTransition(mEmptyScene, mInputBannerScene, enter);
setTransition(mEmptyScene, mKeypadChannelSwitchScene, enter);
setTransition(mEmptyScene, mSelectInputScene, enter);
// Exit transitions
TransitionSet exit = new TransitionSet()
.addTransition(new SceneTransition(SceneTransition.EXIT))
.addTransition(new Fade(Fade.OUT));
setTransition(mChannelBannerScene, mEmptyScene, exit);
setTransition(mInputBannerScene, mEmptyScene, exit);
setTransition(mKeypadChannelSwitchScene, mEmptyScene, exit);
setTransition(mSelectInputScene, mEmptyScene, exit);
// All other possible transitions between scenes
TransitionInflater ti = TransitionInflater.from(mMainActivity);
Transition transition = ti.inflateTransition(R.transition.transition_between_scenes);
setTransition(mChannelBannerScene, mKeypadChannelSwitchScene, transition);
setTransition(mChannelBannerScene, mSelectInputScene, transition);
setTransition(mInputBannerScene, mSelectInputScene, transition);
setTransition(mKeypadChannelSwitchScene, mChannelBannerScene, transition);
setTransition(mKeypadChannelSwitchScene, mSelectInputScene, transition);
setTransition(mSelectInputScene, mChannelBannerScene, transition);
setTransition(mSelectInputScene, mInputBannerScene, transition);
mInitialized = true;
}
示例11: showFragmentByClass
import android.transition.TransitionInflater; //導入方法依賴的package包/類
/**
* Displays a fragment and takes care of lifecycle actions like saving state when rotating the
* screen or managing the back button behavior.
*
* @param clazz the class of the fragment to show
* @param bundle the bundle that is given with the new fragment
*/
public void showFragmentByClass(Class clazz, Bundle bundle) {
Class classToShow = clazz;
final boolean isRegistered = isRegistered();
final Permission permission = permissionForFragment.get(classToShow);
if (permission != null && !hasPermission(permission) && isRegistered) {
Toast.makeText(this, String.format(getString(R.string.fragment_access_denied),
permission.toLocalizedString(this)), Toast.LENGTH_SHORT).show();
return;
}
final Fragment currentFragment = getCurrentFragment();
if (currentFragment != null && Objects.equals(classToShow, currentFragment.getClass())) {
return;
}
// avoid leaving the welcome fragment before registration
if (!isRegistered) {
classToShow = WelcomeScreenFragment.class;
}
final Fragment fragment;
try {
fragment = (Fragment) classToShow.newInstance();
if (bundle != null) {
fragment.setArguments(bundle);
}
} catch (InstantiationException | IllegalAccessException e) {
Log.wtf(TAG, "Could not instantiate fragment", e);
return;
}
// Hide Keyboard before every fragment transaction
View view = getCurrentFocus();
if (view != null) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, fragment);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (currentFragment instanceof MainFragment && fragment instanceof HolidayFragment) {
View fragmentView = currentFragment.getView();
if (fragmentView != null) {
transaction.addSharedElement(fragmentView.findViewById(R.id.holidayButton), "holidayIconTransition");
}
final TransitionInflater inflater = TransitionInflater.from(this);
currentFragment.setSharedElementReturnTransition(
inflater.inflateTransition(R.transition.change_image_trans));
currentFragment.setExitTransition(
inflater.inflateTransition(android.R.transition.explode));
fragment.setSharedElementEnterTransition(
inflater.inflateTransition(R.transition.change_image_trans));
fragment.setEnterTransition(
inflater.inflateTransition(android.R.transition.explode));
} else if (fragment instanceof MainFragment && currentFragment != null) {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
} else {
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
}
}
transaction.commit();
}
示例12: initializeTransitionManager
import android.transition.TransitionInflater; //導入方法依賴的package包/類
private void initializeTransitionManager(ViewGroup contentView) {
TransitionInflater transitionInflater = TransitionInflater.from(this);
mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.favorite_transition_manager, contentView);
}