Search in sources :

Example 51 with ImageButton

use of android.widget.ImageButton in project saga-android by AnandChowdhary.

the class OnClickDialog method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View mView = inflater.inflate(R.layout.dialog_on_click, container, false);
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
    final ProgressBar mProgress = (ProgressBar) mView.findViewById(R.id.progress_doc);
    mImageLoader.get(url, new ImageLoader.ImageListener() {

        @Override
        public void onResponse(ImageLoader.ImageContainer response, boolean isImmediate) {
            ((ImageView) mView.findViewById(R.id.album_iv_doc)).setImageBitmap(response.getBitmap());
        }

        @Override
        public void onErrorResponse(VolleyError error) {
        //should get a cache hit
        }
    });
    ((TextView) mView.findViewById(R.id.artist_value_tv_doc)).setText(arts);
    ((TextView) mView.findViewById(R.id.track_value_tv_doc)).setText(title);
    ImageButton mDownload = (ImageButton) mView.findViewById(R.id.download_btn_doc);
    mDownload.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            MusicDownloader.startDownload(getActivity(), title, arts, new MusicDownloader.DownloaderListener() {

                @Override
                public void showProgressBar() {
                    mProgress.setVisibility(View.VISIBLE);
                }

                @Override
                public void hideProgressBar() {
                    mProgress.setVisibility(View.GONE);
                }

                @Override
                public void onSuccess() {
                    mTracker.send(new HitBuilders.EventBuilder().setCategory("Music Download").setAction("Click").build());
                    dismiss();
                }
            });
        }
    });
    ImageButton mShare = (ImageButton) mView.findViewById(R.id.share_btn_doc);
    mShare.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mProgress.setVisibility(View.VISIBLE);
            String url = null;
            try {
                url = "http://rhythmsa.ga/api/sharable.php?q=" + URLEncoder.encode(title + " " + arts, "utf-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            StringRequest request = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {

                @Override
                public void onResponse(String response) {
                    mProgress.setVisibility(View.GONE);
                    Log.d("kthenks", response);
                    if (Patterns.WEB_URL.matcher(response).matches()) {
                        Intent i = new Intent(Intent.ACTION_SEND);
                        i.setType("text/plain");
                        i.putExtra(Intent.EXTRA_TEXT, "Hey! Check out this amazing song - " + title + " by " + arts + ". " + response + "\nShared via Saga Music app - http://getsa.ga/apk");
                        try {
                            startActivity(Intent.createChooser(i, "Share via"));
                        } catch (android.content.ActivityNotFoundException ex) {
                            Toast.makeText(getActivity(), "No application available to share song", Toast.LENGTH_SHORT).show();
                        }
                        mTracker.send(new HitBuilders.EventBuilder().setCategory("Music Share").setAction("Click").build());
                    } else
                        Toast.makeText(getActivity(), "Error in sharing", Toast.LENGTH_SHORT).show();
                    dismiss();
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    mProgress.setVisibility(View.GONE);
                    VolleyLog.d("kthenks", "Error: " + error.getMessage());
                    Toast.makeText(getActivity(), "Error connecting to the Internet", Toast.LENGTH_SHORT).show();
                    dismiss();
                }
            });
            request.setShouldCache(false);
            mQueue.add(request);
        }
    });
    return mView;
}
Also used : VolleyError(com.android.volley.VolleyError) StringRequest(com.android.volley.toolbox.StringRequest) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) TextView(android.widget.TextView) ImageLoader(com.android.volley.toolbox.ImageLoader) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 52 with ImageButton

use of android.widget.ImageButton in project saga-android by AnandChowdhary.

