Skip to content

Instantly share code, notes, and snippets.

View amitkma's full-sized avatar
🏠
Working from home

Amit Kumar amitkma

🏠
Working from home
View GitHub Profile
@amitkma
amitkma / style-script.gradle
Last active May 14, 2017 07:38
style-script.gradle for medium article.
apply plugin: 'checkstyle'
dependencies {
checkstyle 'com.puppycrawl.tools:checkstyle:7.7'
}
def checkstyleConfigDir = "$project.rootDir/config";
def reportsDir = "$project.buildDir/reports"
check.dependsOn 'checkstyle'
dependencies {
compile 'com.github.amitkma:stitch-lib:1.0.1'
annotationProcessor 'com.github.amitkma:compiler:1.0.1'
}
class ExampleClass {
public ExampleClass() {
}
@CallOnAnyThread
public Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// If getting instance in other class.
ExampleClassStitch exampleClassStitch = ExampleClassStitch.stitch(new ExampleClass());
// Or if getting instance in same class
ExampleClassStitch exampleClassStitch = ExampleClassStitch.stitch(this);.
exampleClassStitch.getBitmapFromURL("https://image.freepik.com/free-vector/android-boot-logo_634639.jpg");
/**
* Base presenter which act as a Presenter in Model-View-Presenter
* This interface will be extended by more specific interface which will be implemented
* in any class which want to act as a MVP presenter
*/
public interface MvpPresenter {
}
/**
* Base view which act as a View in Model-View-Presenter.
* This interface will be extended by more specific interface and which will be implemented
* in any class that want to act as a MVP view.
*/
public interface MvpView<T extends MvpPresenter> {
void setPresenter(T presenter);
void showProgress();
public interface MainContract {
interface View extends MvpView<Presenter> {
void updateView(List<Note> items);
}
interface Presenter extends MvpPresenter{
void addNote(String note);
public interface NoteDetailsContract {
interface View extends MvpView<Presenter> {
void showNote(Note note);
}
interface Presenter extends MvpPresenter{
void loadNoteById(int id);
public class MainActivity extends AppCompatActivity implements MainContract.View, View.OnClickListener {
// Contract Presenter
private MainContract.Presenter mPresenter;
......
// Other fields
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);