Search in sources :

Example 1 with Gank

use of me.drakeet.meizhi.data.entity.Gank in project Meizhi by drakeet.

the class GankListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Gank gank = mGankList.get(position);
    if (position == 0) {
        showCategory(holder);
    } else {
        boolean theCategoryOfLastEqualsToThis = mGankList.get(position - 1).type.equals(mGankList.get(position).type);
        if (!theCategoryOfLastEqualsToThis) {
            showCategory(holder);
        } else {
            hideCategory(holder);
        }
    }
    holder.category.setText(gank.type);
    SpannableStringBuilder builder = new SpannableStringBuilder(gank.desc).append(StringStyles.format(holder.gank.getContext(), " (via. " + gank.who + ")", R.style.ViaTextAppearance));
    CharSequence gankText = builder.subSequence(0, builder.length());
    holder.gank.setText(gankText);
    showItemAnim(holder.gank, position);
}
Also used : Gank(me.drakeet.meizhi.data.entity.Gank) SpannableStringBuilder(android.text.SpannableStringBuilder)

Example 2 with Gank

use of me.drakeet.meizhi.data.entity.Gank in project Meizhi by drakeet.

the class GankFragment method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch(id) {
        case R.id.action_share:
            if (mGankList.size() != 0) {
                Gank gank = mGankList.get(0);
                String shareText = gank.desc + gank.url + getString(R.string.share_from);
                Shares.share(getActivity(), shareText);
            } else {
                Shares.share(getContext(), R.string.share_text);
            }
            return true;
        case R.id.action_subject:
            openTodaySubject();
            return true;
    }
    return super.onOptionsItemSelected(item);
}
Also used : Gank(me.drakeet.meizhi.data.entity.Gank)

Example 3 with Gank

use of me.drakeet.meizhi.data.entity.Gank in project Meizhi by drakeet.

the class MainActivity method getFirstVideoDesc.

private String getFirstVideoDesc(Date publishedAt, List<Gank> results) {
    String videoDesc = "";
    for (int i = mLastVideoIndex; i < results.size(); i++) {
        Gank video = results.get(i);
        if (video.publishedAt == null)
            video.publishedAt = video.createdAt;
        if (Dates.isTheSameDay(publishedAt, video.publishedAt)) {
            videoDesc = video.desc;
            mLastVideoIndex = i;
            break;
        }
    }
    return videoDesc;
}
Also used : Gank(me.drakeet.meizhi.data.entity.Gank)

Aggregations

Gank (me.drakeet.meizhi.data.entity.Gank)3 SpannableStringBuilder (android.text.SpannableStringBuilder)1