Android Open Source - ddgatve-android Image Adapter






From Project

Back to project page ddgatve-android.

License

The source code is released under:

Apache License

If you think the Android project ddgatve-android 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 lv.ddgatve.games.game15;
//from  w  ww .j av a 2  s  . co m
import lv.ddgatve.games.main.R;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
  private Context mContext;

  public ImageAdapter(Context c) {
    mContext = c;
  }

  public int getCount() {
    return Game15Activity.theFrame.getCount();
  }

  public Object getItem(int position) {
    return null;
  }

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

  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {
      imageView = new ImageView(mContext);

      int sqSize = ((Game15Activity) mContext).sqSize;
      GridView.LayoutParams param = new GridView.LayoutParams(sqSize,
          sqSize);
      imageView.setLayoutParams(param);
      imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
      imageView.setPadding(0, 0, 0, 0);

    } else {
      imageView = (ImageView) convertView;
    }

    if (Game15Activity.theFrame.isEmpty()) {
      imageView.setImageResource(R.drawable.blank);
    } else {
      imageView.setImageResource(tiles[Game15Activity.theFrame
          .getSlotByNum(position)]);
    }
    return imageView;
  }

  private Integer[] tiles = { R.drawable.tile_0, R.drawable.tile_1,
      R.drawable.tile_2, R.drawable.tile_3, R.drawable.tile_4,
      R.drawable.tile_5, R.drawable.tile_6, R.drawable.tile_7,
      R.drawable.tile_8, R.drawable.tile_9, R.drawable.tile_10,
      R.drawable.tile_11, R.drawable.tile_12, R.drawable.tile_13,
      R.drawable.tile_14, R.drawable.tile_15 };
}




Java Source Code List

lv.ddgatve.applets.ColoredCircleApplet.java
lv.ddgatve.applets.MovingCircleApplet.java
lv.ddgatve.applets.PlainCircleApplet.java
lv.ddgatve.applets.SmoothCircleApplet.java
lv.ddgatve.games.game15.Game15Activity.java
lv.ddgatve.games.game15.Game15Frame.java
lv.ddgatve.games.game15.ImageAdapter.java
lv.ddgatve.games.game15.PickFrameDialogFragment.java
lv.ddgatve.games.game15.SummaryActivity.java
lv.ddgatve.games.main.MainActivity.java
lv.ddgatve.games.mtable.DataHolder.java
lv.ddgatve.games.mtable.DisplayMessageActivity.java
lv.ddgatve.games.mtable.MainActivity.java
lv.ddgatve.games.mtable.Questions.java
lv.ddgatve.games.mtable.SummaryActivity.java
lv.ddgatve.math.main.ExampleActivity.java
lv.ddgatve.math.main.MainActivity.java
lv.ddgatve.math.main.PostAsyncTask.java
lv.ddgatve.math.main.RegisterActivity.java
lv.hello.HelloWorld.java
lv.hello.MultiplicationTable.java
lv.kapsitis.myfirstapp.MainActivity.java