Android Open Source - pinpoint-android Homescreen Select Activity






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  www  .  j  a va2  s.  co  m
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;

public class HomescreenSelectActivity extends Activity {
  private HomescreenAdapter adapter;

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.homescreenselect);

    List<Homescreen> homescreenList = new ArrayList<Homescreen>();

    for (LauncherItem launcherItem : LauncherReader.getAllItemsNotInDock(this)) {
      int screenId = launcherItem.getScreen();
      Homescreen homescreen = null;

      for (Homescreen preexistingHomescreen : homescreenList) {
        if (preexistingHomescreen.getId() == screenId) {
          homescreen = preexistingHomescreen;
          break;
        }
      }

      if (null == homescreen) {
        homescreen = new Homescreen(screenId);
        homescreenList.add(homescreen);
      }

      homescreen.addLauncherItem(launcherItem);
    }

    ListView listView = (ListView) this.findViewById(R.id.list);

    this.adapter = new HomescreenAdapter(this);
    this.adapter.addAll(homescreenList);
    listView.setAdapter(adapter);
  }

  public void selectHomescreen(View view) {
    Configuration configuration = Configuration.getInstance();

    Resources resources = this.getResources();

    String
        tag = view.getTag().toString(),
        tagFirst = resources.getString(R.string.tag_homescreenselect_first),
        tagSecond = resources.getString(R.string.tag_homescreenselect_second),
        tagThird = resources.getString(R.string.tag_homescreenselect_third);

    int id = Integer.parseInt(
      ((TextView)
        (
          (ViewGroup) view.getParent().getParent()
        ).findViewById(R.id.id)
      ).getText().toString(), 10);

    if (tag.equals(tagFirst)) {
      configuration.setFirstHomescreenId(id);
    } else if (tag.equals(tagSecond)) {
      configuration.setSecondHomescreenId(id);
    } else if (tag.equals(tagThird)) {
      configuration.setThirdHomescreenId(id);
    }

    // restore original background color for all buttons with the same tag as
    // this button
    ViewGroup viewGroup = (ViewGroup) view.getParent().getParent().getParent();
    for (int i = 0, l = viewGroup.getChildCount(); i < l; i++) {
      ((ViewGroup) viewGroup.getChildAt(i).findViewById(R.id.buttons)).findViewWithTag(view.getTag()).setBackgroundResource(R.color.gray);
    }

    // restore original background color for all buttons in the same view group
    viewGroup = (ViewGroup) view.getParent();
    for (int i = 0, l = viewGroup.getChildCount(); i < l; i++) {
      viewGroup.getChildAt(i).setBackgroundResource(R.color.gray);
    }

    // color only selected button
    view.setBackgroundResource(R.color.orange);
  }
}




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