Java源码示例:android.support.v7.graphics.drawable.DrawerArrowDrawable

示例1
public static Drawable getNavigationIcon(@NonNull Context context, @NonNull CandyBarApplication.NavigationIcon navigationIcon) {
    switch (navigationIcon) {
        case DEFAULT:
            return new DrawerArrowDrawable(context);
        case STYLE_1:
            return get(context, R.drawable.ic_toolbar_navigation);
        case STYLE_2:
            return get(context, R.drawable.ic_toolbar_navigation_2);
        case STYLE_3:
            return get(context, R.drawable.ic_toolbar_navigation_3);
        case STYLE_4:
            return get(context, R.drawable.ic_toolbar_navigation_4);
        default:
            return get(context, R.drawable.ic_toolbar_navigation);
    }
}
 
示例2
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    final DrawerArrowDrawable indicator = new DrawerArrowDrawable(this);
    indicator.setColor(Color.WHITE);
    getSupportActionBar().setHomeAsUpIndicator(indicator);

    setTransformer();
    // setListener();
    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawerLayout.setScrimColor(Color.TRANSPARENT);
    drawerLayout.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            if (((ViewGroup) drawerView).getChildAt(1).getId() == R.id.leftSideBar) {
                indicator.setProgress(slideOffset);
            }
        }
    });
}
 
示例3
private void bindViews() {
    // Bind toolbar
    toolbar = (BreadcrumbToolbar) findViewById(R.id.toolbar);
    // We can't use setSupportActionBar()
    toolbar.setBreadcrumbToolbarListener(this);
    toolbar.setTitle(R.string.app_name);
    // Set animated drawer icon to toolbar
    DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this);
    drawerArrow.setColor(ContextCompat.getColor(this, android.R.color.white));
    toolbar.setNavigationIcon(drawerArrow);
    getSupportFragmentManager().addOnBackStackChangedListener(this);

    // Bind drawer and toggle button
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    bindDrawerToggle();
    NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.setCheckedItem(R.id.nav_home);

    // Bind FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(this::openBreadCrumbFragment);
}
 
示例4
public void initToolbar(BreadcrumbToolbarItem object) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    breadcrumbScrollView = (BreadcrumbScrollView) inflater.inflate(R.layout.breadcrumb_scroll_view, null);
    breadcrumbScrollView.setBreadcrumbItemCallback(this);
    addView(breadcrumbScrollView);

    // Breadcrumb scroll view is now initialized and needs its first root element
    addItem(object);

    // Animate toolbar toggle icon if exists, set navigation back icon otherwise.
    if (getNavigationIcon() instanceof DrawerArrowDrawable) {
        animateNavigationIcon(((DrawerArrowDrawable) getNavigationIcon()), true);
    } else {
        initNavigationListener(true);
    }

    // Primary title needs to be saved
    if (getTitle() != null) {
        toolbarTitle = getTitle().toString();
    }

    // Clear toolbar title on breadcrumb before adding breadcrumbs
    setTitle("");

}
 
示例5
public void cleanToolbar() {
    if (breadcrumbScrollView != null) {
        toolbarItemStack.removeAllElements();

        if (getNavigationIcon() instanceof DrawerArrowDrawable) {
            // Animate navigation icon
            animateNavigationIcon(((DrawerArrowDrawable) getNavigationIcon()), false);
        } else {
            // Navigation icon must be removed if none existed
            setNavigationIcon(null);
        }

        // Remove scroll view
        removeView(breadcrumbScrollView);
        breadcrumbScrollView = null;

        // Reset the toolbar title
        setTitle(toolbarTitle);
    }
}
 
示例6
private void openMenuDrawable(final DrawerArrowDrawable drawerArrowDrawable, boolean withAnim) {
    if (withAnim) {
        ValueAnimator anim = ValueAnimator.ofFloat(0.0f, 1.0f);
        anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {

                float value = (Float) animation.getAnimatedValue();
                drawerArrowDrawable.setProgress(value);
            }
        });
        anim.setDuration(MENU_ICON_ANIM_DURATION);
        anim.start();
    } else {
        drawerArrowDrawable.setProgress(1.0f);
    }
}
 
