Android Open Source - scanNedit Action Bar_three






From Project

Back to project page scanNedit.

License

The source code is released under:

MIT License

If you think the Android project scanNedit listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.markupartist.android.widget;
/*from ww w .  j  a v  a 2s  .c  o m*/
import java.util.LinkedList;

import com.markupartist.android.widget.actionbar.R;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class ActionBar_three extends RelativeLayout implements OnClickListener {

    private LayoutInflater mInflater;
    private RelativeLayout mBarView;
    private ImageView mLogoView;
    private View mBackIndicator;
    //private View mHomeView;
    private TextView mTitleView;
    private LinearLayout mActionsView;
    private ImageButton mHomeBtn;
    private RelativeLayout mHomeLayout;
    private ProgressBar mProgress;

    public ActionBar_three(Context context, AttributeSet attrs) {
        super(context, attrs);

        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        mBarView = (RelativeLayout) mInflater.inflate(R.layout.actionbar_three, null);
        addView(mBarView);

        mLogoView = (ImageView) mBarView.findViewById(R.id.actionbar_home_logo);
        mHomeLayout = (RelativeLayout) mBarView.findViewById(R.id.actionbar_home_bg);
        mHomeBtn = (ImageButton) mBarView.findViewById(R.id.actionbar_home_btn);
        mBackIndicator = mBarView.findViewById(R.id.actionbar_home_is_back);

        mTitleView = (TextView) mBarView.findViewById(R.id.actionbar_title);
        mActionsView = (LinearLayout) mBarView.findViewById(R.id.actionbar_actions);
        
        mProgress = (ProgressBar) mBarView.findViewById(R.id.actionbar_progress);

        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.ActionBar_three);
        CharSequence title = a.getString(R.styleable.ActionBar_title);
        if (title != null) {
            setTitle_three(title);
        }
        a.recycle();
    }

   
    
    //second class
    public void setHomeAction_three(Action_three action) {
        //mHomeBtn.setOnClickListener(this);
        //mHomeBtn.setTag(action);
        //mHomeBtn.setImageResource(action.getDrawable_three());
        //mHomeLayout.setVisibility(View.VISIBLE);
    }

    public void clearHomeAction_three() {
        mHomeLayout.setVisibility(View.GONE);
    }

    /**
     * Shows the provided logo to the left in the action bar.
     * 
     * This is ment to be used instead of the setHomeAction and does not draw
     * a divider to the left of the provided logo.
     * 
     * @param resId The drawable resource id
     */
    public void setHomeLogo_three(int resId) {
        // TODO: Add possibility to add an IntentAction as well.
        mLogoView.setImageResource(resId);
        mLogoView.setVisibility(View.VISIBLE);
        mHomeLayout.setVisibility(View.GONE);
    }

    /* Emulating Honeycomb, setdisplayHomeAsUpEnabled takes a boolean
     * and toggles whether the "home" view should have a little triangle
     * indicating "up" */
    public void setDisplayHomeAsUpEnabled_three(boolean show) {
        mBackIndicator.setVisibility(show? View.VISIBLE : View.GONE);
    }


    public void setTitle_three(CharSequence title) {
        mTitleView.setText(title);
    }

    public void setTitle_three(int resid) {
        mTitleView.setText(resid);
    }

    /**
     * Set the enabled state of the progress bar.
     * 
     * @param One of {@link View#VISIBLE}, {@link View#INVISIBLE},
     *   or {@link View#GONE}.
     */
    public void setProgressBarVisibility_three(int visibility) {
        mProgress.setVisibility(visibility);
    }

    /**
     * Returns the visibility status for the progress bar.
     * 
     * @param One of {@link View#VISIBLE}, {@link View#INVISIBLE},
     *   or {@link View#GONE}.
     */
    public int getProgressBarVisibility_three() {
        return mProgress.getVisibility();
    }

    /**
     * Function to set a click listener for Title TextView
     * 
     * @param listener the onClickListener
     */
    public void setOnTitleClickListener_three(OnClickListener listener) {
        mTitleView.setOnClickListener(listener);
    }

    @Override
    public void onClick(View view) {
        final Object tag = view.getTag();
        if (tag instanceof Action_three) {
            final Action_three action = (Action_three) tag;
            action.performAction_three(view);
        }
    }

    /**
     * Adds a list of {@link Action}s.
     * @param actionList the actions to add
     */
    public void addActions_three(ActionList_three actionList) {
        int actions = actionList.size();
        for (int i = 0; i < actions; i++) {
            addAction_three(actionList.get(i));
        }
    }

    /**
     * Adds a new {@link Action}.
     * @param action the action to add
     */
    public void addAction_three(Action_three action) {
        final int index = mActionsView.getChildCount();
        addAction_three(action, index);
    }

    /**
     * Adds a new {@link Action} at the specified index.
     * @param action the action to add
     * @param index the position at which to add the action
     */
    public void addAction_three(Action_three action, int index) {
        mActionsView.addView(inflateAction_three(action), index);
    }

    /**
     * Removes all action views from this action bar
     */
    public void removeAllActions_three() {
        mActionsView.removeAllViews();
    }

    /**
     * Remove a action from the action bar.
     * @param index position of action to remove
     */
    public void removeActionAt_three(int index) {
        mActionsView.removeViewAt(index);
    }

    /**
     * Remove a action from the action bar.
     * @param action The action to remove
     */
    public void removeAction_three(Action_three action) {
        int childCount = mActionsView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View view = mActionsView.getChildAt(i);
            if (view != null) {
                final Object tag = view.getTag();
                if (tag instanceof Action_three && tag.equals(action)) {
                    mActionsView.removeView(view);
                }
            }
        }
    }

    /**
     * Returns the number of actions currently registered with the action bar.
     * @return action count
     */
    public int getActionCount_three() {
        return mActionsView.getChildCount();
    }

    /**
     * Inflates a {@link View} with the given {@link Action}.
     * @param action the action to inflate
     * @return a view
     */
    private View inflateAction_three(Action_three action) {
        View view = mInflater.inflate(R.layout.actionbar_item_three, mActionsView, false);

        ImageButton labelView =
            (ImageButton) view.findViewById(R.id.actionbar_item_three);
        labelView.setImageResource(action.getDrawable_three());

        view.setTag(action);
        view.setOnClickListener(this);
        return view;
    }

    /**
     * A {@link LinkedList} that holds a list of {@link Action}s.
     */
    public static class ActionList_three extends LinkedList<Action_three> {
    }
    
    
    
    
    
    
    
    //second interface
    public interface Action_three{
      public int getDrawable_three();
        public void performAction_three(View view);
      
    }

    public static abstract class AbstractAction_three implements Action_three {
        final private int mDrawable;

        public AbstractAction_three(int drawable) {
            mDrawable = drawable;
        }

        @Override
        public int getDrawable_three() {
            return mDrawable;
        }
    }
    public static class IntentAction_three extends AbstractAction_three {
        private Context mContext;
        private Intent mIntent;

        public IntentAction_three(Context context, Intent intent, int drawable) {
            super(drawable);
            mContext = context;
            mIntent = intent;
        }

        @Override
        public void performAction_three(View view) {
            try {
               mContext.startActivity(mIntent); 
            } catch (ActivityNotFoundException e) {
                Toast.makeText(mContext,
                        mContext.getText(R.string.actionbar_activity_not_found),
                        Toast.LENGTH_SHORT).show();
            }
        }
    
    }
    
    
    
    
    
    
    /*
    public static abstract class SearchAction extends AbstractAction {
        public SearchAction() {
            super(R.drawable.actionbar_search);
        }
    }
    */
}




