use of android.support.v7.app.ActionBarActivity 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));
}
use of android.support.v7.app.ActionBarActivity in project UltimateAndroid by cymcsg.
the class MaterialMenuIconCompat method setActionBarSettings.
@Override
protected void setActionBarSettings(Activity activity) {
ActionBar actionBar = ((ActionBarActivity) activity).getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setIcon(getDrawable());
}
use of android.support.v7.app.ActionBarActivity in project HoloEverywhere by Prototik.
the class ActionBarImplBase method init.
private void init(ActionBarActivity activity) {
mOverlayLayout = (ActionBarOverlayLayout) activity.findViewById(R.id.action_bar_overlay_layout);
if (mOverlayLayout != null) {
mOverlayLayout.setActionBar(this);
}
mActionView = (ActionBarView) activity.findViewById(R.id.action_bar);
mContextView = (ActionBarContextView) activity.findViewById(R.id.action_context_bar);
mContainerView = (ActionBarContainer) activity.findViewById(R.id.action_bar_container);
mTopVisibilityView = (ViewGroup) activity.findViewById(R.id.top_action_bar);
if (mTopVisibilityView == null) {
mTopVisibilityView = mContainerView;
}
mSplitView = (ActionBarContainer) activity.findViewById(R.id.split_action_bar);
if (mActionView == null || mContextView == null || mContainerView == null) {
throw new IllegalStateException(getClass().getSimpleName() + " can only be used " + "with a compatible window decor layout");
}
mActionView.setContextView(mContextView);
mContextDisplayMode = mActionView.isSplitActionBar() ? CONTEXT_DISPLAY_SPLIT : CONTEXT_DISPLAY_NORMAL;
// This was initially read from the action bar style
final int current = mActionView.getDisplayOptions();
final boolean homeAsUp = (current & DISPLAY_HOME_AS_UP) != 0;
if (homeAsUp) {
mDisplayHomeAsUpSet = true;
}
ActionBarPolicy abp = ActionBarPolicy.get(mContext);
setHomeButtonEnabled(abp.enableHomeButtonByDefault() || homeAsUp);
setHasEmbeddedTabs(abp.hasEmbeddedTabs());
setTitle(mActivity.getTitle());
}
use of android.support.v7.app.ActionBarActivity in project BlurDialogFragment by tvbarthel.
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, 0 if the actionBar should be blurred.
int actionBarHeight;
if (mBlurredActionBar) {
actionBarHeight = 0;
} else {
actionBarHeight = getActionBarHeight();
}
//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();
}
// on content bellow the status.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && isStatusBarTranslucent()) {
statusBarHeight = 0;
}
final int topOffset = actionBarHeight + statusBarHeight;
// evaluate bottom or right offset due to navigation bar.
int bottomOffset = 0;
int rightOffset = 0;
final int navBarSize = getNavigationBarOffset();
if (mHoldingActivity.getResources().getBoolean(R.bool.blur_dialog_has_bottom_navigation_bar)) {
bottomOffset = navBarSize;
} else {
rightOffset = navBarSize;
}
//add offset to the source boundaries since we don't want to blur actionBar pixels
Rect srcRect = new Rect(0, topOffset, bkg.getWidth() - rightOffset, 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.
double height = Math.ceil((view.getHeight() - topOffset - bottomOffset) / mDownScaleFactor);
double width = Math.ceil(((view.getWidth() - rightOffset) * height / (view.getHeight() - topOffset - bottomOffset)));
// Render script doesn't work with RGB_565
if (mUseRenderScript) {
overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.ARGB_8888);
} else {
overlay = Bitmap.createBitmap((int) width, (int) height, Bitmap.Config.RGB_565);
}
try {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB || mHoldingActivity instanceof ActionBarActivity || mHoldingActivity instanceof AppCompatActivity) {
//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;
}
} catch (NoClassDefFoundError e) {
// no dependency to appcompat, that means no additional top offset due to actionBar.
mBlurredBackgroundLayoutParams.setMargins(0, 0, 0, 0);
}
//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
if (mUseRenderScript) {
overlay = RenderScriptBlurHelper.doBlur(overlay, mBlurRadius, true, mHoldingActivity);
} else {
overlay = FastBlurHelper.doBlur(overlay, mBlurRadius, true);
}
if (mDebugEnable) {
String blurTime = (System.currentTimeMillis() - startMs) + " ms";
Log.d(TAG, "Blur method : " + (mUseRenderScript ? "RenderScript" : "FastBlur"));
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 (blurred bitmap)" + (!mUseRenderScript ? " + temp buff " + overlay.getRowBytes() + "ko." : "."));
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.setScaleType(ImageView.ScaleType.CENTER_CROP);
mBlurredBackgroundView.setImageDrawable(new BitmapDrawable(mHoldingActivity.getResources(), overlay));
}
use of android.support.v7.app.ActionBarActivity in project easy by MehdiBenmesa.
the class RendeVousFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar3);
((ActionBarActivity) getActivity()).setSupportActionBar(toolbar);
((ActionBarActivity) getActivity()).getSupportActionBar().setTitle("Chercher un enseignant");
toolbar.setTitleTextColor(Color.parseColor("#FFFFFF"));
lstView = (RecyclerView) getActivity().findViewById(R.id.lstView);
/*ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, lstSource);
lstView.setAdapter(adapter);*/
getTeachers();
searcheView = (MaterialSearchView) getActivity().findViewById(R.id.searche_view);
searcheView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {
@Override
public void onSearchViewShown() {
}
@Override
public void onSearchViewClosed() {
lstView = (RecyclerView) getActivity().findViewById(R.id.lstView);
/*ArrayAdapter adapter = new ArrayAdapter(RendeVous.this, android.R.layout.simple_list_item_1, lstSource);
lstView.setAdapter(adapter);*/
getTeachers();
}
});
searcheView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (newText != null && !newText.isEmpty()) {
/*List<String> lstFound = new ArrayList<String>();
for (String item:lstSource) {
if (item.contains(newText)) {
lstFound.add(item);
}
}
ArrayAdapter adapter = new ArrayAdapter(RendeVous.this, android.R.layout.simple_list_item_1, lstFound);
//lstView.setAdapter(adapter);*/
getTeachersSearcheed(newText);
} else {
/*ArrayAdapter adapter = new ArrayAdapter(RendeVous.this, android.R.layout.simple_list_item_1, lstSource);
//lstView.setAdapter(adapter);*/
getTeachers();
}
return true;
}
});
}
Aggregations