Example usage for android.widget ImageView setPadding

List of usage examples for android.widget ImageView setPadding

Introduction

In this page you can find the example usage for android.widget ImageView setPadding.

Prototype

public void setPadding(int left, int top, int right, int bottom) 

Source Link

Document

Sets the padding.

Usage

From source file:com.javielinux.tweettopics2.TweetTopicsActivity.java

public void refreshActionBarColumns() {

    int currentPosition = pager.getCurrentItem();

    layoutBackgroundColumnsBar.removeAllViews();

    int padding = (int) getResources().getDimension(R.dimen.default_padding);
    //int sizeButton = (int) getResources().getDimension(R.dimen.actionbar_columns_height);

    for (int i = 1; i < fragmentAdapter.getFragmentList().size(); i++) {

        ImageView view = new ImageView(this);
        view.setPadding(padding, padding, padding, padding);
        view.setImageBitmap(ColumnsUtils.getButtonWithTitle(this, fragmentAdapter.getFragmentList().get(i),
                true, currentPosition == i ? Color.GREEN : Color.BLACK));
        view.setTag(i);// ww  w . j  a  v a 2s  . c o m
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (layoutMainOptionsColumns.getVisibility() != View.VISIBLE) {
                    showActionBarIndicatorAndMovePager((Integer) view.getTag());
                }
            }
        });
        view.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                int pos = (Integer) view.getTag();
                int[] loc = new int[2];
                view.getLocationOnScreen(loc);
                showOptionsColumns(loc[0], pos, true);
                return false;
            }
        });
        layoutBackgroundColumnsBar.addView(view);
    }
}

From source file:org.telegram.ui.Components.ShareAlert.java