Java Source Code List

com.googlecode.leptonica.android.AdaptiveMap.java
com.googlecode.leptonica.android.Binarize.java
com.googlecode.leptonica.android.Box.java
com.googlecode.leptonica.android.Constants.java
com.googlecode.leptonica.android.Convert.java
com.googlecode.leptonica.android.Enhance.java
com.googlecode.leptonica.android.JpegIO.java
com.googlecode.leptonica.android.Pix.java
com.googlecode.leptonica.android.Pixa.java
com.googlecode.leptonica.android.ReadFile.java
com.googlecode.leptonica.android.Rotate.java
com.googlecode.leptonica.android.Scale.java
com.googlecode.leptonica.android.Skew.java
com.googlecode.leptonica.android.WriteFile.java
com.googlecode.tesseract.android.TessBaseAPI.java
com.markupartist.android.widget.ActionBar.java
com.markupartist.android.widget.ActionBar_three.java
com.markupartist.android.widget.ActionBar_two.java
com.markupartist.android.widget.ScrollingTextView.java
com.me.android.scanNedit.CameraActivity.java
com.me.android.scanNedit.CropOptionAdapter.java
com.me.android.scanNedit.CropOption.java
com.me.android.scanNedit.FileCache.java
com.me.android.scanNedit.GalleryActivity.java
com.me.android.scanNedit.HelpActivity.java
com.me.android.scanNedit.ImageLoader.java
com.me.android.scanNedit.LazyAdapter.java
com.me.android.scanNedit.MemoryCache.java
com.me.android.scanNedit.Picture.java
com.me.android.scanNedit.SampleActivity.java
com.me.android.scanNedit.StartActivity.java
com.me.android.scanNedit.TessBaseAPITest.java
com.me.android.scanNedit.Utils.java
com.me.android.scanNedit.XMLParser.java