use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.
the class FoldingDrawerLayoutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.folding_drawer_activity_drawer);
mTitle = mDrawerTitle = getTitle();
mAnimalTitles = getResources().getStringArray(R.array.items_name);
mDrawerLayout = (FoldingDrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
// mFoldLayout = (FoldingNavigationLayout)findViewById(R.id.fold_view);
// mFoldLayout.setBackgroundColor(Color.BLACK);
// set a custom shadow that overlays the main content when the drawer
// opens
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
// set up the drawer's list view with items and click listener
mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.left_menu_layout, mAnimalTitles));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mItemSelectedListener = new ItemSelectedListener();
// enable ActionBar app icon to behave as action to toggle nav drawer
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close) {
/* "close drawer" description for accessibility */
@SuppressLint("NewApi")
public void onDrawerClosed(View view) {
getSupportActionBar().setTitle(mTitle);
if (IS_HONEYCOMB) {
// creates call to
invalidateOptionsMenu();
// onPrepareOptionsMenu()
}
}
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@SuppressLint("NewApi")
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
if (IS_HONEYCOMB) {
// creates call to
invalidateOptionsMenu();
// onPrepareOptionsMenu()
}
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
if (savedInstanceState == null) {
selectItem(0);
}
// try {
// mDrawerLayout.getFoldingLayout(mDrawerList).setNumberOfFolds(
// numOfFolder);
// } catch (Exception e) {
// e.printStackTrace();
// Logs.e(e, "" + (mDrawerLayout != null) + " " + (mDrawerList != null)
// + " " + (mDrawerLayout.getFoldingLayout(mDrawerList) != null));
// }
HandlerUtils.sendMessageHandlerDelay(getNumHandler, 0, 1000);
}
use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.
the class AnimationFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = (QuickReturnListView) getListView();
mQuickReturnView.setText("Animation");
mListView.addHeaderView(mHeader);
String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };
setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.quick_return_listview_list_item, R.id.text1, array));
mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mQuickReturnHeight = mQuickReturnView.getHeight();
mListView.computeScrollY();
mCachedVerticalScrollRange = mListView.getListHeight();
}
});
mListView.setOnScrollListener(new OnScrollListener() {
@SuppressLint("NewApi")
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
mScrollY = 0;
int translationY = 0;
if (mListView.scrollYIsComputed()) {
mScrollY = mListView.getComputedScrollY();
}
rawY = mPlaceHolder.getTop() - Math.min(mCachedVerticalScrollRange - mListView.getHeight(), mScrollY);
switch(mState) {
case STATE_OFFSCREEN:
if (rawY <= mMinRawY) {
mMinRawY = rawY;
} else {
mState = STATE_RETURNING;
}
translationY = rawY;
break;
case STATE_ONSCREEN:
if (rawY < -mQuickReturnHeight) {
System.out.println("test3");
mState = STATE_OFFSCREEN;
mMinRawY = rawY;
}
translationY = rawY;
break;
case STATE_RETURNING:
if (translationY > 0) {
translationY = 0;
mMinRawY = rawY - mQuickReturnHeight;
} else if (rawY > 0) {
mState = STATE_ONSCREEN;
translationY = rawY;
} else if (translationY < -mQuickReturnHeight) {
mState = STATE_OFFSCREEN;
mMinRawY = rawY;
} else if (mQuickReturnView.getTranslationY() != 0 && !noAnimation) {
noAnimation = true;
anim = new TranslateAnimation(0, 0, -mQuickReturnHeight, 0);
anim.setFillAfter(true);
anim.setDuration(250);
mQuickReturnView.startAnimation(anim);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
noAnimation = false;
mMinRawY = rawY;
mState = STATE_EXPANDED;
}
});
}
break;
case STATE_EXPANDED:
if (rawY < mMinRawY - 2 && !noAnimation) {
noAnimation = true;
anim = new TranslateAnimation(0, 0, 0, -mQuickReturnHeight);
anim.setFillAfter(true);
anim.setDuration(250);
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
noAnimation = false;
mState = STATE_OFFSCREEN;
}
});
mQuickReturnView.startAnimation(anim);
} else if (translationY > 0) {
translationY = 0;
mMinRawY = rawY - mQuickReturnHeight;
} else if (rawY > 0) {
mState = STATE_ONSCREEN;
translationY = rawY;
} else if (translationY < -mQuickReturnHeight) {
mState = STATE_OFFSCREEN;
mMinRawY = rawY;
} else {
mMinRawY = rawY;
}
}
/** this can be used if the build is below honeycomb **/
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
anim = new TranslateAnimation(0, 0, translationY, translationY);
anim.setFillAfter(true);
anim.setDuration(0);
mQuickReturnView.startAnimation(anim);
} else {
mQuickReturnView.setTranslationY(translationY);
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
});
}
use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.
the class BottomFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mListView = (QuickReturnListView) getListView();
String[] array = new String[] { "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android", "Android" };
setListAdapter(new ArrayAdapter<String>(getActivity(), R.layout.quick_return_listview_list_item, R.id.text1, array));
mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
mQuickReturnHeight = mQuickReturnView.getHeight();
mListView.computeScrollY();
}
});
mListView.setOnScrollListener(new OnScrollListener() {
@SuppressLint("NewApi")
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
mScrollY = 0;
int translationY = 0;
if (mListView.scrollYIsComputed()) {
mScrollY = mListView.getComputedScrollY();
}
int rawY = mScrollY;
switch(mState) {
case STATE_OFFSCREEN:
if (rawY >= mMinRawY) {
mMinRawY = rawY;
} else {
mState = STATE_RETURNING;
}
translationY = rawY;
break;
case STATE_ONSCREEN:
if (rawY > mQuickReturnHeight) {
mState = STATE_OFFSCREEN;
mMinRawY = rawY;
}
translationY = rawY;
break;
case STATE_RETURNING:
translationY = (rawY - mMinRawY) + mQuickReturnHeight;
System.out.println(translationY);
if (translationY < 0) {
translationY = 0;
mMinRawY = rawY + mQuickReturnHeight;
}
if (rawY == 0) {
mState = STATE_ONSCREEN;
translationY = 0;
}
if (translationY > mQuickReturnHeight) {
mState = STATE_OFFSCREEN;
mMinRawY = rawY;
}
break;
}
/** this can be used if the build is below honeycomb **/
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.HONEYCOMB) {
anim = new TranslateAnimation(0, 0, translationY, translationY);
anim.setFillAfter(true);
anim.setDuration(0);
mQuickReturnView.startAnimation(anim);
} else {
mQuickReturnView.setTranslationY(translationY);
}
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
});
}
use of android.annotation.SuppressLint in project UltimateAndroid by cymcsg.
the class Blur method fastblur.
@SuppressLint("NewApi")
public static Bitmap fastblur(Context context, Bitmap sentBitmap, int radius, boolean canReuseInBitmap) {
if (VERSION.SDK_INT > 16) {
Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
final RenderScript rs = RenderScript.create(context);
final Allocation input = Allocation.createFromBitmap(rs, sentBitmap, Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
final Allocation output = Allocation.createTyped(rs, input.getType());
final ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
script.setRadius(radius);
script.setInput(input);
script.forEach(output);
output.copyTo(bitmap);
return bitmap;
}
// Stack Blur Algorithm by Mario Klingemann <mario@quasimondo.com>
Bitmap bitmap;
if (canReuseInBitmap) {
bitmap = sentBitmap;
} else {
bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);
}
if (radius < 1) {
return (null);
}
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int[] pix = new int[w * h];
bitmap.getPixels(pix, 0, w, 0, 0, w, h);
int wm = w - 1;
int hm = h - 1;
int wh = w * h;
int div = radius + radius + 1;
int[] r = new int[wh];
int[] g = new int[wh];
int[] b = new int[wh];
int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
int[] vmin = new int[Math.max(w, h)];
int divsum = (div + 1) >> 1;
divsum *= divsum;
int[] dv = new int[256 * divsum];
for (i = 0; i < 256 * divsum; i++) {
dv[i] = (i / divsum);
}
yw = yi = 0;
int[][] stack = new int[div][3];
int stackpointer;
int stackstart;
int[] sir;
int rbs;
int r1 = radius + 1;
int routsum, goutsum, boutsum;
int rinsum, ginsum, binsum;
for (y = 0; y < h; y++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
for (i = -radius; i <= radius; i++) {
p = pix[yi + Math.min(wm, Math.max(i, 0))];
sir = stack[i + radius];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rbs = r1 - Math.abs(i);
rsum += sir[0] * rbs;
gsum += sir[1] * rbs;
bsum += sir[2] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
}
stackpointer = radius;
for (x = 0; x < w; x++) {
r[yi] = dv[rsum];
g[yi] = dv[gsum];
b[yi] = dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (y == 0) {
vmin[x] = Math.min(x + radius + 1, wm);
}
p = pix[yw + vmin[x]];
sir[0] = (p & 0xff0000) >> 16;
sir[1] = (p & 0x00ff00) >> 8;
sir[2] = (p & 0x0000ff);
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[(stackpointer) % div];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi++;
}
yw += w;
}
for (x = 0; x < w; x++) {
rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
yp = -radius * w;
for (i = -radius; i <= radius; i++) {
yi = Math.max(0, yp) + x;
sir = stack[i + radius];
sir[0] = r[yi];
sir[1] = g[yi];
sir[2] = b[yi];
rbs = r1 - Math.abs(i);
rsum += r[yi] * rbs;
gsum += g[yi] * rbs;
bsum += b[yi] * rbs;
if (i > 0) {
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
} else {
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
}
if (i < hm) {
yp += w;
}
}
yi = x;
stackpointer = radius;
for (y = 0; y < h; y++) {
// Preserve alpha channel: ( 0xff000000 & pix[yi] )
pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];
rsum -= routsum;
gsum -= goutsum;
bsum -= boutsum;
stackstart = stackpointer - radius + div;
sir = stack[stackstart % div];
routsum -= sir[0];
goutsum -= sir[1];
boutsum -= sir[2];
if (x == 0) {
vmin[y] = Math.min(y + r1, hm) * w;
}
p = x + vmin[y];
sir[0] = r[p];
sir[1] = g[p];
sir[2] = b[p];
rinsum += sir[0];
ginsum += sir[1];
binsum += sir[2];
rsum += rinsum;
gsum += ginsum;
bsum += binsum;
stackpointer = (stackpointer + 1) % div;
sir = stack[stackpointer];
routsum += sir[0];
goutsum += sir[1];
boutsum += sir[2];
rinsum -= sir[0];
ginsum -= sir[1];
binsum -= sir[2];
yi += w;
}
}
bitmap.setPixels(pix, 0, w, 0, 0, w, h);
return (bitmap);
}
use of android.annotation.SuppressLint in project AntennaPod by AntennaPod.
the class ItemDescriptionFragment method onCreate.
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "Creating fragment");
Bundle args = getArguments();
saveState = args.getBoolean(ARG_SAVE_STATE, false);
highlightTimecodes = args.getBoolean(ARG_HIGHLIGHT_TIMECODES, false);
}
Aggregations