mirror of https://github.com/kurisufriend/Clover
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.
34 lines
1004 B
34 lines
1004 B
package org.floens.chan.utils;
|
|
|
|
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) {
|
|
TypedArray arr = view.getContext().obtainStyledAttributes(
|
|
new int[] {android.R.attr.selectableItemBackground});
|
|
|
|
Drawable drawable = arr.getDrawable(0);
|
|
|
|
view.setBackgroundDrawable(drawable);
|
|
|
|
arr.recycle();
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|
|
|