mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-24 18:08:23 +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);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
final DrawerLayout drawer = findViewById(R.id.drawer_layout);
|
||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
|
||||
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
|
||||
drawer.addDrawerListener(toggle);
|
||||
@ -142,8 +142,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
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);
|
||||
|
||||
mSubscribedSubredditViewModel = ViewModelProviders.of(this).get(SubscribedSubredditViewModel.class);
|
||||
mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, new Observer<List<SubscribedSubredditData>>() {
|
||||
@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);
|
||||
mSubscribedUserViewModel = ViewModelProviders.of(this).get(SubscribedUserViewModel.class);
|
||||
mSubscribedUserViewModel.getAllSubscribedUsers().observe(this, new Observer<List<SubscribedUserData>>() {
|
||||
|
@ -200,17 +200,31 @@ class ParsePost {
|
||||
bestPostData.add(new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
||||
title, url, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost));
|
||||
} else {
|
||||
//Link post
|
||||
Log.i("link", Integer.toString(i));
|
||||
int postType = PostData.LINK_TYPE;
|
||||
PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
||||
title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost);
|
||||
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
|
||||
linkPostData.setSelfText("");
|
||||
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 {
|
||||
linkPostData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
||||
//Link post
|
||||
Log.i("link", Integer.toString(i));
|
||||
int postType = PostData.LINK_TYPE;
|
||||
PostData linkPostData = new PostData(id, fullName, subredditNamePrefixed, formattedPostTime,
|
||||
title, previewUrl, url, permalink, score, postType, voteType, gilded, nsfw, stickied, isCrosspost);
|
||||
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
|
||||
linkPostData.setSelfText("");
|
||||
} else {
|
||||
linkPostData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
|
||||
}
|
||||
bestPostData.add(linkPostData);
|
||||
}
|
||||
bestPostData.add(linkPostData);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -36,7 +36,6 @@ class PostData implements Parcelable {
|
||||
private boolean isCrosspost;
|
||||
private boolean isDashVideo;
|
||||
private boolean isDownloadableGifOrVideo;
|
||||
private PostData crosspostParentPostData;
|
||||
|
||||
PostData(String id, String fullName, String subredditNamePrefixed, String postTime, String title,
|
||||
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;
|
||||
mPaginationSynchronizer = paginationSynchronizer;
|
||||
this.hasMultipleSubreddits = hasMultipleSubreddits;
|
||||
glide = Glide.with(mContext);
|
||||
subredditDao = SubredditRoomDatabase.getDatabase(mContext).subredditDao();
|
||||
glide = Glide.with(mContext.getApplicationContext());
|
||||
subredditDao = SubredditRoomDatabase.getDatabase(mContext.getApplicationContext()).subredditDao();
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,8 +308,9 @@ class PostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
case PostData.TEXT_TYPE:
|
||||
((DataViewHolder) holder).typeTextView.setText("TEXT");
|
||||
break;
|
||||
}
|
||||
|
||||
((DataViewHolder) holder).upvoteButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -20,10 +20,16 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
|
||||
private Context mContext;
|
||||
private List<SubscribedSubredditData> mSubscribedSubredditData;
|
||||
private RequestManager glide;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
SubscribedSubredditRecyclerViewAdapter(Context context) {
|
||||
mContext = context;
|
||||
glide = Glide.with(context);
|
||||
interface OnItemClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
SubscribedSubredditRecyclerViewAdapter(Context context, OnItemClickListener onItemClickListener) {
|
||||
mContext = context.getApplicationContext();
|
||||
glide = Glide.with(context.getApplicationContext());
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -38,6 +44,7 @@ class SubscribedSubredditRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if(viewHolder.getAdapterPosition() >= 0) {
|
||||
mOnItemClickListener.onClick();
|
||||
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, mSubscribedSubredditData.get(viewHolder.getAdapterPosition()).getName());
|
||||
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;
|
||||
|
||||
class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<SubscribedUserData> mSubscribedUserData;
|
||||
private RequestManager glide;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
SubscribedUserRecyclerViewAdapter(Context context) {
|
||||
mContext = context;
|
||||
glide = Glide.with(context);
|
||||
interface OnItemClickListener {
|
||||
void onClick();
|
||||
}
|
||||
|
||||
SubscribedUserRecyclerViewAdapter(Context context, OnItemClickListener onItemClickListener) {
|
||||
glide = Glide.with(context.getApplicationContext());
|
||||
mOnItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -33,6 +37,14 @@ class SubscribedUserRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie
|
||||
|
||||
@Override
|
||||
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("")) {
|
||||
glide.load(mSubscribedUserData.get(i).getIconUrl()).into(((UserViewHolder) viewHolder).iconCircleImageView);
|
||||
} else {
|
||||
|
@ -205,6 +205,12 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
||||
if(mPostData.isNSFW()) {
|
||||
mNSFWTextView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
if(!mPostData.getSelfText().equals("")) {
|
||||
mContentTextView.setVisibility(View.VISIBLE);
|
||||
mContentTextView.setHtml(mPostData.getSelfText());
|
||||
}
|
||||
|
||||
mScoreTextView.setText(Integer.toString(mPostData.getScore()));
|
||||
|
||||
mShareButton.setOnClickListener(new View.OnClickListener() {
|
||||
@ -235,10 +241,6 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
||||
break;
|
||||
case PostData.LINK_TYPE:
|
||||
mTypeTextView.setText("LINK");
|
||||
if(mPostData.getSelfText() != null && !mPostData.getSelfText().equals("")) {
|
||||
mContentTextView.setVisibility(View.VISIBLE);
|
||||
mContentTextView.setHtml(mPostData.getSelfText());
|
||||
}
|
||||
|
||||
mImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -296,10 +298,6 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
||||
break;
|
||||
case PostData.NO_PREVIEW_LINK_TYPE:
|
||||
mTypeTextView.setText("LINK");
|
||||
if(!mPostData.getSelfText().equals("")) {
|
||||
mContentTextView.setVisibility(View.VISIBLE);
|
||||
mContentTextView.setHtml(mPostData.getSelfText());
|
||||
}
|
||||
mNoPreviewLinkImageView.setVisibility(View.VISIBLE);
|
||||
mNoPreviewLinkImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -315,10 +313,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
||||
break;
|
||||
case PostData.TEXT_TYPE:
|
||||
mTypeTextView.setText("TEXT");
|
||||
if(!mPostData.getSelfText().equals("")) {
|
||||
mContentTextView.setVisibility(View.VISIBLE);
|
||||
mContentTextView.setHtml(mPostData.getSelfText());
|
||||
}
|
||||
break;
|
||||
}
|
||||
queryComment();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user