Android Open Source - rhetolog Fallacy View






From Project

Back to project page rhetolog.

License

The source code is released under:

Copyright (c) 2012 Kirk Zurell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Soft...

If you think the Android project rhetolog 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 name.zurell.kirk.apps.android.rhetolog;
//from  w w  w  .  j av  a 2s  .c  o m
/*
 * Copyright (c) 2012 Kirk Zurell
 *
 * See the file LICENSE for copying permission.
 */

import android.content.ClipData;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


public class FallacyView extends LinearLayout implements View.OnTouchListener {

  public static final String FALLACY_DRAG_IDENTIFIER = "identifier";
  
  Fallacy mfallacy;

  ImageView fallacyIcon;
  TextView fallacyTitle;
  TextView fallacyDescription;

  public FallacyView(Context context, AttributeSet attrs) {
    super(context, attrs);
    // Not called during inflation
  }

  /* (non-Javadoc)
   * @see android.view.View#onFinishInflate()
   */
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    // References to View's own components
    fallacyIcon = (ImageView) findViewById(R.id.fallacyIcon);
    fallacyTitle = (TextView) findViewById(R.id.fallacyTitle);
    fallacyDescription = (TextView) findViewById(R.id.fallacyDescription);

    // The icon image is draggable
    fallacyIcon.setOnTouchListener(this);  

  }

  /**
   * @return the view's associated fallacy
   */
  public Fallacy getFallacy() {
    return mfallacy;
  }

  /**
   * @param fallacy The fallacy to set.
   */
  public void setFallacy(Fallacy fallacy) {
    mfallacy = fallacy;
    Drawable newIcon = fallacy.getIcon();
    fallacyIcon.setImageDrawable(newIcon);
    fallacyTitle.setText(fallacy.getTitle());
    fallacyDescription.setText(fallacy.getDescription());
    setBackgroundColor(fallacy.getColor());
  }


  /**
   * Fallacies are draggable from the original list to the participants or to the MRU list.
   */

  @Override
  public boolean onTouch(View v, MotionEvent event) {
    boolean result = false;
    int action = event.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN :
      ClipData clipData = ClipData.newPlainText(FALLACY_DRAG_IDENTIFIER, mfallacy.getName());

      View.DragShadowBuilder dsb = new View.DragShadowBuilder(fallacyIcon);
      v.startDrag(clipData, dsb, mfallacy, 0);
      result = true;
      break;
    }
    return result;
  }


}




Java Source Code List

name.zurell.kirk.apps.android.rhetolog.DigitalSessionClock.java
name.zurell.kirk.apps.android.rhetolog.FallacyAdapter.java
name.zurell.kirk.apps.android.rhetolog.FallacyView.java
name.zurell.kirk.apps.android.rhetolog.Fallacy.java
name.zurell.kirk.apps.android.rhetolog.MRUAdapter.java
name.zurell.kirk.apps.android.rhetolog.MRUView.java
name.zurell.kirk.apps.android.rhetolog.MainActivity.java
name.zurell.kirk.apps.android.rhetolog.ParticipantAdapter.java
name.zurell.kirk.apps.android.rhetolog.ParticipantView.java
name.zurell.kirk.apps.android.rhetolog.PreferencesActivity.java
name.zurell.kirk.apps.android.rhetolog.PreferencesGeneralFragment.java
name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java
name.zurell.kirk.apps.android.rhetolog.RhetologContentProvider.java
name.zurell.kirk.apps.android.rhetolog.RhetologContract.java
name.zurell.kirk.apps.android.rhetolog.SessionActor.java
name.zurell.kirk.apps.android.rhetolog.SessionDateTimeDialogFragment.java
name.zurell.kirk.apps.android.rhetolog.SessionDetailActivity.java
name.zurell.kirk.apps.android.rhetolog.SessionDetailFragment.java
name.zurell.kirk.apps.android.rhetolog.SessionListActivity.java
name.zurell.kirk.apps.android.rhetolog.SessionListFragment.java
name.zurell.kirk.apps.android.rhetolog.SimpleGraphView.java