Added source shared IDs to comments and modified views to reflect share source.

This commit is contained in:
RyanBateman 2012-09-17 16:55:50 -04:00
parent 53622aa9b7
commit 803d3e370e
7 changed files with 105 additions and 10 deletions

View file

@ -22,6 +22,41 @@
android:layout_marginRight="10dp"
android:contentDescription="@string/description_comment_user"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/comment_sharesource_image"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_marginRight="10dp"
android:visibility="invisible"
android:contentDescription="@string/description_comment_user"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/comment_user_reshare_image"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:visibility="invisible"
android:contentDescription="@string/description_comment_user"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/comment_user_reshare_image"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:contentDescription="@string/description_comment_user"
android:scaleType="fitCenter" />
<ImageView
android:id="@+id/comment_reply_icon"

View file

@ -54,6 +54,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
private final String COMMENT_SQL = "CREATE TABLE " + DatabaseConstants.COMMENT_TABLE + " (" +
DatabaseConstants.COMMENT_DATE + TEXT + ", " +
DatabaseConstants.COMMENT_SHAREDDATE + TEXT + ", " +
DatabaseConstants.COMMENT_SOURCE_USERID + TEXT + ", " +
DatabaseConstants.COMMENT_ID + TEXT + " PRIMARY KEY, " +
DatabaseConstants.COMMENT_LIKING_USERS + TEXT + ", " +
DatabaseConstants.COMMENT_STORYID + TEXT + ", " +
@ -91,6 +92,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
DatabaseConstants.STORY_COMMENT_COUNT + INTEGER + ", " +
DatabaseConstants.STORY_SHARE_COUNT + INTEGER + ", " +
DatabaseConstants.STORY_SOCIAL_USER_ID + TEXT + ", " +
DatabaseConstants.STORY_SOURCE_USER_ID + TEXT + ", " +
DatabaseConstants.STORY_SHARED_USER_IDS + TEXT + ", " +
DatabaseConstants.STORY_PUBLIC_USER_IDS + TEXT + ", " +
DatabaseConstants.STORY_FRIEND_USER_IDS + TEXT + ", " +

View file

