Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 94 additions & 24 deletions satellite-menu/src/android/view/ext/SatelliteMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,44 +120,107 @@ public void onClick(View v) {
internalItemClickListener = new InternalSatelliteOnClickListener(this);
}

/**
* issue:
* 1,when the menu was opened,we clicked the item frequently so that the item would closed,
* the issue occur:
* there is no response we click the imgMain to expand the menu again!!!!
*
* http://stackoverflow.com/questions/8213089/how-to-block-and-wait-using-atomicboolean
*
* there is a solution in above . includeing the final clause
*
*
* AtomicBoolean lock = new AtomicBoolean(false);
if(lock.compareAndSet(false, true)){
try {
//do something
} catch(Exception e){
//error handling
} finally {
lock.set(false);
}
}
*
* */


private void onClick() {
if (plusAnimationActive.compareAndSet(false, true)) {
if (!rotated) {
imgMain.startAnimation(mainRotateLeft);
for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getOutAnimation());
}
} else {
imgMain.startAnimation(mainRotateRight);
for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getInAnimation());

try {
//do something
if (!rotated) {
imgMain.startAnimation(mainRotateLeft);

//evan add imgMain checked image
//imgMain.setImageResource(R.drawable.menu_button_pressed);

for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getOutAnimation());
}
} else {
imgMain.startAnimation(mainRotateRight);

//evan add imgMain default image
//imgMain.setImageResource(R.drawable.sat_main);

for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getInAnimation());
}
}
}
rotated = !rotated;
rotated = !rotated;
} catch(Exception e){
//error handling
} finally {
plusAnimationActive.set(false);
}

}
}

private void openItems() {
if (plusAnimationActive.compareAndSet(false, true)) {
if (!rotated) {
imgMain.startAnimation(mainRotateLeft);
for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getOutAnimation());
try {
//do something
if (!rotated) {
imgMain.startAnimation(mainRotateLeft);
for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getOutAnimation());
}
}
}
rotated = !rotated;
rotated = !rotated;
} catch(Exception e){
//error handling
} finally {
plusAnimationActive.set(false);
}

}
}

private void closeItems() {
if (plusAnimationActive.compareAndSet(false, true)) {
if (rotated) {
imgMain.startAnimation(mainRotateRight);
for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getInAnimation());

try {
//do something
if (rotated) {
imgMain.startAnimation(mainRotateRight);

//evan add imgMain default image
//imgMain.setImageResource(R.drawable.sat_main);

for (SatelliteMenuItem item : menuItems) {
item.getView().startAnimation(item.getInAnimation());
}
}
}
rotated = !rotated;
rotated = !rotated;

} catch(Exception e){
//error handling
} finally {
plusAnimationActive.set(false);
}
}
}

Expand Down Expand Up @@ -342,6 +405,13 @@ public Map<View, SatelliteMenuItem> getViewToItemMap() {
return viewToItemMap;
}

/**
* @return ���չ�� rotateΪtrue
*/
public boolean getRotate(){
return rotated;
}

private static FrameLayout.LayoutParams getLayoutParams(View view) {
return (FrameLayout.LayoutParams) view.getLayoutParams();
}
Expand Down Expand Up @@ -544,4 +614,4 @@ public SavedState[] newArray(int size) {
}
};
}
}
}