Android Open Source - qcn Cover Event Receiver






From Project

Back to project page qcn.

License

The source code is released under:

GNU General Public License

If you think the Android project qcn 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 zsoltmester.qcn.quickcircle;
/*  w  w w  .j a va2 s .c o  m*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import zsoltmester.qcn.tools.Logger;

public class CoverEventReceiver extends BroadcastReceiver {

  private final Logger logger = Logger.createWithLogTag(CoverEventReceiver.class.getSimpleName());
  // Declared in LGIntent.java of LG Framework
  public static final String ACTION_ACCESSORY_COVER_EVENT = "com.lge.android.intent.action.ACCESSORY_COVER_EVENT";
  private CoverEventListener coverEventListener;

  private CoverEventReceiver(CoverEventListener coverEventListener) {
    this.coverEventListener = coverEventListener;
  }

  public static CoverEventReceiver createWithCoverEventListener(CoverEventListener coverEventListener) {
    return new CoverEventReceiver(coverEventListener);
  }

  @Override
  public void onReceive(Context context, Intent intent) {
    logger.log("onReceive");
    String action = intent.getAction();
    if (action != null && action.equals(ACTION_ACCESSORY_COVER_EVENT)) {
      handleCoverEvent(intent);
    }
  }

  private void handleCoverEvent(Intent intent) {
    // Declared in LGIntent.java of LG Framework
    final String EXTRA_NAME_ACCESSORY_COVER_STATE = "com.lge.intent.extra.ACCESSORY_COVER_STATE";
    final int EXTRA_VALUE_ACCESSORY_COVER_OPENED = 0;
    final int EXTRA_VALUE_ACCESSORY_COVER_CLOSED = 1;
    
    int coverState = intent.getIntExtra(EXTRA_NAME_ACCESSORY_COVER_STATE, EXTRA_VALUE_ACCESSORY_COVER_OPENED);
    logger.log("coverState: " + coverState);
    switch (coverState) {
      case EXTRA_VALUE_ACCESSORY_COVER_CLOSED:
        coverEventListener.onCoverClosed();
        break;
      case EXTRA_VALUE_ACCESSORY_COVER_OPENED:
        coverEventListener.onCoverOpened();
        break;
    }
  }

  public interface CoverEventListener {
    public void onCoverClosed();
    public void onCoverOpened();
  }
}




Java Source Code List

zsoltmester.qcn.desktop.ContactFragment.java
zsoltmester.qcn.desktop.DesktopActivity.java
zsoltmester.qcn.quickcircle.CoverEventReceiver.java
zsoltmester.qcn.quickcircle.QuickCircleBaseActivity.java
zsoltmester.qcn.quickcircle.notifications.NotificationActivity.java
zsoltmester.qcn.quickcircle.notifications.NotificationAdapter.java
zsoltmester.qcn.quickcircle.notifications.NotificationHelper.java
zsoltmester.qcn.quickcircle.notifications.NotificationListener.java
zsoltmester.qcn.tools.Logger.java
zsoltmester.qcn.ui.SimpleOnGestureListenerWithDoubleTapSupport.java