Skip to content

Instantly share code, notes, and snippets.

@mazurio
Created June 8, 2015 15:02
Show Gist options
  • Save mazurio/bfa3e4a77d259ec9e633 to your computer and use it in GitHub Desktop.
Save mazurio/bfa3e4a77d259ec9e633 to your computer and use it in GitHub Desktop.
Presenter in MVP (Android)
package io.mazur.presenter;
import java.io.Serializable;
import io.mazur.view.TestView;
public abstract class Presenter<T extends TestView> implements Serializable {
/**
* Transient is a Java keyword which marks a member variable not to be serialized when it is persisted to streams of bytes.
* When an object is transferred through the network, the object needs to be 'serialized'.
* Serialization converts the object state to serial bytes.
*/
protected transient T mView;
public void onCreateView(T view) {
mView = view;
}
public void onRestoreView(T view) {
mView = view;
}
public T getView() {
return mView;
}
public boolean isViewNotNull() {
if(mView == null) {
return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment