New design of bookmark list activity.

This commit is contained in:
Dmitry Yunitsky 2015-05-19 18:30:31 +03:00 committed by Alex Zolotarev
parent 08eba39620
commit 31abef4ac0
51 changed files with 190 additions and 284 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 956 B

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 960 B

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 956 B

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 B

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 B

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 675 B

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 649 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

After

Width:  |  Height:  |  Size: 662 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_marginBottom="10dp" >
<EditText
android:id="@+id/pin_set_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:hint="@string/name"
android:imeOptions="actionDone"
android:inputType="textCapWords"
android:singleLine="true" />
</LinearLayout>

View file

@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"/>
</LinearLayout>

View file

@ -1,27 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- This view'll take focus. And user will not see keyboard when open this screen. -->
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:focusable="true"
android:focusableInTouchMode="true"/>
<include
layout="@layout/edit_bookmark_set"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:animationCache="false"
android:scrollingCache="false"/>
</LinearLayout>
<ListView
android:id="@android:id/list"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"/>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_oneline">
<ImageView
android:id="@+id/iv__bookmark_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_marginRight="@dimen/margin_medium"/>
<TextView
android:id="@+id/tv__bookmark_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/tv__bookmark_distance"
android:layout_toRightOf="@id/iv__bookmark_color"
android:singleLine="true"
android:textAppearance="@style/MwmTextAppearance.Body1"/>
<TextView
android:id="@+id/tv__bookmark_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_x_4"
android:textAppearance="@style/MwmTextAppearance.Body3"/>
</RelativeLayout>

View file

@ -12,6 +12,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:background="@null"
android:button="@drawable/btn_bookmark_visibility"
android:focusable="false"/>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/text"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/height_item_oneline"
android:gravity="left|center_vertical"
android:paddingLeft="@dimen/margin_medium"
android:paddingTop="@dimen/margin_small"
android:text="@string/bookmarks"/>

View file

@ -7,7 +7,7 @@
android:paddingRight="3dp" >
<ImageView
android:id="@+id/pi_pin_color"
android:id="@+id/iv__bookmark_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
@ -21,12 +21,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/pi_pin_color"
android:layout_toRightOf="@+id/iv__bookmark_color"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/pi_name"
android:id="@+id/tv__bookmark_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
@ -34,7 +34,7 @@
android:textColor="@color/text_dark" />
<TextView
android:id="@+id/pi_distance"
android:id="@+id/tv__bookmark_distance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Small"

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="3dp"
android:paddingRight="3dp" >
<ImageView
android:id="@+id/pi_pin_color"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp" />
<TextView
android:id="@+id/pi_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/pi_distance"
android:layout_toRightOf="@id/pi_pin_color"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="@color/text_dark" />
<TextView
android:id="@+id/pi_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_x_4"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="@color/text_dark_subtitle" />
</RelativeLayout>

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/dp_x_6" >
<!--style="@style/Holo.TextView.ListSeparator.Light"-->
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left|center"
android:paddingLeft="@dimen/dp_x_3"
android:text="@string/bookmarks" />
</LinearLayout>

View file

