Code refactoring
This commit is contained in:
parent
d68c669396
commit
03272e0712
|
@ -42,8 +42,8 @@ public class DetailModel implements Model.Detail {
|
|||
presenter = null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
|
||||
private void sendMessage(String message) {
|
||||
presenter.showMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ public class ItemModel implements Model.Item {
|
|||
presenter = null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
|
||||
private void sendMessage(String message) {
|
||||
presenter.showMessage(message);
|
||||
}
|
||||
// events <--
|
||||
|
|
|
@ -18,7 +18,6 @@ public interface Model {
|
|||
void onDestroy(boolean isConfigurationChanging);
|
||||
void executeQuery();
|
||||
void notifyDataSetChanged();
|
||||
void sendMessage(String message);
|
||||
void onEvent(Message event);
|
||||
}
|
||||
|
||||
|
@ -28,9 +27,9 @@ public interface Model {
|
|||
int getSetsCount();
|
||||
void setPresenter(Presenter.SetList presenter);
|
||||
Presenter.SetList getPresenter();
|
||||
|
||||
//GLM
|
||||
List<hikapro.com.backpack.model.entities.Set> getSet();
|
||||
List<hikapro.com.backpack.model.entities.Set> getSets(); // tag renamed
|
||||
void setsReorderNotify();
|
||||
}
|
||||
|
||||
interface Item extends Base {
|
||||
|
|
|
@ -66,8 +66,8 @@ public class SetModel implements Model.Set {
|
|||
presenter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
|
||||
private void sendMessage(String message) {
|
||||
presenter.showMessage(message);
|
||||
}
|
||||
|
||||
|
@ -104,6 +104,14 @@ public class SetModel implements Model.Set {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setsReorderNotify() {
|
||||
Message command = Message.obtain();
|
||||
command.what = Command.SET_REORDER;
|
||||
command.obj = cache;
|
||||
dao.executeCommand(command);
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region other
|
||||
|
@ -124,8 +132,8 @@ public class SetModel implements Model.Set {
|
|||
//GLM
|
||||
|
||||
@Override
|
||||
public List<hikapro.com.backpack.model.entities.Set> getSet()
|
||||
public List<hikapro.com.backpack.model.entities.Set> getSets()
|
||||
{
|
||||
return iList;
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,11 @@ package hikapro.com.backpack.presenter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.widget.DefaultItemAnimator;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.DragEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -17,14 +14,12 @@ import java.lang.ref.WeakReference;
|
|||
import java.util.Collections;
|
||||
|
||||
import hikapro.com.backpack.R;
|
||||
import hikapro.com.backpack.model.SetModel;
|
||||
import hikapro.com.backpack.model.Model;
|
||||
import hikapro.com.backpack.model.entities.Set;
|
||||
import hikapro.com.backpack.presenter.adapters.SetListAdapter;
|
||||
import hikapro.com.backpack.presenter.adapters.helper.OnStartDragListener;
|
||||
import hikapro.com.backpack.presenter.adapters.helper.SimpleItemTouchHelperCallback;
|
||||
import hikapro.com.backpack.view.View;
|
||||
import hikapro.com.backpack.view.fragments.SetListFragment;
|
||||
import hikapro.com.backpack.view.recycler.SetViewHolder;
|
||||
|
||||
/**
|
||||
|
@ -51,15 +46,16 @@ public class SetListPresenter implements Presenter.SetList {
|
|||
//GLM_add_resources_SetList
|
||||
@Override
|
||||
public void onItemDismiss(int position) {
|
||||
model.getSet().remove(position);
|
||||
model.getSets().remove(position);
|
||||
adapter.notifyItemRemoved(position);
|
||||
}
|
||||
|
||||
//GLM_add_resources_SetList
|
||||
@Override
|
||||
public boolean onItemMove(int fromPosition, int toPosition) {
|
||||
Collections.swap(model.getSet(), fromPosition, toPosition);
|
||||
Collections.swap(model.getSets(), fromPosition, toPosition);
|
||||
adapter.notifyItemMoved(fromPosition, toPosition);
|
||||
model.setsReorderNotify();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue