Android Open Source - rhetolog Participant 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 ww .  j a va2 s  .  c o m*/
/*
 * Copyright (c) 2012 Kirk Zurell
 *
 * See the file LICENSE for copying permission.
 */

import android.app.Activity;
import android.content.Context;
import android.graphics.LightingColorFilter;
import android.net.Uri;
import android.util.AttributeSet;
import android.view.DragEvent;
import android.view.View;
import android.view.View.OnDragListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ParticipantView extends RelativeLayout implements OnDragListener {
  
  // The View's related participant by _ID
  private int mParticipant;

  // Reference to the owning Activity.
  public Activity activity;
  
  // Reference to the Application (or otherwise) for performing actions
  SessionActor application = null;
  
  /**
   * @return the application
   */
  public SessionActor getApplication() {
    return application;
  }

  /**
   * @param application the application to set
   */
  public void setApplication(SessionActor application) {
    this.application = application;
  }


  Context context;
  
  ImageView participantPhoto;
  TextView participantCaption;
  
  /**
   * @return the mParticipant
   */
  public int getParticipant() {
    return mParticipant;
  }

  /**
   * @param mParticipant the mParticipant to set
   */
  public void setParticipant(int mParticipant) {
    this.mParticipant = mParticipant;
  }

  
  
  public ParticipantView(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    // Not sure one can get application context here in design mode.
    application = (SessionActor) ((MainActivity)context).getApplication();
  }
  
  /* (non-Javadoc)
   * @see android.view.View#onFinishInflate()
   */
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    
    participantPhoto = (ImageView) findViewById(R.id.participantPhoto);
    participantCaption = (TextView) findViewById(R.id.participantCaption);
    
    this.setOnDragListener(this);
    
  }
  
  
  final static LightingColorFilter mediumDropColor = new LightingColorFilter(0xFF404040, 0xFF101010);
  final static LightingColorFilter lightDropColor = new LightingColorFilter(0xFF808080, 0xFF101010);
  

  // Run by activity onDrag
  @Override
  public boolean onDrag(View v, DragEvent event) {
    
    boolean result = false;
    int action = event.getAction();
    
    switch (action) {
    case DragEvent.ACTION_DRAG_STARTED:
      ParticipantView.this.participantPhoto.setColorFilter(mediumDropColor);
      result = true;
      break;
    case DragEvent.ACTION_DRAG_ENTERED:
      ParticipantView.this.participantPhoto.setColorFilter(lightDropColor);
      result = true;
      break;
    case DragEvent.ACTION_DRAG_EXITED:
      ParticipantView.this.participantPhoto.setColorFilter(mediumDropColor);
      result = true;
      break;
    case DragEvent.ACTION_DROP:
      ParticipantView.this.participantPhoto.clearColorFilter();
      
      // Create new event.
      Fallacy droppedFallacy = (Fallacy) event.getLocalState();
      
      long timestamp = ((MainActivity)this.getContext()).sessionClock.getSessionTime();
      
      //Uri session = ((MainActivity)this.getContext()).getCurrentSession();
      Uri session = RhetologContract.EVENTSCURRENTSESSION_URI;
      
      // Record event.
      if (application != null) {
        application.onInsertEvent(droppedFallacy.getName(), this.getParticipant(), session, timestamp);
      }
      
      result = true;
      break;
    case DragEvent.ACTION_DRAG_ENDED:
      ParticipantView.this.participantPhoto.clearColorFilter();
      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