Search in sources :

Example 26 with NinePatchDrawable

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

the class ExpandableDraggableWithSectionExampleFragment 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());
    final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
    mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
    mRecyclerViewExpandableItemManager.setOnGroupExpandListener(this);
    mRecyclerViewExpandableItemManager.setOnGroupCollapseListener(this);
    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    mRecyclerViewTouchActionGuardManager.setEnabled(true);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
    //adapter
    final ExpandableDraggableWithSectionExampleAdapter myItemAdapter = new ExpandableDraggableWithSectionExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for expanding
    mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter);
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mWrappedAdapter);
    // wrap for swiping
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter);
    mRecyclerViewDragDropManager.setCheckCanDropEnabled(ALLOW_ITEMS_MOVE_ACROSS_SECTIONS);
    myItemAdapter.setAllowItemsMoveAcrossSections(ALLOW_ITEMS_MOVE_ACROSS_SECTIONS);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Need to disable them when using animation indicator.
    animator.setSupportsChangeAnimations(false);
    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)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop > ExpandableItem
    mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) Parcelable(android.os.Parcelable) 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) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 27 with NinePatchDrawable

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

the class ExpandableDraggableSwipeableExampleFragment 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());
    final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null;
    mRecyclerViewExpandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState);
    mRecyclerViewExpandableItemManager.setOnGroupExpandListener(this);
    mRecyclerViewExpandableItemManager.setOnGroupCollapseListener(this);
    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    mRecyclerViewTouchActionGuardManager.setEnabled(true);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
    //adapter
    final ExpandableDraggableSwipeableExampleAdapter myItemAdapter = new ExpandableDraggableSwipeableExampleAdapter(mRecyclerViewExpandableItemManager, getDataProvider());
    myItemAdapter.setEventListener(new ExpandableDraggableSwipeableExampleAdapter.EventListener() {

        @Override
        public void onGroupItemRemoved(int groupPosition) {
            ((ExpandableDraggableSwipeableExampleActivity) getActivity()).onGroupItemRemoved(groupPosition);
        }

        @Override
        public void onChildItemRemoved(int groupPosition, int childPosition) {
            ((ExpandableDraggableSwipeableExampleActivity) getActivity()).onChildItemRemoved(groupPosition, childPosition);
        }

        @Override
        public void onGroupItemPinned(int groupPosition) {
            ((ExpandableDraggableSwipeableExampleActivity) getActivity()).onGroupItemPinned(groupPosition);
        }

        @Override
        public void onChildItemPinned(int groupPosition, int childPosition) {
            ((ExpandableDraggableSwipeableExampleActivity) getActivity()).onChildItemPinned(groupPosition, childPosition);
        }

        @Override
        public void onItemViewClicked(View v, boolean pinned) {
            onItemViewClick(v, pinned);
        }
    });
    mAdapter = myItemAdapter;
    // wrap for expanding
    mWrappedAdapter = mRecyclerViewExpandableItemManager.createWrappedAdapter(myItemAdapter);
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(mWrappedAdapter);
    // wrap for swiping
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mWrappedAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Disable the change animation in order to make turning back animation of swiped item works properly.
    // Also need to disable them when using animation indicator.
    animator.setSupportsChangeAnimations(false);
    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)));
    }
    mRecyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(getContext(), R.drawable.list_divider_h), true));
    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop > ExpandableItem
    mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewExpandableItemManager.attachRecyclerView(mRecyclerView);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) Parcelable(android.os.Parcelable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) RecyclerViewExpandableItemManager(com.h6ah4i.android.widget.advrecyclerview.expandable.RecyclerViewExpandableItemManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 28 with NinePatchDrawable

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

the class VerticalSwipeableExampleFragment 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.HORIZONTAL, false);
    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    mRecyclerViewTouchActionGuardManager.setEnabled(true);
    // swipe manager
    mRecyclerViewSwipeManager = new RecyclerViewSwipeManager();
    //adapter
    final VerticalSwipeableExampleAdapter myItemAdapter = new VerticalSwipeableExampleAdapter(getDataProvider());
    myItemAdapter.setEventListener(new VerticalSwipeableExampleAdapter.EventListener() {

        @Override
        public void onItemRemoved(int position) {
            ((VerticalSwipeableExampleActivity) getActivity()).onItemRemoved(position);
        }

        @Override
        public void onItemPinned(int position) {
            ((VerticalSwipeableExampleActivity) getActivity()).onItemPinned(position);
        }

        @Override
        public void onItemViewClicked(View v, boolean pinned) {
            onItemViewClick(v, pinned);
        }
    });
    mAdapter = myItemAdapter;
    // wrap for swiping
    mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    // Change animations are enabled by default since support-v7-recyclerview v22.
    // Disable the change animation in order to make turning back animation of swiped item works properly.
    animator.setSupportsChangeAnimations(false);
    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(null, ContextCompat.getDrawable(getContext(), R.drawable.list_divider_v), true));
    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop
    mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView);
    mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