public ShareAlert(final Context context, MessageObject messageObject, final String text, boolean publicChannel,
        final String copyLink) {
    super(context, true);

    shadowDrawable = context.getResources().getDrawable(R.drawable.sheet_shadow);

    linkToCopy = copyLink;/*from   w w  w .  j  a va  2  s .  c  o  m*/
    sendingMessageObject = messageObject;
    searchAdapter = new ShareSearchAdapter(context);
    isPublicChannel = publicChannel;
    sendingText = text;

    if (publicChannel) {
        loadingLink = true;
        TLRPC.TL_channels_exportMessageLink req = new TLRPC.TL_channels_exportMessageLink();
        req.id = messageObject.getId();
        req.channel = MessagesController.getInputChannel(messageObject.messageOwner.to_id.channel_id);
        ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() {
            @Override
            public void run(final TLObject response, TLRPC.TL_error error) {
                AndroidUtilities.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        if (response != null) {
                            exportedMessageLink = (TLRPC.TL_exportedMessageLink) response;
                            if (copyLinkOnEnd) {
                                copyLink(context);
                            }
                        }
                        loadingLink = false;
                    }
                });
            }
        });
    }

    containerView = new FrameLayout(context) {

        private boolean ignoreLayout = false;

        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            if (ev.getAction() == MotionEvent.ACTION_DOWN && scrollOffsetY != 0 && ev.getY() < scrollOffsetY) {
                dismiss();
                return true;
            }
            return super.onInterceptTouchEvent(ev);
        }

        @Override
        public boolean onTouchEvent(MotionEvent e) {
            return !isDismissed() && super.onTouchEvent(e);
        }

        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            int height = MeasureSpec.getSize(heightMeasureSpec);
            if (Build.VERSION.SDK_INT >= 21) {
                height -= AndroidUtilities.statusBarHeight;
            }
            int size = Math.max(searchAdapter.getItemCount(), listAdapter.getItemCount());
            int contentSize = AndroidUtilities.dp(48)
                    + Math.max(3, (int) Math.ceil(size / 4.0f)) * AndroidUtilities.dp(100)
                    + backgroundPaddingTop;
            int padding = contentSize < height ? 0 : height - (height / 5 * 3) + AndroidUtilities.dp(8);
            if (gridView.getPaddingTop() != padding) {
                ignoreLayout = true;
                gridView.setPadding(0, padding, 0, AndroidUtilities.dp(8));
                ignoreLayout = false;
            }
            super.onMeasure(widthMeasureSpec,
                    MeasureSpec.makeMeasureSpec(Math.min(contentSize, height), MeasureSpec.EXACTLY));
        }

        @Override
        protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
            super.onLayout(changed, left, top, right, bottom);
            updateLayout();
        }

        @Override
        public void requestLayout() {
            if (ignoreLayout) {
                return;
            }
            super.requestLayout();
        }

        @Override
        protected void onDraw(Canvas canvas) {
            shadowDrawable.setBounds(0, scrollOffsetY - backgroundPaddingTop, getMeasuredWidth(),
                    getMeasuredHeight());
            shadowDrawable.draw(canvas);
        }
    };
    containerView.setWillNotDraw(false);
    containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background));
    frameLayout.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    doneButton = new LinearLayout(context);
    doneButton.setOrientation(LinearLayout.HORIZONTAL);
    doneButton.setBackgroundDrawable(
            Theme.createBarSelectorDrawable(Theme.ACTION_BAR_AUDIO_SELECTOR_COLOR, false));
    doneButton.setPadding(AndroidUtilities.dp(21), 0, AndroidUtilities.dp(21), 0);
    frameLayout.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));
    doneButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (selectedDialogs.isEmpty() && (isPublicChannel || linkToCopy != null)) {
                if (linkToCopy == null && loadingLink) {
                    copyLinkOnEnd = true;
                    Toast.makeText(ShareAlert.this.getContext(),
                            LocaleController.getString("Loading", R.string.Loading), Toast.LENGTH_SHORT).show();
                } else {
                    copyLink(ShareAlert.this.getContext());
                }
                dismiss();
            } else {
                if (sendingMessageObject != null) {
                    ArrayList<MessageObject> arrayList = new ArrayList<>();
                    arrayList.add(sendingMessageObject);
                    for (HashMap.Entry<Long, TLRPC.TL_dialog> entry : selectedDialogs.entrySet()) {
                        SendMessagesHelper.getInstance().sendMessage(arrayList, entry.getKey());
                    }
                } else if (sendingText != null) {
                    for (HashMap.Entry<Long, TLRPC.TL_dialog> entry : selectedDialogs.entrySet()) {
                        SendMessagesHelper.getInstance().sendMessage(sendingText, entry.getKey(), null, null,
                                true, null, null, null);
                    }
                }
                dismiss();
            }
        }
    });

    doneButtonBadgeTextView = new TextView(context);
    doneButtonBadgeTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButtonBadgeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    doneButtonBadgeTextView.setTextColor(Theme.SHARE_SHEET_BADGE_TEXT_COLOR);
    doneButtonBadgeTextView.setGravity(Gravity.CENTER);
    doneButtonBadgeTextView.setBackgroundResource(R.drawable.bluecounter);
    doneButtonBadgeTextView.setMinWidth(AndroidUtilities.dp(23));
    doneButtonBadgeTextView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8),
            AndroidUtilities.dp(1));
    doneButton.addView(doneButtonBadgeTextView,
            LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 23, Gravity.CENTER_VERTICAL, 0, 0, 10, 0));

    doneButtonTextView = new TextView(context);
    doneButtonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    doneButtonTextView.setGravity(Gravity.CENTER);
    doneButtonTextView.setCompoundDrawablePadding(AndroidUtilities.dp(8));
    doneButtonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    doneButton.addView(doneButtonTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
            LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL));

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.search_share);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setPadding(0, AndroidUtilities.dp(2), 0, 0);
    imageView.getDrawable().setTint(Theme.SHARE_SHEET_EDIT_PLACEHOLDER_TEXT_COLOR);
    frameLayout.addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.CENTER_VERTICAL));

    nameTextView = new EditText(context);
    nameTextView.setHint(LocaleController.getString("ShareSendTo", R.string.ShareSendTo));
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    nameTextView.setBackgroundDrawable(null);
    nameTextView.setHintTextColor(Theme.SHARE_SHEET_EDIT_PLACEHOLDER_TEXT_COLOR);
    nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    nameTextView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    AndroidUtilities.clearCursorDrawable(nameTextView);
    nameTextView.setTextColor(Theme.SHARE_SHEET_EDIT_TEXT_COLOR);
    frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 48, 2, 96, 0));
    nameTextView.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            String text = nameTextView.getText().toString();
            if (text.length() != 0) {
                if (gridView.getAdapter() != searchAdapter) {
                    topBeforeSwitch = getCurrentTop();
                    gridView.setAdapter(searchAdapter);
                    searchAdapter.notifyDataSetChanged();
                }
                if (searchEmptyView != null) {
                    searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
                }
            } else {
                if (gridView.getAdapter() != listAdapter) {
                    int top = getCurrentTop();
                    searchEmptyView.setText(LocaleController.getString("NoChats", R.string.NoChats));
                    gridView.setAdapter(listAdapter);
                    listAdapter.notifyDataSetChanged();
                    if (top > 0) {
                        layoutManager.scrollToPositionWithOffset(0, -top);
                    }
                }
            }
            if (searchAdapter != null) {
                searchAdapter.searchDialogs(text);
            }
        }
    });

    gridView = new RecyclerListView(context);
    gridView.setTag(13);
    gridView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
    gridView.setClipToPadding(false);
    gridView.setLayoutManager(layoutManager = new GridLayoutManager(getContext(), 4));
    gridView.setHorizontalScrollBarEnabled(false);
    gridView.setVerticalScrollBarEnabled(false);
    gridView.addItemDecoration(new RecyclerView.ItemDecoration() {
        @Override
        public void getItemOffsets(android.graphics.Rect outRect, View view, RecyclerView parent,
                RecyclerView.State state) {
            Holder holder = (Holder) parent.getChildViewHolder(view);
            if (holder != null) {
                int pos = holder.getAdapterPosition();
                outRect.left = pos % 4 == 0 ? 0 : AndroidUtilities.dp(4);
                outRect.right = pos % 4 == 3 ? 0 : AndroidUtilities.dp(4);
            } else {
                outRect.left = AndroidUtilities.dp(4);
                outRect.right = AndroidUtilities.dp(4);
            }
        }
    });
    containerView.addView(gridView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0));
    gridView.setAdapter(listAdapter = new ShareDialogsAdapter(context));
    gridView.setGlowColor(0xfff5f6f7);
    gridView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (position < 0) {
                return;
            }
            TLRPC.TL_dialog dialog;
            if (gridView.getAdapter() == listAdapter) {
                dialog = listAdapter.getItem(position);
            } else {
                dialog = searchAdapter.getItem(position);
            }
            if (dialog == null) {
                return;
            }
            ShareDialogCell cell = (ShareDialogCell) view;
            if (selectedDialogs.containsKey(dialog.id)) {
                selectedDialogs.remove(dialog.id);
                cell.setChecked(false, true);
            } else {
                selectedDialogs.put(dialog.id, dialog);
                cell.setChecked(true, true);
            }
            updateSelectedCount();
        }
    });
    gridView.setOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateLayout();
        }
    });

    searchEmptyView = new EmptyTextProgressView(context);
    searchEmptyView.setShowAtCenter(true);
    searchEmptyView.showTextView();
    searchEmptyView.setText(LocaleController.getString("NoChats", R.string.NoChats));
    gridView.setEmptyView(searchEmptyView);
    containerView.addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT,
            LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0));

    containerView.addView(frameLayout,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP));

    shadow = new View(context);
    shadow.setBackgroundResource(R.drawable.header_shadow);
    containerView.addView(shadow,
            LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3, Gravity.TOP | Gravity.LEFT, 0, 48, 0, 0));

    updateSelectedCount();

    if (!DialogsActivity.dialogsLoaded) {
        MessagesController.getInstance().loadDialogs(0, 100, true);
        ContactsController.getInstance().checkInviteText();
        DialogsActivity.dialogsLoaded = true;
    }
    if (listAdapter.dialogs.isEmpty()) {
        NotificationCenter.getInstance().addObserver(this, NotificationCenter.dialogsNeedReload);
    }
}

