Refactor save-tags - closes #112

This commit is contained in:
Negue 2015-12-06 21:25:07 +01:00
parent 8555def802
commit 190a2eb66a
5 changed files with 12 additions and 20 deletions

View file

@ -26,6 +26,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:textColor="@color/white"
android:text="+" />
</LinearLayout>
</LinearLayout>

View file

@ -73,7 +73,9 @@ public class EditTextDrawer extends BasePrimaryDrawerItem<EditTextDrawer> {
@Override
public void onClick(View v) {
if (editText.getText().equals(""))
String text = editText.getText().toString();
if (text.equals(""))
return;
EventBus.getDefault().post(new CreateTagCommand(editText.getText().toString()));

View file

@ -133,16 +133,6 @@ public class PartyFragment extends BaseFragment {
}
});
tabLayout.setupWithViewPager(viewPager);
}
//region Events
// until there is a party event
public void onEvent(CreateTagCommand event) {
}
}

View file

@ -391,14 +391,19 @@ public class TasksFragment extends BaseFragment implements TaskScoringCallback.O
//region Events
public void onEvent(CreateTagCommand event) {
Tag t = new Tag();
public void onEvent(final CreateTagCommand event) {
final Tag t = new Tag();
t.setName(event.tagName);
t.async().save();
mAPIHelper.apiService.createTag(t, new Callback<List<Tag>>() {
@Override
public void success(List<Tag> tags, Response response) {
// Since we get a list of all tags, we just save them all
for(Tag onlineTag : tags){
onlineTag.user_id = user.getId();
onlineTag.async().save();
}
fillTagFilterDrawer(tags);
}

View file

@ -9,7 +9,6 @@ import android.view.View;
import android.view.ViewGroup;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.events.commands.CreateTagCommand;
/**
* Created by viirus on 19/11/15.
@ -34,9 +33,4 @@ public class TavernFragment extends BaseFragment {
fragmentTransaction.replace(R.id.tavern_framelayout, fragment);
fragmentTransaction.commit();
}
//we don't have custom tavern events right now.
public void onEvent(CreateTagCommand event) {
}
}