Search in sources :

Example 26 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project LeafPic by HoraApps.

the class AlertDialogsHelper method getInsertTextDialog.

public static AlertDialog getInsertTextDialog(final ThemedActivity activity, AlertDialog.Builder dialogBuilder, EditText editText, @StringRes int title) {
    View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_insert_text, null);
    TextView textViewTitle = (TextView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.rename_title);
    ((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.dialog_chose_provider_title)).setCardBackgroundColor(activity.getCardBackgroundColor());
    textViewTitle.setBackgroundColor(activity.getPrimaryColor());
    textViewTitle.setText(title);
    ThemeHelper.setCursorDrawableColor(editText, activity.getTextColor());
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    editText.setLayoutParams(layoutParams);
    editText.setSingleLine(true);
    editText.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_IN);
    editText.setTextColor(activity.getTextColor());
    try {
        Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
        f.setAccessible(true);
        f.set(editText, null);
    } catch (Exception ignored) {
    }
    ((RelativeLayout) dialogLayout.findViewById(org.horaapps.leafpic.R.id.container_edit_text)).addView(editText);
    dialogBuilder.setView(dialogLayout);
    return dialogBuilder.create();
}
Also used : Field(java.lang.reflect.Field) FrameLayout(android.widget.FrameLayout) CardView(android.support.v7.widget.CardView) RelativeLayout(android.widget.RelativeLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView)

Example 27 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project LeafPic by HoraApps.

the class SelectAlbumBottomSheet method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    View contentView = View.inflate(getContext(), R.layout.select_folder_bottom_sheet, null);
    theme = new ThemeHelper(getContext());
    RecyclerView mRecyclerView = (RecyclerView) contentView.findViewById(R.id.folders);
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 1));
    adapter = new BottomSheetAlbumsAdapter();
    mRecyclerView.setAdapter(adapter);
    exploreModePanel = (LinearLayout) contentView.findViewById(R.id.explore_mode_panel);
    currentFolderPath = (TextView) contentView.findViewById(R.id.bottom_sheet_sub_title);
    imgExploreMode = (IconicsImageView) contentView.findViewById(R.id.toggle_hidden_icon);
    imgExploreMode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            toggleExplorerMode(!exploreMode);
        }
    });
    toggleExplorerMode(false);
    /**SET UP THEME**/
    theme.setColorScrollBarDrawable(ContextCompat.getDrawable(dialog.getContext(), R.drawable.ic_scrollbar));
    contentView.findViewById(R.id.ll_bottom_sheet_title).setBackgroundColor(theme.getPrimaryColor());
    contentView.findViewById(R.id.ll_select_folder).setBackgroundColor(theme.getCardBackgroundColor());
    ((TextView) contentView.findViewById(R.id.bottom_sheet_title)).setText(title);
    ((IconicsImageView) contentView.findViewById(R.id.create_new_folder)).setColor(theme.getIconColor());
    ((TextView) contentView.findViewById(R.id.create_new_folder_text)).setTextColor(theme.getSubTextColor());
    ((IconicsImageView) contentView.findViewById(R.id.done)).setColor(theme.getIconColor());
    contentView.findViewById(R.id.done).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            selectAlbumInterface.folderSelected(currentFolderPath.getText().toString());
        }
    });
    contentView.findViewById(R.id.ll_create_new_folder).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final EditText editText = new EditText(getContext());
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), theme.getDialogStyle());
            AlertDialogsHelper.getInsertTextDialog(((ThemedActivity) getActivity()), builder, editText, R.string.new_folder);
            builder.setPositiveButton(R.string.ok_action, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    File folderPath = new File(currentFolderPath.getText().toString() + File.separator + editText.getText().toString());
                    if (folderPath.mkdir())
                        displayContentFolder(folderPath);
                }
            });
            builder.show();
        }
    });
    dialog.setContentView(contentView);
    CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
    CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
    if (behavior != null && behavior instanceof BottomSheetBehavior) {
        ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
    }
    adapter.notifyDataSetChanged();
}
Also used : EditText(android.widget.EditText) AlertDialog(android.support.v7.app.AlertDialog) ThemeHelper(org.horaapps.leafpic.util.ThemeHelper) DialogInterface(android.content.DialogInterface) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) IconicsImageView(com.mikepenz.iconics.view.IconicsImageView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) GridLayoutManager(android.support.v7.widget.GridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) File(java.io.File)

Example 28 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class NavBarTuner method inflatePreview.