the class DownloadFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mRecyclerView = (RecyclerView) view.findViewById(R.id.grid_view);
    GridLayoutManager glm = new GridLayoutManager(getActivity(), 2);
    Point size = new Point();
    getActivity().getWindowManager().getDefaultDisplay().getSize(size);
    int screenWidth = size.x;
    glm.setSpanCount(screenWidth / (getResources().getDimensionPixelOffset(R.dimen.column_width_main_recyclerview)));
    mRecyclerView.setLayoutManager(glm);
    mProgress = (ProgressBar) view.findViewById(R.id.progressBar);
    mInput = (EditText) view.findViewById(R.id.et_input);
    mInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                processQuery(textView.getText().toString());
                return true;
            }
            return false;
        }
    });
    ImageButton downloadBtn = (ImageButton) view.findViewById(R.id.btn_download);
    downloadBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            processQuery(mInput.getText().toString());
        }
    });
    getCharts();
    Updater.checkForUpdates(getActivity(), false);
}
Also used : KeyEvent(android.view.KeyEvent) ImageButton(android.widget.ImageButton) GridLayoutManager(android.support.v7.widget.GridLayoutManager) TextView(android.widget.TextView) Point(android.graphics.Point) NetworkImageView(com.android.volley.toolbox.NetworkImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Point(android.graphics.Point)

Example 53 with ImageButton

use of android.widget.ImageButton in project AndroidChromium by JackyAndroid.

the class AppMenuDragHelper method menuItemAction.

/**
     * Performs the specified action on the menu item specified by the screen coordinate position.
     * @param screenX X in screen space coordinate.
     * @param screenY Y in screen space coordinate.
     * @param action  Action type to perform, it should be one of ITEM_ACTION_* constants.
     * @return true whether or not a menu item is performed (executed).
     */
private boolean menuItemAction(int screenX, int screenY, int action) {
    ListView listView = mAppMenu.getPopup().getListView();
    // Starting M, we have a popup menu animation that slides down. If we process dragging
    // events while it's sliding, it will touch many views that are passing by user's finger,
    // which is not desirable. So we only process when the first item is below the menu button.
    // Unfortunately, there is no available listener for sliding animation finished. Thus the
    // following nasty heuristics.
    final View firstRow = listView.getChildAt(0);
    if (listView.getFirstVisiblePosition() == 0 && firstRow != null && firstRow.getTop() == 0 && getScreenVisibleRect(firstRow).bottom <= mMenuButtonScreenCenterY) {
        return false;
    }
    ArrayList<View> itemViews = new ArrayList<View>();
    for (int i = 0; i < listView.getChildCount(); ++i) {
        boolean hasImageButtons = false;
        if (listView.getChildAt(i) instanceof LinearLayout) {
            LinearLayout layout = (LinearLayout) listView.getChildAt(i);
            for (int j = 0; j < layout.getChildCount(); ++j) {
                itemViews.add(layout.getChildAt(j));
                if (layout.getChildAt(j) instanceof ImageButton)
                    hasImageButtons = true;
            }
        }
        if (!hasImageButtons)
            itemViews.add(listView.getChildAt(i));
    }
    boolean didPerformClick = false;
    for (int i = 0; i < itemViews.size(); ++i) {
        View itemView = itemViews.get(i);
        boolean shouldPerform = itemView.isEnabled() && itemView.isShown() && getScreenVisibleRect(itemView).contains(screenX, screenY);
        switch(action) {
            case ITEM_ACTION_HIGHLIGHT:
                itemView.setPressed(shouldPerform);
                break;
            case ITEM_ACTION_PERFORM:
                if (shouldPerform) {
                    RecordUserAction.record("MobileUsingMenuBySwButtonDragging");
                    itemView.performClick();
                    didPerformClick = true;
                }
                break;
            case ITEM_ACTION_CLEAR_HIGHLIGHT_ALL:
                itemView.setPressed(false);
                break;
            default:
                assert false;
                break;
        }
    }
    return didPerformClick;
}
Also used : ImageButton(android.widget.ImageButton) ListView(android.widget.ListView) ArrayList(java.util.ArrayList) View(android.view.View) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout)

Example 54 with ImageButton

use of android.widget.ImageButton in project AndroidChromium by JackyAndroid.

the class EmptyBackgroundViewTablet method setMenuOnTouchListener.

/**
     * Creates an on touch listener for the menu button using the given menu handler.
     * @param menuHandler The menu handler to be used for showing the pop up menu.
     */
public void setMenuOnTouchListener(final AppMenuHandler menuHandler) {
    final ImageButton menuBtn = (ImageButton) findViewById(R.id.empty_menu_button);
    final AppMenuButtonHelper menuPopupButtonHelper = new AppMenuButtonHelper(menuHandler);
    menuBtn.setOnTouchListener(menuPopupButtonHelper);
    menuPopupButtonHelper.setOnAppMenuShownListener(new Runnable() {

        @Override
        public void run() {
            RecordUserAction.record("MobileToolbarShowMenu");
        }
    });
}
Also used : AppMenuButtonHelper(org.chromium.chrome.browser.appmenu.AppMenuButtonHelper) ImageButton(android.widget.ImageButton)

Example 55 with ImageButton

use of android.widget.ImageButton in project AndroidChromium by JackyAndroid.

the class CustomTabBottomBarDelegate method updateBottomBarButtons.

/**
     * Updates the custom buttons on bottom bar area.
     * @param params The {@link CustomButtonParams} that describes the button to update.
     */
public void updateBottomBarButtons(CustomButtonParams params) {
    ImageButton button = (ImageButton) getBottomBarView().findViewById(params.getId());
    button.setContentDescription(params.getDescription());
    button.setImageDrawable(params.getIcon(mActivity.getResources()));
}
Also used : ImageButton(android.widget.ImageButton)

Aggregations

ImageButton (android.widget.ImageButton)158 View (android.view.View)112 TextView (android.widget.TextView)87 ImageView (android.widget.ImageView)55 Button (android.widget.Button)27 ListView (android.widget.ListView)25 AdapterView (android.widget.AdapterView)24 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)21 Intent (android.content.Intent)19 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)12 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7