From source file:co.mrktplaces.android.ui.views.smarttablayout.SmartTabLayout.java

/**
 * Create a default view to be used for tabs. This is called if a custom tab view is not set via
 * {@link #setCustomTabView(int, int)}./*  w ww. j  a v a2  s. c  om*/
 */
protected ImageView createDefaultTabView(int resource) {
    ImageView imageView = new ImageView(getContext());
    imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1));
    imageView.setImageResource(resource);
    if (tabViewBackgroundResId != NO_ID) {
        imageView.setBackgroundResource(tabViewBackgroundResId);
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // If we're running on Honeycomb or newer, then we can use the Theme's
        // selectableItemBackground to ensure that the View has a pressed state
        TypedValue outValue = new TypedValue();
        getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true);
        imageView.setBackgroundResource(outValue.resourceId);
    }

    imageView.setPadding(tabViewTextHorizontalPadding, 0, tabViewTextHorizontalPadding, 0);

    if (tabViewTextMinWidth > 0) {
        imageView.setMinimumWidth(tabViewTextMinWidth);
    }

    return imageView;
}

From source file:com.money.manager.ex.home.MainActivity.java

private void startSyncIconRotation(MenuItem item) {
    if (item == null)
        return;// w w w.j ava 2 s  . co m

    // define the animation for rotation
    Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setInterpolator(new LinearInterpolator());
    animation.setDuration(1200);
    //        animRotate = AnimationUtils.loadAnimation(this, R.anim.rotation);
    animation.setRepeatCount(Animation.INFINITE);

    ImageView imageView = new ImageView(this);
    UIHelper uiHelper = new UIHelper(this);
    imageView.setImageDrawable(
            uiHelper.getIcon(GoogleMaterial.Icon.gmd_cached).color(uiHelper.getToolbarItemColor()));
    imageView.setPadding(8, 8, 8, 8);
    //        imageView.setLayoutParams(new Toolbar.LayoutParams());

    imageView.startAnimation(animation);
    item.setActionView(imageView);
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/** initAddDestButton()
 * adds the Driving Through button/*from  w  w  w . ja v a2 s.  com*/
 */
protected void initAddDestButton() {

    //Adds/enables the FrameLayout
    AddDestFrameLayout = new FrameLayout(this);
    AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, 80));
    AddDestFrameLayout.setEnabled(true);

    //Fills the Image Icon
    ImageView destAddIcon = new ImageView(this);
    FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2));
    destAddIcon.setLayoutParams(lliDestIcon);
    destAddIcon.setPadding(0, dipToPx(5), 0, 0);
    destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through);

    //Adds the imageicon to the framelayout/enables it 
    AddDestFrameLayout.addView(destAddIcon);

    //Fills/sets the text
    TextView destAddText = new TextView(this);
    FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDest.setMargins(0, dipToPx(5), 0, 0);
    destAddText.setLayoutParams(lliDest);
    destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0);
    destAddText.setTextSize(15);
    destAddText.setText(R.string.mapViewAcField);

    //Adds the text to the framelayout
    AddDestFrameLayout.addView(destAddText);

    //Adds the framelayout to the linearlayout (in the scrollview)
    sclLayout = (LinearLayout) findViewById(R.id.sclLayout);
    sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount());

    final Button button = ((Button) findViewById(R.id.btnChooseRoute));

    //Adds a clicklistener to the frameLayout
    AddDestFrameLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //Adds a new destination field
            initDestFrameLayout();

            //Moves the button to the bottom
            setLayoutParams();

            if (checkFields() == false) {
                button.setEnabled(false);
                button.setText("Show on map");
            } else {
                mapView.getOverlays().clear();
                createMap();
            }
        }

    });
}

