Search in sources :

Example 16 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project jmonkeyengine by jMonkeyEngine.

the class AndroidHarness method layoutDisplay.

public void layoutDisplay() {
    logger.log(Level.FINE, "Splash Screen Picture Resource ID: {0}", splashPicID);
    if (view == null) {
        logger.log(Level.FINE, "view is null!");
    }
    if (splashPicID != 0) {
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER);
        frameLayout = new FrameLayout(this);
        splashImageView = new ImageView(this);
        Drawable drawable = this.getResources().getDrawable(splashPicID);
        if (drawable instanceof NinePatchDrawable) {
            splashImageView.setBackgroundDrawable(drawable);
        } else {
            splashImageView.setImageResource(splashPicID);
        }
        if (view.getParent() != null) {
            ((ViewGroup) view.getParent()).removeView(view);
        }
        frameLayout.addView(view);
        if (splashImageView.getParent() != null) {
            ((ViewGroup) splashImageView.getParent()).removeView(splashImageView);
        }
        frameLayout.addView(splashImageView, lp);
        setContentView(frameLayout);
        logger.log(Level.FINE, "Splash Screen Created");
    } else {
        logger.log(Level.FINE, "Splash Screen Skipped.");
        setContentView(view);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) ImageView(android.widget.ImageView) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 17 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project jmonkeyengine by jMonkeyEngine.

the class AndroidHarnessFragment method createLayout.

public void createLayout() {
    logger.log(Level.FINE, "Splash Screen Picture Resource ID: {0}", splashPicID);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    if (frameLayout != null && frameLayout.getParent() != null) {
        ((ViewGroup) frameLayout.getParent()).removeView(frameLayout);
    }
    frameLayout = new FrameLayout(getActivity());
    if (view.getParent() != null) {
        ((ViewGroup) view.getParent()).removeView(view);
    }
    frameLayout.addView(view);
    if (splashPicID != 0) {
        splashImageView = new ImageView(getActivity());
        Drawable drawable = getResources().getDrawable(splashPicID);
        if (drawable instanceof NinePatchDrawable) {
            splashImageView.setBackgroundDrawable(drawable);
        } else {
            splashImageView.setImageResource(splashPicID);
        }
        if (splashImageView.getParent() != null) {
            ((ViewGroup) splashImageView.getParent()).removeView(splashImageView);
        }
        frameLayout.addView(splashImageView, lp);
        logger.fine("Splash Screen Created");
    } else {
        logger.fine("Splash Screen Skipped.");
    }
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) ImageView(android.widget.ImageView) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 18 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project android-advancedrecyclerview by h6ah4i.

the class DraggableStaggeredGridExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // Start dragging after long press
    mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
    mRecyclerViewDragDropManager.setInitiateOnMove(false);
    mRecyclerViewDragDropManager.setLongPressTimeout(750);
    //adapter
    final DraggableStaggeredGridExampleAdapter myItemAdapter = new DraggableStaggeredGridExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setHasFixedSize(false);
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 19 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project android-advancedrecyclerview by h6ah4i.

the class DraggableWithSectionExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mLayoutManager = new LinearLayoutManager(getContext());
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    //adapter
    final DraggableWithSectionExampleAdapter myItemAdapter = new DraggableWithSectionExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 20 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project android-advancedrecyclerview by h6ah4i.

the class DraggableExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    //adapter
    final DraggableExampleItemAdapter myItemAdapter = new DraggableExampleItemAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Aggregations

NinePatchDrawable (android.graphics.drawable.NinePatchDrawable)34 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)19 ItemShadowDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator)19 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)16 SimpleListDividerDecorator (com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator)16 RecyclerViewDragDropManager (com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager)10 RecyclerView (android.support.v7.widget.RecyclerView)9 View (android.view.View)9 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)9 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)9 Bitmap (android.graphics.Bitmap)8 DraggableItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator)8 Rect (android.graphics.Rect)7 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)7 NinePatch (com.android.ninepatch.NinePatch)6 NinePatchChunk (com.android.ninepatch.NinePatchChunk)6 MalformedURLException (java.net.MalformedURLException)6 Parcelable (android.os.Parcelable)5 RecyclerViewExpandableItemManager (com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager)5 ImageView (android.widget.ImageView)4