Search in sources :

Example 36 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project xRecyclerViewF by Dsiner.

the class XRecyclerView method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    // 解决和CollapsingToolbarLayout冲突的问题
    AppBarLayout appBarLayout = null;
    ViewParent p = getParent();
    while (p != null) {
        if (p instanceof CoordinatorLayout) {
            break;
        }
        p = p.getParent();
    }
    if (p instanceof CoordinatorLayout) {
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) p;
        final int childCount = coordinatorLayout.getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
            final View child = coordinatorLayout.getChildAt(i);
            if (child instanceof AppBarLayout) {
                appBarLayout = (AppBarLayout) child;
                break;
            }
        }
        if (appBarLayout != null) {
            appBarLayout.addOnOffsetChangedListener(new AppBarStateChangeListener() {

                @Override
                public void onStateChanged(AppBarLayout appBarLayout, State state) {
                    appbarState = state;
                }
            });
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) AppBarStateChangeListener(com.d.lib.xrv.listener.AppBarStateChangeListener) ViewParent(android.view.ViewParent) ListState(com.d.lib.xrv.view.ListState) AppBarLayout(android.support.design.widget.AppBarLayout) IRecyclerView(com.d.lib.xrv.listener.IRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 37 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project gh4a by slapperwan.

the class IssueMilestoneEditActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Gh4Application.get().isAuthorized()) {
        Intent intent = new Intent(this, Github4AndroidActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    LayoutInflater headerInflater = LayoutInflater.from(UiUtils.makeHeaderThemedContext(this));
    View header = headerInflater.inflate(R.layout.issue_create_header, null);
    addHeaderView(header, false);
    mTitleWrapper = header.findViewById(R.id.title_wrapper);
    mTitleView = header.findViewById(R.id.et_title);
    mTitleView.setOnFocusChangeListener(this);
    mDescriptionView = findViewById(R.id.editor);
    mDueView = findViewById(R.id.tv_due);
    mMarkdownButtons = findViewById(R.id.markdown_buttons);
    mMarkdownButtons.setEditText(mDescriptionView);
    MarkdownPreviewWebView preview = findViewById(R.id.preview);
    preview.setEditText(mDescriptionView);
    CoordinatorLayout rootLayout = getRootLayout();
    mSaveFab = (IssueStateTrackingFloatingActionButton) getLayoutInflater().inflate(R.layout.accept_fab, rootLayout, false);
    mSaveFab.setOnClickListener(this);
    rootLayout.addView(mSaveFab);
    findViewById(R.id.due_container).setOnClickListener(this);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    if (mMilestone == null) {
        mMilestone = Milestone.builder().state(IssueState.Open).build();
    }
    mTitleView.addTextChangedListener(new UiUtils.ButtonEnableTextWatcher(mTitleView, mSaveFab));
    mTitleView.addTextChangedListener(new UiUtils.EmptinessWatchingTextWatcher(mTitleView) {

        @Override
        public void onIsEmpty(boolean isEmpty) {
            if (isEmpty) {
                mTitleWrapper.setError(getString(R.string.issue_error_milestone_title));
            } else {
                mTitleWrapper.setErrorEnabled(false);
            }
        }
    });
    mTitleView.setText(mMilestone.title());
    mDescriptionView.setText(mMilestone.description());
    updateHighlightColor();
    updateLabels();
    setToolbarScrollable(false);
    adjustTabsForHeaderAlignedFab(true);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LayoutInflater(android.view.LayoutInflater) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) Intent(android.content.Intent) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) View(android.view.View) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) UiUtils(com.gh4a.utils.UiUtils)

Example 38 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project gh4a by slapperwan.

the class IssueMilestoneListActivity method onCreate.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Gh4Application.get().isAuthorized()) {
        CoordinatorLayout rootLayout = getRootLayout();
        mCreateFab = (FloatingActionButton) getLayoutInflater().inflate(R.layout.add_fab, rootLayout, false);
        mCreateFab.setOnClickListener(this);
        rootLayout.addView(mCreateFab);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout)

Example 39 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project gh4a by slapperwan.

the class IssueLabelListActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.generic_list);
    setContentShown(false);
    mAdapter = new IssueLabelAdapter(this);
    mAdapter.setOnItemClickListener(this);
    RecyclerView recyclerView = findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DividerItemDecoration(this));
    recyclerView.setTag(R.id.FloatingActionButtonScrollEnabled, new Object());
    recyclerView.setAdapter(mAdapter);
    CoordinatorLayout rootLayout = getRootLayout();
    mFab = (FloatingActionButton) getLayoutInflater().inflate(R.layout.add_fab, rootLayout, false);
    mFab.setOnClickListener(this);
    rootLayout.addView(mFab);
    updateFabVisibility();
    loadLabels(false);
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(STATE_KEY_ADDED_LABEL)) {
            mAddedLabel = savedInstanceState.getParcelable(STATE_KEY_EDITING_LABEL);
            mAdapter.add(mAddedLabel);
            startEditing(mAddedLabel);
        } else if (savedInstanceState.containsKey(STATE_KEY_EDITING_LABEL)) {
            IssueLabelAdapter.EditableLabel label = savedInstanceState.getParcelable(STATE_KEY_EDITING_LABEL);
            int count = mAdapter.getCount();
            for (int i = 0; i < count; i++) {
                IssueLabelAdapter.EditableLabel item = mAdapter.getItem(i);
                if (item.name().equals(label.name())) {
                    item.editedName = label.editedName;
                    item.editedColor = label.editedColor;
                    startEditing(item);
                    break;
                }
            }
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) IssueLabelAdapter(com.gh4a.adapter.IssueLabelAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.gh4a.widget.DividerItemDecoration)

Example 40 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project teamward-client by Neamar.

the class SnackBarActivity method displaySnack.

public void displaySnack(String snack) {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
    assert coordinatorLayout != null;
    try {
        Snackbar snackbar = Snackbar.make(coordinatorLayout, snack, Snackbar.LENGTH_LONG);
        snackbar.show();
    } catch (NullPointerException | IllegalArgumentException e) {
        // If the activity is not visible anymore, this will throw.
        e.printStackTrace();
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Snackbar(android.support.design.widget.Snackbar)

Aggregations

CoordinatorLayout (android.support.design.widget.CoordinatorLayout)57 View (android.view.View)37 AppBarLayout (android.support.design.widget.AppBarLayout)17 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)13 RecyclerView (android.support.v7.widget.RecyclerView)12 Intent (android.content.Intent)9 Toolbar (android.support.v7.widget.Toolbar)8 Snackbar (android.support.design.widget.Snackbar)7 ViewParent (android.view.ViewParent)7 ImageView (android.widget.ImageView)7 NavigationView (android.support.design.widget.NavigationView)5 ViewPager (android.support.v4.view.ViewPager)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 SearchView (android.support.v7.widget.SearchView)5 LayoutInflater (android.view.LayoutInflater)5 FrameLayout (android.widget.FrameLayout)5 TabLayout (android.support.design.widget.TabLayout)4 PagerAdapter (android.support.v4.view.PagerAdapter)4 NestedScrollView (android.support.v4.widget.NestedScrollView)4