@OnClick(R.id.btn_next) public void onNextEvent() { String phone = mPhoneView.getText().toString(); if (StringUtils.isBlank(phone)) { mPhoneView.setError(getString(R.string.reqd_login_info)); return; } Object countrySelection = mCountryListView.getSelectedItem(); CountryVO selectedCountryVO = mCountriesView2VOMap.get(countrySelection.toString()); PhonePINVerifyFragment next = PhonePINVerifyFragment.newInstance( phone, selectedCountryVO == null ? "" : selectedCountryVO.getCode()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Transition exit = TransitionInflater.from(getContext()).inflateTransition(R.transition.slide_right); Transition enter = TransitionInflater.from(getContext()).inflateTransition(R.transition.slide_left); next.setSharedElementEnterTransition(enter); next.setEnterTransition(enter); setExitTransition(exit); next.setSharedElementReturnTransition(exit); } getActivity() .getSupportFragmentManager() .beginTransaction() .addSharedElement(mBtnNextView, "btn_next") .replace(R.id.container, next) .addToBackStack(null) .commit(); }
public void onClick(View trykketPåKnap) { // Lav bindinger til mål-aktiviteten, så der kan laves glidende overgange // Navnene skal passe med det TransitionName viewsne har i mål-aktiviteten FragmentovergangSlut fragmentovergangSlut = new FragmentovergangSlut(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setSharedElementReturnTransition( TransitionInflater.from(getActivity()) .inflateTransition(R.transition.lekt32_overgange_trans)); setExitTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.fade)); fragmentovergangSlut.setSharedElementEnterTransition( TransitionInflater.from(getActivity()) .inflateTransition(R.transition.lekt32_overgange_trans)); fragmentovergangSlut.setEnterTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.fade)); ikon.setTransitionName("ikon"); trykketPåKnap.setTransitionName("knappen"); knap3.setTransitionName("knap3"); } getFragmentManager() .beginTransaction() .replace(R.id.fragmentindhold, fragmentovergangSlut) .addToBackStack("Overgange") .addSharedElement(ikon, "ikon") .addSharedElement(trykketPåKnap, "knappen") .addSharedElement(knap3, "knap3") .commit(); }
private void setupWindowAnimations() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Transition slideTransition = TransitionInflater.from(this).inflateTransition(R.transition.slide); Transition slideTransitionReenter = TransitionInflater.from(this).inflateTransition(R.transition.slide); slideTransitionReenter.setInterpolator(new FastOutSlowInInterpolator()); getWindow().setReenterTransition(slideTransitionReenter); getWindow().setExitTransition(slideTransition); } }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ImageSwitcher albumImage = (ImageSwitcher) view.findViewById(R.id.albumImage); View albumText = view.findViewById(R.id.album_grid_text_box); Album album = mAlbumList.get(position); int childNum = albumImage.getDisplayedChild(); Drawable albumArtwork = ((ImageView) albumImage.getChildAt(childNum)).getDrawable(); AlbumDetailFragment albumDetailFragment = AlbumDetailFragment.newInstance(album, albumArtwork); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { albumImage.setTransitionName("albumImage"); albumText.setTransitionName("albumTextBox"); setSharedElementEnterTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); setSharedElementReturnTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); // // setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.explode)); albumDetailFragment.setSharedElementEnterTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); albumDetailFragment.setSharedElementReturnTransition( TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.move)); // // albumDetailFragment.setEnterTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.explode)); // // albumDetailFragment.setExitTransition(TransitionInflater.from(getActivity()).inflateTransition(android.R.transition.explode)); } getActivity() .getSupportFragmentManager() .beginTransaction() .addToBackStack(null) .addSharedElement(albumImage, "albumImage") .addSharedElement(albumText, "albumTextBox") .replace(R.id.library_inner_fragment, albumDetailFragment) .commit(); if (null != mListener) { // Notify the active callbacks interface (the activity, if the // fragment is attached to one) that an item has been selected. // mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 设置contentFeature,可使用切换动画 getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); Transition explode = TransitionInflater.from(this).inflateTransition(android.R.transition.explode); getWindow().setEnterTransition(explode); setContentView(R.layout.activity_three); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow() .setSharedElementEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.postsinfotransition)); } setContentView(R.layout.post_details_layout); ButterKnife.bind(this); /*We want to set the menu visibility to none because this activity doesn't require a toolbar*/ setMenuVisibility(false); initViews(); }
@Override protected void onCreate(Bundle savedInstanceState) { // Inflate and set the enter transition for this activity. final Transition sharedElementEnterTransition = TransitionInflater.from(this).inflateTransition(R.transition.menu_enter); getWindow().setSharedElementEnterTransition(sharedElementEnterTransition); mMenuCategory = getIntent().getParcelableExtra(MenuCategory.TAG); mInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in); if (savedInstanceState != null) { mSavedStateIsPlaying = savedInstanceState.getBoolean(STATE_IS_PLAYING); } super.onCreate(savedInstanceState); populate(); }
@Override public void onTeamSelected(int teamId) { Transition transition = TransitionInflater.from(this).inflateTransition(android.R.transition.move); mAllTeamsFragment.setSharedElementReturnTransition(transition); mAllTeamsFragment.setExitTransition(transition); if (mTeamViewFragment == null) { Bundle args = new Bundle(); args.putInt(TEAM_ID, teamId); mTeamViewFragment = new TeamViewFragment(); mTeamViewFragment.setArguments(args); } FragmentTransaction ft = getFragmentTransaction(); ft.setCustomAnimations( R.animator.slide_up, R.animator.scale_down, R.animator.scale_up, R.animator.slide_down); ft.add(R.id.main_container, mTeamViewFragment, mTeamViewFragment.getClass().getSimpleName()); ft.addToBackStack(mTeamViewFragment.getClass().getSimpleName()); ft.commit(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Check if the android version is 21+ for activity transition animations. if (Build.VERSION.SDK_INT >= 21) { getWindow() .setSharedElementEnterTransition( TransitionInflater.from(this) .inflateTransition(R.transition.shared_element_transition)); } setContentView(R.layout.activity_store_details); Log.d(getLocalClassName(), "Activity created"); // Configure the toolbar configToolbar(); // Configure views configView(); // Get store data from bundle Bundle extras = getIntent().getExtras(); if (extras != null) { address = extras.getString("ADDR", ""); city = extras.getString("CITY", ""); name = extras.getString("NAME", ""); latitude = extras.getString("LAT", ""); zipcode = extras.getString("ZIP", ""); longitude = extras.getString("LON", ""); phone = extras.getString("PHONE", ""); state = extras.getString("STATE", ""); storeID = extras.getString("ID", ""); storeLogoURL = extras.getString("LOGO", ""); } // Set the views. setViews(); }
@Override protected void onCreate(Bundle savedInstanceState) { remplaceFont.replaceDefaultFont(this, "DEFAULT", "Exo-Medium.otf"); remplaceFont.replaceDefaultFont(this, "SANS", "Roboto-Light.ttf"); remplaceFont.replaceDefaultFont(this, "SERIF", "Roboto-Light.ttf"); super.onCreate(savedInstanceState); FacebookSdk.sdkInitialize(this); setContentView(R.layout.activity_inscription); firstName = (TextInputLayout) findViewById(R.id.layoutFirstName); lastName = (TextInputLayout) findViewById(R.id.layoutLastName); email = (TextInputLayout) findViewById(R.id.layoutEmail); emailConfirmed = (TextInputLayout) findViewById(R.id.layoutEmailConfirmed); password = (TextInputLayout) findViewById(R.id.layoutPassword); passwordConfirmed = (TextInputLayout) findViewById(R.id.layoutPasswordConfirmed); inscrptionButton = (ImageView) findViewById(R.id.inscrptionButton); progressBar = (ProgressBar) findViewById(R.id.ProgressBar); imageSuccess = (ImageView) findViewById(R.id.yes); imageEchec = (ImageView) findViewById(R.id.no); progressBar.setVisibility(View.GONE); imageSuccess.setVisibility(View.GONE); imageEchec.setVisibility(View.GONE); Retrofit retrofit = new Retrofit.Builder().baseUrl(GitHubService.baseUrl).build(); gitHubService = retrofit.create(GitHubService.class); if (Build.VERSION.SDK_INT >= 21) { Slide slide = new Slide(); slide.setDuration(400); getWindow().setEnterTransition(slide); getWindow() .setReturnTransition( TransitionInflater.from(this).inflateTransition(R.transition.shared_element_a)); } inscrptionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { String firstNameValue = firstName.getEditText().getText().toString(); String lastNameValue = lastName.getEditText().getText().toString(); String emailValue = email.getEditText().getText().toString(); String emailConfirmedValue = emailConfirmed.getEditText().getText().toString(); String passwordValue = password.getEditText().getText().toString(); String passwordConfirmedValue = passwordConfirmed.getEditText().getText().toString(); firstName.setErrorEnabled(false); firstName.requestFocus(); lastName.setErrorEnabled(false); lastName.requestFocus(); email.setErrorEnabled(false); email.requestFocus(); emailConfirmed.setErrorEnabled(false); emailConfirmed.requestFocus(); password.setErrorEnabled(false); password.requestFocus(); passwordConfirmed.setErrorEnabled(false); passwordConfirmed.requestFocus(); if (!validateInput(firstNameValue)) { firstName.setError("nom non valide !"); firstName.requestFocus(); // hideButton(); mdperreur(); } else if (!validateInput(lastNameValue)) { lastName.setError("prénom non valide !"); lastName.requestFocus(); mdperreur(); } else if (!validateEmail(emailValue)) { email.setError("Email non valide !"); email.requestFocus(); // hideButton(); mdperreur(); } else if (!validateEmail(emailConfirmedValue)) { emailConfirmed.setError("Email non valide !"); emailConfirmed.requestFocus(); // hideButton(); mdperreur(); } else if (!(emailValue.equals(emailConfirmedValue))) { email.setError("Les deux e-mails ne sont pas identiques"); emailConfirmed.setError("Les deux e-mails ne sont pas identiques"); emailConfirmed.requestFocus(); // hideButton(); mdperreur(); } else if (!validatePassword(passwordValue)) { password.setError("Mot de passe non valide !"); password.requestFocus(); // hideButton(); mdperreur(); } else if (!validateInput(passwordConfirmedValue)) { passwordConfirmed.setError("Mot de passe non valide !"); passwordConfirmed.requestFocus(); // hideButton(); mdperreur(); } else if (!(passwordValue.equals(passwordConfirmedValue))) { password.setError("Les deux mots de passe ne sont pas identiques"); passwordConfirmed.setError("Les deux mots de passe ne sont pas identiques"); passwordConfirmed.requestFocus(); // hideButton(); mdperreur(); } else { hideKeyboard(); doInscri(firstNameValue, lastNameValue, emailValue, passwordValue); } } }); // facebook login callbackManager = CallbackManager.Factory.create(); loginFacebook = (LoginButton) findViewById(R.id.login_button); loginManager = LoginManager.getInstance(); loginFacebook.setReadPermissions(readPermissions); loginFacebook.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { hideButton(); } }); loginFacebook.registerCallback( callbackManager, new FacebookCallback<LoginResult>() { @Override public void onSuccess(LoginResult loginResult) { accessToken = AccessToken.getCurrentAccessToken(); // Log.d("user facebook",loginResult.toString()); GraphRequest request = GraphRequest.newMeRequest( loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() { @Override public void onCompleted(JSONObject object, GraphResponse response) { Log.v("LoginActivity", response.toString()); try { User user = new User( object.get("id").toString(), object.get("email").toString(), object.get("name").toString()); AuthUtils.saveUser(InscriptionActivity.this, user); succ(); } catch (JSONException e) { e.printStackTrace(); } } }); Bundle parameters = new Bundle(); parameters.putString("fields", "id,name,email"); request.setParameters(parameters); request.executeAsync(); } @Override public void onCancel() { Toast.makeText(getBaseContext(), "cancel", Toast.LENGTH_SHORT).show(); } @Override public void onError(FacebookException error) { Toast.makeText(getBaseContext(), "error,retry again", Toast.LENGTH_SHORT).show(); error.printStackTrace(); mdperreur(); } }); // google+ login // [START configure_signin] // Configure sign-in to request the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build(); // [START build_client] // Build a GoogleApiClient with access to the Google Sign-In API and the // options specified by gso. mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); signInButtonGoogle = (SignInButton) findViewById(R.id.sign_in_button); signInButtonGoogle.setSize(SignInButton.SIZE_STANDARD); signInButtonGoogle.setScopes(gso.getScopeArray()); signInButtonGoogle.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { progressBar.setVisibility(View.VISIBLE); Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); hideButton(); } }); }
public void setUpAnimation() { Transition slide = TransitionInflater.from(this).inflateTransition(R.transition.slide); getWindow().setExitTransition(slide); }
@Override protected void onCreate(Bundle savedInstanceState) { // TRANSITIONS if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { /*Explode trans1 = new Explode(); trans1.setDuration(3000); Fade trans2 = new Fade(); trans2.setDuration(3000); getWindow().setEnterTransition( trans1 ); getWindow().setReturnTransition( trans2 );*/ TransitionInflater inflater = TransitionInflater.from(this); Transition transition = inflater.inflateTransition(R.transition.transitions); getWindow().setSharedElementEnterTransition(transition); Transition transition1 = getWindow().getSharedElementEnterTransition(); transition1.addListener( new Transition.TransitionListener() { @Override public void onTransitionStart(Transition transition) {} @Override public void onTransitionEnd(Transition transition) { TransitionManager.beginDelayedTransition(mRoot, new Slide()); tvDescription.setVisibility(View.VISIBLE); } @Override public void onTransitionCancel(Transition transition) {} @Override public void onTransitionPause(Transition transition) {} @Override public void onTransitionResume(Transition transition) {} }); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_car); if (savedInstanceState != null) { car = savedInstanceState.getParcelable("car"); } else { if (getIntent() != null && getIntent().getExtras() != null && getIntent().getExtras().getParcelable("car") != null) { car = getIntent().getExtras().getParcelable("car"); } else { Toast.makeText(this, "Fail!", Toast.LENGTH_SHORT).show(); finish(); } } mCollapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); mCollapsingToolbarLayout.setTitle(car.getModel()); mToolbar = (Toolbar) findViewById(R.id.tb_main); mToolbar.setTitle(car.getModel()); setSupportActionBar(mToolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(false); mRoot = (ViewGroup) findViewById(R.id.ll_tv_description); tvDescription = (TextView) findViewById(R.id.tv_description); ImageView ivCar = (ImageView) findViewById(R.id.iv_car); TextView tvModel = (TextView) findViewById(R.id.tv_model); TextView tvBrand = (TextView) findViewById(R.id.tv_brand); Button btPhone = (Button) findViewById(R.id.bt_phone); btPhone.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mMaterialDialog = new MaterialDialog(new ContextThemeWrapper(CarActivity.this, R.style.MyAlertDialog)) .setTitle("Telefone Empresa") .setMessage(car.getTel()) .setPositiveButton( "Ligar", new View.OnClickListener() { @Override public void onClick(View v) { Intent it = new Intent(Intent.ACTION_CALL); it.setData(Uri.parse("tel:" + car.getTel().trim())); startActivity(it); } }) .setNegativeButton( "Voltar", new View.OnClickListener() { @Override public void onClick(View v) { mMaterialDialog.dismiss(); } }); mMaterialDialog.show(); } }); ivCar.setImageResource(car.getPhoto()); tvModel.setText(car.getModel()); tvBrand.setText(car.getBrand()); tvDescription.setText(car.getDescription()); tvDescription.setVisibility( Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? View.VISIBLE : View.INVISIBLE); navigationDrawerLeft = new Drawer() .withActivity(this) .withToolbar(mToolbar) .withActionBarDrawerToggle(false) .withCloseOnClick(true) .withActionBarDrawerToggleAnimated(false) .withActionBarDrawerToggle( new ActionBarDrawerToggle( this, new DrawerLayout(this), R.string.drawer_open, R.string.drawer_close) { @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); navigationDrawerLeft.closeDrawer(); finish(); } }) .build(); // FAB FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(CarActivity.this, "FAB clicked", Toast.LENGTH_SHORT).show(); } }); }
public void showDetails(int pos) { Bundle bundle = new Bundle(); bundle.putInt("key", pos); List<SoulissTypical> typicalList = collected.getAssignedTypicals(); android.support.v4.app.FragmentManager manager = getSupportFragmentManager(); // Check what fragment is currently shown, replace if needed. Fragment details = manager.findFragmentById(R.id.detailPane); Fragment NewFrag = null; // Istanzia e ci mette l'indice if (typicalList.get(pos).isSensor()) NewFrag = T5nSensorFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical16AdvancedRGB) NewFrag = T16RGBAdvancedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical19AnalogChannel) NewFrag = T19SingleChannelLedFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical31Heating) NewFrag = T31HeatingFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical11DigitalOutput || typicalList.get(pos) instanceof SoulissTypical12DigitalOutputAuto) NewFrag = T1nGenericLightFragment.newInstance(pos, typicalList.get(pos)); else if (typicalList.get(pos) instanceof SoulissTypical41AntiTheft || typicalList.get(pos) instanceof SoulissTypical42AntiTheftPeer || typicalList.get(pos) instanceof SoulissTypical43AntiTheftLocalPeer) NewFrag = T4nFragment.newInstance(pos, typicalList.get(pos)); FragmentTransaction ft = manager.beginTransaction(); if (NewFrag != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // details.setSharedElementReturnTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); // details.setExitTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); // Create new fragment to add (Fragment B) // NewFrag.setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(android.R.transition.move)); NewFrag.setEnterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.explode)); // Our shared element (in Fragment A) ImageView mProductImage = (ImageView) details.getView().findViewById(R.id.card_thumbnail_image2); TextView mProductText = (TextView) findViewById(R.id.TextViewTypicalsTitle); AppBarLayout.Behavior beh = new AppBarLayout.Behavior(); // Add Fragment B manager .beginTransaction() .replace(R.id.detailPane, NewFrag) .addToBackStack("transaction") .addSharedElement(mProductText, "hero_title") .commit(); // NOT WORK // .addSharedElement(mProductText, "ToolbarText"); } else { // if (opzioni.isAnimationsEnabled()) // ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left); ft.replace(R.id.detailPane, NewFrag); ft.addToBackStack(null); // ft.remove(details); // ft.add(NewFrag,"BOH"); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); ft.commit(); } } else { Toast.makeText(getApplicationContext(), "No detail to show", Toast.LENGTH_SHORT).show(); } }