Add archived icon

captchafix
Floens 11 years ago
parent 95b8ebe725
commit f50cfcb398
  1. 1
      Clover/app/src/main/java/org/floens/chan/core/model/Post.java
  2. 3
      Clover/app/src/main/java/org/floens/chan/core/net/ChanReaderRequest.java
  3. 17
      Clover/app/src/main/java/org/floens/chan/ui/view/PostView.java
  4. 17
      Clover/app/src/main/java/org/floens/chan/utils/IconCache.java
  5. BIN
      Clover/app/src/main/res/drawable-mdpi/archived_icon.png

@ -69,6 +69,7 @@ public class Post {
public String imageUrl; public String imageUrl;
public boolean sticky = false; public boolean sticky = false;
public boolean closed = false; public boolean closed = false;
public boolean archived = false;
public String tripcode = ""; public String tripcode = "";
public String id = ""; public String id = "";
public String capcode = ""; public String capcode = "";

@ -331,6 +331,9 @@ public class ChanReaderRequest extends JsonReaderRequest<List<Post>> {
case "closed": case "closed":
post.closed = reader.nextInt() == 1; post.closed = reader.nextInt() == 1;
break; break;
case "archived":
post.archived = reader.nextInt() == 1;
break;
case "trip": case "trip":
post.tripcode = reader.nextString(); post.tripcode = reader.nextString();
break; break;

@ -78,6 +78,7 @@ public class PostView extends LinearLayout implements View.OnClickListener {
private ImageView stickyView; private ImageView stickyView;
private ImageView closedView; private ImageView closedView;
private ImageView deletedView; private ImageView deletedView;
private ImageView archivedView;
private NetworkImageView countryView; private NetworkImageView countryView;
private ImageView optionsView; private ImageView optionsView;
private View lastSeen; private View lastSeen;
@ -215,14 +216,16 @@ public class PostView extends LinearLayout implements View.OnClickListener {
boolean showCountryFlag = isList() && !TextUtils.isEmpty(post.country) && !TextUtils.isEmpty(post.countryUrl); boolean showCountryFlag = isList() && !TextUtils.isEmpty(post.country) && !TextUtils.isEmpty(post.countryUrl);
boolean showStickyIcon = isList() && post.sticky; boolean showStickyIcon = isList() && post.sticky;
boolean showClosedIcon = isList() && post.closed;
boolean showDeletedIcon = isList() && post.deleted; boolean showDeletedIcon = isList() && post.deleted;
boolean showArchivedIcon = isList() && post.archived;
boolean showClosedIcon = isList() && post.closed && !showArchivedIcon;
iconsView.setVisibility((showCountryFlag || showStickyIcon || showClosedIcon || showDeletedIcon) ? View.VISIBLE : View.GONE); iconsView.setVisibility((showCountryFlag || showStickyIcon || showClosedIcon || showDeletedIcon || showArchivedIcon) ? View.VISIBLE : View.GONE);
stickyView.setVisibility(showStickyIcon ? View.VISIBLE : View.GONE); stickyView.setVisibility(showStickyIcon ? View.VISIBLE : View.GONE);
closedView.setVisibility(showClosedIcon ? View.VISIBLE : View.GONE); closedView.setVisibility(showClosedIcon ? View.VISIBLE : View.GONE);
deletedView.setVisibility(showDeletedIcon ? View.VISIBLE : View.GONE); deletedView.setVisibility(showDeletedIcon ? View.VISIBLE : View.GONE);
archivedView.setVisibility(showArchivedIcon ? View.VISIBLE : View.GONE);
if (showCountryFlag) { if (showCountryFlag) {
countryView.setVisibility(View.VISIBLE); countryView.setVisibility(View.VISIBLE);
countryView.setImageUrl(post.countryUrl, ChanApplication.getVolleyImageLoader()); countryView.setImageUrl(post.countryUrl, ChanApplication.getVolleyImageLoader());
@ -352,17 +355,21 @@ public class PostView extends LinearLayout implements View.OnClickListener {
iconsView.setPadding(postPadding, iconPadding, postPadding, 0); iconsView.setPadding(postPadding, iconPadding, postPadding, 0);
stickyView = new ImageView(context); stickyView = new ImageView(context);
stickyView.setImageBitmap(IconCache.stickyIcon); stickyView.setImageDrawable(IconCache.stickyIcon);
iconsView.addView(stickyView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); iconsView.addView(stickyView, new LinearLayout.LayoutParams(iconWidth, iconHeight));
closedView = new ImageView(context); closedView = new ImageView(context);
closedView.setImageBitmap(IconCache.closedIcon); closedView.setImageDrawable(IconCache.closedIcon);
iconsView.addView(closedView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); iconsView.addView(closedView, new LinearLayout.LayoutParams(iconWidth, iconHeight));
deletedView = new ImageView(context); deletedView = new ImageView(context);
deletedView.setImageBitmap(IconCache.trashIcon); deletedView.setImageDrawable(IconCache.trashIcon);
iconsView.addView(deletedView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); iconsView.addView(deletedView, new LinearLayout.LayoutParams(iconWidth, iconHeight));
archivedView = new ImageView(context);
archivedView.setImageDrawable(IconCache.archivedIcon);
iconsView.addView(archivedView, new LinearLayout.LayoutParams(iconWidth, iconHeight));
countryView = new NetworkImageView(context); countryView = new NetworkImageView(context);
countryView.setScaleType(ImageView.ScaleType.FIT_CENTER); countryView.setScaleType(ImageView.ScaleType.FIT_CENTER);
iconsView.addView(countryView, new LinearLayout.LayoutParams(iconWidth, iconHeight)); iconsView.addView(countryView, new LinearLayout.LayoutParams(iconWidth, iconHeight));

@ -18,19 +18,24 @@
package org.floens.chan.utils; package org.floens.chan.utils;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import org.floens.chan.R; import org.floens.chan.R;
public class IconCache { public class IconCache {
public static Bitmap stickyIcon; public static BitmapDrawable stickyIcon;
public static Bitmap closedIcon; public static BitmapDrawable closedIcon;
public static Bitmap trashIcon; public static BitmapDrawable trashIcon;
public static BitmapDrawable archivedIcon;
public static void createIcons(final Context context) { public static void createIcons(final Context context) {
stickyIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.sticky_icon); Resources res = context.getResources();
closedIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.closed_icon); stickyIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.sticky_icon));
trashIcon = BitmapFactory.decodeResource(context.getResources(), R.drawable.trash_icon); closedIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.closed_icon));
trashIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.trash_icon));
archivedIcon = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.archived_icon));
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 554 B

Loading…
Cancel
Save