Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ViewPresenter's hard dependency on android.view.View #191

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
import mortar.HasContext;

import javax.inject.Inject;

public class MainView extends LinearLayout {
public class MainView extends LinearLayout implements HasContext {
@Inject Main.Presenter presenter;

private TextView textView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.TextView;
import mortar.HasContext;

public class HelloView extends LinearLayout {
public class HelloView extends LinearLayout implements HasContext {
private final HelloPresenter presenter;

private TextView textView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import mortar.HasContext;
import mortar.dagger1support.ObjectGraphService;
import com.example.mortar.model.Chat;
import com.example.mortar.screen.ChatListScreen;
import java.util.List;
import javax.inject.Inject;

public class ChatListView extends ListView {
public class ChatListView extends ListView implements HasContext {
@Inject ChatListScreen.Presenter presenter;

public ChatListView(Context context, AttributeSet attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import mortar.HasContext;
import mortar.dagger1support.ObjectGraphService;
import com.example.mortar.model.Message;
import com.example.mortar.screen.ChatScreen;
import javax.inject.Inject;

public class ChatView extends ListView {
public class ChatView extends ListView implements HasContext {
@Inject ChatScreen.Presenter presenter;

private final ConfirmerPopup confirmerPopup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import mortar.HasContext;
import mortar.dagger1support.ObjectGraphService;
import com.example.mortar.model.User;
import com.example.mortar.screen.FriendListScreen;
import java.util.List;
import javax.inject.Inject;

public class FriendListView extends ListView {
public class FriendListView extends ListView implements HasContext {
@Inject FriendListScreen.Presenter presenter;

public FriendListView(Context context, AttributeSet attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;
import mortar.HasContext;
import mortar.dagger1support.ObjectGraphService;
import com.example.mortar.screen.FriendScreen;
import javax.inject.Inject;

public class FriendView extends TextView {
public class FriendView extends TextView implements HasContext {
@Inject FriendScreen.Presenter presenter;

public FriendView(Context context, AttributeSet attrs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import mortar.HasContext;
import mortar.dagger1support.ObjectGraphService;
import com.example.mortar.R;
import com.example.mortar.screen.MessageScreen;
import javax.inject.Inject;

public class MessageView extends LinearLayout {
public class MessageView extends LinearLayout implements HasContext {
@Inject MessageScreen.Presenter presenter;

private TextView userView;
Expand Down
7 changes: 7 additions & 0 deletions mortar/src/main/java/mortar/HasContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package mortar;

import android.content.Context;

public interface HasContext {
Context getContext();
}
3 changes: 1 addition & 2 deletions mortar/src/main/java/mortar/ViewPresenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
*/
package mortar;

import android.view.View;
import mortar.bundler.BundleService;

public class ViewPresenter<V extends View> extends Presenter<V> {
public class ViewPresenter<V extends HasContext> extends Presenter<V> {
@Override protected final BundleService extractBundleService(V view) {
return BundleService.getBundleService(view.getContext());
}
Expand Down