示例7
private void closeMenuDrawable(final DrawerArrowDrawable drawerArrowDrawable, boolean withAnim) {
    if (withAnim) {
        ValueAnimator anim = ValueAnimator.ofFloat(1.0f, 0.0f);
        anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {

                float value = (Float) animation.getAnimatedValue();
                drawerArrowDrawable.setProgress(value);
            }
        });
        anim.setDuration(MENU_ICON_ANIM_DURATION);
        anim.start();
    } else {
        drawerArrowDrawable.setProgress(0.0f);
    }
}
 
示例8
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String name = getIntent().getStringExtra(EXTRA_FILE_NAME);
    mPath = getIntent().getStringExtra(EXTRA_FILE_PATH);

    setContentView(R.layout.activity_view_text_file);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    DrawerArrowDrawable drawerDrawable = new DrawerArrowDrawable(this);
    drawerDrawable.setColor(getResources().getColor(android.R.color.white));
    drawerDrawable.setProgress(1f);
    toolbar.setNavigationIcon(drawerDrawable);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(name);
    getSupportActionBar().setHomeButtonEnabled(true);

    mContentView = (TextView) findViewById(R.id.content);
    mStorage = new Storage(this);
    byte[] bytes = mStorage.readFile(mPath);
    mContentView.setText(new String(bytes));
}
 
示例9
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set content view
    binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

    // set support action bar
    binding.toolbar.setNavigationIcon(new DrawerArrowDrawable(this));
    setSupportActionBar(binding.toolbar);

    // set moving toolbar
    helper = new MovingToolbarHelper();
    helper.bind(
            binding.nestedScrollView,
            binding.imageView,
            binding.imageContainer,
            binding.toolbarContainer,
            binding.contentContainer);
}
 
示例10
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String name = getIntent().getStringExtra(EXTRA_FILE_NAME);
    mPath = getIntent().getStringExtra(EXTRA_FILE_PATH);

    setContentView(R.layout.activity_view_text_file);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    DrawerArrowDrawable drawerDrawable = new DrawerArrowDrawable(this);
    drawerDrawable.setColor(getResources().getColor(android.R.color.white));
    drawerDrawable.setProgress(1f);
    toolbar.setNavigationIcon(drawerDrawable);

    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(name);
    getSupportActionBar().setHomeButtonEnabled(true);

    mContentView = (TextView) findViewById(R.id.content);
    mStorage = new Storage(this);
    byte[] bytes = mStorage.readFile(mPath);
    mContentView.setText(new String(bytes));
}
 
示例11
@Override
public void onSearchExpanded(boolean expand) {
    Toolbar toolbar = findViewById(R.id.toolbar);
    mIsMenuVisible = !expand;

    if (expand) {
        int color = ColorHelper.getAttributeColor(this, R.attr.toolbar_icon);
        toolbar.setNavigationIcon(DrawableHelper.getTintedDrawable(
                this, R.drawable.ic_toolbar_back, color));
        toolbar.setNavigationOnClickListener(view -> onBackPressed());
    } else {
        SoftKeyboardHelper.closeKeyboard(this);
        ColorHelper.setStatusBarColor(this, Color.TRANSPARENT, true);
        if (CandyBarApplication.getConfiguration().getNavigationIcon() == CandyBarApplication.NavigationIcon.DEFAULT) {
            mDrawerToggle.setDrawerArrowDrawable(new DrawerArrowDrawable(this));
        } else {
            toolbar.setNavigationIcon(ConfigurationHelper.getNavigationIcon(this,
                    CandyBarApplication.getConfiguration().getNavigationIcon()));
        }

        toolbar.setNavigationOnClickListener(view ->
                mDrawerLayout.openDrawer(GravityCompat.START));
    }

    mDrawerLayout.setDrawerLockMode(expand ? DrawerLayout.LOCK_MODE_LOCKED_CLOSED :
            DrawerLayout.LOCK_MODE_UNLOCKED);
    supportInvalidateOptionsMenu();
}
 
