-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
L10: Created AnswersActivity, made models Parcelable, handling RV cli…
…ck events
- Loading branch information
Showing
18 changed files
with
383 additions
and
31 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
26 changes: 26 additions & 0 deletions
26
lesson10/src/main/java/com/orobator/helloandroid/lesson10/answers/AnswersActivity.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,26 @@ | ||
package com.orobator.helloandroid.lesson10.answers; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import com.orobator.helloandroid.lesson10.R; | ||
import com.orobator.helloandroid.stackoverflow.questions.Question; | ||
|
||
public class AnswersActivity extends AppCompatActivity { | ||
private static final String KEY_QUESTION = "question"; | ||
|
||
public static Intent getIntent(Context context, Question question) { | ||
Intent intent = new Intent(context, AnswersActivity.class); | ||
intent.putExtra(KEY_QUESTION, question); | ||
return intent; | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_answers); | ||
|
||
Question question = getIntent().getParcelableExtra(KEY_QUESTION); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...10/src/main/java/com/orobator/helloandroid/lesson10/answers/di/AnswersActivityModule.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,21 @@ | ||
package com.orobator.helloandroid.lesson10.answers.di; | ||
|
||
import com.orobator.helloandroid.stackoverflow.answers.AnswersApi; | ||
import com.orobator.helloandroid.stackoverflow.answers.AnswersRepository; | ||
import com.orobator.helloandroid.stackoverflow.answers.AnswersRepositoryImpl; | ||
import dagger.Module; | ||
import dagger.Provides; | ||
import retrofit2.Retrofit; | ||
|
||
@Module | ||
public class AnswersActivityModule { | ||
@Provides | ||
public AnswersApi provideAnswersApi(Retrofit retrofit) { | ||
return retrofit.create(AnswersApi.class); | ||
} | ||
|
||
@Provides | ||
public AnswersRepository provideAnswersRepository(AnswersApi answersApi) { | ||
return new AnswersRepositoryImpl(answersApi); | ||
} | ||
} |
12 changes: 9 additions & 3 deletions
12
lesson10/src/main/java/com/orobator/helloandroid/lesson10/di/ActivityBindingModule.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,11 +1,17 @@ | ||
package com.orobator.helloandroid.lesson10.di; | ||
|
||
import com.orobator.helloandroid.lesson10.view.QuestionsActivity; | ||
import com.orobator.helloandroid.lesson10.answers.AnswersActivity; | ||
import com.orobator.helloandroid.lesson10.answers.di.AnswersActivityModule; | ||
import com.orobator.helloandroid.lesson10.questions.di.QuestionsActivityModule; | ||
import com.orobator.helloandroid.lesson10.questions.view.QuestionsActivity; | ||
import dagger.Module; | ||
import dagger.android.ContributesAndroidInjector; | ||
|
||
@Module | ||
public abstract class ActivityBindingModule { | ||
abstract class ActivityBindingModule { | ||
@ContributesAndroidInjector(modules = { QuestionsActivityModule.class }) | ||
abstract QuestionsActivity bindNumberFactActivity(); | ||
abstract QuestionsActivity bindQuestionsActivity(); | ||
|
||
@ContributesAndroidInjector(modules = { AnswersActivityModule.class }) | ||
abstract AnswersActivity bindAnswersActivity(); | ||
} |
4 changes: 2 additions & 2 deletions
4
.../lesson10/di/QuestionsActivityModule.java → ...questions/di/QuestionsActivityModule.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
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
2 changes: 1 addition & 1 deletion
2
...lesson10/viewmodel/QuestionViewModel.java → ...uestions/viewmodel/QuestionViewModel.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
Oops, something went wrong.