private void inflatePreview(ViewGroup view) {
    Display display = getActivity().getWindowManager().getDefaultDisplay();
    boolean isRotated = display.getRotation() == Surface.ROTATION_90 || display.getRotation() == Surface.ROTATION_270;
    Configuration config = new Configuration(getContext().getResources().getConfiguration());
    boolean isPhoneLandscape = isRotated && (config.smallestScreenWidthDp < 600);
    final float scale = isPhoneLandscape ? PREVIEW_SCALE_LANDSCAPE : PREVIEW_SCALE;
    config.densityDpi = (int) (config.densityDpi * scale);
    mPreview = (PreviewNavInflater) LayoutInflater.from(getContext().createConfigurationContext(config)).inflate(R.layout.nav_bar_tuner_inflater, view, false);
    final ViewGroup.LayoutParams layoutParams = mPreview.getLayoutParams();
    layoutParams.width = (int) ((isPhoneLandscape ? display.getHeight() : display.getWidth()) * scale);
    // Not sure why, but the height dimen is not being scaled with the dp, set it manually
    // for now.
    layoutParams.height = (int) (layoutParams.height * scale);
    if (isPhoneLandscape) {
        int width = layoutParams.width;
        layoutParams.width = layoutParams.height;
        layoutParams.height = width;
    }
    view.addView(mPreview);
    if (isRotated) {
        mPreview.findViewById(R.id.rot0).setVisibility(View.GONE);
        final View rot90 = mPreview.findViewById(R.id.rot90);
    } else {
        mPreview.findViewById(R.id.rot90).setVisibility(View.GONE);
        final View rot0 = mPreview.findViewById(R.id.rot0);
    }
}
Also used : Configuration(android.content.res.Configuration) ViewGroup(android.view.ViewGroup) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Display(android.view.Display)

Example 29 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project Lightning-Browser by anthonycr.

the class BrowserActivity method initialize.

private synchronized void initialize(Bundle savedInstanceState) {
    initializeToolbarHeight(getResources().getConfiguration());
    setSupportActionBar(mToolbar);
    ActionBar actionBar = getSupportActionBar();
    //TODO make sure dark theme flag gets set correctly
    mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
    mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
    mDisabledIconColor = mDarkTheme ? ContextCompat.getColor(this, R.color.icon_dark_theme_disabled) : ContextCompat.getColor(this, R.color.icon_light_theme_disabled);
    mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
    mSwapBookmarksAndTabs = mPreferences.getBookmarksAndTabsSwapped();
    // initialize background ColorDrawable
    int primaryColor = ThemeUtils.getPrimaryColor(this);
    mBackground.setColor(primaryColor);
    // Drawer stutters otherwise
    mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
    mDrawerLayout.addDrawerListener(new DrawerListener() {

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

        @Override
        public void onDrawerOpened(View drawerView) {
        }

        @Override
        public void onDrawerClosed(View drawerView) {
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            if (newState == DrawerLayout.STATE_DRAGGING) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            } else if (newState == DrawerLayout.STATE_IDLE) {
                mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
                mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) {
        getWindow().setStatusBarColor(Color.BLACK);
    }
    setNavigationDrawerWidth();
    mDrawerLayout.addDrawerListener(new DrawerLocker());
    mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
    final FragmentManager fragmentManager = getSupportFragmentManager();
    TabsFragment tabsFragment = (TabsFragment) fragmentManager.findFragmentByTag(TAG_TABS_FRAGMENT);
    BookmarksFragment bookmarksFragment = (BookmarksFragment) fragmentManager.findFragmentByTag(TAG_BOOKMARK_FRAGMENT);
    if (tabsFragment != null) {
        fragmentManager.beginTransaction().remove(tabsFragment).commit();
    }
    tabsFragment = TabsFragment.createTabsFragment(isIncognito(), mShowTabsInDrawer);
    mTabsView = tabsFragment;
    if (bookmarksFragment != null) {
        fragmentManager.beginTransaction().remove(bookmarksFragment).commit();
    }
    bookmarksFragment = BookmarksFragment.createFragment(isIncognito());
    mBookmarksView = bookmarksFragment;
    fragmentManager.executePendingTransactions();
    fragmentManager.beginTransaction().replace(getTabsFragmentViewId(), tabsFragment, TAG_TABS_FRAGMENT).replace(getBookmarksFragmentViewId(), bookmarksFragment, TAG_BOOKMARK_FRAGMENT).commit();
    if (mShowTabsInDrawer) {
        mToolbarLayout.removeView(findViewById(R.id.tabs_toolbar_container));
    }
    Preconditions.checkNonNull(actionBar);
    // set display options of the ActionBar
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.toolbar_content);
    View customView = actionBar.getCustomView();
    LayoutParams lp = customView.getLayoutParams();
    lp.width = LayoutParams.MATCH_PARENT;
    lp.height = LayoutParams.MATCH_PARENT;
    customView.setLayoutParams(lp);
    mArrowImage = (ImageView) customView.findViewById(R.id.arrow);
    FrameLayout arrowButton = (FrameLayout) customView.findViewById(R.id.arrow_button);
    if (mShowTabsInDrawer) {
        if (mArrowImage.getWidth() <= 0) {
            mArrowImage.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
        }
        updateTabNumber(0);
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getTabDrawer());
            }
        });
    } else {
        // Post drawer locking in case the activity is being recreated
        Handlers.MAIN.post(new Runnable() {

            @Override
            public void run() {
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, getTabDrawer());
            }
        });
        mArrowImage.setImageResource(R.drawable.ic_action_home);
        mArrowImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
    }
    // Post drawer locking in case the activity is being recreated
    Handlers.MAIN.post(new Runnable() {

        @Override
        public void run() {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getBookmarkDrawer());
        }
    });
    arrowButton.setOnClickListener(this);
    // create the search EditText in the ToolBar
    mSearch = (SearchView) customView.findViewById(R.id.search);
    mSearchBackground = customView.findViewById(R.id.search_container);
    // initialize search background color
    mSearchBackground.getBackground().setColorFilter(getSearchBarColor(primaryColor, primaryColor), PorterDuff.Mode.SRC_IN);
    mSearch.setHintTextColor(ThemeUtils.getThemedTextHintColor(mDarkTheme));
    mSearch.setTextColor(mDarkTheme ? Color.WHITE : Color.BLACK);
    mUntitledTitle = getString(R.string.untitled);
    mBackgroundColor = ThemeUtils.getPrimaryColor(this);
    mDeleteIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    mRefreshIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_refresh, mDarkTheme);
    mClearIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
    int iconBounds = Utils.dpToPx(24);
    mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
    mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
    mClearIcon.setBounds(0, 0, iconBounds, iconBounds);
    mIcon = mRefreshIcon;
    SearchListenerClass search = new SearchListenerClass();
    mSearch.setCompoundDrawablePadding(Utils.dpToPx(3));
    mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
    mSearch.setOnKeyListener(search);
    mSearch.setOnFocusChangeListener(search);
    mSearch.setOnEditorActionListener(search);
    mSearch.setOnTouchListener(search);
    mSearch.setOnPreFocusListener(search);
    initializeSearchSuggestions(mSearch);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
    if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        //noinspection deprecation
        WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
    }
    @SuppressWarnings("VariableNotUsedInsideIf") Intent intent = savedInstanceState == null ? getIntent() : null;
    boolean launchedFromHistory = intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
    if (isPanicTrigger(intent)) {
        setIntent(null);
        panicClean();
    } else {
        if (launchedFromHistory) {
            intent = null;
        }
        mPresenter.setupTabs(intent);
        setIntent(null);
        mProxyUtils.checkForProxy(this);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TabsFragment(acr.browser.lightning.fragment.TabsFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) BookmarksView(acr.browser.lightning.browser.BookmarksView) BrowserView(acr.browser.lightning.browser.BrowserView) SearchView(acr.browser.lightning.view.SearchView) AutoCompleteTextView(android.widget.AutoCompleteTextView) LightningView(acr.browser.lightning.view.LightningView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) VideoView(android.widget.VideoView) TabsView(acr.browser.lightning.browser.TabsView) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener) FragmentManager(android.support.v4.app.FragmentManager) BookmarksFragment(acr.browser.lightning.fragment.BookmarksFragment) FrameLayout(android.widget.FrameLayout) ActionBar(android.support.v7.app.ActionBar)

