Created
July 17, 2013 02:59
-
-
Save acidjazz/6017335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.plugin.drawer; | |
import org.apache.cordova.api.CallbackContext; | |
import org.apache.cordova.api.CordovaPlugin; | |
import org.apache.cordova.api.PluginResult; | |
import org.json.JSONArray; | |
import android.widget.AdapterView; | |
import android.widget.ListView; | |
import android.support.v4.widget.DrawerLayout.DrawerListener; | |
import android.util.Log; | |
import android.view.Gravity; | |
import android.view.View; | |
import com.samsung.gea.NavDrawerDroidGap; | |
public class NavDrawerPlugin extends CordovaPlugin implements DrawerListener { | |
protected NavDrawerDroidGap drawerActivity; | |
protected CallbackContext context; | |
public void initDrawer() { | |
NavDrawerDroidGap drawerActivity = (NavDrawerDroidGap) cordova.getActivity(); | |
drawerActivity.setDrawerListener(this); | |
} | |
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { | |
if (action.equals("init")) { | |
initDrawer(); | |
this.context = callbackContext; | |
//this.context.success("inited"); | |
PluginResult result = new PluginResult(PluginResult.Status.OK, "inited"); | |
result.setKeepCallback(true); | |
this.context.sendPluginResult(result); | |
Log.w("DRAWER", "DRAWER INIT COMPLETE"); | |
return true; | |
} | |
if (action.equals("openLeft")) { | |
Log.w("DRAWER", "OPENING THE MENU YO"); | |
try { | |
this.drawerActivity.getDrawerLayout().openDrawer(this.drawerActivity.getLeftLayout()); | |
} catch(Error e) { | |
Log.w("DRAWERERROR", e.toString()); | |
} | |
Log.w("DRAWER", "MENU OPENED YO"); | |
//callbackContext.success("opened"); | |
} | |
return true; | |
} | |
@Override | |
public void onDrawerClosed(View arg0) { | |
PluginResult result = new PluginResult(PluginResult.Status.OK, "close"); | |
result.setKeepCallback(true); | |
this.context.sendPluginResult(result); | |
} | |
@Override | |
public void onDrawerOpened(View arg0) { | |
PluginResult result = new PluginResult(PluginResult.Status.OK, "open"); | |
result.setKeepCallback(true); | |
this.context.sendPluginResult(result); | |
} | |
@Override | |
public void onDrawerSlide(View arg0, float arg1) { | |
// TODO Auto-generated method stub | |
//this.context.success("onDrawerSlide"); | |
} | |
@Override | |
public void onDrawerStateChanged(int arg0) { | |
// TODO Auto-generated method stub | |
//this.context.success("onDrawerStateChanged"); | |
} | |
/* | |
private class DrawerItemClickListener implements ListView.OnItemClickListener { | |
@Override | |
public void onItemClick(AdapterView parent, View view, int position, long id) { | |
//selectItem(position); | |
PluginResult result = new PluginResult(PluginResult.Status.OK, "select"); | |
result.setKeepCallback(true); | |
this.context.sendPluginResult(result); | |
} | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment