Android Open Source - rhetolog M R U 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 a2 s .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.ColorFilter;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.view.MotionEvent;
import android.view.View;

/**
 * @author kirk
 *
 */
public class MRUView extends RelativeLayout {

  // MRUView's associated Fallacy
  Fallacy fallacy;
  
  // The text/icon image
  ImageView fallacyImage;
  
  // Colour filter to change appearance 
  ColorFilter colorFilter;
  
  
  public MRUView(Context context, AttributeSet attrs) {
    super(context, attrs);  
  }

  
  
  /* (non-Javadoc)
   * @see android.view.View#onFinishInflate()
   */
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    
    fallacyImage = (ImageView) findViewById(R.id.mruImage);
    //fallacyTitle = (TextView) findViewById(R.id.mruTitle);
    
    MRUTouchListener mruTouchListener = new MRUTouchListener();
    setOnTouchListener(mruTouchListener);

  }

  /**
   * @return the fallacy
   */
  public Fallacy getFallacy() {
    return fallacy;
  }

  /**
   * @param fallacy the fallacy to set
   */
  public void setFallacy(Fallacy fallacy) {
    this.fallacy = fallacy;
    if(fallacy != null) {
      fallacyImage.setImageDrawable(fallacy.getIcon());
      //fallacyTitle.setText(fallacy.getTitle());  
      setBackgroundColor(fallacy.getColor());
    } else {
      fallacyImage.setImageResource(R.drawable.empty);
      //fallacyTitle.setText(R.string.mruDefaultTitle);
    }
    
  }

  /**
   * @return the colorFilter
   */
  public ColorFilter getColorFilter() {
    return colorFilter;
  }

  /**
   * @param colorFilter the colorFilter to set
   */
  public void setColorFilter(ColorFilter colorFilter) {
    this.colorFilter = colorFilter;
    if (colorFilter != null)
      this.fallacyImage.setColorFilter(colorFilter);
    else
      this.fallacyImage.clearColorFilter();
  }

  
  private final class MRUTouchListener implements View.OnTouchListener {
    
    @Override
    public boolean onTouch(View v, MotionEvent event) {
      boolean result = false;
      int action = event.getAction();
      MRUView mruView = (MRUView) v;
      
      // If not a valid MRU setting, do nothing.
      if (mruView.getFallacy() == null) return false;
      
      switch (action) {
      case MotionEvent.ACTION_DOWN :
        // MRUView should be a child of FallacyView
        ClipData clipData = ClipData.newPlainText(FallacyView.FALLACY_DRAG_IDENTIFIER, fallacy.getName());
        
        View.DragShadowBuilder dsb = new View.DragShadowBuilder(fallacyImage);
        
        // Send selected Fallacy as payload.
        v.startDrag(clipData, dsb, fallacy, 0);
        
        result = true;
        break;
      }
      
      return result;
    }    
  }
  
  
  
  
  
//  /**
//   * @return the fallacyImage
//   */
//  public ImageView getFallacyImage() {
//    return fallacyImage;
//  }
//
//  /**
//   * @param fallacyImage the fallacyImage to set
//   */
//  public void setFallacyImage(ImageView fallacyImage) {
//    this.fallacyImage = fallacyImage;
//  }
  
  

}




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