use of android.transition.Fade in project Camera-Roll-Android-App by kollerlukas.
the class FileExplorerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_file_explorer);
currentDir = new File_POJO("", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setEnterTransition(new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER).addTransition(new Slide(Gravity.BOTTOM)).addTransition(new Fade()).setInterpolator(new AccelerateDecelerateInterpolator()));
getWindow().setReturnTransition(new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER).addTransition(new Slide(Gravity.BOTTOM)).addTransition(new Fade()).setInterpolator(new AccelerateDecelerateInterpolator()));
}
final Toolbar toolbar = findViewById(R.id.toolbar);
toolbar.setBackgroundColor(toolbarColor);
toolbar.setTitleTextColor(textColorPrimary);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && showAnimations()) {
AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) ContextCompat.getDrawable(FileExplorerActivity.this, R.drawable.back_to_cancel_avd);
// mutating avd to reset it
drawable.mutate();
toolbar.setNavigationIcon(drawable);
} else {
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white);
}
Drawable navIcon = toolbar.getNavigationIcon();
if (navIcon != null) {
navIcon = DrawableCompat.wrap(navIcon);
DrawableCompat.setTint(navIcon.mutate(), textColorSecondary);
toolbar.setNavigationIcon(navIcon);
}
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(getString(R.string.file_explorer));
actionBar.setDisplayHomeAsUpEnabled(true);
}
Util.colorToolbarOverflowMenuIcon(toolbar, textColorSecondary);
// need to be called after setTitle(), to ensure, that mTitleTextView exists
final TextView titleTextView = Util.setToolbarTypeface(toolbar);
if (titleTextView != null) {
titleTextView.setEllipsize(TextUtils.TruncateAt.START);
}
final ViewGroup rootView = findViewById(R.id.swipeBackView);
if (rootView instanceof SwipeBackCoordinatorLayout) {
((SwipeBackCoordinatorLayout) rootView).setOnSwipeListener(this);
}
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerViewAdapter = new FileExplorerAdapter(new OnDirectoryChangeCallback() {
@Override
public void changeDir(String path) {
loadDirectory(path);
}
}, this);
if (savedInstanceState != null && savedInstanceState.containsKey(CURRENT_DIR)) {
recyclerViewAdapter.setFiles(currentDir);
}
recyclerViewAdapter.notifyDataSetChanged();
recyclerView.setAdapter(recyclerViewAdapter);
// setup fab
final FloatingActionButton fab = findViewById(R.id.fab);
fab.setImageResource(R.drawable.ic_create_new_folder_white);
Drawable d = fab.getDrawable();
d = DrawableCompat.wrap(d);
DrawableCompat.setTint(d.mutate(), accentTextColor);
fab.setImageDrawable(d);
fab.setScaleX(0.0f);
fab.setScaleY(0.0f);
// setting window insets manually
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
rootView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
@Override
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
toolbar.setPadding(toolbar.getPaddingStart(), /*+ insets.getSystemWindowInsetLeft()*/
toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd(), /*+ insets.getSystemWindowInsetRight()*/
toolbar.getPaddingBottom());
ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarParams.leftMargin += insets.getSystemWindowInsetLeft();
toolbarParams.rightMargin += insets.getSystemWindowInsetRight();
toolbar.setLayoutParams(toolbarParams);
recyclerView.setPadding(recyclerView.getPaddingStart() + insets.getSystemWindowInsetLeft(), recyclerView.getPaddingTop() + insets.getSystemWindowInsetTop(), recyclerView.getPaddingEnd() + insets.getSystemWindowInsetRight(), recyclerView.getPaddingBottom() + insets.getSystemWindowInsetBottom());
fab.setTranslationY(-insets.getSystemWindowInsetBottom());
fab.setTranslationX(-insets.getSystemWindowInsetRight());
// clear this listener so insets aren't re-applied
rootView.setOnApplyWindowInsetsListener(null);
return insets.consumeSystemWindowInsets();
}
});
} else {
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// hacky way of getting window insets on pre-Lollipop
// somewhat works...
int[] screenSize = Util.getScreenSize(FileExplorerActivity.this);
int[] windowInsets = new int[] { Math.abs(screenSize[0] - rootView.getLeft()), Math.abs(screenSize[1] - rootView.getTop()), Math.abs(screenSize[2] - rootView.getRight()), Math.abs(screenSize[3] - rootView.getBottom()) };
toolbar.setPadding(toolbar.getPaddingStart(), toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd(), toolbar.getPaddingBottom());
ViewGroup.MarginLayoutParams toolbarParams = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
toolbarParams.leftMargin += windowInsets[0];
toolbarParams.rightMargin += windowInsets[2];
toolbar.setLayoutParams(toolbarParams);
recyclerView.setPadding(recyclerView.getPaddingStart() + windowInsets[0], recyclerView.getPaddingTop() + windowInsets[1], recyclerView.getPaddingEnd() + windowInsets[2], recyclerView.getPaddingBottom() + windowInsets[3]);
fab.setTranslationY(-windowInsets[2]);
fab.setTranslationX(-windowInsets[3]);
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
}
// needed to achieve transparent navBar
setSystemUiFlags();
// load files
if (savedInstanceState != null && savedInstanceState.containsKey(CURRENT_DIR) && savedInstanceState.containsKey(ROOTS)) {
roots = savedInstanceState.getParcelable(ROOTS);
currentDir = savedInstanceState.getParcelable(CURRENT_DIR);
recyclerViewAdapter.setFiles(currentDir);
recyclerViewAdapter.notifyDataSetChanged();
onDataChanged();
if (savedInstanceState.containsKey(MODE)) {
int mode = savedInstanceState.getInt(MODE);
if (mode == FileExplorerAdapter.SELECTOR_MODE) {
if (savedInstanceState.containsKey(SELECTED_ITEMS)) {
final File_POJO[] selectedItems = (File_POJO[]) savedInstanceState.getParcelableArray(SELECTED_ITEMS);
if (selectedItems != null) {
rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
rootView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
recyclerViewAdapter.enterSelectorMode(selectedItems);
}
});
}
}
} else if (mode == FileExplorerAdapter.PICK_TARGET_MODE && savedInstanceState.containsKey(FILE_OPERATION)) {
onSelectorModeEnter();
// fileOp = savedInstanceState.getParcelable(FILE_OPERATION);
/*FileOperation.operation = fileOp != null ?
fileOp.getType() : FileOperation.EMPTY;*/
// need to call pick target after onSelectorModeEnter animation are done
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
recyclerViewAdapter.pickTarget();
}
}, (int) (500 * Util.getAnimatorSpeed(this)));
}
}
} else {
loadRoots();
// show warning dialog
/*new AlertDialog.Builder(this, getDialogThemeRes())
.setTitle(R.string.warning)
.setMessage(Html.fromHtml(getString(R.string.file_explorer_warning_message)))
.setPositiveButton(R.string.ok, null)
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
finish();
}
})
.show();*/
}
}
use of android.transition.Fade in project opacclient by opacapp.
the class SearchResultDetailActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//
if (savedInstanceState == null) {
// Create the detail fragment and add it to the activity
// using a fragment transaction.
Bundle arguments = new Bundle();
arguments.putInt(SearchResultDetailFragment.ARG_ITEM_NR, getIntent().getIntExtra(SearchResultDetailFragment.ARG_ITEM_NR, 0));
if (getIntent().hasExtra(SearchResultDetailFragment.ARG_ITEM_ID)) {
arguments.putString(SearchResultDetailFragment.ARG_ITEM_ID, getIntent().getStringExtra(SearchResultDetailFragment.ARG_ITEM_ID));
}
if (getIntent().hasExtra(SearchResultDetailFragment.ARG_ITEM_COVER_BITMAP)) {
arguments.putParcelable(SearchResultDetailFragment.ARG_ITEM_COVER_BITMAP, getIntent().getParcelableExtra(SearchResultDetailFragment.ARG_ITEM_COVER_BITMAP));
}
if (getIntent().hasExtra(SearchResultDetailFragment.ARG_ITEM_MEDIATYPE)) {
arguments.putString(SearchResultDetailFragment.ARG_ITEM_MEDIATYPE, getIntent().getStringExtra(SearchResultDetailFragment.ARG_ITEM_MEDIATYPE));
}
detailFragment = new SearchResultDetailFragment();
detailFragment.setArguments(arguments);
getSupportFragmentManager().beginTransaction().add(R.id.searchresult_detail_container, detailFragment).commit();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int touchX = getIntent().getIntExtra(ARG_TOUCH_POSITION_X, 0);
int touchY = getIntent().getIntExtra(ARG_TOUCH_POSITION_Y, 0);
TransitionSet enterTransition = new TransitionSet();
enterTransition.addTransition(new CircularRevealTransition().setStartPosition(this, touchX, touchY).addTarget(R.id.gradient_top).addTarget(R.id.gradient_bottom));
enterTransition.addTransition(new VerticalExplodeTransition().excludeTarget(R.id.gradient_bottom, true).excludeTarget(R.id.gradient_top, true));
enterTransition.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setEnterTransition(enterTransition);
TransitionSet exitTransition = new TransitionSet();
exitTransition.addTransition(new Fade().addTarget(R.id.gradient_bottom).addTarget(R.id.gradient_top));
exitTransition.addTransition(new VerticalExplodeTransition().excludeTarget(R.id.gradient_bottom, true).excludeTarget(R.id.gradient_top, true));
exitTransition.excludeTarget(android.R.id.statusBarBackground, true);
getWindow().setReturnTransition(exitTransition);
getWindow().setSharedElementsUseOverlay(false);
}
}
}
use of android.transition.Fade in project packages_apps_Contacts by AOKP.
the class ExpandingEntryCardView method expand.
private void expand() {
ChangeBounds boundsTransition = new ChangeBounds();
boundsTransition.setDuration(DURATION_EXPAND_ANIMATION_CHANGE_BOUNDS);
Fade fadeIn = new Fade(Fade.IN);
fadeIn.setDuration(DURATION_EXPAND_ANIMATION_FADE_IN);
fadeIn.setStartDelay(DELAY_EXPAND_ANIMATION_FADE_IN);
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(boundsTransition);
transitionSet.addTransition(fadeIn);
transitionSet.excludeTarget(R.id.text, /* exclude = */
true);
final ViewGroup transitionViewContainer = mAnimationViewGroup == null ? this : mAnimationViewGroup;
transitionSet.addListener(new TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
mListener.onExpand();
}
@Override
public void onTransitionEnd(Transition transition) {
mListener.onExpandDone();
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
TransitionManager.beginDelayedTransition(transitionViewContainer, transitionSet);
mIsExpanded = true;
// In order to insert new entries, we may need to inflate them for the first time
inflateAllEntries(LayoutInflater.from(getContext()));
insertEntriesIntoViewGroup();
updateExpandCollapseButton(getCollapseButtonText(), DURATION_EXPAND_ANIMATION_CHANGE_BOUNDS);
}
use of android.transition.Fade in project Fragmentation by YoKeyword.
the class FirstHomeFragment method initView.
private void initView(View view) {
mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
mRecy = (RecyclerView) view.findViewById(R.id.recy);
mRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.refresh_layout);
mFab = (FloatingActionButton) view.findViewById(R.id.fab);
mToolbar.setTitle(R.string.home);
mRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
mRefreshLayout.setOnRefreshListener(this);
mAdapter = new FirstHomeAdapter(_mActivity);
LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
mRecy.setLayoutManager(manager);
mRecy.setAdapter(mAdapter);
mAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position, View view, RecyclerView.ViewHolder vh) {
FirstDetailFragment fragment = FirstDetailFragment.newInstance(mAdapter.getItem(position));
// LOLLIPOP(5.0)系统的 SharedElement支持有 系统BUG, 这里判断大于 > LOLLIPOP
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
setExitTransition(new Fade());
fragment.setEnterTransition(new Fade());
fragment.setSharedElementReturnTransition(new DetailTransition());
fragment.setSharedElementEnterTransition(new DetailTransition());
// 25.1.0以下的support包,Material过渡动画只有在进栈时有,返回时没有;
// 25.1.0+的support包,SharedElement正常
extraTransaction().addSharedElement(((FirstHomeAdapter.VH) vh).img, getString(R.string.image_transition)).addSharedElement(((FirstHomeAdapter.VH) vh).tvTitle, "tv").start(fragment);
} else {
start(fragment);
}
}
});
// Init Datas
List<Article> articleList = new ArrayList<>();
for (int i = 0; i < 8; i++) {
int index = i % 5;
Article article = new Article(mTitles[index], mImgRes[index]);
articleList.add(article);
}
mAdapter.setDatas(articleList);
mRecy.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
mScrollTotal += dy;
if (mScrollTotal <= 0) {
mInAtTop = true;
} else {
mInAtTop = false;
}
if (dy > 5) {
mFab.hide();
} else if (dy < -5) {
mFab.show();
}
}
});
mFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(_mActivity, "Action", Toast.LENGTH_SHORT).show();
}
});
}
use of android.transition.Fade in project Material-Animations by lgvalle.
the class RevealActivity method setupExitAnimations.
private void setupExitAnimations() {
Fade returnTransition = new Fade();
getWindow().setReturnTransition(returnTransition);
returnTransition.setDuration(getResources().getInteger(R.integer.anim_duration_medium));
returnTransition.setStartDelay(getResources().getInteger(R.integer.anim_duration_medium));
returnTransition.addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
transition.removeListener(this);
animateButtonsOut();
animateRevealHide(bgViewGroup);
}
@Override
public void onTransitionEnd(Transition transition) {
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
}
Aggregations