示例12
/**
 * Get hamburger icon on navigation drawer
 * @param toolbar Toolbar
 * @return View
 */
private static View getNavButtonInToolBar(Toolbar toolbar) {
    for (int i = 0;i<toolbar.getChildCount();i++) {
        if(toolbar.getChildAt(i) instanceof ImageButton){
            ImageButton button = (ImageButton) toolbar.getChildAt(i);
            if(button.getDrawable().getClass().getSuperclass().equals(DrawerArrowDrawable.class))
                return toolbar.getChildAt(i);
        }
    }
    return null;
}
 
示例13
protected void inflateUi(@Nullable Bundle savedInstanceState) {
    setContentView(R.layout.activity_browsing);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this);
    drawerArrow.setColor(0xFFFFFF);


    toolbar.setNavigationIcon(drawerArrow);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setDisplayShowTitleEnabled(false);
    }
    mBooksInformationDbHelper = BooksInformationDbHelper.getInstance(BrowsingActivity.this);
    appBarLayout = findViewById(R.id.appBar);

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    actionBarDrawerToggle = new ActionBarDrawerToggle(
            this, drawer, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(actionBarDrawerToggle);
    actionBarDrawerToggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


    toolbarDownloadOnlySwitch = findViewById(R.id.toolbar_downloaded_only_switch);
    navDownloadedOnlySwitch = (SwitchCompat) navigationView.getMenu().findItem(R.id.nav_item_downloaded_only).getActionView();

    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    mShouldDisplayDownloadOnly = sharedPref.getBoolean(KEY_DOWNLOADED_ONLY, false);
    setToolbarDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly);
    setDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly);

    toolbarDownloadOnlySwitch.setCheckedChangeListener(v -> switchDownloadOnlyFilter(!shouldDisplayDownloadedOnly()));
    navDownloadedOnlySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> switchDownloadOnlyFilter(isChecked));

    //this is done to prevent motion of drawer when the user tries to slide thes switch
    navDownloadedOnlySwitch.setOnTouchListener((v, event) -> {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
        }
        return false;
    });

    View filterPagerContainer = findViewById(R.id.filter_pager_container);
    bookListContainer = findViewById(R.id.book_list_container);
    View bookInfoContainer = findViewById(R.id.book_info_container);
    FragmentManager fragmentManager = getSupportFragmentManager();


    mPaneNumber = getmumberOfpans(filterPagerContainer, bookInfoContainer);

    @Nullable
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);

    int oldPanNumbers = savedInstanceState == null ? 0 : savedInstanceState.getInt(NUMBER_OF_PANS_KEY);

    browsingActivityNavigationController = BrowsingActivityNavigationController.create(
            mPaneNumber,
            oldPanNumbers,
            fragmentManager,
            savedInstanceState != null,
            this,
            bottomNavigationView,
            this);
    if (browsingActivityNavigationController != null) {
        browsingActivityNavigationController.intiializePans();
        if (bottomNavigationView != null) {
            bottomNavigationView.setOnNavigationItemSelectedListener(browsingActivityNavigationController::handleButtomNavigationItem);
        }
    }

    appRateController = new AppRateController(this);

    appRateController
            .monitor()
            .showRateDialogIfMeetsConditions(this);
}
 
示例14
private void initDrawables() {
    mMenuBtnDrawable = new DrawerArrowDrawable(getContext());
    mIconClear = Util.getWrappedDrawable(getContext(), R.drawable.ic_clear_black_24dp);
    mIconBackArrow = Util.getWrappedDrawable(getContext(), R.drawable.ic_arrow_back_black_24dp);
    mIconSearch = Util.getWrappedDrawable(getContext(), R.drawable.ic_search_black_24dp);
}