Beispiel #1
0
  @Override
  public void onResume() {
    super.onResume();

    // Format the most recently clicked item upon returning from info page
    if (ListData.indexLastClicked != 99) {
      int idx = ListData.indexLastClicked;
      RelativeLayout lastClicked =
          (RelativeLayout)
              theListView.getChildAt(
                  ListData.indexLastClicked - theListView.getFirstVisiblePosition());
      TextView v = (TextView) lastClicked.getChildAt(0);
      TextView w = (TextView) lastClicked.getChildAt(1);
      boolean completed = ListData.getCompletedList().get(ListData.indexLastClicked);

      if (completed) {
        v.setTextColor(Color.LTGRAY);
        w.setText("DONE!");
        w.setTextColor(Color.parseColor("#73e600"));

      } else {
        v.setTextColor(Color.BLACK);
        w.setText("\u2705");
        w.setTextColor(Color.LTGRAY);
      }
    }
  }
Beispiel #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    // Initialize and set the content view
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ListData.initializeListData();

    // Store local reference to the ListView
    theListView = (ListView) findViewById(android.R.id.list);

    // Populate local ArrayLists
    titleList = ListData.getTitleList();
    infoList = ListData.getInfoList();
    completedList = ListData.getCompletedList();

    // Create adapter to dynamically pass strings to the view
    SpecialAdapter listAdapter = new SpecialAdapter(this, R.layout.list_layout, titleList);
    setListAdapter(listAdapter);

    // Set on click listener to generate an intent and launch new activity
    theListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Log.i("Item Click", "Position: " + position + "id: " + id);
            String clickedText = (String) parent.getItemAtPosition(position);
            ListData.setIndexLastClicked(position);
            Intent intent = new Intent(MainActivity.this, InfoPage.class);
            intent.putExtra(INDEX_MESSAGE, position);
            startActivity(intent);
          }
        });

    // Long click listener used to complete/reset items from the main list view
    theListView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            Log.i("Item Long Click", "Position: " + position + "id: " + id);
            boolean completed = ListData.getCompletedList().get(position);
            RelativeLayout l = (RelativeLayout) view;
            TextView v = (TextView) l.getChildAt(0);
            TextView w = (TextView) l.getChildAt(1);
            Log.i("Children", "v:" + v.getText().toString() + " w: " + w.getText().toString());

            if (completed) {
              // Reset
              ListData.setCompleted(position, false);
              v.setTextColor(Color.BLACK);
              w.setText("\u2705");
              w.setTextColor(Color.LTGRAY);

            } else {
              // Complete
              ListData.setCompleted(position, true);
              v.setTextColor(Color.LTGRAY);
              w.setText("DONE!");
              w.setTextColor(Color.parseColor("#73e600"));
            }
            return true;
          }
        });
  }
Beispiel #3
0
 public void add(
     int i,
     String s1,
     String info,
     String s,
     String t,
     String frame,
     String ethernet,
     String myppoe,
     String ip,
     String tcp,
     String udp,
     String icmp,
     String packettype) {
   ListData tmp;
   tmp = new ListData();
   tmp.data = info;
   tmp.header = s1;
   tmp.dataset = s;
   tmp.type = t;
   tmp.ip = ip;
   tmp.tcp = tcp;
   tmp.ethernet = ethernet;
   tmp.frame = frame;
   tmp.myppoe = myppoe;
   tmp.udp = udp;
   tmp.icmp = icmp;
   tmp.packettype = packettype;
   // System.out.println(i+info);
   ljep.add(i, tmp);
 }