mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Modified socialfeed style for item lists.
This commit is contained in:
parent
72a50217e5
commit
b1af812754
23 changed files with 164 additions and 148 deletions
|
@ -1,15 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/darkgray" />
|
||||
<size android:height="1dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="1dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/lightgray" />
|
||||
<size android:height="1dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:top="1dp">
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="@color/white" />
|
||||
<size android:height="0.5dp" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
|
@ -4,21 +4,7 @@
|
|||
<item>
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="@color/negative" />
|
||||
<stroke android:width="1dp" android:color="@color/darknegative" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:innerRadiusRatio="3"
|
||||
android:thicknessRatio="9"
|
||||
android:useLevel="false" >
|
||||
<gradient
|
||||
android:type="sweep"
|
||||
android:centerColor="#99ffffff"
|
||||
android:endColor="#0000"
|
||||
android:centerY="0.3"
|
||||
android:startColor="#0000" />
|
||||
<stroke android:width="3dp" android:color="@color/item_background" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -4,21 +4,7 @@
|
|||
<item>
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="@color/neutral" />
|
||||
<stroke android:width="1dp" android:color="@color/darkneutral" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:innerRadiusRatio="3"
|
||||
android:thicknessRatio="9"
|
||||
android:useLevel="false" >
|
||||
<gradient
|
||||
android:type="sweep"
|
||||
android:centerColor="#99ffffff"
|
||||
android:endColor="#0000"
|
||||
android:centerY="0.3"
|
||||
android:startColor="#0000" />
|
||||
<stroke android:width="3dp" android:color="@color/item_background" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -4,21 +4,7 @@
|
|||
<item>
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="@color/positive" />
|
||||
<stroke android:width="1dp" android:color="@color/darkgreen" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape
|
||||
android:shape="ring"
|
||||
android:innerRadiusRatio="3"
|
||||
android:thicknessRatio="9"
|
||||
android:useLevel="false" >
|
||||
<gradient
|
||||
android:type="sweep"
|
||||
android:centerColor="#99ffffff"
|
||||
android:endColor="#0000"
|
||||
android:centerY="0.3"
|
||||
android:startColor="#0000" />
|
||||
<stroke android:width="3dp" android:color="@color/item_background" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item>
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="@color/lightgray" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:bottom="2dp">
|
||||
<shape android:shape="oval" >
|
||||
<solid android:color="@color/white" />
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</layer-list>
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res/com.newsblur"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white" >
|
||||
android:background="@color/item_background" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -78,6 +78,7 @@
|
|||
<WebView
|
||||
android:id="@+id/reading_webview"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/item_background"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="none" />
|
||||
|
||||
|
|
|
@ -2,79 +2,78 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/item_background"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:padding="10dp" >
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/row_item_first_line_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
<View
|
||||
android:id="@+id/row_item_favicon_borderbar_1"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_sidebar"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="8dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:layout_marginRight="4dp" />
|
||||
<View
|
||||
android:id="@+id/row_item_favicon_borderbar_2"
|
||||
android:layout_width="8dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_toRightOf="@id/row_item_favicon_borderbar_1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11sp" />
|
||||
<TextView
|
||||
android:id="@+id/row_item_sidebar"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_toRightOf="@id/row_item_favicon_borderbar_1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_feedtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_toLeftOf="@id/row_item_date"
|
||||
android:layout_toRightOf="@id/row_item_sidebar"
|
||||
android:textColor="@color/lightgray"
|
||||
android:textSize="11dp"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
<ImageView
|
||||
android:id="@+id/row_item_feedicon"
|
||||
android:layout_width="21dp"
|
||||
android:layout_height="21dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@drawable/white_background_circle"
|
||||
android:paddingBottom="4dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:layout_toRightOf="@id/row_item_sidebar" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/row_item_date"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/row_item_first_line_container"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp" >
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/row_item_feedicon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp" />
|
||||
<TextView
|
||||
android:id="@+id/row_item_feedtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_toLeftOf="@id/row_item_date"
|
||||
android:layout_toRightOf="@id/row_item_feedicon"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/row_item_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:maxLines="2"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="18dp" />
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:id="@+id/row_item_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/row_item_feedicon"
|
||||
android:layout_below="@id/row_item_feedicon"
|
||||
android:layout_marginRight="8dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="20dp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/row_item_favicon_borderbar"
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/lightgray" />
|
||||
|
||||
</LinearLayout>
|
|
@ -12,6 +12,8 @@
|
|||
<color name="lightgreen">#3b8207</color>
|
||||
<color name="darkgreen">#134c00</color>
|
||||
|
||||
<color name="item_background">#f5f5f5</color>
|
||||
|
||||
<color name="half_black">#7000</color>
|
||||
<color name="transparent">#0000</color>
|
||||
<color name="half_darkgray">#77434343</color>
|
||||
|
|
|
@ -25,14 +25,13 @@ public class FeedReading extends Reading {
|
|||
|
||||
feedId = getIntent().getStringExtra(Reading.EXTRA_FEED);
|
||||
Uri storiesURI = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
|
||||
storiesToMarkAsRead = new HashSet<String>();
|
||||
stories = contentResolver.query(storiesURI, null, FeedProvider.getSelectionFromState(currentState), null, null);
|
||||
|
||||
final Uri feedUri = FeedProvider.FEEDS_URI.buildUpon().appendPath(feedId).build();
|
||||
Feed feed = Feed.fromCursor(contentResolver.query(feedUri, null, null, null, null));
|
||||
setTitle(feed.title);
|
||||
setupPager(stories);
|
||||
storiesToMarkAsRead = new HashSet<String>();
|
||||
|
||||
createFloatingHeader(feed);
|
||||
Story story = readingAdapter.getStory(passedPosition);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.newsblur.activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
|
||||
|
@ -24,8 +25,8 @@ public class SocialFeedItemsList extends ItemsList {
|
|||
userIcon = getIntent().getStringExtra(EXTRA_BLURBLOG_USER_ICON );
|
||||
userId = getIntent().getStringExtra(EXTRA_BLURBLOG_USERID);
|
||||
|
||||
// Drawable drawable = ((NewsBlurApplication) getApplication()).getImageLoader().getImage(userIcon, userId);
|
||||
// getSupportActionBar().setLogo(drawable);
|
||||
// Drawable drawable = ((NewsBlurApplication) getApplication()).getImageLoader().getImage(userIcon, userId);
|
||||
// getSupportActionBar().setLogo(drawable);
|
||||
|
||||
setTitle(username);
|
||||
|
||||
|
|
|
@ -23,14 +23,13 @@ public class SocialFeedReading extends Reading {
|
|||
super.onCreate(savedInstanceBundle);
|
||||
|
||||
String userId = getIntent().getStringExtra(Reading.EXTRA_USERID);
|
||||
markSocialAsReadList = new MarkSocialAsReadUpdate(userId);
|
||||
|
||||
Uri storiesURI = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
stories = contentResolver.query(storiesURI, null, FeedProvider.getSelectionFromState(currentState), null, null);
|
||||
setTitle(getIntent().getStringExtra(EXTRA_USERNAME));
|
||||
setupPager(stories);
|
||||
|
||||
markSocialAsReadList = new MarkSocialAsReadUpdate(userId);
|
||||
|
||||
Story story = readingAdapter.getStory(passedPosition);
|
||||
markSocialAsReadList.add(story.feedId, story.id);
|
||||
|
||||
|
@ -41,7 +40,9 @@ public class SocialFeedReading extends Reading {
|
|||
public void onPageSelected(int position) {
|
||||
super.onPageSelected(position);
|
||||
Story story = readingAdapter.getStory(position);
|
||||
markSocialAsReadList.add(story.feedId, story.id);
|
||||
if (story != null) {
|
||||
markSocialAsReadList.add(story.feedId, story.id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,6 +69,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
DatabaseConstants.STORY_AUTHORS + TEXT + ", " +
|
||||
DatabaseConstants.STORY_CONTENT + TEXT + ", " +
|
||||
DatabaseConstants.STORY_DATE + TEXT + ", " +
|
||||
DatabaseConstants.STORY_SHARED_DATE + TEXT + ", " +
|
||||
DatabaseConstants.STORY_SHORTDATE + TEXT + ", " +
|
||||
DatabaseConstants.STORY_FEED_ID + INTEGER + ", " +
|
||||
DatabaseConstants.STORY_ID + TEXT + " PRIMARY KEY, " +
|
||||
|
|
|
@ -59,6 +59,7 @@ public class DatabaseConstants {
|
|||
public static final String STORY_AUTHORS = "authors";
|
||||
public static final String STORY_TITLE = "title";
|
||||
public static final String STORY_DATE = "date";
|
||||
public static final String STORY_SHARED_DATE = "sharedDate";
|
||||
public static final String STORY_CONTENT = "content";
|
||||
public static final String STORY_COMMENT_COUNT = "comment_count";
|
||||
public static final String STORY_FEED_ID = "feed_id";
|
||||
|
@ -108,7 +109,7 @@ public class DatabaseConstants {
|
|||
};
|
||||
|
||||
public static final String[] STORY_COLUMNS = {
|
||||
STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_DATE, STORY_SHORTDATE, STORY_TABLE + "." + STORY_FEED_ID, STORY_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, STORY_INTELLIGENCE_TITLE,
|
||||
STORY_AUTHORS, STORY_COMMENT_COUNT, STORY_CONTENT, STORY_DATE, STORY_SHARED_DATE, STORY_SHORTDATE, STORY_TABLE + "." + STORY_FEED_ID, STORY_TABLE + "." + STORY_ID, STORY_INTELLIGENCE_AUTHORS, STORY_INTELLIGENCE_FEED, STORY_INTELLIGENCE_TAGS, STORY_INTELLIGENCE_TITLE,
|
||||
STORY_PERMALINK, STORY_READ, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, STORY_SOCIAL_USER_ID, STORY_SHARED_USER_IDS
|
||||
};
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ public class FeedProvider extends ContentProvider {
|
|||
" ON " + DatabaseConstants.STORY_TABLE + "." + DatabaseConstants.STORY_ID + " = " + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE + "." + DatabaseConstants.SOCIALFEED_STORY_STORYID +
|
||||
" INNER JOIN " + DatabaseConstants.FEED_TABLE +
|
||||
" ON " + DatabaseConstants.STORY_TABLE + "." + DatabaseConstants.STORY_FEED_ID + " = " + DatabaseConstants.FEED_TABLE + "." + DatabaseConstants.FEED_ID +
|
||||
" WHERE " + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE + "." + DatabaseConstants.SOCIALFEED_STORY_USER_ID + " = ? ";
|
||||
" WHERE " + DatabaseConstants.SOCIALFEED_STORY_MAP_TABLE + "." + DatabaseConstants.SOCIALFEED_STORY_USER_ID + " = ?";
|
||||
|
||||
StringBuilder storyBuilder = new StringBuilder();
|
||||
storyBuilder.append(userQuery);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MixedExpandableListAdapter extends BaseExpandableListAdapter{
|
|||
private ViewBinder groupViewBinder;
|
||||
private ViewBinder blogViewBinder;
|
||||
|
||||
public String currentState = DatabaseConstants.FOLDER_INTELLIGENCE_ALL;
|
||||
public String currentState = DatabaseConstants.FOLDER_INTELLIGENCE_SOME;
|
||||
|
||||
public MixedExpandableListAdapter(final Context context, final Cursor folderCursor, final Cursor blogCursor, final int collapsedGroupLayout,
|
||||
int expandedGroupLayout, int blogGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, String[] childFrom, int[] childTo, String[] blogFrom, int[] blogTo) {
|
||||
|
|
|
@ -38,24 +38,21 @@ public class SocialFeedItemsAdapter extends SimpleCursorAdapter {
|
|||
@Override
|
||||
public View getView(int position, View view, ViewGroup viewGroup) {
|
||||
View v = super.getView(position, view, viewGroup);
|
||||
View border = v.findViewById(R.id.row_item_favicon_borderbar);
|
||||
|
||||
cursor.moveToPosition(position);
|
||||
View borderOne = v.findViewById(R.id.row_item_favicon_borderbar_1);
|
||||
View borderTwo = v.findViewById(R.id.row_item_favicon_borderbar_2);
|
||||
|
||||
GradientDrawable gradient;
|
||||
cursor.moveToPosition(position);
|
||||
String feedColour = cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_FAVICON_COLOUR));
|
||||
String feedFade = cursor.getString(cursor.getColumnIndex(DatabaseConstants.FEED_FAVICON_FADE));
|
||||
|
||||
if (!TextUtils.equals(feedColour, "#null") && !TextUtils.equals(feedFade, "#null")) {
|
||||
gradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { Color.parseColor(feedColour), Color.parseColor(feedFade)});
|
||||
borderOne.setBackgroundColor(Color.parseColor(feedColour));
|
||||
borderTwo.setBackgroundColor(Color.parseColor(feedFade));
|
||||
} else {
|
||||
gradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[] { Color.DKGRAY, Color.LTGRAY });
|
||||
borderOne.setBackgroundColor(Color.GRAY);
|
||||
borderTwo.setBackgroundColor(Color.LTGRAY);
|
||||
}
|
||||
Drawable[] layers = new Drawable[2];
|
||||
layers[0] = gradient;
|
||||
layers[1] = context.getResources().getDrawable(R.drawable.shiny_plastic);
|
||||
border.setBackgroundDrawable(new LayerDrawable(layers));
|
||||
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ public class Story implements Serializable {
|
|||
|
||||
@SerializedName("story_date")
|
||||
public Date date;
|
||||
|
||||
@SerializedName("shared_date")
|
||||
public Date sharedDate;
|
||||
|
||||
@SerializedName("story_content")
|
||||
public String content;
|
||||
|
@ -66,6 +69,7 @@ public class Story implements Serializable {
|
|||
values.put(DatabaseConstants.STORY_ID, id);
|
||||
values.put(DatabaseConstants.STORY_TITLE, title);
|
||||
values.put(DatabaseConstants.STORY_DATE, date.getTime());
|
||||
values.put(DatabaseConstants.STORY_SHARED_DATE, sharedDate != null ? sharedDate.getTime() : new Date().getTime());
|
||||
values.put(DatabaseConstants.STORY_SHORTDATE, shortDate);
|
||||
values.put(DatabaseConstants.STORY_CONTENT, content);
|
||||
values.put(DatabaseConstants.STORY_PERMALINK, permalink);
|
||||
|
@ -90,6 +94,7 @@ public class Story implements Serializable {
|
|||
story.content = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_CONTENT));
|
||||
story.title = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_TITLE));
|
||||
story.date = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_DATE)));
|
||||
story.sharedDate = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.STORY_DATE)));
|
||||
story.shortDate = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHORTDATE));
|
||||
story.shareCount = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHARE_COUNT));
|
||||
story.commentCount = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_COMMENT_COUNT));
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.newsblur.database.DatabaseConstants;
|
|||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.util.AppConstants;
|
||||
import com.newsblur.util.NetworkUtils;
|
||||
import com.newsblur.view.ItemViewBinder;
|
||||
|
||||
public class FeedItemListFragment extends ItemListFragment implements LoaderManager.LoaderCallbacks<Cursor>, OnItemClickListener, OnScrollListener {
|
||||
|
@ -41,6 +42,7 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
private int currentState;
|
||||
private int currentPage = 1;
|
||||
private boolean requestedPage = false;
|
||||
private boolean doRequest = true;
|
||||
|
||||
public static int ITEMLIST_LOADER = 0x01;
|
||||
private int READING_RETURNED = 0x02;
|
||||
|
@ -58,6 +60,9 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!NetworkUtils.isOnline(getActivity())) {
|
||||
doRequest = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static FeedItemListFragment newInstance(final String feedId, int currentState) {
|
||||
|
@ -150,7 +155,7 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
break;
|
||||
}
|
||||
|
||||
if (loadMore && !requestedPage) {
|
||||
if (loadMore && !requestedPage && doRequest) {
|
||||
currentPage += 1;
|
||||
requestedPage = true;
|
||||
((ItemsList) getActivity()).triggerRefresh(currentPage);
|
||||
|
@ -158,7 +163,6 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
Log.d(TAG, "No need");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -192,9 +192,10 @@ public class APIManager {
|
|||
Uri storySocialUri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
contentResolver.insert(storySocialUri, story.getValues());
|
||||
}
|
||||
|
||||
for (Feed feed : socialFeedResponse.feeds) {
|
||||
contentResolver.insert(FeedProvider.FEEDS_URI, feed.getValues());
|
||||
if (socialFeedResponse != null && socialFeedResponse .feeds!= null) {
|
||||
for (Feed feed : socialFeedResponse.feeds) {
|
||||
contentResolver.insert(FeedProvider.FEEDS_URI, feed.getValues());
|
||||
}
|
||||
}
|
||||
return socialFeedResponse;
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,9 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
|
@ -18,9 +21,14 @@ public class DateStringTypeAdapter implements JsonDeserializer<Date> {
|
|||
@Override
|
||||
public Date deserialize(JsonElement element, Type type, JsonDeserializationContext arg2) throws JsonParseException {
|
||||
try {
|
||||
return df.parse(element.getAsString());
|
||||
if (element == null || TextUtils.isEmpty(element.getAsString())) {
|
||||
return new Date();
|
||||
} else {
|
||||
return df.parse(element.getAsString());
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new JsonParseException(e);
|
||||
Log.e("DateTypeAdapter", e.getLocalizedMessage());
|
||||
return new Date();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,14 +68,14 @@ public class ImageLoader {
|
|||
public void displayImageByUid(String uid, ImageView imageView) {
|
||||
Bitmap bitmap = memoryCache.get(uid);
|
||||
if (bitmap != null) {
|
||||
bitmap = UIUtils.roundCorners(bitmap, 10f);
|
||||
bitmap = UIUtils.roundBitmap(bitmap);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
} else {
|
||||
File f = fileCache.getFile(uid);
|
||||
bitmap = BitmapFactory.decodeFile(f.getAbsolutePath());
|
||||
if (bitmap != null) {
|
||||
memoryCache.put(uid, bitmap);
|
||||
bitmap = UIUtils.roundCorners(bitmap, 10f);
|
||||
bitmap = UIUtils.roundBitmap(bitmap);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.logo);
|
||||
|
@ -102,7 +102,7 @@ public class ImageLoader {
|
|||
if (bitmap != null) {
|
||||
Log.d(TAG, "Retrieving bitmap From file cache");
|
||||
memoryCache.put(uid, bitmap);
|
||||
bitmap = UIUtils.roundCorners(bitmap, 10f);
|
||||
bitmap = UIUtils.roundBitmap(bitmap);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,29 @@ public class UIUtils {
|
|||
|
||||
clipped.recycle();
|
||||
|
||||
return rounded;
|
||||
}
|
||||
|
||||
public static Bitmap roundBitmap(Bitmap source) {
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(WHITE);
|
||||
|
||||
Bitmap clipped = Bitmap.createBitmap(width, height, ARGB_8888);
|
||||
Canvas canvas = new Canvas(clipped);
|
||||
canvas.drawCircle(width / 2, height / 2, width / 2, paint);
|
||||
paint.setXfermode(new PorterDuffXfermode(DST_IN));
|
||||
|
||||
Bitmap rounded = Bitmap.createBitmap(width, height, ARGB_8888);
|
||||
canvas = new Canvas(rounded);
|
||||
canvas.drawBitmap(source, 0, 0, null);
|
||||
canvas.drawBitmap(clipped, 0, 0, paint);
|
||||
|
||||
clipped.recycle();
|
||||
|
||||
return rounded;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.newsblur.view;
|
|||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.v4.widget.SimpleCursorAdapter.ViewBinder;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
@ -31,9 +30,9 @@ public class SocialItemViewBinder implements ViewBinder {
|
|||
if (TextUtils.equals(columnName, DatabaseConstants.STORY_READ)) {
|
||||
String read = cursor.getString(columnIndex);
|
||||
if (TextUtils.equals(read, "0")) {
|
||||
((TextView) view).setTypeface(null, Typeface.BOLD);
|
||||
((TextView) view).setTextColor(context.getResources().getColor(R.color.darkgray));
|
||||
} else {
|
||||
((TextView) view).setTypeface(null, Typeface.NORMAL);
|
||||
((TextView) view).setTextColor(context.getResources().getColor(R.color.lightgray));
|
||||
}
|
||||
return true;
|
||||
} else if (TextUtils.equals(columnName, DatabaseConstants.STORY_AUTHORS)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue