Search in sources :

Example 16 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project SuperSLiM by TonicArtos.

the class LayoutManager method trimStart.

/**
     * Trim content wholly beyond the start edge.
     *
     * @param state Layout state.
     */
private void trimStart(LayoutState state) {
    // Find the first view visible on the screen.
    View anchor = null;
    int anchorIndex = 0;
    for (int i = 0; i < getChildCount(); i++) {
        View look = getChildAt(i);
        if (getDecoratedBottom(look) > 0) {
            anchor = look;
            anchorIndex = i;
            break;
        }
    }
    if (anchor == null) {
        detachAndScrapAttachedViews(state.recycler);
        return;
    }
    LayoutParams anchorParams = (LayoutParams) anchor.getLayoutParams();
    if (anchorParams.isHeader) {
        for (int i = anchorIndex - 1; i >= 0; i--) {
            View look = getChildAt(i);
            LayoutParams lookParams = (LayoutParams) look.getLayoutParams();
            if (lookParams.getTestedFirstPosition() == anchorParams.getTestedFirstPosition()) {
                anchor = look;
                anchorParams = lookParams;
                anchorIndex = i;
                break;
            }
        }
    }
    for (int i = 0; i < anchorIndex; i++) {
        removeAndRecycleViewAt(0, state.recycler);
    }
    int sfp = anchorParams.getTestedFirstPosition();
    View header = findAttachedHeaderForSection(sfp, Direction.START);
    if (header != null) {
        if (getDecoratedTop(header) < 0) {
            updateHeaderForTrimFromStart(header);
        }
        if (getDecoratedBottom(header) <= 0) {
            removeAndRecycleView(header, state.recycler);
        }
    }
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 17 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project SuperSLiM by TonicArtos.

the class LayoutManager method fillToStart.

/**
     * Fill towards the start edge.
     *
     * @param leadingEdge Line to fill up to. Content will not be wholly beyond this line.
     * @param state       Layout state.
     * @return Line content was filled up to.
     */
private int fillToStart(int leadingEdge, LayoutState state) {
    View anchor = getAnchorAtStart();
    LayoutParams anchorParams = (LayoutParams) anchor.getLayoutParams();
    final int sfp = anchorParams.getTestedFirstPosition();
    final View first = getHeaderOrFirstViewForSection(sfp, Direction.START, state);
    final SectionData sd = new SectionData(this, first);
    final SectionLayoutManager slm = getSlm(sd);
    int markerLine;
    int anchorPosition = getPosition(anchor);
    if (anchorPosition == sd.firstPosition) {
        markerLine = getDecoratedTop(anchor);
    } else {
        if (anchorPosition - 1 == sd.firstPosition && sd.hasHeader) {
            // Already at first content position, so no more to do.
            markerLine = getDecoratedTop(anchor);
        } else {
            markerLine = slm.finishFillToStart(leadingEdge, anchor, sd, state);
        }
    }
    markerLine = updateHeaderForStart(first, leadingEdge, markerLine, sd, state);
    if (markerLine > leadingEdge) {
        markerLine = fillNextSectionToStart(leadingEdge, markerLine, state);
    }
    return markerLine;
}
Also used : View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView)

Example 18 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project SuperSLiM by TonicArtos.

the class Utils method doOverscrollTest.

/**
     * Perform an overscroll test.
     *
     * @param offset         Offset to apply to simulate overscroll; dx, dy.
     * @param padding        Padding values; l, t, r, b.
     * @param expected       Expected bounds; l, t, r, b.
     * @param adapter        Adapter to use.
     * @param mLayoutManager Layout manager to use.
     * @param mRecyclerView  RecyclerView to use.
     */
public static void doOverscrollTest(int[] offset, int[] padding, boolean expected, RecyclerView.Adapter adapter, LayoutManagerWrapper mLayoutManager, RecyclerView mRecyclerView) throws Exception {
    setupLayoutTest(padding, adapter, mLayoutManager, mRecyclerView);
    // Shift so that bounds are after start and end.
    adjustPosition(mRecyclerView, offset[0], offset[1]);
    Method isOverscrolled = LayoutManager.class.getDeclaredMethod("isOverscrolled", LayoutState.class);
    isOverscrolled.setAccessible(true);
    LayoutState state = mock(LayoutState.class);
    RecyclerView.State mRecyclerViewState = mock(RecyclerView.State.class);
    when(state.getRecyclerState()).thenReturn(mRecyclerViewState);
    when(mRecyclerViewState.getItemCount()).thenReturn(adapter.getItemCount());
    boolean result = (Boolean) isOverscrolled.invoke(mLayoutManager, state);
    assertEquals(expected, result);
}
Also used : LayoutState(com.tonicartos.superslim.LayoutState) RecyclerView(android.support.v7.widget.RecyclerView) Method(java.lang.reflect.Method)