From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java

@Override
protected void onCreate() {
    Activity activity = getActivity();/*from  ww  w  . j  a  v a  2 s  .  c o m*/
    PullableListView listView = getListView();
    PageHolder pageHolder = getPageHolder();
    UiManager uiManager = getUiManager();
    hidePerformer = new HidePerformer();
    PostsExtra extra = getExtra();
    listView.setDivider(ResourceUtils.getDrawable(activity, R.attr.postsDivider, 0));
    ChanConfiguration.Board board = getChanConfiguration().safe().obtainBoard(pageHolder.boardName);
    if (board.allowPosting) {
        replyable = data -> getUiManager().navigator().navigatePosting(pageHolder.chanName,
                pageHolder.boardName, pageHolder.threadNumber, data);
    }
    PostsAdapter adapter = new PostsAdapter(activity, pageHolder.chanName, pageHolder.boardName, uiManager,
            replyable, hidePerformer, extra.userPostNumbers, listView);
    initAdapter(adapter, adapter);
    ImageLoader.getInstance().observable().register(this);
    listView.getWrapper().setPullSides(PullableWrapper.Side.BOTH);
    uiManager.observable().register(this);
    hidePerformer.setPostsProvider(adapter);

    Context darkStyledContext = new ContextThemeWrapper(activity, R.style.Theme_General_Main_Dark);
    searchController = new LinearLayout(darkStyledContext);
    searchController.setOrientation(LinearLayout.HORIZONTAL);
    searchController.setGravity(Gravity.CENTER_VERTICAL);
    float density = ResourceUtils.obtainDensity(getResources());
    int padding = (int) (10f * density);
    searchTextResult = new Button(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    searchTextResult.setTextSize(11f);
    if (!C.API_LOLLIPOP) {
        searchTextResult.setTypeface(null, Typeface.BOLD);
    }
    searchTextResult.setPadding((int) (14f * density), 0, (int) (14f * density), 0);
    searchTextResult.setMinimumWidth(0);
    searchTextResult.setMinWidth(0);
    searchTextResult.setOnClickListener(v -> showSearchDialog());
    searchController.addView(searchTextResult, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    ImageView backButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    backButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    backButtonView.setImageResource(obtainIcon(R.attr.actionBack));
    backButtonView.setPadding(padding, padding, padding, padding);
    backButtonView.setOnClickListener(v -> findBack());
    searchController.addView(backButtonView, (int) (48f * density), (int) (48f * density));
    ImageView forwardButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    forwardButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    forwardButtonView.setImageResource(obtainIcon(R.attr.actionForward));
    forwardButtonView.setPadding(padding, padding, padding, padding);
    forwardButtonView.setOnClickListener(v -> findForward());
    searchController.addView(forwardButtonView, (int) (48f * density), (int) (48f * density));
    if (C.API_LOLLIPOP) {
        for (int i = 0, last = searchController.getChildCount() - 1; i <= last; i++) {
            View view = searchController.getChildAt(i);
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            if (i == 0) {
                layoutParams.leftMargin = (int) (-6f * density);
            }
            if (i == last) {
                layoutParams.rightMargin = (int) (6f * density);
            } else {
                layoutParams.rightMargin = (int) (-6f * density);
            }
        }
    }

    scrollToPostNumber = pageHolder.initialPostNumber;
    FavoritesStorage.getInstance().getObservable().register(this);
    LocalBroadcastManager.getInstance(activity).registerReceiver(galleryPagerReceiver,
            new IntentFilter(C.ACTION_GALLERY_NAVIGATE_POST));
    boolean hasNewPostDatas = handleNewPostDatas();
    extra.forceRefresh = hasNewPostDatas || !pageHolder.initialFromCache;
    if (extra.cachedPosts != null && extra.cachedPostItems.size() > 0) {
        onDeserializePostsCompleteInternal(true, extra.cachedPosts, new ArrayList<>(extra.cachedPostItems),
                true);
    } else {
        deserializeTask = new DeserializePostsTask(this, pageHolder.chanName, pageHolder.boardName,
                pageHolder.threadNumber, extra.cachedPosts);
        deserializeTask.executeOnExecutor(DeserializePostsTask.THREAD_POOL_EXECUTOR);
        getListView().getWrapper().startBusyState(PullableWrapper.Side.BOTH);
        switchView(ViewType.PROGRESS, null);
    }
    pageHolder.setInitialPostsData(false, null);
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;/*  ww  w  .  j  a  v a  2  s.com*/
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}

From source file:com.mobicage.rogerthat.util.ui.SendMessageView.java

private ImageView generateImageView(final int imageButton, final int visible) {
    ImageView iv = new ImageView(mActivity);
    iv.setVisibility(visible);//from  w  w  w.  j  av  a  2 s. c o m
    final int imageResourse = getImageResourceForKey(imageButton);
    if (imageResourse != 0)
        iv.setImageResource(imageResourse);
    iv.setOnClickListener(new SafeViewOnClickListener() {
        @Override
        public void safeOnClick(View v) {
            processOnClickListenerForKey(imageButton);
        }
    });

    if (IMAGE_BUTTON_TEXT == imageButton) {
        iv.setColorFilter(UIUtils.imageColorFilter(ContextCompat.getColor(mActivity, R.color.mc_divider_gray)));
    }

    iv.setPadding(_5_DP_IN_PX, _5_DP_IN_PX, _5_DP_IN_PX, _5_DP_IN_PX);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(_30_DP_IN_PX, _30_DP_IN_PX, 1.0f);
    iv.setLayoutParams(lp);
    return iv;
}

From source file:org.egov.android.view.activity.ComplaintDetailActivity.java

/**
 * Function called when the activity was created to show the images attached
 * with the complaints Get the files from the complaint folder path and show
 * that images in horizontal scroll view
 *///  ww  w .ja v a 2s .co  m
private void _showComplaintImages() {
    File folder = new File(complaintFolderName);
    if (!folder.exists()) {
        return;
    }
    File[] listOfFiles = folder.listFiles();

    int imageidx = 0;

    for (int i = 0; i < listOfFiles.length; i++) {

        if (listOfFiles[i].isFile()) {
            Log.d("EGOV_JOB", "File path" + complaintFolderName + File.separator + listOfFiles[i].getName());

            if (listOfFiles[i].getName().startsWith("photo_")) {
                continue;
            }

            ImageView image = new ImageView(this);
            Bitmap bmp = _getBitmapImage(complaintFolderName + File.separator + listOfFiles[i].getName());
            image.setImageBitmap(bmp);
            image.setId(imageidx);
            imageidx = imageidx + 1;
            image.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent photo_viewer = new Intent(ComplaintDetailActivity.this, PhotoViewerActivity.class);
                    photo_viewer.putExtra("path", complaintFolderName);
                    photo_viewer.putExtra("complaintId", complaintId);
                    photo_viewer.putExtra("imageId", v.getId());
                    startActivity(photo_viewer);
                }
            });
            LinearLayout.LayoutParams inner_container_params = new LinearLayout.LayoutParams(_dpToPix(90),
                    _dpToPix(90));
            inner_container_params.setMargins(0, 0, 10, 0);
            image.setLayoutParams(inner_container_params);
            image.setPadding(2, 2, 2, 2);
            image.setBackgroundDrawable(getResources().getDrawable(R.drawable.edittext_border));
            image.setScaleType(ScaleType.CENTER_INSIDE);
            imageCntainer.addView(image);
        }
    }
}

From source file:gov.wa.wsdot.android.wsdot.ui.trafficmap.TrafficMapActivity.java

private void refreshOverlays(final MenuItem item) {

    // define the animation for rotation
    Animation animation = new RotateAnimation(360.0f, 0.0f, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setDuration(1000);/*from w  w  w  .j av a 2s .  co m*/
    animation.setRepeatCount(Animation.INFINITE);

    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mToolbar.getMenu().getItem(menu_item_refresh).setActionView(null);
            mToolbar.getMenu().getItem(menu_item_refresh).setIcon(R.drawable.ic_menu_refresh);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    ImageView imageView = new ImageView(this, null, android.R.style.Widget_Material_ActionButton);
    imageView.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_menu_refresh));
    imageView.setPadding(31, imageView.getPaddingTop(), 32, imageView.getPaddingBottom());
    imageView.startAnimation(animation);
    item.setActionView(imageView);

    if (mMap != null) {
        mapCameraViewModel.refreshCameras();
        mapHighwayAlertViewModel.refreshAlerts();
    }
}