Android Open Source - bbstalker Detector Activity






From Project

Back to project page bbstalker.

License

The source code is released under:

GNU General Public License

If you think the Android project bbstalker 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 org.raegdan.bbstalker;
/*  w  w  w  .ja  v  a  2 s .  com*/
import org.json.JSONException;
import org.json.JSONObject;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import yuku.ambilwarna.*;

public class DetectorActivity extends ActivityEx implements OnClickListener {

  CheckBox cbDETUnicorn, cbDETPegasus, cbDETEarthen, cbDETAlicorn, cbDETMane, cbDETBody, cbDETNonpony;
  Button btnDETManeColor, btnDETBodyColor, btnDETQuery;
  
  // Initial colors
  final static int MANE_DEFAULT = 0xffff00ff;  // magenta
  final static int BODY_DEFAULT = 0xffffff00;  // yellow
  final static int DEALPHA = 0x00ffffff;      // color & DEALPHA == color with stripped alpha value
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.detector);
    
    // Controls init
    btnDETManeColor = (Button) findViewById(R.id.btnDETManeColor);
    btnDETBodyColor = (Button) findViewById(R.id.btnDETBodyColor);
    btnDETQuery = (Button) findViewById(R.id.btnDETQuery);
    
    btnDETManeColor.setBackgroundColor(MANE_DEFAULT);
    btnDETManeColor.setTag(Integer.valueOf(MANE_DEFAULT));
    btnDETBodyColor.setBackgroundColor(BODY_DEFAULT);
    btnDETBodyColor.setTag(Integer.valueOf(BODY_DEFAULT));
        
    cbDETUnicorn = (CheckBox) findViewById(R.id.cbDETUnicorn);
    cbDETPegasus = (CheckBox) findViewById(R.id.cbDETPegasus);
    cbDETEarthen = (CheckBox) findViewById(R.id.cbDETEarthen);
    cbDETAlicorn = (CheckBox) findViewById(R.id.cbDETAlicorn);
    cbDETMane = (CheckBox) findViewById(R.id.cbDETMane);
    cbDETBody = (CheckBox) findViewById(R.id.cbDETBody);
    cbDETNonpony = (CheckBox) findViewById(R.id.cbDETNonpony);
  
    btnDETManeColor.setOnClickListener(this);
    btnDETBodyColor.setOnClickListener(this);  
    btnDETQuery.setOnClickListener(this);
  }

  protected void SelectColor(final View v)   {
    AmbilWarnaDialog dialog = new AmbilWarnaDialog(this, ((Integer) v.getTag()).intValue(), new  AmbilWarnaDialog.OnAmbilWarnaListener() {
          @Override
          public void onOk(AmbilWarnaDialog dialog, int color) {
              v.setBackgroundColor(color);
              v.setTag(Integer.valueOf(color));
          }
                  
          @Override
          public void onCancel(AmbilWarnaDialog dialog) {
            // selection cancelled, do nothing
          }
  });

  dialog.show();
  }
  
  protected void Query() {
    JSONObject js = new JSONObject();
    
    try {
      js.put("alicorn", cbDETAlicorn.isChecked());
      js.put("unicorn", cbDETUnicorn.isChecked());
      js.put("pegasus", cbDETPegasus.isChecked());
      js.put("earthen", cbDETEarthen.isChecked());
      js.put("nonpony", cbDETNonpony.isChecked());
      js.put("mane", cbDETMane.isChecked());
      js.put("body", cbDETBody.isChecked());
      js.put("manecolor", ((Integer) btnDETManeColor.getTag()).intValue() & DEALPHA);
      js.put("bodycolor", ((Integer) btnDETBodyColor.getTag()).intValue() & DEALPHA);
    } catch (JSONException e) {
      e.printStackTrace();
      return;
    }
    
    Intent intent = new Intent(this, DBListActivity.class);
    intent.putExtra("query", js.toString());
    intent.putExtra("mode", DBListActivity.MODE_DETECTOR);
    startActivity(intent);
  }
  
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.btnDETManeColor:    
      case R.id.btnDETBodyColor: {
        SelectColor(v);
        break;
      }
      
      case R.id.btnDETQuery: {
        Query();
        break;
      }
      
    }
  }
}




Java Source Code List

org.raegdan.bbstalker.ActivityEx.java
org.raegdan.bbstalker.ActivitySwipeDetector.java
org.raegdan.bbstalker.BBStalkerApplication.java
org.raegdan.bbstalker.BlindbagDB.java
org.raegdan.bbstalker.Blindbag.java
org.raegdan.bbstalker.ConfigActivity.java
org.raegdan.bbstalker.DBListActivity.java
org.raegdan.bbstalker.DBList.java
org.raegdan.bbstalker.DetectorActivity.java
org.raegdan.bbstalker.MainActivity.java
org.raegdan.bbstalker.MyLocation.java
org.raegdan.bbstalker.RegexpField.java
org.raegdan.bbstalker.SwipeInterface.java
org.raegdan.bbstalker.Wave.java
org.raegdan.bbstalker.WavesActivity.java
yuku.ambilwarna.AmbilWarnaDialog.java
yuku.ambilwarna.AmbilWarnaKotak.java
yuku.ambilwarna.widget.AmbilWarnaPrefWidgetView.java
yuku.ambilwarna.widget.AmbilWarnaPreference.java