|
|
|
@ -17,59 +17,58 @@ import javax.inject.Inject;
|
|
|
|
|
|
|
|
|
|
public class TagViewFragment extends TaskListFragment {
|
|
|
|
|
|
|
|
|
|
public static final String EXTRA_TAG_NAME = "tag"; //$NON-NLS-1$
|
|
|
|
|
private static final String EXTRA_TAG_DATA = "extra_tag_data";
|
|
|
|
|
|
|
|
|
|
public static final String EXTRA_TAG_NAME = "tag"; //$NON-NLS-1$
|
|
|
|
|
public static final String EXTRA_TAG_UUID = "uuid"; //$NON-NLS-1$
|
|
|
|
|
|
|
|
|
|
protected TagData tagData;
|
|
|
|
|
|
|
|
|
|
@Inject TagDataDao tagDataDao;
|
|
|
|
|
|
|
|
|
|
private boolean dataLoaded = false;
|
|
|
|
|
|
|
|
|
|
// --- UI initialization
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onActivityCreated(final Bundle savedInstanceState) {
|
|
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
getListView().setOnKeyListener(null);
|
|
|
|
|
}
|
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
if (savedInstanceState != null) {
|
|
|
|
|
tagData = savedInstanceState.getParcelable(EXTRA_TAG_DATA);
|
|
|
|
|
} else {
|
|
|
|
|
String tag = extras.getString(EXTRA_TAG_NAME);
|
|
|
|
|
String uuid = RemoteModel.NO_UUID;
|
|
|
|
|
if (extras.containsKey(EXTRA_TAG_UUID)) {
|
|
|
|
|
uuid = extras.getString(EXTRA_TAG_UUID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// --- data loading
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void initializeData() {
|
|
|
|
|
synchronized(this) {
|
|
|
|
|
if(dataLoaded) {
|
|
|
|
|
if(tag == null && RemoteModel.NO_UUID.equals(uuid)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
dataLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String tag = extras.getString(EXTRA_TAG_NAME);
|
|
|
|
|
String uuid = RemoteModel.NO_UUID;
|
|
|
|
|
if (extras.containsKey(EXTRA_TAG_UUID)) {
|
|
|
|
|
uuid = extras.getString(EXTRA_TAG_UUID);
|
|
|
|
|
}
|
|
|
|
|
tagData = RemoteModel.isUuidEmpty(uuid)
|
|
|
|
|
? tagDataDao.getTagByName(tag, TagData.PROPERTIES)
|
|
|
|
|
: tagDataDao.getByUuid(uuid, TagData.PROPERTIES);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tag == null && RemoteModel.NO_UUID.equals(uuid)) {
|
|
|
|
|
return;
|
|
|
|
|
if (tagData == null) {
|
|
|
|
|
tagData = new TagData();
|
|
|
|
|
tagData.setName(tag);
|
|
|
|
|
tagData.setUUID(uuid);
|
|
|
|
|
tagDataDao.persist(tagData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onActivityCreated(final Bundle savedInstanceState) {
|
|
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
|
|
|
|
|
tagData = RemoteModel.isUuidEmpty(uuid)
|
|
|
|
|
? tagDataDao.getTagByName(tag, TagData.PROPERTIES)
|
|
|
|
|
: tagDataDao.getByUuid(uuid, TagData.PROPERTIES);
|
|
|
|
|
getListView().setOnKeyListener(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tagData == null) {
|
|
|
|
|
tagData = new TagData();
|
|
|
|
|
tagData.setName(tag);
|
|
|
|
|
tagData.setUUID(uuid);
|
|
|
|
|
tagDataDao.persist(tagData);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void onSaveInstanceState(Bundle outState) {
|
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
|
|
|
|
|
|
super.initializeData();
|
|
|
|
|
outState.putParcelable(EXTRA_TAG_DATA, tagData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|