-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jedsada Tiwongvorakul
committed
May 7, 2017
1 parent
ca24ec3
commit e9a4bd6
Showing
13 changed files
with
394 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 92 additions & 2 deletions
94
.../main/java/com/wisdomlanna/www/dagger2_mvp_example/template/frangment/CustomFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,94 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.template.frangment; | ||
|
||
public class CustomFragment { | ||
} | ||
import android.annotation.SuppressLint; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ApplicationComponent; | ||
import com.wisdomlanna.www.dagger2_mvp_example.R; | ||
import com.wisdomlanna.www.dagger2_mvp_example.Utils; | ||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.BaseFragment; | ||
|
||
import javax.inject.Inject; | ||
|
||
import butterknife.BindView; | ||
import timber.log.Timber; | ||
|
||
public class CustomFragment extends BaseFragment<CustomFragmentPresenter> | ||
implements CustomFragmentInterface.View { | ||
|
||
@Inject | ||
Utils utils; | ||
|
||
@BindView(R.id.tv_test) | ||
TextView tvTest; | ||
private int number; | ||
|
||
public static CustomFragment newInstance() { | ||
CustomFragment fragment = new CustomFragment(); | ||
Bundle bundle = new Bundle(); | ||
fragment.setArguments(bundle); | ||
return fragment; | ||
} | ||
|
||
@SuppressLint("DefaultLocale") | ||
@Override | ||
public void testResult() { | ||
Timber.d("status network : %b", utils.isNetworkAvailable()); | ||
tvTest.setText(String.format("test : %d", number)); | ||
} | ||
|
||
@Override | ||
protected int layoutToInflate() { | ||
return R.layout.custom_fragment; | ||
} | ||
|
||
@Override | ||
protected void doInjection(ApplicationComponent component) { | ||
component.inject(CustomFragment.this); | ||
} | ||
|
||
@Override | ||
protected void startView() { | ||
|
||
} | ||
|
||
@Override | ||
protected void stopView() { | ||
|
||
} | ||
|
||
@Override | ||
protected void bindView(View view) { | ||
|
||
} | ||
|
||
@Override | ||
protected void setupInstance() { | ||
|
||
} | ||
|
||
@Override | ||
protected void setupView() { | ||
|
||
} | ||
|
||
@Override | ||
protected void initialize() { | ||
Timber.d("initialize"); | ||
number = 5555; | ||
getPresenter().testFragment(); | ||
} | ||
|
||
@Override | ||
protected void saveInstanceState(Bundle outState) { | ||
outState.putInt("number", number); | ||
} | ||
|
||
@Override | ||
public void restoreView(Bundle savedInstanceState) { | ||
number = savedInstanceState.getInt("number"); | ||
testResult(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...a/com/wisdomlanna/www/dagger2_mvp_example/template/frangment/CustomFragmentInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.template.frangment; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.BaseInterface; | ||
|
||
class CustomFragmentInterface { | ||
|
||
interface View extends BaseInterface.View { | ||
void testResult(); | ||
} | ||
|
||
interface Presenter { | ||
void testFragment(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...a/com/wisdomlanna/www/dagger2_mvp_example/template/frangment/CustomFragmentPresenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.wisdomlanna.www.dagger2_mvp_example.template.frangment; | ||
|
||
import com.wisdomlanna.www.dagger2_mvp_example.ui.base.BasePresenter; | ||
|
||
import javax.inject.Inject; | ||
|
||
class CustomFragmentPresenter extends BasePresenter<CustomFragmentInterface.View> | ||
implements CustomFragmentInterface.Presenter { | ||
|
||
@Inject | ||
CustomFragmentPresenter() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void onViewCreate() { | ||
|
||
} | ||
|
||
@Override | ||
public void onViewDestroy() { | ||
|
||
} | ||
|
||
@Override | ||
public void onViewStart() { | ||
|
||
} | ||
|
||
@Override | ||
public void onViewStop() { | ||
|
||
} | ||
|
||
@Override | ||
public void testFragment() { | ||
getView().testResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.