blob: e1f441ddf2cdc4857abee246dc406688b65071cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
package com.mapswithme.maps.widget.placepage;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import com.mapswithme.maps.R;
import com.mapswithme.maps.bookmarks.IconsAdapter;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.Icon;
import java.util.List;
public class BookmarkColorDialogFragment extends DialogFragment
{
public static final String ICON_TYPE = "ExtraIconType";
private String mIconType;
interface OnBookmarkColorChangeListener
{
void onBookmarkColorSet(int colorPos);
}
private OnBookmarkColorChangeListener mColorSetListener;
public BookmarkColorDialogFragment() {}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
if (getArguments() != null)
mIconType = getArguments().getString(ICON_TYPE);
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setView(buildView()).
setTitle(R.string.bookmark_color).
setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
});
return builder.create();
}
public void setOnColorSetListener(OnBookmarkColorChangeListener listener)
{
mColorSetListener = listener;
}
private View buildView()
{
final List<Icon> icons = BookmarkManager.getIcons();
final IconsAdapter adapter = new IconsAdapter(getActivity(), icons);
adapter.chooseItem(mIconType);
final GridView gView = (GridView) LayoutInflater.from(getActivity()).inflate(R.layout.fragment_color_grid, null);
gView.setAdapter(adapter);
gView.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View who, int pos, long id)
{
if (mColorSetListener != null)
mColorSetListener.onBookmarkColorSet(pos);
dismiss();
}
});
return gView;
}
}
|