@ -76,12 +76,14 @@ public class DatabaseConstants {
public static final String STORY_PUBLIC_USER_IDS = "public_user_ids";
public static final String STORY_SHORTDATE = "shortDate";
public static final String STORY_SOCIAL_USER_ID = "socialUserId";
public static final String STORY_SOURCE_USER_ID = "sourceUserId";
public static final String STORY_TAGS = "tags";
public static final String COMMENT_ID = BaseColumns._ID;
public static final String COMMENT_STORYID = "comment_storyid";
public static final String COMMENT_TEXT = "comment_text";
public static final String COMMENT_DATE = "comment_date";
public static final String COMMENT_SOURCE_USERID = "comment_source_user";
public static final String COMMENT_LIKING_USERS = "comment_liking_users";
public static final String COMMENT_SHAREDDATE = "comment_shareddate";
public static final String COMMENT_USERID = "comment_userid";
@ -114,7 +116,7 @@ public class DatabaseConstants {
};
public static final String[] COMMENT_COLUMNS = {
COMMENT_ID, COMMENT_STORYID, COMMENT_TEXT, COMMENT_USERID, COMMENT_DATE, COMMENT_LIKING_USERS, COMMENT_SHAREDDATE
COMMENT_ID, COMMENT_STORYID, COMMENT_TEXT, COMMENT_USERID, COMMENT_DATE, COMMENT_LIKING_USERS, COMMENT_SHAREDDATE, COMMENT_SOURCE_USERID
};
public static final String[] REPLY_COLUMNS = {
@ -127,7 +129,7 @@ public class DatabaseConstants {
public static final String[] STORY_COLUMNS = {
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, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS
STORY_PERMALINK, STORY_READ, STORY_SHARE_COUNT, STORY_TAGS, STORY_TITLE, STORY_SOCIAL_USER_ID, STORY_SOURCE_USER_ID, STORY_SHARED_USER_IDS, STORY_FRIEND_USER_IDS, STORY_PUBLIC_USER_IDS
};
public static final String FOLDER_INTELLIGENCE_ALL = " HAVING SUM(" + DatabaseConstants.FEED_NEGATIVE_COUNT + " + " + DatabaseConstants.FEED_NEUTRAL_COUNT + " + " + DatabaseConstants.FEED_POSITIVE_COUNT + ") >= 0 ";
@ -143,4 +145,5 @@ public class DatabaseConstants {
public static final String STORY_INTELLIGENCE_ALL = " (" + DatabaseConstants.STORY_INTELLIGENCE_AUTHORS + " + " + DatabaseConstants.STORY_INTELLIGENCE_FEED + " + " + DatabaseConstants.STORY_INTELLIGENCE_TAGS + " + " + DatabaseConstants.STORY_INTELLIGENCE_TITLE + ") >= 0 ";
}

View file

@ -22,6 +22,9 @@ public class Comment implements Serializable {
@SerializedName("shared_date")
public String sharedDate;
@SerializedName("source_user_id")
public String sourceUserId;
@SerializedName("date")
public String date;
@ -40,6 +43,7 @@ public class Comment implements Serializable {
values.put(DatabaseConstants.COMMENT_LIKING_USERS, TextUtils.join(",", likingUsers));
values.put(DatabaseConstants.COMMENT_TEXT, commentText);
values.put(DatabaseConstants.COMMENT_SHAREDDATE, sharedDate);
values.put(DatabaseConstants.COMMENT_SOURCE_USERID, sourceUserId);
values.put(DatabaseConstants.COMMENT_USERID, userId);
values.put(DatabaseConstants.COMMENT_ID, id);
return values;
@ -55,6 +59,7 @@ public class Comment implements Serializable {
comment.userId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_USERID));
String likingUsers = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_LIKING_USERS));
comment.likingUsers = TextUtils.split(likingUsers, ",");
comment.sourceUserId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_SOURCE_USERID));
comment.id = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_ID));
return comment;

View file

@ -43,6 +43,9 @@ public class Story implements Serializable {
@SerializedName("social_user_id")
public String socialUserId;
@SerializedName("source_user_id")
public String sourceUserId;
@SerializedName("story_title")
public String title;
@ -86,6 +89,7 @@ public class Story implements Serializable {
values.put(DatabaseConstants.STORY_SHARE_COUNT, shareCount);
values.put(DatabaseConstants.STORY_AUTHORS, authors);
values.put(DatabaseConstants.STORY_SOCIAL_USER_ID, socialUserId);
values.put(DatabaseConstants.STORY_SOURCE_USER_ID, sourceUserId);
values.put(DatabaseConstants.STORY_SHARED_USER_IDS, TextUtils.join(",", sharedUserIds));
values.put(DatabaseConstants.STORY_FRIEND_USER_IDS, TextUtils.join(",", friendUserIds));
values.put(DatabaseConstants.STORY_PUBLIC_USER_IDS, TextUtils.join(",", publicUserIds));
@ -110,6 +114,7 @@ public class Story implements Serializable {
story.shareCount = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHARE_COUNT));
story.commentCount = cursor.getInt(cursor.getColumnIndex(DatabaseConstants.STORY_COMMENT_COUNT));
story.socialUserId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SOCIAL_USER_ID));
story.sourceUserId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SOURCE_USER_ID));
story.permalink = cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_PERMALINK));
story.sharedUserIds = TextUtils.split(cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_SHARED_USER_IDS)), ",");
story.friendUserIds = TextUtils.split(cursor.getString(cursor.getColumnIndex(DatabaseConstants.STORY_FRIEND_USER_IDS)), ",");

View file

