history changes
This commit is contained in:
23
src/main/java/org/solovyev/android/view/AMenu.java
Normal file
23
src/main/java/org/solovyev/android/view/AMenu.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||
* For more information, please, contact se.solovyev@gmail.com
|
||||
* or visit http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.view;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
* Time: 1:30 PM
|
||||
*/
|
||||
public interface AMenu<T extends AMenuItem> {
|
||||
@Nullable
|
||||
T itemAt(int i);
|
||||
|
||||
@NotNull
|
||||
CharSequence[] getMenuCaptions();
|
||||
}
|
23
src/main/java/org/solovyev/android/view/AMenuItem.java
Normal file
23
src/main/java/org/solovyev/android/view/AMenuItem.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||
* For more information, please, contact se.solovyev@gmail.com
|
||||
* or visit http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.view;
|
||||
|
||||
import android.content.Context;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
* Time: 1:29 PM
|
||||
*/
|
||||
public interface AMenuItem<T> {
|
||||
|
||||
@NotNull
|
||||
String getCaption();
|
||||
|
||||
void doAction(@NotNull T data, @NotNull Context context);
|
||||
}
|
35
src/main/java/org/solovyev/android/view/EnumMenu.java
Normal file
35
src/main/java/org/solovyev/android/view/EnumMenu.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||
* For more information, please, contact se.solovyev@gmail.com
|
||||
* or visit http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.view;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
* Time: 1:34 PM
|
||||
*/
|
||||
public class EnumMenu<T extends Enum & AMenuItem> implements AMenu<T> {
|
||||
|
||||
@NotNull
|
||||
private final AMenu<T> menu;
|
||||
|
||||
public EnumMenu(Class<T> enumClass) {
|
||||
this.menu = new MenuImpl<T>(enumClass.getEnumConstants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public T itemAt(int i) {
|
||||
return this.menu.itemAt(i);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public CharSequence[] getMenuCaptions() {
|
||||
return this.menu.getMenuCaptions();
|
||||
}
|
||||
}
|
52
src/main/java/org/solovyev/android/view/MenuImpl.java
Normal file
52
src/main/java/org/solovyev/android/view/MenuImpl.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2009-2011. Created by serso aka se.solovyev.
|
||||
* For more information, please, contact se.solovyev@gmail.com
|
||||
* or visit http://se.solovyev.org
|
||||
*/
|
||||
|
||||
package org.solovyev.android.view;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.solovyev.common.utils.CollectionsUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 12/18/11
|
||||
* Time: 1:31 PM
|
||||
*/
|
||||
public class MenuImpl<T extends AMenuItem> implements AMenu<T> {
|
||||
|
||||
private final List<T> menuItems = new ArrayList<T>();
|
||||
|
||||
public MenuImpl(T... menuItems) {
|
||||
this(CollectionsUtils.asList(menuItems));
|
||||
}
|
||||
|
||||
public MenuImpl(@NotNull List<T> menuItems) {
|
||||
this.menuItems.addAll(menuItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T itemAt(int i) {
|
||||
if (i >= 0 && i < menuItems.size()) {
|
||||
return menuItems.get(i);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CharSequence[] getMenuCaptions() {
|
||||
final CharSequence[] result = new CharSequence[this.menuItems.size()];
|
||||
for (int i = 0; i < this.menuItems.size(); i++) {
|
||||
result[i] = this.menuItems.get(i).getCaption();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -308,7 +308,7 @@ public class DirectionDragButton extends DragButton {
|
||||
}
|
||||
|
||||
protected static int getDefaultDirectionTextAlpha() {
|
||||
return 150;
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
Reference in New Issue
Block a user