-
Notifications
You must be signed in to change notification settings - Fork 0
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
Damien
committed
Oct 30, 2015
1 parent
b175989
commit ee5d0a3
Showing
53 changed files
with
595 additions
and
210 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
97 changes: 97 additions & 0 deletions
97
app/src/main/java/com/eseo/allmytvshows/ui/activities/DetailEpisodeActivity.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,97 @@ | ||
package com.eseo.allmytvshows.ui.activities; | ||
|
||
import android.app.Activity; | ||
import android.graphics.Bitmap; | ||
import android.graphics.drawable.BitmapDrawable; | ||
import android.graphics.drawable.Drawable; | ||
import android.os.Bundle; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v4.app.NavUtils; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.FrameLayout; | ||
|
||
import com.eseo.allmytvshows.R; | ||
import com.eseo.allmytvshows.dao.season.ISeasonDao; | ||
import com.eseo.allmytvshows.dao.season.impl.SeasonDaoImpl; | ||
import com.eseo.allmytvshows.managers.RetrofitManager; | ||
import com.eseo.allmytvshows.model.realm.RealmSeason; | ||
import com.eseo.allmytvshows.ui.adapters.DetailEpisodeAdapter; | ||
import com.squareup.picasso.Picasso; | ||
import com.squareup.picasso.Target; | ||
|
||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
import io.realm.Realm; | ||
|
||
/** | ||
* An example full-screen activity that shows and hides the system UI (i.e. | ||
* status bar and navigation/system bar) with user interaction. | ||
*/ | ||
public class DetailEpisodeActivity extends Activity { | ||
|
||
private Realm realm; | ||
|
||
@Bind(R.id.detail_episode_content_layout) | ||
FrameLayout frameLayout; | ||
@Bind(R.id.episode_recycler_view) | ||
RecyclerView recyclerView; | ||
@Bind(R.id.season_already_seen_button) | ||
Button button; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_detail_episode); | ||
ButterKnife.bind(this); | ||
realm = Realm.getInstance(this); | ||
|
||
long season = getIntent().getLongExtra("season", -1); | ||
final ISeasonDao iSeasonDao = new SeasonDaoImpl(realm); | ||
RealmSeason realmSeason = iSeasonDao.find(season); | ||
|
||
Picasso.with(this) | ||
.load(RetrofitManager.IMAGE_URL + realmSeason.getTvShow().getPoster_path()) | ||
.into(new Target() { | ||
@Override | ||
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { | ||
frameLayout.setBackground(new BitmapDrawable(getResources(), bitmap)); | ||
} | ||
|
||
@Override | ||
public void onBitmapFailed(Drawable errorDrawable) { | ||
|
||
} | ||
|
||
@Override | ||
public void onPrepareLoad(Drawable placeHolderDrawable) { | ||
|
||
} | ||
}); | ||
|
||
final DetailEpisodeAdapter detailEpisodeAdapter = new DetailEpisodeAdapter(this, realmSeason); | ||
recyclerView.setHasFixedSize(true); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
recyclerView.setAdapter(detailEpisodeAdapter); | ||
button.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Snackbar.make(v,"not plugged yet", Snackbar.LENGTH_SHORT).show(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
int id = item.getItemId(); | ||
if (id == android.R.id.home) { | ||
NavUtils.navigateUpFromSameTask(this); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
} |
95 changes: 95 additions & 0 deletions
95
app/src/main/java/com/eseo/allmytvshows/ui/activities/DetailSeasonActivity.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,95 @@ | ||
package com.eseo.allmytvshows.ui.activities; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.afollestad.materialdialogs.MaterialDialog; | ||
import com.eseo.allmytvshows.R; | ||
import com.eseo.allmytvshows.dao.season.ISeasonDao; | ||
import com.eseo.allmytvshows.dao.season.impl.SeasonDaoImpl; | ||
import com.eseo.allmytvshows.dao.tvshow.ITvShowDao; | ||
import com.eseo.allmytvshows.dao.tvshow.impl.TvShowDaoImpl; | ||
import com.eseo.allmytvshows.managers.RetrofitManager; | ||
import com.eseo.allmytvshows.model.realm.RealmSeason; | ||
import com.eseo.allmytvshows.model.realm.RealmTvShow; | ||
import com.eseo.allmytvshows.ui.adapters.DetailSeasonAdapter; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
import io.realm.Realm; | ||
import io.realm.RealmList; | ||
import io.realm.RealmResults; | ||
|
||
public class DetailSeasonActivity extends AppCompatActivity { | ||
|
||
@Bind(R.id.detail_season_tvshow_name) | ||
TextView textView; | ||
@Bind(R.id.detail_season_picture) | ||
ImageView imageView; | ||
@Bind(R.id.my_recycler_view) | ||
public RecyclerView recyclerView; | ||
|
||
private Realm realm; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_detail_season); | ||
ButterKnife.bind(this); | ||
realm = Realm.getInstance(this); | ||
|
||
final Long realmTvShowId = getIntent().getLongExtra("tvshow", 0); | ||
final ITvShowDao iTvShowDao = new TvShowDaoImpl(realm); | ||
final RealmTvShow realmTvShow = iTvShowDao.find(realmTvShowId); | ||
|
||
final ISeasonDao iSeasonDao = new SeasonDaoImpl(realm); | ||
final RealmResults<RealmSeason> seasonResults = iSeasonDao.getSeasonsWithoutZero(realmTvShowId); | ||
final RealmList<RealmSeason> seasonRealmList = new RealmList<>(); | ||
seasonRealmList.addAll(seasonResults); | ||
|
||
realm.executeTransaction(new Realm.Transaction() { | ||
@Override | ||
public void execute(Realm realm) { | ||
realmTvShow.setSeasons(seasonRealmList); | ||
} | ||
}); | ||
|
||
textView.setText(realmTvShow.getOriginal_name()); | ||
Picasso.with(this) | ||
.load(RetrofitManager.IMAGE_URL + realmTvShow.getPoster_path()) | ||
.fit() | ||
.centerCrop() | ||
.into(imageView); | ||
imageView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
new MaterialDialog.Builder(DetailSeasonActivity.this) | ||
.title(realmTvShow.getOriginal_name()) | ||
.content(realmTvShow.getOverview()) | ||
.neutralText("Close") | ||
.show(); | ||
} | ||
}); | ||
recyclerView.setHasFixedSize(true); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
recyclerView.setAdapter(new DetailSeasonAdapter(this, realmTvShow)); | ||
|
||
} | ||
|
||
public Realm getRealm() { | ||
return realm; | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
realm.close(); | ||
} | ||
|
||
} |
Oops, something went wrong.