You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Clover/Chan/src/org/floens/chan/utils/Utils.java

40 lines
1.2 KiB

package org.floens.chan.utils;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
public class Utils {
/**
* Sets the android.R.attr.selectableItemBackground as background drawable on the view.
* @param view
*/
@SuppressWarnings("deprecation")
public static void setPressedDrawable(View view) {
Drawable drawable = Utils.getSelectableBackgroundDrawable(view.getContext());
view.setBackgroundDrawable(drawable);
}
public static Drawable getSelectableBackgroundDrawable(Context context) {
TypedArray arr = context.obtainStyledAttributes(
new int[] {android.R.attr.selectableItemBackground});
Drawable drawable = arr.getDrawable(0);
arr.recycle();
return drawable;
}
/**
* Causes the runnable to be added to the message queue.
* The runnable will be run on the ui thread.
* @param runnable
*/
public static void runOnUiThread(Runnable runnable) {
new Handler(Looper.getMainLooper()).post(runnable);
}
}