Example usage for android.view View post

List of usage examples for android.view View post

Introduction

In this page you can find the example usage for android.view View post.

Prototype

public boolean post(Runnable action) 

Source Link

Document

Causes the Runnable to be added to the message queue.

Usage

From source file:com.weihuoya.bboo._G.java

public static void colorizeToolbar(Toolbar toolbar, int foregroundColor, int backgroundColor) {
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(foregroundColor,
            PorterDuff.Mode.MULTIPLY);/*from  w w  w  . jav a 2 s .  c  o  m*/

    toolbar.setTitleTextColor(foregroundColor);
    toolbar.setSubtitleTextColor(foregroundColor);
    toolbar.setBackgroundColor(backgroundColor);

    for (int i = 0; i < toolbar.getChildCount(); ++i) {
        final View view = toolbar.getChildAt(i);

        if (view instanceof ImageButton) {
            ((ImageButton) view).getDrawable().setColorFilter(colorFilter);
        } else if (view instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) view).getChildCount(); ++j) {
                final View innerView = ((ActionMenuView) view).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                    for (int k = 0; k < drawablesCount; ++k) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            final int finalK = k;
                            //Important to set the color filter in seperate thread,
                            //by adding it to the message queue
                            //Won't work otherwise.
                            innerView.post(new Runnable() {
                                @Override
                                public void run() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK]
                                            .setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }
    }
}

From source file:com.artioml.practice.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_license);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// w  w w .j  av  a 2 s.  co m

    Button acceptButton = (Button) findViewById(R.id.acceptButton);

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IS_FIRST_TIME, true)) {
        getSupportActionBar().setDisplayShowHomeEnabled(false);
        getSupportActionBar().setHomeButtonEnabled(false);
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
    }
    if (getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).getBoolean(IS_ACCEPTED, false)) {
        acceptButton.setVisibility(View.INVISIBLE);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    acceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).edit().putBoolean(IS_ACCEPTED, true).apply();
            finish();
        }
    });

    final View line = findViewById(R.id.lineView);
    line.post(new Runnable() {
        @Override
        public void run() {
            BitmapDrawable parallel = drawParallelogramLine(line.getWidth());
            line.setBackground(parallel);
        }
    });

}

From source file:org.traccar.manager.DevicesFragment.java

@Override
public void onClick(final View view) {
    view.post(new Runnable() {
        @Override/*from   w w w  .j  a v a 2 s. co  m*/
        public void run() {
            showPopupMenu(view);
        }
    });
}

From source file:com.artioml.practice.activities.LicenseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_license);
    setActionBar();/* w  w w.ja  v a 2  s  .  c om*/

    Button acceptButton = (Button) findViewById(R.id.acceptButton);

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IS_FIRST_TIME, true)) {
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setHomeButtonEnabled(false);
            actionBar.setDisplayHomeAsUpEnabled(false);
        }
    }
    if (getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).getBoolean(IS_ACCEPTED, false)) {
        acceptButton.setVisibility(View.INVISIBLE);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }

    acceptButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getSharedPreferences(PERSISTENT_STORAGE, MODE_PRIVATE).edit().putBoolean(IS_ACCEPTED, true).apply();
            finish();
        }
    });

    final View line = findViewById(R.id.lineView);
    line.post(new Runnable() {
        @Override
        public void run() {
            BitmapDrawable parallel = drawParallelogramLine(line.getWidth());
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                line.setBackgroundDrawable(parallel);
            } else {
                line.setBackground(parallel);
            }
        }
    });

}

From source file:com.simas.vc.editor.tree_view.AttributeTreeAdapter.java

private void selectView(final View view, final Object parentNode) {
    view.post(new Runnable() {
        @Override//from  ww  w.ja v  a  2s. c om
        public void run() {
            mSelectedChildren.put(parentNode, view);
            view.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.DARKEN);
        }
    });
}

From source file:org.mariotaku.twidere.fragment.BaseListFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final View view = super.onCreateView(inflater, container, savedInstanceState);
    final ViewGroup progress_container = (ViewGroup) view
            .findViewById(ListFragmentTrojan.INTERNAL_PROGRESS_CONTAINER_ID);
    final View progress = progress_container.getChildAt(0);
    progress.post(new InvalidateProgressBarRunnable(progress));
    return view;/*from w w w  .  j a  v a 2 s  . c  om*/
}

From source file:com.tingtingapps.securesms.ContactSelectionActivity.java

private void expandTapArea(final View container, final View child, final int padding) {
    container.post(new Runnable() {
        @Override// ww w. j a va  2 s. co  m
        public void run() {
            Rect rect = new Rect();
            child.getHitRect(rect);

            rect.top -= padding;
            rect.left -= padding;
            rect.right += padding;
            rect.bottom += padding;

            container.setTouchDelegate(new TouchDelegate(rect, child));
        }
    });
}

From source file:com.gh4a.adapter.RootAdapter.java

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof FooterViewHolder) {
        if (mFooterListener != null) {
            mFooterListener.onScrolledToFooter();
        }//from ww w  .j  a  va 2s.  c  om
    } else if (!(holder instanceof HeaderViewHolder)) {
        onBindViewHolder((VH) holder, getItemFromAdapterPosition(position));
        if (position == mHighlightPosition) {
            final View v = holder.itemView;
            v.post(new Runnable() {
                @Override
                public void run() {
                    if (v.getBackground() != null) {
                        final int centerX = v.getWidth() / 2;
                        final int centerY = v.getHeight() / 2;
                        DrawableCompat.setHotspot(v.getBackground(), centerX, centerY);
                    }
                    v.setPressed(true);
                    v.setPressed(false);
                    mHighlightPosition = -1;
                }
            });
        }
    }
}

From source file:com.example.android.actionbarcompat.listpopupmenu.PopupListFragment.java

@Override
public void onClick(final View view) {
    // We need to post a Runnable to show the popup to make sure that the PopupMenu is
    // correctly positioned. The reason being that the view may change position before the
    // PopupMenu is shown.
    view.post(new Runnable() {
        @Override/*ww w . java2s  .c  o m*/
        public void run() {
            showPopupMenu(view);
        }
    });
}

From source file:im.vector.adapters.ImagesSliderAdapter.java

@Override
public void setPrimaryItem(ViewGroup container, final int position, Object object) {
    if (mLastPrimaryItem != position) {
        mLastPrimaryItem = position;/*from   w  ww . j  a v a2s  . com*/
        //
        if (mHighResMediaIndex.indexOf(position) < 0) {
            final View view = (View) object;
            view.post(new Runnable() {
                @Override
                public void run() {
                    downloadHighResPict(view, position);
                }
            });
        }
    }
}