//        animator.setRemoveDuration(2000);
//        mRecyclerViewSwipeManager.setMoveToOutsideWindowAnimationDuration(2000);
//        mRecyclerViewSwipeManager.setReturnToDefaultPositionAnimationDuration(2000);
}
Also used : RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 29 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project android_frameworks_base by ParanoidAndroid.

the class ResourceHelper method getNinePatchDrawable.

private static Drawable getNinePatchDrawable(InputStream inputStream, Density density, boolean isFramework, String cacheKey, BridgeContext context) throws IOException {
    // see if we still have both the chunk and the bitmap in the caches
    NinePatchChunk chunk = Bridge.getCached9Patch(cacheKey, isFramework ? null : context.getProjectKey());
    Bitmap bitmap = Bridge.getCachedBitmap(cacheKey, isFramework ? null : context.getProjectKey());
    // if either chunk or bitmap is null, then we reload the 9-patch file.
    if (chunk == null || bitmap == null) {
        try {
            NinePatch ninePatch = NinePatch.load(inputStream, true, /*is9Patch*/
            false);
            if (ninePatch != null) {
                if (chunk == null) {
                    chunk = ninePatch.getChunk();
                    Bridge.setCached9Patch(cacheKey, chunk, isFramework ? null : context.getProjectKey());
                }
                if (bitmap == null) {
                    bitmap = Bitmap_Delegate.createBitmap(ninePatch.getImage(), false, /*isMutable*/
                    density);
                    Bridge.setCachedBitmap(cacheKey, bitmap, isFramework ? null : context.getProjectKey());
                }
            }
        } catch (MalformedURLException e) {
        // URL is wrong, we'll return null below
        }
    }
    if (chunk != null && bitmap != null) {
        int[] padding = chunk.getPadding();
        Rect paddingRect = new Rect(padding[0], padding[1], padding[2], padding[3]);
        return new NinePatchDrawable(context.getResources(), bitmap, NinePatch_Delegate.serialize(chunk), paddingRect, null);
    }
    return null;
}
Also used : Bitmap(android.graphics.Bitmap) MalformedURLException(java.net.MalformedURLException) Rect(android.graphics.Rect) NinePatch(com.android.ninepatch.NinePatch) NinePatchChunk(com.android.ninepatch.NinePatchChunk) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Example 30 with NinePatchDrawable

use of android.graphics.drawable.NinePatchDrawable in project CoCoin by Nightonke.

