I want to implement a radial menu widget and i have used radial-menu-v4 jar. My code is as follows...
public class RadialMenuActivity extends Activity {
private RadialMenuWidget pieMenu;
public Activity activity = this;
RelativeLayout l1;
public RadialMenuItem menuItem1,menuItem2,menuItem3,menuItem4,menuItem5,menuItem6,menuItem7,menuItem8,menuItem9,menuItem10, menuCloseItem, menuExpandItem;
public RadialMenuItem firstChildItem, secondChildItem, thirdChildItem;
private List<RadialMenuItem> children = new ArrayList<RadialMenuItem>();
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.radial);
pieMenu = new RadialMenuWidget(this);
l1 = (RelativeLayout)findViewById(R.id.reltv1);
l1.addView(pieMenu);
menuCloseItem = new RadialMenuItem("Close", "Menu");
//menuCloseItem.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem1 = new RadialMenuItem("1","j");
menuItem1.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
/*firstChildItem = new RadialMenuItem("First","First");
firstChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
#Override
public void execute() {
startActivity(new Intent(RadialMenuActivity.this, TestActivity.class));
pieMenu.dismiss();
}
});
secondChildItem = new RadialMenuItem("Second",null);
secondChildItem.setDisplayIcon(R.drawable.ic_launcher);
secondChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
#Override
public void execute() {
Toast.makeText(RadialMenuActivity.this, "Second inner menu selected.", Toast.LENGTH_LONG).show();
}
});
thirdChildItem = new RadialMenuItem("Third","Third");
thirdChildItem.setDisplayIcon(R.drawable.ic_launcher);
thirdChildItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
#Override
public void execute() {
Toast.makeText(RadialMenuActivity.this, "Third inner menu selected.", Toast.LENGTH_LONG).show();
}
});*/
menuItem2 = new RadialMenuItem("2", "a");
menuItem2.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem3 = new RadialMenuItem("3", "i");
menuItem3.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem4 = new RadialMenuItem("4", "b");
menuItem4.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem5 = new RadialMenuItem("5", "c");
menuItem5.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem6 = new RadialMenuItem("6", "d");
menuItem6.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem7 = new RadialMenuItem("7", "e");
menuItem7.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem8 = new RadialMenuItem("8", "f");
menuItem8.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem9 = new RadialMenuItem("9", "g");
menuItem9.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
menuItem10 = new RadialMenuItem("10", "h");
menuItem10.setDisplayIcon(android.R.drawable.ic_menu_close_clear_cancel);
/*children.add(firstChildItem);
children.add(secondChildItem);
children.add(thirdChildItem);*/
//menuExpandItem.setMenuChildren(children);
menuCloseItem.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
#Override
public void execute() {
//menuLayout.removeAllViews();
pieMenu.dismiss();
}
});
menuItem1.setOnMenuItemPressed(new RadialMenuItem.RadialMenuItemClickListener() {
#Override
public void execute() {
startActivity(new Intent(RadialMenuActivity.this, TestActivity.class));
pieMenu.dismiss();
}
});
//pieMenu.setDismissOnOutsideClick(true, menuLayout);
int xLayoutSize = l1.getWidth();
int yLayoutSize = l1.getHeight();
pieMenu.setAnimationSpeed(0L);
//pieMenu.setSourceLocation(200, 200);
pieMenu.setSourceLocation(1000,1000);
pieMenu.setIconSize(10, 20);
pieMenu.setTextSize(10);
pieMenu.setOutlineColor(Color.WHITE, 225);
//pieMenu.setInnerRingColor(0xAA66CC, 10000000);
//pieMenu.setOuterRingColor(0x0099CC, 10000000);
//pieMenu.setCenterCircleRadius(40);
pieMenu.setOuterRingRadius(600, 600);
//pieMenu.setInnerRingRadius(100,100);
//pieMenu.setHeader("Test Menu", 20);
pieMenu.setCenterCircle(menuCloseItem);
pieMenu.addMenuEntry(new ArrayList<RadialMenuItem>() {{
add(menuItem1);
add(menuItem2);
add(menuItem3);
add(menuItem4);
add(menuItem5);
add(menuItem6);
add(menuItem7);
add(menuItem8);
add(menuItem9);
add(menuItem10);
}});
//pieMenu.addMenuEntry(menuItem);
//pieMenu.addMenuEntry(menuExpandItem);
/*Button testButton = (Button) this.findViewById(R.id.radial_menu_btn);
testButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
//menuLayout.addView(pieMenu);
pieMenu.show(v);
}
});*/
}
But I cant increase outer radius of the circle. I am using min sdk version 8. Please help me with this. Thank you in advance.
Related
I have a working app using threads in fragments, the thing is I need to change the layout. It's not gonna be a Fragment anymore but a standard Activity.
My big problem is that I don't know exactly where to place what's in "onViewCreated" and "onCreateView" so it's crashing when I call "connect to device" which's placed on "onCreateView". Probably because it's too early or something.
#Nullable
#Override
public View onCreateView(final LayoutInflater inflater, #Nullable ViewGroup container, #Nullable Bundle savedInstanceState){
View view;
view = inflater.inflate(R.layout.fragment_home_2, container, false);
//Linking layout views
connectToDevice = view.findViewById(R.id.connect_to_device);
startRecording = view.findViewById(R.id.start_recording);
stopRecording = view.findViewById(R.id.stop_recording);
connectedToDevice = view.findViewById(R.id.connected_to_device);
mAdapter = new DeviceListAdapter(container.getContext(), activeDevices);
imgEkoDevice = view.findViewById(R.id.img_ekodevice);
//Enable bluetooth and start scanning thread
BluetoothAdapter btAdapter = BluetoothAdapter.getDefaultAdapter();
if (btAdapter != null && !btAdapter.isEnabled()) {
btAdapter.enable();
}
//Layout setup
connectedToDevice.setText(getResources().getString(R.string.welcome_to_scopefy));
//Thread setup to search for device
scanningThread = new Thread(){
#Override
public void run(){
Log.i(AppConstants.TAG, "scanning...");
LibCore.getInstance(ConnectDeviceActivity.this).startScanningForDevices(new EkoDeviceScan() {
#Override
public void foundDevice(BLEDevice bleDevice) {
//Log.i(AppPreferences.log, "foundDevice: " + bleDevice.toString());
if(activeDevices.isEmpty()){
//Adding first device to list
activeDevices.add(bleDevice);
}
else{
int i = 0;
newDevice = true;
//Checks if its already on the list
while(i < activeDevices.size() && newDevice){
if(activeDevices.get(i).getAddress().equals(bleDevice.getAddress())){
newDevice = false;
}
i++;
}
if(newDevice){
activeDevices.add(bleDevice);
}
}
//Show list and dismiss search dialog
if(connect){
showDeviceListDialog();
if(emptyListDialog != null){
emptyListDialog.dismiss();
}
connect = false;
}
}
});
}
};
LocalBroadcastManager.getInstance(ConnectDeviceActivity.this).registerReceiver(mDeviceReceiver, new IntentFilter(Parameters.DEVICE_REFRESH_DATA));
//Starting scanning background to speed up
if(LibCore.getInstance(ConnectDeviceActivity.this).getCurrentConnectedDevice() == null){
scanningThread.start();
LibCore.getInstance(ConnectDeviceActivity.this).setFiltering(true);
connected = false;
} else {
mEkoDevice = LibCore.getInstance(ConnectDeviceActivity.this).getCurrentConnectedDevice();
connected = true;
}
//Broadcast receiver for patientId
LocalBroadcastManager.getInstance(ConnectDeviceActivity.this).registerReceiver(mPatientReceiver, new IntentFilter(Parameters.PATIENT_ID));
//Listeners and receivers for device connection
LibCore.getInstance(ConnectDeviceActivity.this).setBatteryListener(new EkoDeviceBatteryLevel() {
#Override
public void deviceUpdatedBatteryLevel(float v) {
Log.i("HUEBR123", "updateou bat");
LocalBroadcastManager.getInstance(ConnectDeviceActivity.this).sendBroadcast(new Intent(Parameters.DEVICE_REFRESH_DATA).putExtra(Parameters.DEVICE_UPDATED_BATTERY_LEVEL, v));
}
});
LibCore.getInstance(ConnectDeviceActivity.this).setVolumeListener(new EkoDeviceVolume() {
#Override
public void deviceUpdatedVolumeLevel(int i) {
Log.i("HUEBR123", "updateou vol");
LocalBroadcastManager.getInstance(ConnectDeviceActivity.this).sendBroadcast(new Intent(Parameters.DEVICE_REFRESH_DATA).putExtra(Parameters.DEVICE_UPDATED_VOLUME_LEVEL, i));
}
});
//Settings
userSettingsDAO = new UserSettingsDAO(ConnectDeviceActivity.this);
settings = userSettingsDAO.getUserSettings();
//Button's listeners
connectToDevice.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
connect = true;
scanningThread.run();
showDeviceListEmptyDialog();
}
});
startRecording.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Log.i(AppConstants.TAG, "starting recording...");
stopped = false;
startRecording();
//startPlayRecordThroughEko();
startRecording.setVisibility(View.GONE);
stopRecording.setVisibility(View.VISIBLE);
recording = true;
settings = userSettingsDAO.getUserSettings();
settings.getRecordingLength();
Timer timer = new Timer();
TimerTask task = new StopRecordingTask();
timer.schedule(task, settings.getRecordingLength() * 1000);
Log.i(AppConstants.TAG, "#timer starting for " + settings.getRecordingLength() + " seconds");
}
});
stopRecording.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
try {
mEkoOutputAudioByteListener = null;
mAudioFileOutputStream.close();
writeWAVHeader(mCachedAudioRecordingFile, 4000);
//writeWAVHeader(mCachedECGRecordingFile, 500);
stopOutputtingAudioDataPoints();
} catch (Exception e) {
e.printStackTrace();
}
startRecording.setVisibility(View.VISIBLE);
stopRecording.setVisibility(View.GONE);
recording = false;
short[] output;
output = new short[outData.size() * 32];
for(int i=0; i<outData.size(); i++){
for(int j=0; j<32; j++){
output[i] = outData.get(i)[j];
}
}
Intent intent = new Intent(ConnectDeviceActivity.this, AuscultationActivity.class);
intent.putExtra("output", output);
intent.putExtra("patient-id", patientId);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Log.i(AppConstants.TAG, "OUPUTLEN: " + output.length);
if(!stopped) {
stopped = true;
startActivity(intent);
}
}
});
return view;
}
//This overridden method makes DynamicWaveformViews avoid crashing
#Override
public void onViewCreated(View view, #Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
dynamicWaveformView = (DynamicWaveformView) view.findViewById(R.id.dynamic_waveform_view);
dynamicWaveformView.init();
mAudioThread = new HandlerThread("AudioThread");
mAudioThread.start();
mAudioHandler = new Handler(mAudioThread.getLooper());
//updateView again for consistency (mDeviceBroadcast may be too much but still works)
updateView(connected);
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mEkoDevice = new EkoDevice("DUMMY_DEVICE", "0");
buyNow = findViewById(R.id.buyNow);
back = findViewById(R.id.back_icon);
back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
}
});
buyNow.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
}
});
changeAudioAmplitudeScaleFactor(8);
mPlayerManager = new PlayerManager();
mPlayerManager.onCreate();
LibCore.getInstance(ConnectDeviceActivity.this).setFiltering(true);
}
trying to place at the bottom of "onCreate" it gives me the following error:
PopupWindow $BadTokenException: Unable to add window — token null is not valid
Regarding you error
PopupWindow $BadTokenException: Unable to add window — token null is
not valid
Maybe add that code in the Activity onResume() lifecykle method instead of onCreate if it need to run more then one time
Move the scanningThread, BluetoothAdapter and LocalBroadcastManager LibCore everything to the 'onCreate()' . The 'onCreateView()' should only have the view = inflater.inflate(R.layout.fragment_home_2, container, false);
The onCreate() only initiate stuff hook up local variables views and set clicklisteners. Like all the one-time-stuff. Going from Fragment to Activity is basically almost the same since they have the same lifecykle methods
Check this nice explanation about the-android-lifecycle-cheat-sheet
My MainActivity contains one mikepenz/MaterialDrawer and one pager view which contains 5 fragments. I am using material drawer to launch other activities but after launching many activities and coming back to my base Main activity the below crash occurs.
I have no clue to find the actual root cause of this issue. Your help will be highly appreciated.
java.lang.StackOverflowError
at android.view.GLES20Canvas.drawTextRun(GLES20Canvas.java:1345)
at android.text.SpannableStringBuilder.drawTextRun(SpannableStringBuilder.java:1139)
at android.view.GLES20Canvas.drawTextRun(GLES20Canvas.java:1372)
at android.text.TextLine.drawTextRun(TextLine.java:988)
at android.text.TextLine.handleText(TextLine.java:789)
at android.text.TextLine.handleRun(TextLine.java:956)
at android.text.TextLine.drawRun(TextLine.java:395)
at android.text.TextLine.draw(TextLine.java:193)
at android.text.Layout.drawText(Layout.java:348)
at android.widget.Editor.drawHardwareAccelerated(Editor.java:1455)
at android.widget.Editor.onDraw(Editor.java:1378)
at android.widget.TextView.onDraw(TextView.java:5170)
at android.view.View.draw(View.java:14476)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.getDisplayList(View.java:13368)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.getDisplayList(View.java:13368)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at android.widget.HorizontalScrollView.draw(HorizontalScrollView.java:1609)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at android.widget.HorizontalScrollView.draw(HorizontalScrollView.java:1609)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.getDisplayList(View.java:13368)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.widget.FrameLayout.draw(FrameLayout.java:472)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
at android.view.View.draw(View.java:14193)
at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
at android.view.View.draw(View.java:14479)
at android.support.v4.view.ViewPager.draw(ViewPager.java:2443)
at android.view.View.getDisplayList(View.java:13373)
at android.view.View.getDisplayList(View.java:13415)
public class MainActivity extends MyAppFragmentActivity {
public static final String app_version="v1.134";
#Inject protected MyAppServiceProvider serviceProvider;
#Inject protected LogoutService logoutService;
private MyApplication app =MyApplication.getInstance();
private boolean userHasAuthenticated = false;
MainActivity activity;
public static final String TAG = MainActivity.class.getSimpleName();
public static final String permission = MainActivity.class+".permission";
//NEW CODE
private FrameLayout rootLayout;
private LinearLayout msgContainer;
//save our header or result
private AccountHeader headerResult = null;
private Drawer result = null;
private Login login;
private String sourceMenuJson;
//PAGER RELATED
ViewPager pager;
PagerAdapter pagerAdapter;
SlidingTabLayout tabs;
static final int noOfTabs= 5;
CharSequence pagerTitles[] = {
//some strings
};
//TABLET LAUNCH SCREEN RELATED
private myappHorizontalOptionsMenu mmyappHorizontalOptionsMenu;
private myappHorizontalOption mSelectedmyappOption;
private TeachingPlanListFragment mTeachingPlanListFragment;
private Bus bus = app.getBus();
private Bundle savedInstanceState; //used by drawer menu
#Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.savedInstanceState = savedInstanceState;
setContentView(R.layout.main_activity);
msgContainer = (LinearLayout) findViewById(R.id.croutonContainer);
rootLayout = (FrameLayout) findViewById(R.id.rootLayout);
rootLayout.getForeground().setAlpha(0);
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
View mobilePagerView = findViewById(R.id.pager);
View tabletWrapperView = findViewById(R.id.tablet_wrapper_view);
// View injection with ButterKnife
Views.inject(this);
//INJECTS INTO DAGGER
Injector.inject(this);
activity = this;
checkAuth();
Log.d(TAG,"userHasAuthenticated "+userHasAuthenticated);
if(isTablet()) {
//setContentView(R.layout.main_activity_tablet);
Log.d(TAG,"IS table view");
processTabletView();
} else {
//setContentView(R.layout.main_activity);
Log.d(TAG,"IS mobile view");
LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT, 1.0f);
mobilePagerView.setLayoutParams(param);
tabletWrapperView.setVisibility(View.GONE);
}
}
#Override
protected void onPostCreate(final Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
}
#Override
protected void onResume() {
super.onResume();
bus.register(this);
if(userHasAuthenticated){
initScreen();
}
}
#Override
public void onBackPressed() {
//handle the back press :D close the drawer first and if the drawer is closed close the activity
if (result != null && result.isDrawerOpen()) {
result.closeDrawer();
} else {
super.onBackPressed();
}
}
public boolean isTablet() {
return UIUtils.isTablet(this);
}
private void initScreen() {
if (userHasAuthenticated) {
login = app.getLogin();
setNavigationDrawer();
setUserProfile();
initPager();
}
}
private void setAttendenceType() {
if (NetworkUtil.isInternetAvailable())
new AttendanceType().execute();
}
private void checkAuth() {
new SafeAsyncTask<Boolean>() {
#Override
public Boolean call() throws Exception {
final MyAppService svc = serviceProvider.getService(MainActivity.this);
return svc != null;
}
#Override
protected void onException(final Exception e) throws RuntimeException {
super.onException(e);
if (e instanceof OperationCanceledException) {
// User cancelled the authentication process (back button, etc).
// Since auth could not take place, lets finish this activity.
finish();
}
}
#Override
protected void onSuccess(Boolean hasAuthenticated) throws Exception {
Log.d(TAG,"onSuccess "+hasAuthenticated);
if(app.getLogin() == null
|| app.getLogin().getId() == null){
Login login = new Login();
SharedPreferences pref = getApplicationContext().getSharedPreferences("session", 0); // 0 - for private mode
app.setLogin(login);
}
setAttendenceType();
/**GCM RELATED CODE**/
myappGCMUtil gcmUtil = new myappGCMUtil(getApplicationContext(), app.getLogin());
String regid = gcmUtil.getRegistrationId();
if (regid.isEmpty()) {
gcmUtil.registerInBackground();
}
super.onSuccess(hasAuthenticated);
userHasAuthenticated = true;
initScreen();
}
}.execute();
}
private class AttendanceType extends AsyncTask<Void, Void, Void>{
#Override
protected Void doInBackground(Void... voids) {
try {
serviceProvider.getService(activity).getAttendanceType(activity);
} catch (IOException e) {
e.printStackTrace();
} catch (AccountsException e) {
e.printStackTrace();
}
return null;
}
}
//get the list of permission
private void getPermissions(){
String permissions = "";
new AsyncTask<Void, Void, String>(){
#Override
protected String doInBackground(Void... voids) {
PermissionWrapper postPermission = new PermissionWrapper();
List<PermissionCode> permissionCodes = new ArrayList<PermissionCode>();
for(int i=0; i < MainActivity.permissionCodes.length; i++){
PermissionCode code = new PermissionCode();
code.setCode(MainActivity.permissionCodes[i]);
permissionCodes.add(code);
}
for(int i=0; i < MainActivity.canPermissionCodes.length; i++){
PermissionCode code = new PermissionCode();
code.setCode(MainActivity.canPermissionCodes[i]);
permissionCodes.add(code);
}
postPermission.setId(app.getLogin().getName());
postPermission.setResperm(permissionCodes);
Log.d(TAG, new Gson().toJson(postPermission));
try {
HttpRequest requestPermission = post(app.getURL_PERMISSION())
.contentType("application/json")
.header(HEADER_TOKEN_KEY, HEADER_TOKEN)
.send(new Gson().toJson(postPermission));
if (requestPermission.ok()) {
Log.d(TAG, "permission loaded");
return Strings.toString(requestPermission.buffer());
} else {
Log.d(TAG, "permission loading failed");
return "";
}
}
catch (Exception e){
e.printStackTrace();
}
return "";
}
#Override
protected void onPostExecute(String permissionList) {
super.onPostExecute(permissionList);
SharedPreferences pref = getApplicationContext().getSharedPreferences("session", 0); // 0 - for private mode
SharedPreferences.Editor editor = pref.edit();
if(permissionList!=null && permissionList.length() > 0)
editor.putString(MainActivity.permission, permissionList);
editor.apply();
}
}.execute();
}
//RETRIEVES INSTITUTES LIST FROM STRING
public List<Institute> retrieveInstitutes(String instituteString){
List<Institute> institutes = new ArrayList<Institute>();
if(instituteString!=null){
Gson gson = new Gson();
Institute[] institutesArray = gson.fromJson(instituteString,Institute[].class);
institutes = Arrays.asList(institutesArray);
institutes = new ArrayList<Institute>(institutes);
}
return institutes;
}
/***********************************************
* PAGER RELATED
* **********************************************/
//INIT PAGER RELATED
private void initPager(){
// Assigning ViewPager View and setting the adapter
pager = (ViewPager) findViewById(R.id.pager);
// Assiging the Sliding Tab Layout View
tabs = (SlidingTabLayout) findViewById(R.id.tabs);
tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width
// Setting Custom Color for the Scroll bar indicator of the Tab View
tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
#Override
public int getIndicatorColor(int position) {
return ContextCompat.getColor(getApplicationContext(),R.color.colorWhite);
}
});
// Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs.
pagerAdapter = new PagerAdapter(getSupportFragmentManager(), pagerTitles, noOfTabs);
pager.setAdapter(null);
pager.setAdapter(pagerAdapter);
pager.setCurrentItem(1, true);
// Setting the ViewPager For the SlidingTabsLayout
tabs.setViewPager(pager);
}
/***************************************************
* Navigation Drawer Menu Related
* *************************************************/
//TO LOAD READ DRAWER MENUS FROM JSON FILE
public String loadJSONMenuFromAsset() {
if(sourceMenuJson==null){
try {
InputStream is = getAssets().open("drawer_menus.json");
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
sourceMenuJson = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}else
Log.d(TAG,"sourceMenuJson already exists");
return sourceMenuJson;
}
//INITIALIZE NAVIGATION DRAWER
private void setNavigationDrawer(){
// Handle Toolbar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//set the back arrow in the toolbar
setTitle(R.string.app_name);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
// Create the AccountHeader
headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(ContextCompat.getDrawable(this,R.drawable.left_menu_header_bg))
.withTranslucentStatusBar(false)
.withCompactStyle(true)
.withSavedInstance(savedInstanceState)
.build();
result = new DrawerBuilder()
.withActivity(this)
.withToolbar(toolbar)
.withDisplayBelowStatusBar(false)
.withTranslucentStatusBar(false)
.withActionBarDrawerToggleAnimated(true)
.withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
#Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
if (drawerItem != null) {
onDrawerMenuSelected(drawerItem.getIdentifier());
}
return false;
}
})
.addDrawerItems(
setMenuList()
)
.addStickyDrawerItems(new PrimaryDrawerItem().withName(R.string.logout_action).withIcon(myappIcon.Icon.cmu_logout).withIdentifier(-1))
.withSavedInstance(savedInstanceState)
.withShowDrawerOnFirstLaunch(true)
.build();
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);//SHOW HAMBURGER ICON
}
#Nullable
private IDrawerItem[] setMenuList() {
List<IDrawerItem> iDrawerItems = new ArrayList<IDrawerItem>();
List<DrawerMenuItem> allMenus = new Gson().fromJson(loadJSONMenuFromAsset(),DrawerMenuWrapper.class).getMenuItems();
SharedPreferences pref = app.getSharedPreferences("session", 0);
if(null != pref.getString(MainActivity.permission, null)) {
Log.d(TAG, pref.getString(MainActivity.permission, null));
PermissionResponseWrapper responseWrapper;
try {
responseWrapper = new Gson().fromJson(pref.getString(MainActivity.permission, null), PermissionResponseWrapper.class);
} catch (Exception e) {
responseWrapper = null;
}
if (responseWrapper != null && responseWrapper.getOutput().getData().getResperm() != null) {
for (DrawerMenuItem menuItem : allMenus) {
// iterate through list add the permissions available
for (PermissionCode code : responseWrapper.getOutput().getData().getResperm()) {
if (code.getCode().equals(menuItem.getCode())) {
//SETS MENU ITEM SHOW TO TRUE;
menuItem.setShow(true);
}
}
}
}
//ITERATE ALL MENUS AND ADD TO VIEW ONLY IF "show==true"
for (DrawerMenuItem menuItem : allMenus){
if (menuItem.isShow()) {
int stringID = getResources().getIdentifier(menuItem.getName(), "string", this.getPackageName());
iDrawerItems.add(new PrimaryDrawerItem().withName(stringID).withIcon(menuItem.getIcon()).withIdentifier(menuItem.getPos()));
iDrawerItems.add(new DividerDrawerItem());
}
}
return iDrawerItems.toArray(new IDrawerItem[iDrawerItems.size()]);
}
return null;
}
//SETS THE USER NAME AND PHOTO
private void setUserProfile(){
IProfile profile = new ProfileDrawerItem().withName(login.getUname()).withEmail(login.getOrgname());
String imageUrl = login.getImageUrl();
if(imageUrl!=null && imageUrl.length()>0){
//LOADS IMAGE FROM SERVER
//initialize and create the image loader logic
DrawerImageLoader.init(new DrawerImageLoader.IDrawerImageLoader() {
#Override
public void set(ImageView imageView, Uri uri, Drawable placeholder) {
Picasso.with(imageView.getContext()).load(uri).transform(new CircleTransformPicasso()).placeholder(placeholder).into(imageView);
}
#Override
public void cancel(ImageView imageView) {
Picasso.with(imageView.getContext()).cancelRequest(imageView);
}
#Override
public Drawable placeholder(Context ctx) {
return null;
}
#Override
public Drawable placeholder(Context ctx,String s) {
return null;
}
});
profile.withIcon(app.getURL_GET_AVATAR()+imageUrl);
}else {
//SETS DEFAULT IMAGE
profile.withIcon(myappIcon.Icon.cmu_students);
}
headerResult.addProfile(profile, 0);
}
public void onDrawerMenuSelected(long position) {
int selectedMenu = (int) position;
switch(selectedMenu) {
case -1:
//Logout
logoutService.logout(new Runnable() {
#Override
public void run() {
//Reload activity
Intent intent =getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
startActivity(intent);
}
});
break;
}
}
/***************************************************
* Tablet Land Screen Related
****************************************************/
//Initialize Tablet screen related work
private void processTabletView(){
mSelectedmyappOption = new myappHorizontalOption();
loadHorizontalMenus();
}
//LOAD HORIZONTAL OPTION MENUS FOR TABLET VIEW
private void loadHorizontalMenus(){
final Map<String,String> tabletLaunchOptions= new LinkedHashMap<>();
tabletLaunchOptions.put("AA", app.getResources().getString(R.string.menu_teaching_plan));
tabletLaunchOptions.put("BB", app.getResources().getString(R.string.assignments));
tabletLaunchOptions.put("CC", app.getResources().getString(R.string.attendance));
mmyappHorizontalOptionsMenu = (myappHorizontalOptionsMenu) findViewById(R.id.myappHorizontalOptionsMenu);
mmyappHorizontalOptionsMenu.distributeEvenly(true);
mmyappHorizontalOptionsMenu.setOptions(tabletLaunchOptions);
mmyappHorizontalOptionsMenu.disableOptionClick(true);
// Setting Custom Color for the Scroll bar indicator of the Tab View
mmyappHorizontalOptionsMenu.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() {
#Override
public int getIndicatorColor(int position) {
return ContextCompat.getColor(getApplicationContext(),R.color.colorPrimary);
}
});
}
//Launch Attendance Fragment
public void launchAttendanceFragment(final Intent intent, String sourceFragment){
//Post deselection inorder to swap current selection view
ListItemDeselectEvent event = new ListItemDeselectEvent();
if(sourceFragment.equals("ScheduleListFragment")){
event.setTargetClassName("MyClassListFragment");
}else {
event.setTargetClassName("ScheduleListFragment");
}
bus.post(event);
//Get selected option and set option
mSelectedmyappOption.setTag("ATTENDANCE");
mSelectedmyappOption.setLabel(app.getResources().getString(R.string.attendance));
mSelectedmyappOption.setPosition(2);
mmyappHorizontalOptionsMenu.setSelectedOption(mSelectedmyappOption, false);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
AttendanceListFragment attendanceListFragment = new AttendanceListFragment();
attendanceListFragment.intiFragment(MainActivity.this,intent);
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_details, attendanceListFragment)
.commit();
}
},300);
}
//Set selected schedule and launches teaching plan
public void launchTeachingPlanUpdateFragment(final Schedule schedule){
//Post deselection inorder to swap current selection view
ListItemDeselectEvent event = new ListItemDeselectEvent();
event.setTargetClassName("MyClassListFragment");
bus.post(event);
mSelectedmyappOption.setTag("CC");
mSelectedmyappOption.setLabel(app.getResources().getString(R.string.menu_teaching_plan));
mSelectedmyappOption.setPosition(0);
mmyappHorizontalOptionsMenu.setSelectedOption(mSelectedmyappOption, false);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
mTeachingPlanListFragment = new TeachingPlanListFragment();
mTeachingPlanListFragment.intiFragment(schedule);
getSupportFragmentManager().beginTransaction()
.replace(R.id.fragment_details, mTeachingPlanListFragment)
.commit();
}
},300);
}
}
Finally I have cracked it myself. The problem is I have initialized "View Pager" and "Drawer Menu" from the onResume(). As whenever I come back from other activities "View Pager" and "Drawer Menu" are initialized again which in turn produces StackOverflow exception.
I've developed a keyboard and now i need to add emojis to it , from other questions i've realized the best way is with popupwindow,
Here's what i've done:
case -102:
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.emoji_view, null);
final PopupWindow popupWindow = new PopupWindow(
popupView,
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT);
popupWindow.showAsDropDown(getWindow().getOwnerActivity().getCurrentFocus(),50, -30);
Unfortunatly this doesn't work , showAsDropDown needs a view as its first var , and if the keyboard is in another app i don't have a view to give him...
Is there a way to fix that ?
or am i going about it all wrong and there is a better way...
all help will be appreciated!
Given that you are using the official SoftKeyBoard implementation as a template for your keyboard:
//Cut some pieces of the code for clarity
case -102:
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.emoji_view, null);
PopupWindow popupWindow = new PopupWindow(popupView, MATCH_PARENT, MATCH_PARENT);
popupWindow.showAsDropDown(mInputView);
Use the view that you have inflated for your keyboard, in the offical SoftKeyBoard and the snippet above it is called mInputView.
hi i have done same things. I have made one custom keyboard in android.
EmoticonsPagerAdapter emojiAdapter;
/**
* Defining all components of emoticons keyboard
*/
private void enablePopUpView() {
final ViewPager pager = (ViewPager) popUpView
.findViewById(R.id.emoticons_pager);
pager.setOffscreenPageLimit(3);
final ArrayList<EmojiItem> paths = EmojiUtil.getInstance(acitiviy)
.getAllEmojis();
final ArrayList<EmojiItem>[] groups = new ArrayList[5];
for (EmojiItem emoji : paths) {
if (groups[emoji.emojiGroup] == null) {
groups[emoji.emojiGroup] = new ArrayList<EmojiItem>();
}
groups[emoji.emojiGroup].add(emoji);
}
final ArrayList<EmojiItem> history = new ArrayList<EmojiItem>();
ArrayList<Integer> historyIds = SettingsUtil.getHistoryItems(acitiviy);
for (Integer his : historyIds) {
for (EmojiItem emoji : paths) {
if (emoji.id == his) {
history.add(emoji);
break;
}
}
}
history.add(paths.get(0));
final KeyClickListener onEmojiClick = new KeyClickListener() {
#Override
public void keyClickedIndex(EmojiItem index) {
int cursorPosition = editMessage.getSelectionStart();
editMessage.getText().insert(cursorPosition, index.emojiText);
try {
editMessage.getText().setSpan(
new ImageSpan(index.emojiDrawable), cursorPosition,
cursorPosition + 1,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} catch (Exception e) {
}
if (history.get(0) != index)
history.add(0, index);
SettingsUtil.setHistoryItems(acitiviy, history);
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
};
((ImageButton) popUpView.findViewById(R.id.emoji2))
.setImageDrawable(groups[0].get(0).emojiDrawable);
((ImageButton) popUpView.findViewById(R.id.emoji3))
.setImageDrawable(groups[1].get(0).emojiDrawable);
((ImageButton) popUpView.findViewById(R.id.emoji4))
.setImageDrawable(groups[2].get(0).emojiDrawable);
((ImageButton) popUpView.findViewById(R.id.emoji5))
.setImageDrawable(groups[3].get(0).emojiDrawable);
((ImageButton) popUpView.findViewById(R.id.emoji6))
.setImageDrawable(groups[4].get(0).emojiDrawable);
popUpView.findViewById(R.id.emoji1).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = history;
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
popUpView.findViewById(R.id.emoji2).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = groups[0];
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
popUpView.findViewById(R.id.emoji3).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = groups[1];
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
popUpView.findViewById(R.id.emoji4).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = groups[2];
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
popUpView.findViewById(R.id.emoji5).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = groups[3];
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
popUpView.findViewById(R.id.emoji6).setOnClickListener(
new OnClickListener() {
#Override
public void onClick(View v) {
emojiAdapter.emojis = groups[4];
emojiAdapter.notifyDataSetChanged();
pager.setAdapter(emojiAdapter);
}
});
emojiAdapter = new EmoticonsPagerAdapter(acitiviy, groups[0],
onEmojiClick);
pager.setAdapter(emojiAdapter);
// Creating a pop window for emoticons keyboard
popupWindow = new PopupWindow(popUpView, LayoutParams.MATCH_PARENT,
(int) keyboardHeight, false);
View backSpace = (View) popUpView.findViewById(R.id.imageBackspace);
backSpace.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0,
0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
editMessage.dispatchKeyEvent(event);
}
});
popupWindow.setOnDismissListener(new OnDismissListener() {
#Override
public void onDismiss() {
emoticonsCover.setVisibility(LinearLayout.GONE);
}
});
ViewPager pagerStickers = (ViewPager) popUpView
.findViewById(R.id.stickers_pager);
pagerStickers.setOffscreenPageLimit(3);
}
private void showKeyboardPopup(View root, boolean attaches) {
if (!popupWindow.isShowing()) {
popupWindow.setHeight((int) (keyboardHeight));
if (isKeyBoardVisible) {
imageEmoji.setImageResource(R.drawable.emoji_kbd);
emoticonsCover.setVisibility(LinearLayout.GONE);
} else {
imageEmoji.setImageResource(R.drawable.ic_down);
emoticonsCover.setVisibility(LinearLayout.VISIBLE);
}
try {
popupWindow.showAtLocation(root, Gravity.BOTTOM, 0, 0);
} catch (Exception e) {
}
} else {
imageEmoji.setImageResource(R.drawable.emoji_btn_normal);
popupWindow.dismiss();
return;
}
imageAttaches.setBackgroundColor(attaches ? 0xFF808080 : 0x00000000);
imageEmojis.setBackgroundColor(attaches ? 0x00000000 : 0xFF808080);
imageStickers.setBackgroundColor(0x00000000);
layoutEmojis.setVisibility(attaches ? View.GONE : View.VISIBLE);
layoutStickers.setVisibility(View.GONE);
}
Please checkout for more details click here.
Thanks hope this will help you.It is bit old but you can try it.
you can refer this github link for complete code
EmojiIcon
My code:
public void setAboveButton() {
aboveButton = new TextView(mContext);
ColorDrawable cd = new ColorDrawable(Color.GRAY);
aboveButton.setBackground(cd);
aboveButton.setText("<回游戏");
aboveButton.setGravity(Gravity.CENTER);
aboveButton.setTextSize(25);
aboveButton.setClickable(isClickable());
aboveButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
instance.setVisibility(View.INVISIBLE);
aboveView.setVisibility(View.INVISIBLE);
buttomView.setVisibility(View.INVISIBLE);
aboveButton.setVisibility(View.INVISIBLE);
buttomButton.setVisibility(View.INVISIBLE);
}
});
android.view.WindowManager.LayoutParams viewParams = new android.view.WindowManager.LayoutParams();
viewParams.x = -(dm.widthPixels);
viewParams.y = -(dm.heightPixels);
viewParams.width = dm.widthPixels / 4;
viewParams.height = 120;
instance.mWindowManager.addView(aboveButton, viewParams);
}
public void setBottomButton() {
buttomButton = new TextView(mContext);
ColorDrawable cd = new ColorDrawable(Color.GRAY);
buttomButton.setBackground(cd);
buttomButton.setText("发送");
buttomButton.setGravity(Gravity.CENTER);
buttomButton.setTextSize(25);
buttomButton.setClickable(isClickable());
buttomButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
aboveButton.setVisibility(View.INVISIBLE);
}
});
android.view.WindowManager.LayoutParams viewParams = new android.view.WindowManager.LayoutParams();
viewParams.x = -(dm.widthPixels);
viewParams.y = dm.heightPixels;
viewParams.width = dm.widthPixels / 4;
viewParams.height = 120;
instance.mWindowManager.addView(buttomButton, viewParams);
}
and my MainActivity:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
NoticeBoard.init(MainActivity.this);
NoticeBoard.getInstance().setAboveView();
NoticeBoard.getInstance().setBottomView();
NoticeBoard.getInstance().setBottomButton();
NoticeBoard.getInstance().setAboveButton();
setContentView(NoticeBoard.getInstance());
}
}
Right now, only the last onClick set works. How can I make them work together?
if I change the NoticeBoard.getInstance().setAboveButton() to bottom in the mainActivity,aboveButton's onclick will work,if I change the NoticeBoard.getInstance().setButtomButton() to bottom in mainActivity,bottomButton's onclick will work.
Thanks for your help!
I solve my problem. add flag'WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE' to WindowManager.LayoutParams in every view,and then all view will be worked~
I am using Sliding menu from library jfeinstein, i have two sliding menu 'menuLeft' 'menuRight' in my activity one from left side and one from right,i have toggle buttons for respective sliding menu,how ever if menuLeft is open and if i slide from right to left in order to close menuLeft ,menuRiht also gets opened,what can be the solution to avoid this misbehaviour
here's my activity which contains SlidingMenu's
public class ChatListActivity extends SherlockActivity {
private SlidingMenu menuLeft;
private SlidingMenu menuRight;
private Button btnSliderLeftToggle;
private Button btnSliderRightToggle;
private ListView lvSliderLeft;
private ListView lvSliderRight;
private int width;
private int height;
private DBContacts db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.chatlist_layout);
db = new DBContacts(this);
WindowManager wmanager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = wmanager.getDefaultDisplay();
width = display.getWidth();
height = display.getHeight();
menuLeft = new SlidingMenu(this);
menuRight = new SlidingMenu(this);
initLeftSlider();
initRightSlider();
btnSliderLeftToggle = (Button) findViewById(R.id.mnuSlidingleftToggle);
btnSliderLeftToggle.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v)
{
ChatListActivity.this.menuLeft.toggle();
}
});
btnSliderRightToggle = (Button) findViewById(R.id.mnuSlidingRightToggle);
btnSliderRightToggle.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View v)
{
ChatListActivity.this.menuRight.toggle();
}
});
menuLeft.setOnOpenedListener(new OnOpenedListener()
{
#Override
public void onOpened()
{
lvSliderLeft = (ListView) findViewById(R.id.lvSlidingmenuLeft);
MySLidingMenuLeftAdapter adapter = new MySLidingMenuLeftAdapter(ChatListActivity.this,
R.layout.crow_listview_lvslidingleft_chatlist);
lvSliderLeft.setAdapter(adapter);
}
});
menuRight.setOnOpenedListener(new OnOpenedListener()
{
#Override
public void onOpened()
{
lvSliderRight = (ListView) findViewById(R.id.lvSlidingmenuRight);
String column[] = new String[] { DBContacts.USERNAME};
int[] viewId = { R.id.txtContactName};
Cursor dataBaseCursor = db.getAllContacts();
MySLidingMenuRightAdapter customContactListAdapter = new MySLidingMenuRightAdapter(
ChatListActivity.this, R.layout.crow_lvslidingmenu_right_chatlist, dataBaseCursor, column,
viewId, 0);
lvSliderRight.setAdapter(customContactListAdapter);
}
});
}
private void initRightSlider()
{
menuRight.setMode(SlidingMenu.RIGHT);
menuRight.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menuRight.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menuRight.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menuRight.setMenu(R.layout.sliding_menu_chatlist_right);
menuRight.setFadeDegree(0.35f);
}
private void initLeftSlider()
{
menuLeft.setMode(SlidingMenu.LEFT);
menuLeft.setBehindOffsetRes(R.dimen.slidingmenu_offset);
menuLeft.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
menuLeft.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
menuLeft.setMenu(R.layout.sliding_menu_chatlist_left);
menuLeft.setFadeDegree(0.35f);
}
#Override
public void onBackPressed()
{
super.onBackPressed();
System.exit(0);
}
#Override
public boolean onCreateOptionsMenu(Menu menu)
{
menu.add("Refresh");
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item)
{
new SendNativeContacts(this).execute();
return true;
}
}
I have never faced this issue when i used both Left and Right SlidingMenu but for your problem you can have look at SlidingMenu Issues and you can try this solution for your problem. It may help you.
EDIT :
try this
You will need a patch which calls onOpened and onClosed methods for right menu it may have been included in latest code. Write logs to check method calls.
slidingMenuLeft.setOnOpenedListener(new OnOpenedListener() {
#Override
public void onOpened(int pos) {
slidingMenuRight.setSlidingEnabled(false);
}
});
slidingMenuLeft.setOnClosedListener(new OnClosedListener() {
#Override
public void onClosed() {
slidingMenuRight.setSlidingEnabled(true);
}
});
slidingMenuRight.setOnOpenedListener(new OnOpenedListener() {
#Override
public void onOpened(int pos) {
slidingMenuLeft.setSlidingEnabled(false);
}
});
slidingMenuRight.setOnClosedListener(new OnClosedListener() {
#Override
public void onClosed() {
slidingMenuLeft.setSlidingEnabled(true);
}
});