use of tr.bcxip.hummingbird.api.objects.LibraryEntry in project Hummingbird-for-Android by xiprox.
the class LibraryAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_library, parent, false);
holder = new ViewHolder();
holder.cover = (ImageView) convertView.findViewById(R.id.item_library_cover);
holder.title = (TextView) convertView.findViewById(R.id.item_library_title);
holder.desc = (TextView) convertView.findViewById(R.id.item_library_desc);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
LibraryEntry item = mItems.get(position);
Log.d("TAG", item.getAnime().getCoverImage());
Picasso.with(context).load(item.getAnime().getCoverImage()).into(holder.cover, new Callback() {
@Override
public void onSuccess() {
try {
Bitmap bitmap = ((BitmapDrawable) holder.cover.getDrawable()).getBitmap();
int color = Palette.generate(bitmap).getDarkMutedSwatch().getRgb();
ColorDrawable background = new ColorDrawable(color);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onError() {
}
});
holder.title.setText(item.getAnime().getTitle());
String itemEpisodesCount = item.getAnime().getEpisodeCount() != 0 ? item.getAnime().getEpisodeCount() + "" : "?";
if (item.isRewatching()) {
holder.desc.setText(getString(R.string.content_library_rewatching_at) + " " + item.getEpisodesWatched() + "/" + item.getAnime().getEpisodeCount());
} else {
String status = item.getStatus();
if (status.equals(LibraryFragment.FILTER_CURRENTLY_WATCHING))
holder.desc.setText(getString(R.string.content_library_watching_at) + " " + item.getEpisodesWatched() + "/" + itemEpisodesCount);
if (status.equals(LibraryFragment.FILTER_PLAN_TO_WATCH))
holder.desc.setText(getString(R.string.content_library_planning_to_watch));
if (status.equals(LibraryFragment.FILTER_COMPLETED))
holder.desc.setText(getString(R.string.content_library_completed));
if (status.equals(LibraryFragment.FILTER_ON_HOLD))
holder.desc.setText(getString(R.string.content_library_on_hold));
if (status.equals(LibraryFragment.FILTER_DROPPED))
holder.desc.setText(getString(R.string.content_library_dropped));
}
return convertView;
}
use of tr.bcxip.hummingbird.api.objects.LibraryEntry in project Hummingbird-for-Android by xiprox.
the class AnimeDetailsActivity method onCreate.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
Transition sharedElem = TransitionInflater.from(this).inflateTransition(R.transition.move_scale_transition);
getWindow().setSharedElementEnterTransition(sharedElem);
getWindow().setSharedElementExitTransition(sharedElem);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_anime_details);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mActionBar = getSupportActionBar();
api = new HummingbirdApi(this);
prefMan = new PrefManager(this);
mActionBar.setDisplayHomeAsUpEnabled(true);
anime = (Anime) getIntent().getSerializableExtra(ARG_ANIME_OBJ);
ANIME_ID = getIntent().getStringExtra(ARG_ID);
if (savedInstanceState != null) {
Anime savedAnime = (Anime) savedInstanceState.getSerializable(STATE_ANIME);
if (savedAnime != null)
anime = savedAnime;
LibraryEntry savedLibraryEntry = (LibraryEntry) savedInstanceState.getSerializable(STATE_LIBRARY_ENTRY);
if (savedLibraryEntry != null)
libraryEntry = savedLibraryEntry;
}
mActionBarBackgroundDrawable = new ColorDrawable(darkMutedColor != 0 ? darkMutedColor : getResources().getColor(R.color.neutral_darker));
mActionBarBackgroundDrawable.setAlpha(0);
toolbar.setBackgroundDrawable(mActionBarBackgroundDrawable);
mActionButton = (FloatingActionButton) findViewById(R.id.fab);
mQuickReturnView = toolbar;
mPlaceholderView = findViewById(R.id.placeholder);
mObservableScrollView = (ObservableScrollView) findViewById(R.id.anime_details_scroll_view);
mObservableScrollView.setCallbacks(this);
mObservableScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
onScrollChanged(mObservableScrollView.getScrollY());
mMaxScrollY = mObservableScrollView.computeVerticalScrollRange() - mObservableScrollView.getHeight();
mQuickReturnHeight = mQuickReturnView.getHeight();
int headerHeight = mHeaderImage.getHeight();
if (!firstGlobalLayoutPerformed && headerHeight != 0) {
updateHeaderHeight(headerHeight);
firstGlobalLayoutPerformed = true;
}
}
});
mContentsHolder = (LinearLayout) findViewById(R.id.anime_details_content_holder);
mInfoHolder = (FrameLayout) findViewById(R.id.anime_details_info_holder);
mMoreInfoHolder = (LinearLayout) findViewById(R.id.anime_details_more_info_holder);
mLibraryInfoHolder = (LinearLayout) findViewById(R.id.anime_details_library_info_holder);
mHeaderHolder = (FrameLayout) findViewById(R.id.anime_details_header_holder);
mHeaderImage = (ImageView) findViewById(R.id.anime_details_header);
mCoverHolder = (FrameLayout) findViewById(R.id.anime_details_cover_image_holder);
mCoverImage = (ImageView) findViewById(R.id.anime_details_cover_image);
mTitle = (TextView) findViewById(R.id.anime_details_title);
mType = (TextView) findViewById(R.id.anime_details_type);
mGenre = (TextView) findViewById(R.id.anime_details_genres);
mEpisodeCount = (TextView) findViewById(R.id.anime_details_episode_count);
mEpisodeLength = (TextView) findViewById(R.id.anime_details_episode_duration);
mAgeRating = (TextView) findViewById(R.id.anime_details_age_rating);
mAired = (TextView) findViewById(R.id.anime_details_aired);
mCommunityRating = (TextView) findViewById(R.id.anime_details_community_rating);
mSynopsisHolder = (LinearLayout) findViewById(R.id.anime_details_synopsis_holder);
mSynopsis = (TextView) findViewById(R.id.anime_details_synopsis);
mMoreSimilarAnime = (LinearLayout) findViewById(R.id.anime_details_more_similar_anime);
mLibraryProgressBar = (ProgressBar) findViewById(R.id.anime_details_library_progress_bar);
mStatusSpinner = (Spinner) findViewById(R.id.anime_details_status_spinner);
mEpisodesHolder = (LinearLayout) findViewById(R.id.anime_details_library_episodes_holder);
mEpisodes = (TextView) findViewById(R.id.anime_details_library_episodes);
mRewatching = (SwitchCompat) findViewById(R.id.anime_details_library_rewatching);
mRewatchedTimesHolder = (LinearLayout) findViewById(R.id.anime_details_library_rewatched_holder);
mRewatchedTimes = (TextView) findViewById(R.id.anime_details_library_rewatched);
mPrivate = (SwitchCompat) findViewById(R.id.anime_details_library_private);
mRatingBar = (RatingBar) findViewById(R.id.anime_details_library_rating_advanced);
mSimpleRatingView = (SimpleRatingView) findViewById(R.id.anime_details_library_rating_simple);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ViewOutlineProvider infoOutlineProvider = new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setRect(0, Utils.dpToPx(AnimeDetailsActivity.this, getResources().getDimension(R.dimen.offset_details_info_card)), view.getWidth(), view.getHeight());
}
};
mInfoHolder.setOutlineProvider(infoOutlineProvider);
}
if (anime != null) {
displayAnimeInfo();
if (libraryEntry == null)
new LibraryEntryTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else
displayLibraryElements();
} else
new AnimeInfoTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, true);
}
use of tr.bcxip.hummingbird.api.objects.LibraryEntry in project Hummingbird-for-Android by xiprox.
the class HummingbirdApi method getLibraryEntryIfAnimeExists.
public LibraryEntry getLibraryEntryIfAnimeExists(String animeId) {
Map<String, String> params = new HashMap<String, String>();
if (prefMan.getAuthToken() != null)
params.put("auth_token", prefMan.getAuthToken());
LibraryEntry libEntry = null;
for (LibraryEntry entry : getLibrary(prefMan.getUsername(), params)) {
if (entry.getAnime().getId().equals(animeId))
libEntry = entry;
}
return libEntry;
}
Aggregations