Merge "WIP: Added transitions to MainFragment." into mnc-ub-dev
This commit is contained in:
@@ -32,6 +32,7 @@ import android.support.v17.leanback.supportleanbackshowcase.models.CardRow;
|
|||||||
import android.support.v17.leanback.supportleanbackshowcase.models.Movie;
|
import android.support.v17.leanback.supportleanbackshowcase.models.Movie;
|
||||||
import android.support.v17.leanback.supportleanbackshowcase.utils.Utils;
|
import android.support.v17.leanback.supportleanbackshowcase.utils.Utils;
|
||||||
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
import android.support.v17.leanback.widget.ArrayObjectAdapter;
|
||||||
|
import android.support.v17.leanback.widget.ImageCardView;
|
||||||
import android.support.v17.leanback.widget.ListRow;
|
import android.support.v17.leanback.widget.ListRow;
|
||||||
import android.support.v17.leanback.widget.ListRowPresenter;
|
import android.support.v17.leanback.widget.ListRowPresenter;
|
||||||
import android.support.v17.leanback.widget.OnItemViewClickedListener;
|
import android.support.v17.leanback.widget.OnItemViewClickedListener;
|
||||||
@@ -40,6 +41,7 @@ import android.support.v17.leanback.widget.Presenter;
|
|||||||
import android.support.v17.leanback.widget.PresenterSelector;
|
import android.support.v17.leanback.widget.PresenterSelector;
|
||||||
import android.support.v17.leanback.widget.Row;
|
import android.support.v17.leanback.widget.Row;
|
||||||
import android.support.v17.leanback.widget.RowPresenter;
|
import android.support.v17.leanback.widget.RowPresenter;
|
||||||
|
import android.support.v4.app.ActivityOptionsCompat;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@@ -99,44 +101,40 @@ public class MainFragment extends BrowseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item,
|
||||||
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
RowPresenter.ViewHolder rowViewHolder, Row row) {
|
||||||
|
Intent intent = null;
|
||||||
Card card = (Card) item;
|
Card card = (Card) item;
|
||||||
int id = card.getId();
|
int id = card.getId();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 0: {
|
case 0: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
CardExampleActivity.class);
|
CardExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
GridExampleActivity.class);
|
GridExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
DetailViewExampleActivity.class);
|
DetailViewExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
VideoExampleActivity.class);
|
VideoExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 5: {
|
case 5: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
MusicExampleActivity.class);
|
MusicExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 6: {
|
case 6: {
|
||||||
// Let's create a new Wizard for a given Movie. The movie can come from any sort
|
// Let's create a new Wizard for a given Movie. The movie can come from any sort
|
||||||
// of data source. To simplify this example we decode it from a JSON source
|
// of data source. To simplify this example we decode it from a JSON source
|
||||||
// which might be loaded from a server in a real world example.
|
// which might be loaded from a server in a real world example.
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
WizardExampleActivity.class);
|
WizardExampleActivity.class);
|
||||||
|
|
||||||
// Prepare extras which contains the Movie and will be passed to the Activity
|
// Prepare extras which contains the Movie and will be passed to the Activity
|
||||||
@@ -149,24 +147,28 @@ public class MainFragment extends BrowseFragment {
|
|||||||
intent.putExtras(extras);
|
intent.putExtras(extras);
|
||||||
|
|
||||||
// Finally, start the wizard Activity.
|
// Finally, start the wizard Activity.
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 7: {
|
case 7: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
SettingsExampleActivity.class);
|
SettingsExampleActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
case 8: {
|
case 8: {
|
||||||
Intent intent = new Intent(getActivity().getBaseContext(),
|
intent = new Intent(getActivity().getBaseContext(),
|
||||||
DialogExampleActivity.class);
|
DialogExampleActivity.class);
|
||||||
startActivity(intent);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (intent != null) {
|
||||||
|
Bundle bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
|
||||||
|
((ImageCardView) itemViewHolder.view).getMainImageView(), "transition")
|
||||||
|
.toBundle();
|
||||||
|
startActivity(intent, bundle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user