problem with drawable

This commit is contained in:
GaidamakUA 2015-08-22 18:08:47 +03:00
parent b118e9f5a3
commit 2a856156cc
3 changed files with 20 additions and 10 deletions

View file

@ -23,8 +23,12 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import org.apache.commons.logging.Log;
public class ContextMenuAdapter {
// Log log =
public interface OnContextMenuClick {
//boolean return type needed to desribe if drawer needed to be close or not
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked);
@ -345,7 +349,12 @@ public class ContextMenuAdapter {
Drawable imageId = getImage(app, position, holoLight);
if (imageId != null) {
if (layoutId == R.layout.simple_list_menu_item) {
tv.setCompoundDrawablesWithIntrinsicBounds(imageId, null, null, null);
float density = activity.getResources().getDisplayMetrics().density;
int paddingInPixels = (int) (24 * density);
int drawableSizeInPixels = (int) (50 * density); // 32
imageId.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels);
tv.setCompoundDrawables(imageId, null, null, null);
tv.setCompoundDrawablePadding(paddingInPixels);
} else {
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);

View file

@ -221,6 +221,7 @@ public class MapActivity extends AccessibleActivity {
FirstUsageFragment.TAG).commit();
}
ListView menuItemsListView = (ListView) findViewById(R.id.menuItems);
menuItemsListView.setDivider(null);
menuItemsListView.setAdapter(mapActions.createMainOptionsMenu().createSimpleListAdapter(this, true));
}

View file

@ -544,6 +544,14 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
return false;
}
}).reg();
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
.listen(new OnContextMenuClick() {
@Override
@ -557,15 +565,7 @@ public class MapActivityActions implements DialogProvider {
return true;
}
}).reg();
optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
return false;
}
}).reg();
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.item(R.string.search_button)
.iconColor(R.drawable.ic_action_search_dark)
.listen(new OnContextMenuClick() {