Search in sources :

Example 81 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project Ruisi by freedom10086.

the class MyGridDivider method onDraw.

@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final int left = child.getLeft();
        final int right = child.getRight();
        final int top = child.getTop();
        final int bottom = child.getBottom();
        c.drawRect(left + devideWidth / 2, top + devideWidth / 2, right - devideWidth / 2, bottom - devideWidth / 2, maint);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Paint(android.graphics.Paint)

Example 82 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project Ruisi by freedom10086.

the class MyListDivider method drawHorizontalLine.

// 画横线, 这里的parent其实是显示在屏幕显示的这部分
public void drawHorizontalLine(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount - 1; i++) {
        final View child = parent.getChildAt(i);
        // 获得child的布局信息
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getBottom() + params.bottomMargin;
        final int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left + SIZE_PADDING, top, right - SIZE_PADDING, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 83 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project ForPDA by RadiationX.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (EmptyActivity.empty(App.get().getPreferences().getString("auth.user.nick", ""))) {
        startActivity(new Intent(this, EmptyActivity.class));
        finish();
        return;
    }
    Intent intent = getIntent();
    if (intent != null) {
        checkWebView = intent.getBooleanExtra(CHECK_WEBVIEW, checkWebView);
    }
    if (checkWebView) {
        Observable.fromCallable(() -> App.get().isWebViewFound(this)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(aBoolean -> {
            if (!aBoolean) {
                startActivity(new Intent(App.getContext(), WebVewNotFoundActivity.class));
                finish();
            }
        });
    }
    currentThemeIsDark = App.get().isDarkTheme();
    setTheme(currentThemeIsDark ? R.style.DarkAppTheme_NoActionBar : R.style.LightAppTheme_NoActionBar);
    setContentView(R.layout.activity_main);
    DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawerLayout.addDrawerListener(toggle);
    toggle.syncState();
    /*
        * Т.к. 2 вьюхи, делаю цвет в 2 раза прозрачнее, чтобы компенсировать это.
        * P.S. Чем больше вьюх в DrawerLayout находятся до NavigationView, тем сильнее будет затенение
        * P.S.S. Первая вьюха - контейнер фрагментов, вторая - view_for_measure
        * */
    drawerLayout.setScrimColor(0x4C000000);
    drawers = new Drawers(this, drawerLayout);
    drawers.init(savedInstanceState);
    drawerHeader = new DrawerHeader(this, drawerLayout);
    drawerLayout.addDrawerListener(new DrawerLayout.DrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            if (drawerView.getId() == R.id.menu_drawer) {
                if (App.get().getPreferences().getBoolean("drawers.tooltip.link_open", true)) {
                    SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawerView.findViewById(R.id.drawer_header_open_link)).text(R.string.tooltip_link).gravity(Gravity.BOTTOM).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
                    tooltip.show();
                    tooltips.add(tooltip);
                    App.get().getPreferences().edit().putBoolean("drawers.tooltip.link_open", false).apply();
                }
            }
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            if (drawerView.getId() == R.id.menu_drawer) {
                if (App.get().getPreferences().getBoolean("drawers.tooltip.tabs_drawer", true)) {
                    SimpleTooltip tooltip = new SimpleTooltip.Builder(MainActivity.this).anchorView(drawers.getTabDrawer()).text(R.string.tooltip_tabs).gravity(Gravity.START).animated(false).modal(true).transparentOverlay(false).backgroundColor(Color.BLACK).textColor(Color.WHITE).padding((float) App.px16).onDismissListener(simpleTooltip -> tooltips.remove(simpleTooltip)).build();
                    tooltip.show();
                    tooltips.add(tooltip);
                    App.get().getPreferences().edit().putBoolean("drawers.tooltip.tabs_drawer", false).apply();
                }
            }
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            if (newState == DrawerLayout.STATE_DRAGGING) {
                TabFragment fragment = TabManager.get().getActive();
                if (fragment != null) {
                    fragment.hidePopupWindows();
                }
            }
        }
    });
    receiver = new NetworkStateReceiver();
    receiver.registerReceiver();
    KeyboardUtil keyboardUtil = new KeyboardUtil(this, findViewById(R.id.fragments_container));
    keyboardUtil.enable();
    final View viewDiff = findViewById(R.id.view_for_measure);
    viewDiff.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> measureView(v));
    if (Preferences.Notifications.Update.isEnabled(getApplicationContext())) {
        new SimpleUpdateChecker().checkFromGitHub(this);
    }
    checkIntent(getIntent());
}
Also used : SimpleTooltip(io.github.douglasjunior.androidSimpleTooltip.SimpleTooltip) SimpleUpdateChecker(forpdateam.ru.forpda.ui.activities.updatechecker.SimpleUpdateChecker) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TabFragment(forpdateam.ru.forpda.ui.fragments.TabFragment) View(android.view.View) KeyboardUtil(forpdateam.ru.forpda.ui.views.KeyboardUtil) DrawerLayout(android.support.v4.widget.DrawerLayout) Drawers(forpdateam.ru.forpda.ui.views.drawers.Drawers) NetworkStateReceiver(forpdateam.ru.forpda.common.receivers.NetworkStateReceiver) DrawerHeader(forpdateam.ru.forpda.ui.views.drawers.DrawerHeader)

Example 84 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project developmentDependencyLibrary by MatchlessBrother.

the class CSGLItemDecoration method drawHorizontalDecoration.

/**
 ********************关于Item之间水平方向上的分割线*********************
 */
public void drawHorizontalDecoration(Canvas canvas, RecyclerView recyclerView) {
    final int childCount = recyclerView.getChildCount();
    for (int index = 0; index < childCount; index++) {
        final View view = recyclerView.getChildAt(index);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();
        final int left = view.getLeft() - params.leftMargin;
        final int top = view.getBottom() + params.bottomMargin;
        final int bottom = top + mDividerDrawable.getIntrinsicHeight();
        final int right = view.getRight() + params.rightMargin + mDividerDrawable.getIntrinsicWidth();
        mDividerDrawable.setBounds(left, top, right, bottom);
        mDividerDrawable.draw(canvas);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 85 with RIGHT

use of android.support.v7.widget.helper.ItemTouchHelper.RIGHT in project underlx by underlx.

the class SimpleDividerItemDecoration method onDrawOver.

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = parent.getChildAt(i);
        RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        int top = child.getBottom() + params.bottomMargin;
        int bottom = top + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

View (android.view.View)315 RecyclerView (android.support.v7.widget.RecyclerView)294 Paint (android.graphics.Paint)47 TextView (android.widget.TextView)46 ImageView (android.widget.ImageView)29 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)27 ViewGroup (android.view.ViewGroup)15 Intent (android.content.Intent)13 Rect (android.graphics.Rect)12 Preference (android.support.v7.preference.Preference)12 GridLayoutManager (android.support.v7.widget.GridLayoutManager)11 SuppressLint (android.annotation.SuppressLint)10 AlertDialog (android.support.v7.app.AlertDialog)10 Bundle (android.os.Bundle)9 Bitmap (android.graphics.Bitmap)8 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)8 Button (android.widget.Button)8 PreferenceScreen (android.support.v7.preference.PreferenceScreen)7 ArrayList (java.util.ArrayList)7 Animator (android.animation.Animator)6