mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Close the navigation drawer after clicking the item in it. Fix some logic related to post parsing.
This commit is contained in:
parent
86ea4c8982
commit
66402e661b
@ -91,7 +91,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||||
drawer.addDrawerListener(toggle);
|
drawer.addDrawerListener(toggle);
|
||||||
@ -142,8 +142,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
glide.load(mBannerImageUrl).into(mBannerImageView);
|
glide.load(mBannerImageUrl).into(mBannerImageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
final SubscribedSubredditRecyclerViewAdapter subredditadapter = new SubscribedSubredditRecyclerViewAdapter(this);
|
final SubscribedSubredditRecyclerViewAdapter subredditadapter = new SubscribedSubredditRecyclerViewAdapter(this,
|
||||||
|
new SubscribedSubredditRecyclerViewAdapter.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick() {
|
||||||
|
drawer.closeDrawers();
|
||||||
|
}
|
||||||
|
});
|
||||||
subscribedSubredditRecyclerView.setAdapter(subredditadapter);
|
subscribedSubredditRecyclerView.setAdapter(subredditadapter);
|
||||||
|
|
||||||
mSubscribedSubredditViewModel = ViewModelProviders.of(this).get(SubscribedSubredditViewModel.class);
|
mSubscribedSubredditViewModel = ViewModelProviders.of(this).get(SubscribedSubredditViewModel.class);
|
||||||
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, new Observer<List<SubscribedSubredditData>>() {
|
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, new Observer<List<SubscribedSubredditData>>() {
|
||||||
@Override
|
@Override
|
||||||
@ -158,7 +165,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final SubscribedUserRecyclerViewAdapter userAdapter = new SubscribedUserRecyclerViewAdapter(this);
|
final SubscribedUserRecyclerViewAdapter userAdapter = new SubscribedUserRecyclerViewAdapter(this,
|
||||||
|
new SubscribedUserRecyclerViewAdapter.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick() {
|
||||||
|
drawer.closeDrawers();
|
||||||
|
}
|
||||||
|
});
|
||||||
subscribedUserRecyclerView.setAdapter(userAdapter);
|
subscribedUserRecyclerView.setAdapter(userAdapter);
|
||||||
mSubscribedUserViewModel = ViewModelProviders.of(this).get(SubscribedUserViewModel.class);
|
mSubscribedUserViewModel = ViewModelProviders.of(this).get(SubscribedUserViewModel.class);
|
||||||
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, new Observer<List<SubscribedUserData>>() {
|
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, new Observer<List<SubscribedUserData>>() {
|
||||||
|
@ -199,6 +199,19 @@ class ParsePost {
|
|||||||
int postType = PostData.IMAGE_TYPE;
|
int postType = PostData.IMAGE_TYPE;
|
||||||
bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
||||||
title, url, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost));
|
title, url, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost));
|
||||||
|
} else {
|
||||||
|
if (url.contains(permalink)) {
|
||||||
|
//Text post but with a preview
|
||||||
|
Log.i("text with image", Integer.toString(i));
|
||||||
|
int postType = PostData.TEXT_TYPE;
|
||||||
|
PostData textWithImagePostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
||||||
|
title, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost);
|
||||||
|
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
|
||||||
|
textWithImagePostData.setSelfText("");
|
||||||
|
} else {
|
||||||
|
textWithImagePostData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
||||||
|
}
|
||||||
|
bestPostData.add(textWithImagePostData);
|
||||||
} else {
|
} else {
|
||||||
//Link post
|
//Link post
|
||||||
Log.i("link", Integer.toString(i));
|
Log.i("link", Integer.toString(i));
|
||||||
@ -213,6 +226,7 @@ class ParsePost {
|
|||||||
bestPostData.add(linkPostData);
|
bestPostData.add(linkPostData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (url.endsWith("jpg") || url.endsWith("png")) {
|
if (url.endsWith("jpg") || url.endsWith("png")) {
|
||||||
//Image post
|
//Image post
|
||||||
|
@ -36,7 +36,6 @@ class PostData implements Parcelable {
|
|||||||
private boolean isCrosspost;
|
private boolean isCrosspost;
|
||||||
private boolean isDashVideo;
|
private boolean isDashVideo;
|
||||||
private boolean isDownloadableGifOrVideo;
|
private boolean isDownloadableGifOrVideo;
|
||||||
private PostData crosspostParentPostData;
|
|
||||||
|
|
||||||
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
|
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
|
||||||
String previewUrl, String permalink, int score, int postType, int voteType, int gilded,
|
String previewUrl, String permalink, int score, int postType, int voteType, int gilded,
|
||||||
|
@ -69,8 +69,8 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
mPostData = postData;
|
mPostData = postData;
|
||||||
mPaginationSynchronizer = paginationSynchronizer;
|
mPaginationSynchronizer = paginationSynchronizer;
|
||||||
this.hasMultipleSubreddits = hasMultipleSubreddits;
|
this.hasMultipleSubreddits = hasMultipleSubreddits;
|
||||||
glide = Glide.with(mContext);
|
glide = Glide.with(mContext.getApplicationContext());
|
||||||
subredditDao = SubredditRoomDatabase.getDatabase(mContext).subredditDao();
|
subredditDao = SubredditRoomDatabase.getDatabase(mContext.getApplicationContext()).subredditDao();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,8 +308,9 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
case PostData.TEXT_TYPE:
|
||||||
((DataViewHolder) holder).typeTextView.setText("TEXT");
|
((DataViewHolder) holder).typeTextView.setText("TEXT");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).upvoteButton.setOnClickListener(new View.OnClickListener() {
|
((DataViewHolder) holder).upvoteButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -20,10 +20,16 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
private List<SubscribedSubredditData> mSubscribedSubredditData;
|
private List<SubscribedSubredditData> mSubscribedSubredditData;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
|
private OnItemClickListener mOnItemClickListener;
|
||||||
|
|
||||||
SubscribedSubredditRecyclerViewAdapter(Context context) {
|
interface OnItemClickListener {
|
||||||
mContext = context;
|
void onClick();
|
||||||
glide = Glide.with(context);
|
}
|
||||||
|
|
||||||
|
SubscribedSubredditRecyclerViewAdapter(Context context, OnItemClickListener onItemClickListener) {
|
||||||
|
mContext = context.getApplicationContext();
|
||||||
|
glide = Glide.with(context.getApplicationContext());
|
||||||
|
mOnItemClickListener = onItemClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -38,6 +44,7 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if(viewHolder.getAdapterPosition() >= 0) {
|
if(viewHolder.getAdapterPosition() >= 0) {
|
||||||
|
mOnItemClickListener.onClick();
|
||||||
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, mSubscribedSubredditData.get(viewHolder.getAdapterPosition()).getName());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, mSubscribedSubredditData.get(viewHolder.getAdapterPosition()).getName());
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_VALUE_KEY, mSubscribedSubredditData.get(viewHolder.getAdapterPosition()).getId());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_VALUE_KEY, mSubscribedSubredditData.get(viewHolder.getAdapterPosition()).getId());
|
||||||
|
@ -16,13 +16,17 @@ import java.util.List;
|
|||||||
import de.hdodenhof.circleimageview.CircleImageView;
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private Context mContext;
|
|
||||||
private List<SubscribedUserData> mSubscribedUserData;
|
private List<SubscribedUserData> mSubscribedUserData;
|
||||||
private RequestManager glide;
|
private RequestManager glide;
|
||||||
|
private OnItemClickListener mOnItemClickListener;
|
||||||
|
|
||||||
SubscribedUserRecyclerViewAdapter(Context context) {
|
interface OnItemClickListener {
|
||||||
mContext = context;
|
void onClick();
|
||||||
glide = Glide.with(context);
|
}
|
||||||
|
|
||||||
|
SubscribedUserRecyclerViewAdapter(Context context, OnItemClickListener onItemClickListener) {
|
||||||
|
glide = Glide.with(context.getApplicationContext());
|
||||||
|
mOnItemClickListener = onItemClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@ -33,6 +37,14 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||||
|
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
//Need to be implemented
|
||||||
|
|
||||||
|
mOnItemClickListener.onClick();
|
||||||
|
}
|
||||||
|
});
|
||||||
if(!mSubscribedUserData.get(i).getIconUrl().equals("")) {
|
if(!mSubscribedUserData.get(i).getIconUrl().equals("")) {
|
||||||
glide.load(mSubscribedUserData.get(i).getIconUrl()).into(((UserViewHolder) viewHolder).iconCircleImageView);
|
glide.load(mSubscribedUserData.get(i).getIconUrl()).into(((UserViewHolder) viewHolder).iconCircleImageView);
|
||||||
} else {
|
} else {
|
||||||
|
@ -205,6 +205,12 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
if(mPostData.isNSFW()) {
|
if(mPostData.isNSFW()) {
|
||||||
mNSFWTextView.setVisibility(View.VISIBLE);
|
mNSFWTextView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!mPostData.getSelfText().equals("")) {
|
||||||
|
mContentTextView.setVisibility(View.VISIBLE);
|
||||||
|
mContentTextView.setHtml(mPostData.getSelfText());
|
||||||
|
}
|
||||||
|
|
||||||
mScoreTextView.setText(Integer.toString(mPostData.getScore()));
|
mScoreTextView.setText(Integer.toString(mPostData.getScore()));
|
||||||
|
|
||||||
mShareButton.setOnClickListener(new View.OnClickListener() {
|
mShareButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -235,10 +241,6 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case PostData.LINK_TYPE:
|
case PostData.LINK_TYPE:
|
||||||
mTypeTextView.setText("LINK");
|
mTypeTextView.setText("LINK");
|
||||||
if(mPostData.getSelfText() != null && !mPostData.getSelfText().equals("")) {
|
|
||||||
mContentTextView.setVisibility(View.VISIBLE);
|
|
||||||
mContentTextView.setHtml(mPostData.getSelfText());
|
|
||||||
}
|
|
||||||
|
|
||||||
mImageView.setOnClickListener(new View.OnClickListener() {
|
mImageView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -296,10 +298,6 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case PostData.NO_PREVIEW_LINK_TYPE:
|
case PostData.NO_PREVIEW_LINK_TYPE:
|
||||||
mTypeTextView.setText("LINK");
|
mTypeTextView.setText("LINK");
|
||||||
if(!mPostData.getSelfText().equals("")) {
|
|
||||||
mContentTextView.setVisibility(View.VISIBLE);
|
|
||||||
mContentTextView.setHtml(mPostData.getSelfText());
|
|
||||||
}
|
|
||||||
mNoPreviewLinkImageView.setVisibility(View.VISIBLE);
|
mNoPreviewLinkImageView.setVisibility(View.VISIBLE);
|
||||||
mNoPreviewLinkImageView.setOnClickListener(new View.OnClickListener() {
|
mNoPreviewLinkImageView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -315,10 +313,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
|||||||
break;
|
break;
|
||||||
case PostData.TEXT_TYPE:
|
case PostData.TEXT_TYPE:
|
||||||
mTypeTextView.setText("TEXT");
|
mTypeTextView.setText("TEXT");
|
||||||
if(!mPostData.getSelfText().equals("")) {
|
break;
|
||||||
mContentTextView.setVisibility(View.VISIBLE);
|
|
||||||
mContentTextView.setHtml(mPostData.getSelfText());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
queryComment();
|
queryComment();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user