@ -1,11 +1,9 @@
package com.mapswithme.maps.base;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.inputmethod.InputMethodManager;
import com.mapswithme.maps.MWMApplication;
import com.mapswithme.maps.R;
@ -47,8 +45,6 @@ public class BaseMwmFragmentActivity extends AppCompatActivity
{
if (item.getItemId() == android.R.id.home)
{
final InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
onBackPressed();
return true;
}

View file

@ -17,6 +17,7 @@ import com.mapswithme.maps.bookmarks.data.BookmarkManager;
public class BookmarkCategoriesFragment extends BaseMwmListFragment
{
private int mSelectedPosition;
private BookmarkCategoriesAdapter mAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
@ -29,10 +30,23 @@ public class BookmarkCategoriesFragment extends BaseMwmListFragment
{
super.onViewCreated(view, savedInstanceState);
setListAdapter(new BookmarkCategoriesAdapter(getActivity()));
initAdapter();
setListAdapter(mAdapter);
registerForContextMenu(getListView());
}
private void initAdapter()
{
mAdapter = new BookmarkCategoriesAdapter(getActivity());
}
@Override
public void onResume()
{
super.onResume();
mAdapter.notifyDataSetChanged();
}
@Override
public void onListItemClick(ListView l, View v, int position, long id)
{

View file

@ -20,9 +20,7 @@ import com.mapswithme.maps.location.LocationHelper;
import com.mapswithme.util.UiUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BookmarkListAdapter extends BaseAdapter
@ -31,8 +29,13 @@ public class BookmarkListAdapter extends BaseAdapter
private final Activity mActivity;
private final BookmarkCategory mCategory;
// reuse drawables
private final Map<String, Drawable> mBmkToCircle = new HashMap<String, Drawable>(8);
// view types
static final int TYPE_TRACK = 0;
static final int TYPE_BOOKMARK = 1;
static final int TYPE_SECTION = 2;
private static final int SECTION_TRACKS = 0;
private static final int SECTION_BMKS = 1;
public BookmarkListAdapter(Activity activity, BookmarkCategory cat)
{
@ -56,10 +59,6 @@ public class BookmarkListAdapter extends BaseAdapter
return 3; // bookmark + track + section
}
final static int TYPE_TRACK = 0;
final static int TYPE_BMK = 1;
final static int TYPE_SECTION = 2;
@Override
public int getItemViewType(int position)
{
@ -70,13 +69,19 @@ public class BookmarkListAdapter extends BaseAdapter
return TYPE_SECTION;
if (position > bmkPos && !isSectionEmpty(SECTION_BMKS))
return TYPE_BMK;
return TYPE_BOOKMARK;
else if (position > trackPos && !isSectionEmpty(SECTION_TRACKS))
return TYPE_TRACK;
throw new IllegalArgumentException("Position not found: " + position);
}
@Override
public boolean isEnabled(int position)
{
return getItemViewType(position) != TYPE_SECTION;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
@ -84,35 +89,27 @@ public class BookmarkListAdapter extends BaseAdapter
if (type == TYPE_SECTION)
{
View sectionView = null;
TextView sectionName = null;
TextView sectionView;
if (convertView == null)
{
sectionView = LayoutInflater.from(mActivity).inflate(R.layout.list_separator_base, null);
sectionName = (TextView) sectionView.findViewById(R.id.text);
sectionView.setTag(sectionName);
}
sectionView = (TextView) LayoutInflater.from(mActivity).inflate(R.layout.item_category_title, parent, false);
else
{
sectionView = convertView;
sectionName = (TextView) sectionView.getTag();
}
sectionView = (TextView) convertView;
final int sectionIndex = getSectionForPosition(position);
sectionName.setText(getSections().get(sectionIndex));
sectionView.setText(getSections().get(sectionIndex));
return sectionView;
}
if (convertView == null)
{
final int id = (type == TYPE_BMK) ? R.layout.list_item_bookmark : R.layout.list_item_track;
convertView = LayoutInflater.from(mActivity).inflate(id, null);
final int id = (type == TYPE_BOOKMARK) ? R.layout.item_bookmark : R.layout.item_track;
convertView = LayoutInflater.from(mActivity).inflate(id, parent, false);
convertView.setTag(new PinHolder(convertView));
}
final PinHolder holder = (PinHolder) convertView.getTag();
if (type == TYPE_BMK)
if (type == TYPE_BOOKMARK)
holder.set((Bookmark) getItem(position));
else
holder.set((Track) getItem(position));
@ -169,9 +166,9 @@ public class BookmarkListAdapter extends BaseAdapter
public PinHolder(View convertView)
{
icon = (ImageView) convertView.findViewById(R.id.pi_pin_color);
name = (TextView) convertView.findViewById(R.id.pi_name);
distance = (TextView) convertView.findViewById(R.id.pi_distance);
icon = (ImageView) convertView.findViewById(R.id.iv__bookmark_color);
name = (TextView) convertView.findViewById(R.id.tv__bookmark_name);
distance = (TextView) convertView.findViewById(R.id.tv__bookmark_distance);
}
void setName(Bookmark bmk)
@ -201,22 +198,9 @@ public class BookmarkListAdapter extends BaseAdapter
distance.setText(mActivity.getString(R.string.length) + " " + trk.getLengthString());
}
void setIcon(Bookmark bmk)
void setIcon(Bookmark bookmark)
{
final String key = bmk.getIcon().getType();
Drawable circle = null;
if (!mBmkToCircle.containsKey(key))
{
final Resources res = mActivity.getResources();
final int circleSize = (int) (res.getDimension(R.dimen.circle_size) + .5);
circle = UiUtils.drawCircleForPin(key, circleSize, res);
mBmkToCircle.put(key, circle);
}
else
circle = mBmkToCircle.get(key);
icon.setImageDrawable(circle);
icon.setImageResource(bookmark.getIcon().getSelectedResId());
}
void setIcon(Track trk)
@ -243,9 +227,6 @@ public class BookmarkListAdapter extends BaseAdapter
}
}
private final static int SECTION_TRACKS = 0;
private final static int SECTION_BMKS = 1;
private int getTracksSectionPosition()
{
if (isSectionEmpty(SECTION_TRACKS))

View file

@ -6,8 +6,6 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
@ -17,7 +15,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import com.mapswithme.maps.Framework;
@ -34,61 +31,99 @@ import com.mapswithme.util.ShareAction;
public class BookmarksListFragment extends BaseMwmListFragment
{
public static final String TAG = "BookmarkListActivity";
public static final String TAG = BookmarksListFragment.class.getSimpleName();
private static final int ID_SEND_BY_EMAIL = 0x01;
private static final int MENU_DELETE_TRACK = 0x42;
private EditText mSetName;
private BookmarkCategory mEditedSet;
private BookmarkCategory mCategory;
private int mCategoryIndex;
private int mSelectedPosition;
private BookmarkListAdapter mPinAdapter;
private int mIndex;
private BookmarkListAdapter mAdapter;
private ActionBar mActionBar;
// Menu routines
static final int ID_SEND_BY_EMAIL = 0x01;
static final int MENU_DELETE_TRACK = 0x42;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_bookmarks_list, container, false);
setUpViews(root);
return root;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
createListAdapter();
registerForContextMenu(getListView());
setHasOptionsMenu(true);
if (getActivity() instanceof AppCompatActivity)
mActionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Initialize with passed edited set.
mIndex = getArguments().getInt(ChooseBookmarkCategoryActivity.BOOKMARK_SET, -1);
mEditedSet = BookmarkManager.INSTANCE.getCategoryById(mIndex);
mCategoryIndex = getArguments().getInt(ChooseBookmarkCategoryActivity.BOOKMARK_SET, -1);
mCategory = BookmarkManager.INSTANCE.getCategoryById(mCategoryIndex);
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
return inflater.inflate(R.layout.fragment_bookmarks_list, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
initListAdapter();
setListAdapter(mAdapter);
registerForContextMenu(getListView());
setHasOptionsMenu(true);
if (getActivity() instanceof AppCompatActivity)
{
mActionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
mActionBar.setTitle(mCategory.getName());
}
}
@Override
public void onStart()
{
super.onStart();
mAdapter.notifyDataSetChanged();
}
@Override
public void onResume()
{
super.onResume();
mAdapter.startLocationUpdate();
}
@Override
public void onPause()
{
super.onPause();
mAdapter.stopLocationUpdate();
}
private void initListAdapter()
{
mAdapter = new BookmarkListAdapter(getActivity(), mCategory);
mAdapter.startLocationUpdate();
}
private void assignCategoryParams()
{
// TODO add dialog to edit category name
// final String name = mSetName.getText().toString();
// if (!name.equals(mCategory.getName()))
// BookmarkManager.INSTANCE.setCategoryName(mCategory, name);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id)
{
switch (mPinAdapter.getItemViewType(position))
switch (mAdapter.getItemViewType(position))
{
case BookmarkListAdapter.TYPE_SECTION:
return;
case BookmarkListAdapter.TYPE_BMK:
final Bookmark bmk = (Bookmark) mPinAdapter.getItem(position);
BookmarkManager.INSTANCE.showBookmarkOnMap(mIndex, bmk.getBookmarkId());
case BookmarkListAdapter.TYPE_BOOKMARK:
final Bookmark bookmark = (Bookmark) mAdapter.getItem(position);
BookmarkManager.INSTANCE.showBookmarkOnMap(mCategoryIndex, bookmark.getBookmarkId());
break;
case BookmarkListAdapter.TYPE_TRACK:
final Track track = (Track) mPinAdapter.getItem(position);
final Track track = (Track) mAdapter.getItem(position);
Framework.nativeShowTrackRect(track.getCategoryId(), track.getTrackId());
break;
}
@ -98,68 +133,26 @@ public class BookmarksListFragment extends BaseMwmListFragment
startActivity(i);
}
private void createListAdapter()
{
mPinAdapter = new BookmarkListAdapter(getActivity(), mEditedSet);
setListAdapter(mPinAdapter);
mPinAdapter.startLocationUpdate();
}
private void assignCategoryParams()
{
final String name = mSetName.getText().toString();
if (!name.equals(mEditedSet.getName()))
BookmarkManager.INSTANCE.setCategoryName(mEditedSet, name);
}
private void setUpViews(ViewGroup root)
{
mSetName = (EditText) root.findViewById(R.id.pin_set_name);
mSetName.setText(mEditedSet.getName());
mSetName.addTextChangedListener(new TextWatcher()
{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// Note! Do not set actual name here - saving process may be too long
// see assignCategoryParams() instead.
if (mActionBar != null)
mActionBar.setTitle(s);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {}
});
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
assignCategoryParams();
// Some list views can be section delimiters.
if (menuInfo instanceof AdapterView.AdapterContextMenuInfo)
{
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
mSelectedPosition = info.position;
final Object obj = mPinAdapter.getItem(mSelectedPosition);
final int type = mPinAdapter.getItemViewType(mSelectedPosition);
final Object obj = mAdapter.getItem(mSelectedPosition);
final int type = mAdapter.getItemViewType(mSelectedPosition);
if (type == BookmarkListAdapter.TYPE_BMK)
if (type == BookmarkListAdapter.TYPE_BOOKMARK)
{
final MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.pin_sets_context_menu, menu);
for (final ShareAction sa : ShareAction.ACTIONS.values())
for (final ShareAction action : ShareAction.ACTIONS.values())
{
if (sa.isSupported(getActivity()))
menu.add(Menu.NONE, sa.getId(), sa.getId(), getResources().getString(sa.getNameResId()));
if (action.isSupported(getActivity()))
menu.add(Menu.NONE, action.getId(), action.getId(), getResources().getString(action.getNameResId()));
}
menu.setHeaderTitle(((Bookmark) obj).getName());
@ -178,16 +171,16 @@ public class BookmarksListFragment extends BaseMwmListFragment
public boolean onContextItemSelected(MenuItem item)
{
final int itemId = item.getItemId();
final Object obj = mPinAdapter.getItem(mSelectedPosition);
final Object obj = mAdapter.getItem(mSelectedPosition);
if (itemId == R.id.set_edit)
{
startPinActivity(mEditedSet.getId(), ((Bookmark) obj).getBookmarkId());
startPinActivity(mCategory.getId(), ((Bookmark) obj).getBookmarkId());
}
else if (itemId == R.id.set_delete)
{
BookmarkManager.INSTANCE.deleteBookmark((Bookmark) obj);
mPinAdapter.notifyDataSetChanged();
mAdapter.notifyDataSetChanged();
}
else if (ShareAction.ACTIONS.containsKey(itemId))
{
@ -197,7 +190,7 @@ public class BookmarksListFragment extends BaseMwmListFragment
else if (itemId == MENU_DELETE_TRACK)
{
BookmarkManager.INSTANCE.deleteTrack((Track) obj);
mPinAdapter.notifyDataSetChanged();
mAdapter.notifyDataSetChanged();
}
return super.onContextItemSelected(item);
@ -209,38 +202,10 @@ public class BookmarksListFragment extends BaseMwmListFragment
.putExtra(ChooseBookmarkCategoryActivity.BOOKMARK, new ParcelablePoint(cat, bmk)));
}
@Override
public void onResume()
{
super.onResume();
mPinAdapter.startLocationUpdate();
}
@Override
public void onStart()
{
super.onStart();
mPinAdapter.notifyDataSetChanged();
}
@Override
public void onPause()
{
assignCategoryParams();
mPinAdapter.stopLocationUpdate();
super.onPause();
}
private void sendBookmarkMail()
{
assignCategoryParams();
String path = MWMApplication.get().getTempPath();
final String name = BookmarkManager.INSTANCE.saveToKmzFile(mEditedSet.getId(), path);
final String name = BookmarkManager.INSTANCE.saveToKmzFile(mCategory.getId(), path);
if (name == null)
{
// some error occurred
@ -268,7 +233,7 @@ public class BookmarksListFragment extends BaseMwmListFragment
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
{
//
// TODO add options menu
}
@Override