-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* HomeFragment xml introduction * Promoted Story ViewModel * PromotedStoryViewModel * Basic promoted story * Promoted story data display * Promoted card display * GridLayoutManager * Functional HomeFragment * Click listeners * Click listeners final * Chapter name issue fixed * Fully functional with click listeners * Introduce ContinuePlayingActivity * Click listener integration * Test for ContinuePlayingActivity * HomeTest cases * Nit changes * Nit suggested changes * Code updated as per suggestions * Added HomeItemViewModel * Nit changes * Orientation Change * EOF * Test fix
- Loading branch information
Showing
41 changed files
with
1,322 additions
and
70 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
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/oppia/app/databinding/DrawableBindingAdapters.kt
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,15 @@ | ||
package org.oppia.app.databinding | ||
|
||
import android.graphics.drawable.GradientDrawable | ||
import android.view.View | ||
import androidx.annotation.ColorInt | ||
import androidx.databinding.BindingAdapter | ||
import org.oppia.app.R | ||
|
||
/** Used to set a rounded-rect background drawable with a data-bound color. */ | ||
@BindingAdapter("app:roundedRectDrawableWithColor") | ||
fun setBackgroundDrawable(view: View, @ColorInt colorRgb: Int) { | ||
view.setBackgroundResource(R.drawable.rounded_rect_background) | ||
// The input color needs to have alpha channel prepended to it. | ||
(view.background as GradientDrawable).setColor((0xff000000 or colorRgb.toLong()).toInt()) | ||
} |
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
25 changes: 25 additions & 0 deletions
25
app/src/main/java/org/oppia/app/home/ContinuePlayingActivity.kt
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,25 @@ | ||
package org.oppia.app.home | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import org.oppia.app.activity.InjectableAppCompatActivity | ||
import javax.inject.Inject | ||
|
||
/** Activity for recent stories. */ | ||
class ContinuePlayingActivity : InjectableAppCompatActivity() { | ||
@Inject lateinit var continuePlayingActivityPresenter: ContinuePlayingActivityPresenter | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
activityComponent.inject(this) | ||
continuePlayingActivityPresenter.handleOnCreate() | ||
} | ||
|
||
companion object { | ||
/** Returns a new [Intent] to route to [ContinuePlayingActivity]. */ | ||
fun createContinuePlayingActivityIntent(context: Context): Intent { | ||
return Intent(context, ContinuePlayingActivity::class.java) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/org/oppia/app/home/ContinuePlayingActivityPresenter.kt
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,24 @@ | ||
package org.oppia.app.home | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import org.oppia.app.R | ||
import org.oppia.app.activity.ActivityScope | ||
import javax.inject.Inject | ||
|
||
/** The presenter for [ContinuePlayingActivity]. */ | ||
@ActivityScope | ||
class ContinuePlayingActivityPresenter @Inject constructor(private val activity: AppCompatActivity) { | ||
fun handleOnCreate() { | ||
activity.setContentView(R.layout.continue_playing_activity) | ||
if (getContinuePlayingFragment() == null) { | ||
activity.supportFragmentManager.beginTransaction().add( | ||
R.id.continue_playing_fragment_placeholder, | ||
ContinuePlayingFragment() | ||
).commitNow() | ||
} | ||
} | ||
|
||
private fun getContinuePlayingFragment(): ContinuePlayingFragment? { | ||
return activity.supportFragmentManager.findFragmentById(R.id.continue_playing_fragment_placeholder) as ContinuePlayingFragment? | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/org/oppia/app/home/ContinuePlayingFragment.kt
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,23 @@ | ||
package org.oppia.app.home | ||
|
||
import android.content.Context | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import org.oppia.app.fragment.InjectableFragment | ||
import javax.inject.Inject | ||
|
||
/** Fragment that contains all recently played stories. */ | ||
class ContinuePlayingFragment : InjectableFragment() { | ||
@Inject lateinit var continuePlayingFragmentPresenter: ContinuePlayingFragmentPresenter | ||
|
||
override fun onAttach(context: Context?) { | ||
super.onAttach(context) | ||
fragmentComponent.inject(this) | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return continuePlayingFragmentPresenter.handleCreateView(inflater, container) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/java/org/oppia/app/home/ContinuePlayingFragmentPresenter.kt
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,16 @@ | ||
package org.oppia.app.home | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import org.oppia.app.databinding.ContinuePlayingFragmentBinding | ||
import org.oppia.app.fragment.FragmentScope | ||
import javax.inject.Inject | ||
|
||
/** The presenter for [ContinuePlayingFragment]. */ | ||
@FragmentScope | ||
class ContinuePlayingFragmentPresenter @Inject constructor() { | ||
fun handleCreateView(inflater: LayoutInflater, container: ViewGroup?): View? { | ||
return ContinuePlayingFragmentBinding.inflate(inflater, container, /* attachToRoot= */ false).root | ||
} | ||
} |
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
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,6 @@ | ||
package org.oppia.app.home | ||
|
||
import org.oppia.app.viewmodel.ObservableViewModel | ||
|
||
/** The root [ViewModel] for all individual items that may be displayed in home fragment recycler view. */ | ||
abstract class HomeItemViewModel: ObservableViewModel() |
6 changes: 6 additions & 0 deletions
6
app/src/main/java/org/oppia/app/home/RouteToContinuePlayingListener.kt
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,6 @@ | ||
package org.oppia.app.home | ||
|
||
/** Listener for when an activity should route to [ContinuePlayingActivity]. */ | ||
interface RouteToContinuePlayingListener { | ||
fun routeToContinuePlaying() | ||
} |
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,6 @@ | ||
package org.oppia.app.home | ||
|
||
/** Listener for when an activity should route to a topic. */ | ||
interface RouteToTopicListener { | ||
fun routeToTopic(topicId: String) | ||
} |
Oops, something went wrong.