-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
choose sources if there is multiple one
- Loading branch information
1 parent
b92056a
commit e909384
Showing
10 changed files
with
160 additions
and
13 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
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
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/ratanparai/moviedog/ui/SelectMovieSourceDialogActivity.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,22 @@ | ||
package com.ratanparai.moviedog.ui | ||
|
||
import android.app.Activity | ||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.os.Bundle | ||
import androidx.leanback.app.GuidedStepFragment | ||
|
||
class SelectMovieSourceDialogActivity: Activity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
window.setBackgroundDrawable(ColorDrawable(Color.parseColor("#21272A"))) | ||
|
||
if (savedInstanceState == null) { | ||
val fragment = SelectMovieSourceDialogFragment() | ||
GuidedStepFragment.addAsRoot(this, fragment, android.R.id.content) | ||
} | ||
|
||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
app/src/main/java/com/ratanparai/moviedog/ui/SelectMovieSourceDialogFragment.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,88 @@ | ||
package com.ratanparai.moviedog.ui | ||
|
||
import android.os.Bundle | ||
import android.widget.Toast | ||
import androidx.leanback.app.GuidedStepFragment | ||
import androidx.leanback.widget.GuidanceStylist | ||
import androidx.leanback.widget.GuidedAction | ||
import com.ratanparai.moviedog.R | ||
import com.ratanparai.moviedog.db.AppDatabase | ||
import com.ratanparai.moviedog.db.entity.MovieUrl | ||
import com.ratanparai.moviedog.utilities.EXTRA_MOVIE_ID | ||
|
||
class SelectMovieSourceDialogFragment: GuidedStepFragment() { | ||
|
||
private var movieUrls: List<MovieUrl>? = null | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
|
||
val movieId = activity?.intent?.getIntExtra(EXTRA_MOVIE_ID, -1) | ||
|
||
if (movieId == -1) { | ||
activity.finish() | ||
} | ||
|
||
movieUrls = AppDatabase.getInstance(context).movieUrlDao().getMovieUrlsByMovieId(movieId!!) | ||
|
||
super.onCreate(savedInstanceState) | ||
} | ||
|
||
override fun onCreateGuidance(savedInstanceState: Bundle?): GuidanceStylist.Guidance { | ||
|
||
|
||
val guidance = GuidanceStylist.Guidance( | ||
getString(R.string.dialog_movie_select_title), | ||
getString(R.string.dialog_movie_select_description), | ||
"", null | ||
) | ||
|
||
return guidance | ||
} | ||
|
||
|
||
|
||
override fun onCreateActions(actions: MutableList<GuidedAction>, savedInstanceState: Bundle?) { | ||
|
||
for (movieUrl in movieUrls!!) { | ||
actions.add( | ||
GuidedAction.Builder() | ||
.id(movieUrl.id.toLong()) | ||
.description(movieUrl.movieUrl) | ||
.title(movieUrl.serviceName).build() | ||
) | ||
} | ||
|
||
// var action = GuidedAction.Builder() | ||
// .id(ACTION_ID_POSITIVE) | ||
// .title("Positive").build() | ||
// actions.add(action) | ||
// action = GuidedAction.Builder() | ||
// .id(ACTION_ID_NEGATIVE) | ||
// .title("negative").build() | ||
// actions.add(action) | ||
} | ||
|
||
override fun onGuidedActionClicked(action: GuidedAction) { | ||
// if (ACTION_ID_POSITIVE == action.id) { | ||
// Toast.makeText( | ||
// activity, "Positive Clicked", | ||
// Toast.LENGTH_SHORT | ||
// ).show() | ||
// } else { | ||
// Toast.makeText( | ||
// activity, "Negative clicked", | ||
// Toast.LENGTH_SHORT | ||
// ).show() | ||
// } | ||
|
||
for (movieUrl in movieUrls!!) { | ||
if(movieUrl.id == action.id.toInt()) | ||
startActivity(PlaybackActivity.createIntent(context, movieUrl.movieId, movieUrl.movieUrl)) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val ACTION_ID_POSITIVE = 1L | ||
private const val ACTION_ID_NEGATIVE = 2L | ||
} | ||
} |
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