history changes

This commit is contained in:
Sergey Solovyev
2011-12-18 17:05:44 +04:00
parent 9d785e4b1e
commit df392185f3
12 changed files with 521 additions and 63 deletions

View 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();
}

View 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);
}

View 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();
}
}

View 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;
}
}

View File

@@ -308,7 +308,7 @@ public class DirectionDragButton extends DragButton {
}
protected static int getDefaultDirectionTextAlpha() {
return 150;
return 100;
}
@Nullable