use of android.support.v7.app.ActionBar in project UltimateAndroid by cymcsg.
the class DemoOfUiActivity method initViews.
private void initViews() {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
// actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
actionBar.setHomeButtonEnabled(true);
// actionBar.setDisplayShowHomeEnabled(false);
mPlanetTitles = getResources().getStringArray(R.array.items_name);
mTitle = mDrawerTitle = getTitle();
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
getSupportActionBar().setTitle(mTitle);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
getSupportActionBar().setTitle(mDrawerTitle);
// creates call to onPrepareOptionsMenu()
invalidateOptionsMenu();
}
};
// Set the drawer toggle as the DrawerListener
Logs.d("mDrawerLayout " + (mDrawerLayout != null) + " " + "mDrawerToggle " + (mDrawerToggle != null));
mDrawerLayout.setDrawerListener(mDrawerToggle);
//mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.CLIP_VERTICAL);
//mDrawerLayout.setScrimColor(getResources().getColor(R.color.babyBlueColor));
// mDrawerList.setAdapter(new ArrayAdapter<String>(this,
// R.layout.left_menu, mPlanetTitles));
//mDrawerList.setAdapter(new SimpleAdapter(this,null,R.layout.left_menu_layout,null,null));
mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.left_menu_layout, mPlanetTitles));
// Set the list's click listener
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
// getSupportParentActivityIntent();
}
use of android.support.v7.app.ActionBar in project UltimateAndroid by cymcsg.
the class BlurNavigationDrawerActivity method restoreActionBar.
public void restoreActionBar() {
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(mTitle);
}
use of android.support.v7.app.ActionBar in project UltimateAndroid by cymcsg.
the class DynamicGridActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dynamic_grid_view_activity_grid);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
gridView = (DynamicGridView) findViewById(R.id.dynamic_grid_view);
gridView.setAdapter(new CheeseDynamicAdapter(this, new ArrayList<String>(Arrays.asList(Cheeses.sCheeseStrings)), 3));
gridView.setVerticalScrollBarEnabled(false);
// gridView.setEnabled(false);
// add callback to stop edit mode if needed
gridView.setOnDropListener(new DynamicGridView.OnDropListener() {
@Override
public void onActionDrop() {
gridView.stopEditMode();
}
});
// gridView.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// if (gridView.isEditMode()) {
// gridView.stopEditMode();
// }
// return false;
// }
// });
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
gridView.startEditMode();
return false;
}
});
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(DynamicGridActivity.this, parent.getAdapter().getItem(position).toString() + " " + gridView.isEditMode(), Toast.LENGTH_SHORT).show();
}
});
}
use of android.support.v7.app.ActionBar in project UltimateAndroid by cymcsg.
the class CoolDragAndDropActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cooldrag_drop_activity);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
ScrollView scrollView = (ScrollView) findViewById(R.id.scrollView);
mCoolDragAndDropGridView = (CoolDragAndDropGridView) findViewById(R.id.coolDragAndDropGridView);
for (int r = 0; r < 2; r++) {
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_airport_highlighted, 1, "Airport", "Heathrow"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_bar_highlighted, 2, "Bar", "Connaught Bar"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_drink_highlighted, 2, "Drink", "Tequila"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_eat_highlighted, 2, "Eat", "Sliced Steaks"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_florist_highlighted, 1, "Florist", "Roses"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_gas_station_highlighted, 3, "Gas station", "QuickChek"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_general_highlighted, 1, "General", "Service Station"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_grocery_store_highlighted, 1, "Grocery", "E-Z-Mart"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_pizza_highlighted, 1, "Pizza", "Pizza Hut"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_post_office_highlighted, 2, "Post office", "USPS"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_see_highlighted, 2, "See", "Tower Bridge"));
mItems.add(new Item(R.drawable.cool_drag_drop_ic_local_search_shipping_service_highlighted, 3, "Shipping service", "Celio*"));
}
mItemAdapter = new ItemAdapter(this, mItems);
mCoolDragAndDropGridView.setAdapter(mItemAdapter);
mCoolDragAndDropGridView.setScrollingStrategy(new SimpleScrollingStrategy(scrollView));
mCoolDragAndDropGridView.setDragAndDropListener(this);
mCoolDragAndDropGridView.setOnItemLongClickListener(this);
}
use of android.support.v7.app.ActionBar in project UltimateAndroid by cymcsg.
the class BlurDialogEngine method blur.
/**
* Blur the given bitmap and add it to the activity.
*
* @param bkg should be a bitmap of the background.
* @param view background view.
*/
private void blur(Bitmap bkg, View view) {
long startMs = System.currentTimeMillis();
//define layout params to the previous imageView in order to match its parent
mBlurredBackgroundLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
//overlay used to build scaled preview and blur background
Bitmap overlay = null;
//evaluate top offset due to action bar
int actionBarHeight = 0;
try {
if (mHoldingActivity instanceof ActionBarActivity) {
ActionBar supportActionBar = ((ActionBarActivity) mHoldingActivity).getSupportActionBar();
if (supportActionBar != null) {
actionBarHeight = supportActionBar.getHeight();
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
android.app.ActionBar actionBar = mHoldingActivity.getActionBar();
if (actionBar != null) {
actionBarHeight = actionBar.getHeight();
}
}
} catch (NoClassDefFoundError e) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
android.app.ActionBar actionBar = mHoldingActivity.getActionBar();
if (actionBar != null) {
actionBarHeight = actionBar.getHeight();
}
}
}
//evaluate top offset due to status bar
int statusBarHeight = 0;
if ((mHoldingActivity.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0) {
//not in fullscreen mode
statusBarHeight = getStatusBarHeight();
}
final int topOffset = actionBarHeight + statusBarHeight;
final int bottomOffset = getNavigationBarOffset();
//add offset to the source boundaries since we don't want to blur actionBar pixels
Rect srcRect = new Rect(0, actionBarHeight + statusBarHeight, bkg.getWidth(), bkg.getHeight() - bottomOffset);
//in order to keep the same ratio as the one which will be used for rendering, also
//add the offset to the overlay.
overlay = Bitmap.createBitmap((int) ((view.getWidth()) / mDownScaleFactor), (int) ((view.getMeasuredHeight() - topOffset - bottomOffset) / mDownScaleFactor), Bitmap.Config.RGB_565);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || mHoldingActivity instanceof ActionBarActivity) {
//add offset as top margin since actionBar height must also considered when we display
// the blurred background. Don't want to draw on the actionBar.
mBlurredBackgroundLayoutParams.setMargins(0, actionBarHeight, 0, 0);
mBlurredBackgroundLayoutParams.gravity = Gravity.TOP;
}
//scale and draw background view on the canvas overlay
Canvas canvas = new Canvas(overlay);
Paint paint = new Paint();
paint.setFlags(Paint.FILTER_BITMAP_FLAG);
//build drawing destination boundaries
final RectF destRect = new RectF(0, 0, overlay.getWidth(), overlay.getHeight());
//draw background from source area in source background to the destination area on the overlay
canvas.drawBitmap(bkg, srcRect, destRect, paint);
//apply fast blur on overlay
overlay = FastBlurHelper.doBlur(overlay, mBlurRadius, false);
if (mDebudEnable) {
String blurTime = (System.currentTimeMillis() - startMs) + " ms";
//display information in LogCat
Log.d(TAG, "Radius : " + mBlurRadius);
Log.d(TAG, "Down Scale Factor : " + mDownScaleFactor);
Log.d(TAG, "Blurred achieved in : " + blurTime);
Log.d(TAG, "Allocation : " + bkg.getRowBytes() + "ko (screen capture) + " + overlay.getRowBytes() + "ko (FastBlur)");
//display blurring time directly on screen
Rect bounds = new Rect();
Canvas canvas1 = new Canvas(overlay);
paint.setColor(Color.BLACK);
paint.setAntiAlias(true);
paint.setTextSize(20.0f);
paint.getTextBounds(blurTime, 0, blurTime.length(), bounds);
canvas1.drawText(blurTime, 2, bounds.height(), paint);
}
//set bitmap in an image view for final rendering
mBlurredBackgroundView = new ImageView(mHoldingActivity);
mBlurredBackgroundView.setImageDrawable(new BitmapDrawable(mHoldingActivity.getResources(), overlay));
}
Aggregations