Example 30 with LayoutParams

use of android.support.v7.widget.StaggeredGridLayoutManager.LayoutParams in project BGARefreshLayout-Android by bingoogolapple.

the class Divider method drawVertical.

public void drawVertical(Canvas c, RecyclerView parent) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();
    View child;
    RecyclerView.LayoutParams layoutParams;
    int top;
    int bottom;
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount - 1; i++) {
        child = parent.getChildAt(i);
        layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
        top = child.getBottom() + layoutParams.bottomMargin;
        bottom = top + mDividerDrawable.getIntrinsicHeight();
        mDividerDrawable.setBounds(left, top, right, bottom);
        mDividerDrawable.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)138 RecyclerView (android.support.v7.widget.RecyclerView)128 TextView (android.widget.TextView)52 ImageView (android.widget.ImageView)36 LinearLayout (android.widget.LinearLayout)32 ViewGroup (android.view.ViewGroup)31 LayoutParams (android.support.v7.widget.RecyclerView.LayoutParams)16 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)15 FrameLayout (android.widget.FrameLayout)15 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)13 Paint (android.graphics.Paint)12 RelativeLayout (android.widget.RelativeLayout)12 BindView (butterknife.BindView)12 Rect (android.graphics.Rect)11 Toolbar (android.support.v7.widget.Toolbar)11 EditText (android.widget.EditText)10 DialogInterface (android.content.DialogInterface)9 Handler (android.os.Handler)9 AdapterView (android.widget.AdapterView)9 Intent (android.content.Intent)8