Skip to content

Commit

Permalink
Season and episode detail
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien committed Oct 30, 2015
1 parent b175989 commit ee5d0a3
Show file tree
Hide file tree
Showing 53 changed files with 595 additions and 210 deletions.
6 changes: 4 additions & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/beta/1.1.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics-core/2.3.5/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.crashlytics.sdk.android/crashlytics/2.5.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.github.iammert/ProgressLayout/a2ac196500/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.miguelcatalan/materialsearchview/1.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.fabric.sdk.android/fabric/1.3.6/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.reactivex/rxandroid/1.0.1/jars" />
Expand All @@ -102,14 +103,15 @@
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="ProgressLayout-a2ac196500" level="project" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="okio-1.6.0" level="project" />
<orderEntry type="library" exported="" name="realm-android-0.82.2" level="project" />
<orderEntry type="library" exported="" name="picasso-2.5.2" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.5.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="otto-1.3.8" level="project" />
<orderEntry type="library" exported="" name="commons-collections4-4.0" level="project" />
<orderEntry type="library" exported="" name="otto-1.3.8" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="converter-gson-2.0.0-beta1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
Expand All @@ -122,8 +124,8 @@
<orderEntry type="library" exported="" name="cardview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="fabric-1.3.6" level="project" />
<orderEntry type="library" exported="" name="crashlytics-core-2.3.5" level="project" />
<orderEntry type="library" exported="" name="rxandroid-1.0.1" level="project" />
<orderEntry type="library" exported="" name="core-0.8.1.0" level="project" />
<orderEntry type="library" exported="" name="rxandroid-1.0.1" level="project" />
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.0.14" level="project" />
<orderEntry type="library" exported="" name="answers-1.3.2" level="project" />
Expand Down
14 changes: 8 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
Expand All @@ -51,16 +57,12 @@ dependencies {
compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'io.realm:realm-android:0.82.2'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
transitive = true;
}
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'org.apache.commons:commons-collections4:4.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.miguelcatalan:materialsearchview:1.0.0'
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
transitive = true
}
compile 'com.android.support:support-v4:23.0.1'
compile 'com.github.iammert:ProgressLayout:a2ac196500'
}


12 changes: 11 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,23 @@
android:label="@string/title_activity_search" >
</activity>
<activity
android:name=".ui.activities.DetailedTvShowActivity"
android:name=".ui.activities.DetailSeasonActivity"
android:label="@string/title_activity_detailed_tv_show"
android:parentActivityName=".ui.activities.MainActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.eseo.allmytvshows.ui.activities.MainActivity" />
</activity>
<activity
android:name=".ui.activities.DetailEpisodeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/title_activity_detail_episode"
android:parentActivityName=".ui.activities.DetailSeasonActivity"
android:theme="@style/FullscreenTheme" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.eseo.allmytvshows.ui.activities.DetailSeasonActivity" />
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import com.eseo.allmytvshows.dao.IBaseDao;
import com.eseo.allmytvshows.model.realm.RealmSeason;

import io.realm.RealmResults;

/**
* Created by Damien on 9/24/15.
*/
public interface ISeasonDao extends IBaseDao<RealmSeason> {

public void removeSeasonZero();
public RealmResults<RealmSeason> getSeasonsWithoutZero(long tvShowId);

public RealmSeason getSeason(final long tvShowId, final long seasonId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import com.eseo.allmytvshows.dao.impl.BaseDaoImpl;
import com.eseo.allmytvshows.dao.season.ISeasonDao;
import com.eseo.allmytvshows.model.realm.RealmSeason;
import com.eseo.allmytvshows.model.realm.constants.RealmSeasonConstants;
import com.eseo.allmytvshows.model.realm.constants.RealmTvShowConstants;

import io.realm.Realm;
import io.realm.RealmQuery;
import io.realm.RealmResults;

/**
* Created by Damien on 9/24/15.
Expand All @@ -16,10 +20,24 @@ public SeasonDaoImpl (Realm realm) {
}

@Override
public void removeSeasonZero() {
//TODO
public RealmResults<RealmSeason> getSeasonsWithoutZero(final long tvShowId) {

final RealmQuery<RealmSeason> query = realm.where(clazz)
.equalTo(RealmSeasonConstants.Vars.TV_SHOW_SEASON + "." + RealmTvShowConstants.Vars.ID_TV_SHOW, tvShowId)
.notEqualTo(RealmSeasonConstants.Vars.SEASON_NUMBER_SEASON, 0);

RealmResults<RealmSeason> retValue = query.findAllSorted(RealmSeasonConstants.Vars.SEASON_NUMBER_SEASON);
return retValue;
}

@Override
public RealmSeason getSeason(final long tvShowId, final long seasonNumber) {
final RealmQuery<RealmSeason> query = realm.where(clazz)
.equalTo(RealmSeasonConstants.Vars.SEASON_NUMBER_SEASON, seasonNumber)
.equalTo(RealmSeasonConstants.Vars.TV_SHOW_SEASON + "." + RealmTvShowConstants.Vars.ID_TV_SHOW, tvShowId);
final RealmSeason retValue = query.findFirst();

return retValue;
}

}
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);
}

}
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();
}

}
Loading

0 comments on commit ee5d0a3

Please sign in to comment.