@ -17,7 +17,6 @@ import android.widget.Toast;
import com.newsblur.R;
import com.newsblur.domain.Classifier;
import com.newsblur.fragment.ClassifierDialogFragment.TagUpdateCallback;
import com.newsblur.network.APIManager;
public class ClassifierDialogFragment extends DialogFragment {
@ -111,9 +110,10 @@ public class ClassifierDialogFragment extends DialogFragment {
Toast.makeText(getActivity(), R.string.error_saving_classifier, Toast.LENGTH_SHORT).show();
}
ClassifierDialogFragment.this.dismiss();
};
}.execute();
ClassifierDialogFragment.this.dismiss();
}
});
@ -136,9 +136,10 @@ public class ClassifierDialogFragment extends DialogFragment {
} else {
tagCallback.updateTagView(key, classifierType, result.intValue());
}
ClassifierDialogFragment.this.dismiss();
}
}.execute();
ClassifierDialogFragment.this.dismiss();
}
});
@ -169,9 +170,10 @@ public class ClassifierDialogFragment extends DialogFragment {
} else {
tagCallback.updateTagView(key, classifierType, result.intValue());
}
ClassifierDialogFragment.this.dismiss();
}
}.execute();
ClassifierDialogFragment.this.dismiss();
}
});

View file

@ -13,6 +13,7 @@ import android.os.AsyncTask;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.widget.GridLayout;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@ -143,8 +144,17 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
replyText.setText(reply.text);
ImageView replyImage = (ImageView) replyView.findViewById(R.id.reply_user_image);
ProfileResponse replyUser = apiManager.getUser(reply.userId);
final ProfileResponse replyUser = apiManager.getUser(reply.userId);
imageLoader.displayImage(replyUser.user.photoUrl, replyImage);
replyImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
i.putExtra(Profile.USER_ID, replyUser.user.userId);
context.startActivity(i);
}
});
TextView replyUsername = (TextView) replyView.findViewById(R.id.reply_username);
replyUsername.setText(replyUser.user.username);
@ -159,8 +169,31 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
commentUsername.setText(commentUser.username);
String userPhoto = commentUser.photoUrl;
imageLoader.displayImage(userPhoto, commentImage);
if (!TextUtils.isEmpty(comment.sourceUserId)) {
commentImage.setVisibility(View.INVISIBLE);
ImageView usershareImage = (ImageView) commentView.findViewById(R.id.comment_user_reshare_image);
ImageView sourceUserImage = (ImageView) commentView.findViewById(R.id.comment_sharesource_image);
sourceUserImage.setVisibility(View.VISIBLE);
usershareImage.setVisibility(View.VISIBLE);
commentImage.setVisibility(View.INVISIBLE);
UserProfile user;
if (publicUserMap.containsKey(comment.sourceUserId)) {
user = publicUserMap.get(comment.sourceUserId);
} else {
user = friendUserMap.get(comment.sourceUserId);
}
imageLoader.displayImage(user.photoUrl, sourceUserImage);
imageLoader.displayImage(userPhoto, usershareImage);
} else {
imageLoader.displayImage(userPhoto, commentImage);
}
publicCommentViews.add(commentView);
} else {
UserProfile commentUser = friendUserMap.get(comment.userId);
if (commentUser != null) {
@ -171,6 +204,16 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
friendCommentViews.add(commentView);
}
}
commentImage.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
i.putExtra(Profile.USER_ID, comment.userId);
context.startActivity(i);
}
});
}
return null;
}
@ -228,7 +271,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
commentCursor.moveToFirst();
for (int i = 0; i < commentCursor.getCount(); i++) {
Comment comment = Comment.fromCursor(commentCursor);
final Comment comment = Comment.fromCursor(commentCursor);
ImageView image = new ImageView(context);
int imageLength = UIUtils.convertDPsToPixels(context, 25);
image.setMaxHeight(imageLength);
@ -249,7 +292,7 @@ public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
@Override
public void onClick(View view) {
Intent i = new Intent(context, Profile.class);
//i.putExtra(Profile.USER_ID, userId);
i.putExtra(Profile.USER_ID, comment.userId);
context.startActivity(i);
}
});