Search in sources :

Example 1 with ActionBarActivity

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));
}
Also used : Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) Paint(android.graphics.Paint) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Paint(android.graphics.Paint) ActionBarActivity(android.support.v7.app.ActionBarActivity) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) ActionBar(android.support.v7.app.ActionBar)

Example 2 with ActionBarActivity

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());
}
Also used : ActionBarActivity(android.support.v7.app.ActionBarActivity) ActionBar(android.support.v7.app.ActionBar)

Example 3 with ActionBarActivity

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());
}
Also used : ActionBarPolicy(android.support.v7.internal.view.ActionBarPolicy)

Example 4 with ActionBarActivity

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));
}
Also used : Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) AppCompatActivity(android.support.v7.app.AppCompatActivity) Paint(android.graphics.Paint) BitmapDrawable(android.graphics.drawable.BitmapDrawable) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) ActionBarActivity(android.support.v7.app.ActionBarActivity) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView)

Example 5 with ActionBarActivity

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;
        }
    });
}
Also used : ActionBarActivity(android.support.v7.app.ActionBarActivity) MaterialSearchView(com.miguelcatalan.materialsearchview.MaterialSearchView) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ActionBarActivity (android.support.v7.app.ActionBarActivity)4 Bitmap (android.graphics.Bitmap)2 Canvas (android.graphics.Canvas)2 Paint (android.graphics.Paint)2 Rect (android.graphics.Rect)2 RectF (android.graphics.RectF)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 ActionBar (android.support.v7.app.ActionBar)2 FrameLayout (android.widget.FrameLayout)2 ImageView (android.widget.ImageView)2 SuppressLint (android.annotation.SuppressLint)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 ActionBarPolicy (android.support.v7.internal.view.ActionBarPolicy)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 MaterialSearchView (com.miguelcatalan.materialsearchview.MaterialSearchView)1