the class AccountBookListViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_book_list_view);
    mContext = this;
    userName = (TextView) findViewById(R.id.user_name);
    userEmail = (TextView) findViewById(R.id.user_email);
    userName.setTypeface(CoCoinUtil.typefaceLatoRegular);
    userEmail.setTypeface(CoCoinUtil.typefaceLatoLight);
    User user = BmobUser.getCurrentUser(CoCoinApplication.getAppContext(), User.class);
    if (user != null) {
        userName.setText(user.getUsername());
        userEmail.setText(user.getEmail());
    }
    int size = RecordManager.getInstance(CoCoinApplication.getAppContext()).RECORDS.size();
    if (RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS == null) {
        RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS = new LinkedList<>();
    }
    RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS.clear();
    for (int i = 0; i < size; i++) {
        CoCoinRecord record = new CoCoinRecord();
        record.set(RecordManager.RECORDS.get(i));
        RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_RECORDS.add(record);
    }
    RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_SUM = Double.valueOf(RecordManager.getInstance(CoCoinApplication.getAppContext()).SUM);
    originalSum = RecordManager.getInstance(CoCoinApplication.getAppContext()).SELECTED_SUM;
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    setTitle("");
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= Build.VERSION_CODES.LOLLIPOP) {
        // Do something for lollipop and above versions
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(ContextCompat.getColor(mContext, R.color.statusBarColor));
    } else {
        // do something for phones running an SDK before lollipop
        View statusBarView = (View) findViewById(R.id.status_bar_view);
        statusBarView.getLayoutParams().height = CoCoinUtil.getStatusBarHeight();
    }
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer, 0, 0);
    mDrawer.setDrawerListener(mDrawerToggle);
    searchView = (MaterialSearchView) findViewById(R.id.search_view);
    searchView.setVoiceSearch(false);
    searchView.setHint(mContext.getResources().getString(R.string.input_remark_to_search));
    searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

        @Override
        public boolean onQueryTextSubmit(String query) {
            progressDialog = new MaterialDialog.Builder(mContext).title(R.string.selecting_title).content(R.string.selecting_content).cancelable(false).progress(true, 0).show();
            new SelectRecordsByRemark(query).execute();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            return false;
        }
    });
    searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {

        @Override
        public void onSearchViewShown() {
            //Do some magic
            Log.d("Saver", "onSearchViewShown");
        }

        @Override
        public void onSearchViewClosed() {
            //Do some magic
            Log.d("Saver", "onSearchViewClosed");
        }
    });
    emptyTip = (TextView) findViewById(R.id.empty_tip);
    emptyTip.setTypeface(CoCoinUtil.GetTypeface());
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
    recyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager();
    recyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    recyclerViewTouchActionGuardManager.setEnabled(true);
    recyclerViewSwipeManager = new RecyclerViewSwipeManager();
    mAdapter = new MySwipeableItemAdapter(mContext, RecordManager.SELECTED_RECORDS, this, this);
    mAdapter.setEventListener(new MySwipeableItemAdapter.EventListener() {

        @Override
        public void onItemRemoved(int position) {
            activityOnItemRemoved(position);
        }

        @Override
        public void onItemPinned(int position) {
            activityOnItemPinned(position);
        }

        @Override
        public void onItemViewClicked(View v, boolean pinned) {
            int position = recyclerView.getChildAdapterPosition(v);
            if (position != RecyclerView.NO_POSITION) {
                activityOnItemClicked(position);
            }
        }
    });
    adapter = mAdapter;
    wrappedAdapter = recyclerViewSwipeManager.createWrappedAdapter(mAdapter);
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(wrappedAdapter);
    recyclerView.setItemAnimator(animator);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        recyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(mContext, R.drawable.material_shadow_z1)));
    }
    recyclerView.addItemDecoration(new SimpleListDividerDecorator(ContextCompat.getDrawable(mContext, R.drawable.list_divider_h), true));
    // NOTE:
    // The initialization order is very important! This order determines the priority of touch event handling.
    //
    // priority: TouchActionGuard > Swipe > DragAndDrop
    recyclerViewTouchActionGuardManager.attachRecyclerView(recyclerView);
    recyclerViewSwipeManager.attachRecyclerView(recyclerView);
    verticalRecyclerViewFastScroller = (VerticalRecyclerViewFastScroller) findViewById(R.id.fast_scroller);
    // Connect the recycler to the scroller (to let the scroller scroll the list)
    verticalRecyclerViewFastScroller.setRecyclerView(recyclerView);
    // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
    recyclerView.setOnScrollListener(verticalRecyclerViewFastScroller.getOnScrollListener());
    CoCoinUtil.backupCoCoinRecord = null;
    if (RecordManager.SELECTED_RECORDS.size() == 0) {
        emptyTip.setVisibility(View.VISIBLE);
        verticalRecyclerViewFastScroller.setVisibility(View.INVISIBLE);
    } else {
        emptyTip.setVisibility(View.GONE);
        verticalRecyclerViewFastScroller.setVisibility(View.VISIBLE);
    }
    infoLayout = (FrameLayout) mDrawer.findViewById(R.id.info_layout);
    LinearLayout.LayoutParams infoLayoutParams = new LinearLayout.LayoutParams(infoLayout.getLayoutParams());
    infoLayoutParams.setMargins(0, CoCoinUtil.getStatusBarHeight() - CoCoinUtil.dpToPx(30), 0, 0);
    infoLayout.setLayoutParams(infoLayoutParams);
    profileImage = (CircleImageView) mDrawer.findViewById(R.id.profile_image);
    profileImage.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (SettingManager.getInstance().getLoggenOn()) {
                CoCoinUtil.showToast(mContext, R.string.change_logo_tip);
            } else {
                CoCoinUtil.showToast(mContext, R.string.login_tip);
            }
        }
    });
    mDemoSlider = (SliderLayout) findViewById(R.id.slider);
    HashMap<String, Integer> urls = CoCoinUtil.GetDrawerTopUrl();
    for (String name : urls.keySet()) {
        CustomSliderView customSliderView = new CustomSliderView(this);
        // initialize a SliderLayout
        customSliderView.image(urls.get(name)).setScaleType(BaseSliderView.ScaleType.Fit);
        mDemoSlider.addSlider(customSliderView);
    }
    mDemoSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
    mDemoSlider.setCustomAnimation(new DescriptionAnimation());
    mDemoSlider.setDuration(4000);
    mDemoSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
    titleExpense = (TextView) findViewById(R.id.title_expense);
    titleExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
    titleExpense.setText(CoCoinUtil.GetInMoney((int) (double) RecordManager.getInstance(mContext).SELECTED_SUM));
    titleSum = (TextView) findViewById(R.id.title_sum);
    titleSum.setTypeface(CoCoinUtil.typefaceLatoLight);
    titleSum.setText(RecordManager.getInstance(mContext).SELECTED_RECORDS.size() + "'s");
    //        titleSlider = (SliderLayout)findViewById(R.id.title_slider);
    //        titleSlider.getLayoutParams().height = 48;
    //        titleSlider.getLayoutParams().width = 400 - CoCoinUtil.dpToPx(60 * 2);
    //
    //        HashMap<String, Integer> urls2 = CoCoinUtil.getTransparentUrls();
    //
    //        CustomTitleSliderView customTitleSliderView = new CustomTitleSliderView(0 + "'s", CoCoinFragmentManager.NUMBER_SLIDER);
    //        customTitleSliderView
    //                .image(urls2.get("0"))
    //                .setScaleType(BaseSliderView.ScaleType.Fit);
    //        titleSlider.addSlider(customTitleSliderView);
    //
    //        customTitleSliderView = new CustomTitleSliderView(CoCoinUtil.GetInMoney(0), CoCoinFragmentManager.EXPENSE_SLIDER);
    //        customTitleSliderView
    //                .image(urls2.get("1"))
    //                .setScaleType(BaseSliderView.ScaleType.Fit);
    //        titleSlider.addSlider(customTitleSliderView);
    //
    //        titleSlider.setPresetTransformer(SliderLayout.Transformer.ZoomOut);
    //        titleSlider.setCustomAnimation(new DescriptionAnimation());
    //        titleSlider.setDuration(3000);
    //        titleSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
    ((TextView) findViewById(R.id.tag_title)).setTypeface(CoCoinUtil.GetTypeface());
    ((TextView) findViewById(R.id.tag_title_expense)).setTypeface(CoCoinUtil.GetTypeface());
    ((TextView) findViewById(R.id.tag_title_time)).setTypeface(CoCoinUtil.GetTypeface());
    ((TextView) findViewById(R.id.tag_title_tag)).setTypeface(CoCoinUtil.GetTypeface());
    setMoney = (TextView) findViewById(R.id.select_expense);
    setMoney.setTypeface(CoCoinUtil.GetTypeface());
    setMoney.setOnClickListener(this);
    noMoney = (TextView) findViewById(R.id.no_expense);
    noMoney.setTypeface(CoCoinUtil.GetTypeface());
    noMoney.setOnClickListener(this);
    setTime = (TextView) findViewById(R.id.select_time);
    setTime.setTypeface(CoCoinUtil.GetTypeface());
    setTime.setOnClickListener(this);
    noTime = (TextView) findViewById(R.id.no_time);
    noTime.setTypeface(CoCoinUtil.GetTypeface());
    noTime.setOnClickListener(this);
    setTag = (TextView) findViewById(R.id.select_tag);
    setTag.setTypeface(CoCoinUtil.GetTypeface());
    setTag.setOnClickListener(this);
    noTag = (TextView) findViewById(R.id.no_tag);
    noTag.setTypeface(CoCoinUtil.GetTypeface());
    noTag.setOnClickListener(this);
    select = (TextView) findViewById(R.id.select);
    select.setTypeface(CoCoinUtil.GetTypeface());
    select.setOnClickListener(this);
    leftExpense = (TextView) findViewById(R.id.left_expense);
    leftExpense.setTypeface(CoCoinUtil.GetTypeface());
    rightExpense = (TextView) findViewById(R.id.right_expense);
    rightExpense.setTypeface(CoCoinUtil.GetTypeface());
    leftTime = (TextView) findViewById(R.id.left_time);
    leftTime.setTypeface(CoCoinUtil.GetTypeface());
    rightTime = (TextView) findViewById(R.id.right_time);
    rightTime.setTypeface(CoCoinUtil.GetTypeface());
    tagImage = (ImageView) findViewById(R.id.tag_image);
    tagName = (TextView) findViewById(R.id.tag_name);
    tagName.setTypeface(CoCoinUtil.GetTypeface());
    setConditions();
    loadLogo();
}
Also used : BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) TextView(android.widget.TextView) SimpleListDividerDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.SimpleListDividerDecorator) ActionBar(android.support.v7.app.ActionBar) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) Window(android.view.Window) RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) MyGridView(com.nightonke.saver.ui.MyGridView) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) BaseSliderView(com.daimajia.slider.library.SliderTypes.BaseSliderView) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) RecyclerView(android.support.v7.widget.RecyclerView) CoCoinRecord(com.nightonke.saver.model.CoCoinRecord) DescriptionAnimation(com.daimajia.slider.library.Animations.DescriptionAnimation) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) MySwipeableItemAdapter(com.nightonke.saver.adapter.MySwipeableItemAdapter) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) LinearLayout(android.widget.LinearLayout)

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