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;
}
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);
}
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;
}
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");
}
});
}
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()));
}
Aggregations