Android Open Source - LimeLight Act Icon Adapter






From Project

Back to project page LimeLight.

License

The source code is released under:

GNU General Public License

If you think the Android project LimeLight 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

/**
 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0, as well as to the Additional Term regarding proper
 attribution. The latter is located in Term 11 of the License.
 If a copy of the MPL with the Additional Term was not distributed
 with this file, You can obtain one at http://static.fuzzhq.com/licenses/MPL
 *//*w w  w  .j a  v  a 2s .c  om*/
package com.fuzz.android.limelight.recorder.widget.editor;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

import com.fuzz.android.limelight.R;

/**
 * ActIconAdapter populates the icon grid in ActEditor and provides methods to help access and
 * manipulate items.
 *
 * @author William Xu (Fuzz)
 */
public class ActIconAdapter extends BaseAdapter {
    private TypedArray mIcons;
    private int selectedIconPosition = -1;

    public ActIconAdapter(Context context) {
        mIcons = context.getResources().obtainTypedArray(R.array.act_icons);
    }

    @Override
    public int getCount() {
        return mIcons.length();
    }

    @Override
    public String getItem(int position) {
        return mIcons.getString(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView iconImage;

        if (convertView == null) {
            iconImage = new ImageView(parent.getContext());
            GridView.LayoutParams params = new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 150);
            iconImage.setLayoutParams(params);
            iconImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
            iconImage.setPadding(10, 10, 10, 10);
        } else {
            iconImage = (ImageView) convertView;
        }
        iconImage.setBackgroundColor(Color.WHITE);
        if (position == selectedIconPosition) {
            iconImage.setBackgroundColor(Color.LTGRAY);
        }

        iconImage.setImageResource(mIcons.getResourceId(position, -1));

        return iconImage;
    }

    /**
     * @param position the position of an item on the populated list
     * @return the drawable in the given position on the list
     */
    public Drawable getDrawable(int position) {
        return mIcons.getDrawable(position);
    }

    /**
     * saves the given position to manipulate the corresponding list item later
     * @param position the position of an item on the populated list
     */
    public void setIconSelected(int position) {
        selectedIconPosition = position;
    }

    /**
     * @param position the position of an item on the populated list
     * @return the resource id of the drawable in the given position on the list
     */
    public int getDrawableResId(int position) {
        return mIcons.getResourceId(position, -1);
    }
}




Java Source Code List

com.fuzz.android.limelight.LimeLight.java
com.fuzz.android.limelight.animation.AnimationHolder.java
com.fuzz.android.limelight.animation.LeftRightAnimation.java
com.fuzz.android.limelight.animation.UpDownAnimation.java
com.fuzz.android.limelight.automate.DrawerAutomator.java
com.fuzz.android.limelight.automate.ViewAutomator.java
com.fuzz.android.limelight.model.ActToViewHelper.java
com.fuzz.android.limelight.model.Act.java
com.fuzz.android.limelight.model.BaseChapter.java
com.fuzz.android.limelight.model.Book.java
com.fuzz.android.limelight.model.ChapterTransition.java
com.fuzz.android.limelight.model.Chapter.java
com.fuzz.android.limelight.model.ModelHelper.java
com.fuzz.android.limelight.model.Text.java
com.fuzz.android.limelight.model.Transition.java
com.fuzz.android.limelight.recorder.FontListAdapter.java
com.fuzz.android.limelight.recorder.RecorderClickListener.java
com.fuzz.android.limelight.recorder.RecorderWindow.java
com.fuzz.android.limelight.recorder.Recorder.java
com.fuzz.android.limelight.recorder.widget.color.ColorHueSlider.java
com.fuzz.android.limelight.recorder.widget.color.ColorPickDialog.java
com.fuzz.android.limelight.recorder.widget.color.ColorSquareView.java
com.fuzz.android.limelight.recorder.widget.color.OnColorChangedListener.java
com.fuzz.android.limelight.recorder.widget.drag.DragAndEditView.java
com.fuzz.android.limelight.recorder.widget.drag.EditorFrameLayout.java
com.fuzz.android.limelight.recorder.widget.drag.OffSetChangeListener.java
com.fuzz.android.limelight.recorder.widget.editor.ActEditor.java
com.fuzz.android.limelight.recorder.widget.editor.ActIconAdapter.java
com.fuzz.android.limelight.recorder.widget.editor.operations.BaseOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeAnimationOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeBackgroundColorOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.ChangeIconOperation.java
com.fuzz.android.limelight.recorder.widget.editor.operations.SetTextColorOperation.java
com.fuzz.android.limelight.recorder.widget.filedialog.FileDirectoryDialog.java
com.fuzz.android.limelight.recorder.widget.filedialog.OnDirectorySelectListener.java
com.fuzz.android.limelight.recorder.widget.snap.SnapHelper.java
com.fuzz.android.limelight.recorder.widget.snap.SnapInfo.java
com.fuzz.android.limelight.text.PrimeTextWatcher.java
com.fuzz.android.limelight.util.FontUtils.java
com.fuzz.android.limelight.util.IOUtils.java
com.fuzz.android.limelight.util.JSONTool.java
com.fuzz.android.limelight.util.LimeLightLog.java
com.fuzz.android.limelight.util.ViewUtils.java
com.fuzz.android.limelight.view.PrimeClickListener.java
com.fuzz.android.limelight.widget.ManualPositionFrameLayout.java