Example 19 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project CoCoin by Nightonke.

the class AccountBookTodayViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_account_book_today_view);
    SuperToast.cancelAllSuperToasts();
    mContext = this;
    mViewPager = (MaterialViewPager) findViewById(R.id.materialViewPager);
    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());
    }
    setFonts();
    View view = mViewPager.getRootView();
    title = (TextView) view.findViewById(R.id.logo_white);
    title.setTypeface(CoCoinUtil.typefaceLatoLight);
    title.setText(SettingManager.getInstance().getAccountBookName());
    mViewPager.getPagerTitleStrip().setTypeface(CoCoinUtil.GetTypeface(), Typeface.NORMAL);
    setTitle("");
    toolbar = mViewPager.getToolbar();
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    custom = (MaterialRippleLayout) mDrawer.findViewById(R.id.custom_layout);
    tags = (MaterialRippleLayout) mDrawer.findViewById(R.id.tag_layout);
    months = (MaterialRippleLayout) mDrawer.findViewById(R.id.month_layout);
    list = (MaterialRippleLayout) mDrawer.findViewById(R.id.list_layout);
    report = (MaterialRippleLayout) mDrawer.findViewById(R.id.report_layout);
    sync = (MaterialRippleLayout) mDrawer.findViewById(R.id.sync_layout);
    settings = (MaterialRippleLayout) mDrawer.findViewById(R.id.settings_layout);
    help = (MaterialRippleLayout) mDrawer.findViewById(R.id.help_layout);
    feedback = (MaterialRippleLayout) mDrawer.findViewById(R.id.feedback_layout);
    about = (MaterialRippleLayout) mDrawer.findViewById(R.id.about_layout);
    syncIcon = (MaterialIconView) mDrawer.findViewById(R.id.sync_icon);
    setIconEnable(syncIcon, SettingManager.getInstance().getLoggenOn());
    monthExpenseTip = (TextView) mDrawer.findViewById(R.id.month_expense_tip);
    monthExpenseTip.setTypeface(CoCoinUtil.GetTypeface());
    monthExpense = (RiseNumberTextView) mDrawer.findViewById(R.id.month_expense);
    monthExpense.setTypeface(CoCoinUtil.typefaceLatoLight);
    if (SettingManager.getInstance().getIsMonthLimit()) {
        monthExpenseTip.setVisibility(View.VISIBLE);
        monthExpense.setText("0");
    } else {
        monthExpenseTip.setVisibility(View.INVISIBLE);
        monthExpense.setVisibility(View.INVISIBLE);
    }
    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) {

        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            monthExpense.setText("0");
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            monthExpense.withNumber(RecordManager.getCurrentMonthExpense()).setDuration(500).start();
        }
    };
    mDrawer.setDrawerListener(mDrawerToggle);
    View logo = findViewById(R.id.logo_white);
    if (logo != null) {
        logo.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mViewPager.notifyHeaderChanged();
            }
        });
    }
    todayModeAdapter = new TodayViewFragmentAdapter(getSupportFragmentManager());
    mViewPager.getViewPager().setOffscreenPageLimit(todayModeAdapter.getCount());
    mViewPager.getViewPager().setAdapter(todayModeAdapter);
    mViewPager.getPagerTitleStrip().setViewPager(mViewPager.getViewPager());
    mViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {

        @Override
        public HeaderDesign getHeaderDesign(int page) {
            return HeaderDesign.fromColorAndDrawable(CoCoinUtil.GetTagColor(page - 2), CoCoinUtil.GetTagDrawable(-3));
        }
    });
    setListeners();
    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));
    loadLogo();
}
Also used : MaterialViewPager(com.github.florent37.materialviewpager.MaterialViewPager) BmobUser(cn.bmob.v3.BmobUser) User(com.nightonke.saver.model.User) HeaderDesign(com.github.florent37.materialviewpager.header.HeaderDesign) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) RiseNumberTextView(com.nightonke.saver.ui.RiseNumberTextView) View(android.view.View) TextView(android.widget.TextView) BaseSliderView(com.daimajia.slider.library.SliderTypes.BaseSliderView) CustomSliderView(com.nightonke.saver.ui.CustomSliderView) MaterialIconView(net.steamcrafted.materialiconlib.MaterialIconView) TodayViewFragmentAdapter(com.nightonke.saver.adapter.TodayViewFragmentAdapter) DescriptionAnimation(com.daimajia.slider.library.Animations.DescriptionAnimation) ActionBar(android.support.v7.app.ActionBar)

