Android Open Source - pinpoint-android Homescreen Adapter






From Project

Back to project page pinpoint-android.

License

The source code is released under:

MIT License

If you think the Android project pinpoint-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 co.islovely.pinpoint;
/*from w ww.  jav a 2  s  .c  o  m*/
import android.content.Context;
import android.graphics.BitmapFactory;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;

public class HomescreenAdapter extends ArrayAdapter<Homescreen> {
  public HomescreenAdapter(Context context) {
    super(context, R.layout.item_homescreen, new ArrayList<Homescreen>());
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    Homescreen homescreen = this.getItem(position);

    // check if existing view is being reused, otherwise inflate view
    if (convertView == null) {
      convertView = LayoutInflater.from(this.getContext()).inflate(R.layout.item_homescreen, parent, false);
    }

    // populate view
    ((TextView) convertView.findViewById(R.id.id)).setText(
      "" + homescreen.getId()
    );

    for (LauncherItem launcherItem : homescreen.getLauncherItems()) {
      Integer imageViewId = null;

      if (null != launcherItem.getIcon()) {
        switch (launcherItem.getCellY()) {
          case 0:
            switch (launcherItem.getCellX()) {
              case 0:
                imageViewId = R.id.rowOne_columnOne;
                break;
              case 1:
                imageViewId = R.id.rowOne_columnTwo;
                break;
              case 2:
                imageViewId = R.id.rowOne_columnThree;
                break;
              case 3:
                imageViewId = R.id.rowOne_columnFour;
                break;
            }
            break;
          case 1:
            switch (launcherItem.getCellX()) {
              case 0:
                imageViewId = R.id.rowTwo_columnOne;
                break;
              case 1:
                imageViewId = R.id.rowTwo_columnTwo;
                break;
              case 2:
                imageViewId = R.id.rowTwo_columnThree;
                break;
              case 3:
                imageViewId = R.id.rowTwo_columnFour;
                break;
            }
            break;
          case 2:
            switch (launcherItem.getCellX()) {
              case 0:
                imageViewId = R.id.rowThree_columnOne;
                break;
              case 1:
                imageViewId = R.id.rowThree_columnTwo;
                break;
              case 2:
                imageViewId = R.id.rowThree_columnThree;
                break;
              case 3:
                imageViewId = R.id.rowThree_columnFour;
                break;
            }
            break;
          case 3:
            switch (launcherItem.getCellX()) {
              case 0:
                imageViewId = R.id.rowFour_columnOne;
                break;
              case 1:
                imageViewId = R.id.rowFour_columnTwo;
                break;
              case 2:
                imageViewId = R.id.rowFour_columnThree;
                break;
              case 3:
                imageViewId = R.id.rowFour_columnFour;
                break;
            }
            break;
        }

        if (null != imageViewId) {
          ((ImageView) convertView.findViewById(imageViewId)).setImageBitmap(
            BitmapFactory.decodeByteArray(launcherItem.getIcon(), 0, launcherItem.getIcon().length)
          );
        }
      }
    }

    return convertView;
  }
}




Java Source Code List

co.islovely.pinpoint.ColumnsActivity.java
co.islovely.pinpoint.Configuration.java
co.islovely.pinpoint.DeviceMetrics.java
co.islovely.pinpoint.GridActivity.java
co.islovely.pinpoint.HomescreenAdapter.java
co.islovely.pinpoint.HomescreenSelectActivity.java
co.islovely.pinpoint.Homescreen.java
co.islovely.pinpoint.IntermissionActivity.java
co.islovely.pinpoint.LauncherItem.java
co.islovely.pinpoint.LauncherReader.java
co.islovely.pinpoint.LayoutConfigurationActivity.java
co.islovely.pinpoint.MainActivity.java
co.islovely.pinpoint.MyApplication.java
co.islovely.pinpoint.PinpointActivity.java
co.islovely.pinpoint.Pinpoint.java
co.islovely.pinpoint.QuadrantsActivity.java
co.islovely.pinpoint.RowsActivity.java
co.islovely.pinpoint.StatisticsActivity.java
co.islovely.pinpoint.TaskLogEntry.java
co.islovely.pinpoint.TaskLog.java
co.islovely.pinpoint.TaskManager.java
co.islovely.pinpoint.Task.java
co.islovely.pinpoint.User.java
util.Base64.java