Example 20 with START

use of android.support.v7.widget.helper.ItemTouchHelper.START in project CoCoin by Nightonke.

the class TodayViewFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    layoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setHasFixedSize(true);
    Calendar now = Calendar.getInstance();
    Calendar leftRange;
    Calendar rightRange;
    RecordManager recordManager = RecordManager.getInstance(mContext.getApplicationContext());
    int start = -1;
    int end = 0;
    switch(position) {
        case TODAY:
            leftRange = CoCoinUtil.GetTodayLeftRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                }
                if (start == -1) {
                    start = i;
                }
            }
            break;
        case YESTERDAY:
            leftRange = CoCoinUtil.GetYesterdayLeftRange(now);
            rightRange = CoCoinUtil.GetYesterdayRightRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                } else if (!recordManager.RECORDS.get(i).getCalendar().after(rightRange)) {
                    if (start == -1) {
                        start = i;
                    }
                }
            }
            break;
        case THIS_WEEK:
            leftRange = CoCoinUtil.GetThisWeekLeftRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                }
                if (start == -1) {
                    start = i;
                }
            }
            break;
        case LAST_WEEK:
            leftRange = CoCoinUtil.GetLastWeekLeftRange(now);
            rightRange = CoCoinUtil.GetLastWeekRightRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                } else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
                    if (start == -1) {
                        start = i;
                    }
                }
            }
            break;
        case THIS_MONTH:
            leftRange = CoCoinUtil.GetThisMonthLeftRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                }
                if (start == -1) {
                    start = i;
                }
            }
            break;
        case LAST_MONTH:
            leftRange = CoCoinUtil.GetLastMonthLeftRange(now);
            rightRange = CoCoinUtil.GetLastMonthRightRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                } else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
                    if (start == -1) {
                        start = i;
                    }
                }
            }
            break;
        case THIS_YEAR:
            leftRange = CoCoinUtil.GetThisYearLeftRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                }
                if (start == -1) {
                    start = i;
                }
            }
            break;
        case LAST_YEAR:
            leftRange = CoCoinUtil.GetLastYearLeftRange(now);
            rightRange = CoCoinUtil.GetLastYearRightRange(now);
            for (int i = recordManager.RECORDS.size() - 1; i >= 0; i--) {
                if (recordManager.RECORDS.get(i).getCalendar().before(leftRange)) {
                    end = i + 1;
                    break;
                } else if (recordManager.RECORDS.get(i).getCalendar().before(rightRange)) {
                    if (start == -1) {
                        start = i;
                    }
                }
            }
            break;
    }
    adapter = new TodayViewRecyclerViewAdapter(start, end, mContext, position);
    mAdapter = new RecyclerViewMaterialAdapter(adapter);
    mRecyclerView.setAdapter(mAdapter);
    MaterialViewPagerHelper.registerRecyclerView(getActivity(), mRecyclerView, null);
}
Also used : RecordManager(com.nightonke.saver.model.RecordManager) Calendar(java.util.Calendar) TodayViewRecyclerViewAdapter(com.nightonke.saver.adapter.TodayViewRecyclerViewAdapter) RecyclerViewMaterialAdapter(com.github.florent37.materialviewpager.adapter.RecyclerViewMaterialAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

View (android.view.View)367 RecyclerView (android.support.v7.widget.RecyclerView)271 TextView (android.widget.TextView)175 Intent (android.content.Intent)109 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)84 Toolbar (android.support.v7.widget.Toolbar)77 TextWatcher (android.text.TextWatcher)77 Editable (android.text.Editable)76 ImageView (android.widget.ImageView)76 ArrayList (java.util.ArrayList)68 Bundle (android.os.Bundle)48 DialogInterface (android.content.DialogInterface)47 AlertDialog (android.support.v7.app.AlertDialog)47 AdapterView (android.widget.AdapterView)46 EditText (android.widget.EditText)42 SuppressLint (android.annotation.SuppressLint)39 Button (android.widget.Button)39 ActionBar (android.support.v7.app.ActionBar)34 List (java.util.List)34 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)33