mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 10:58:23 +01:00
Add a FAB in ViewSubredditDetailActivity to submit posts. Display the current subreddit in PostXXXActivity if they are opened from ViewSubredditDetailActivity.
This commit is contained in:
parent
e0212985f8
commit
116ce0bb24
@ -56,11 +56,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout;
|
@BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout;
|
||||||
@BindView(R.id.fab_main_activity) FloatingActionButton fab;
|
@BindView(R.id.fab_main_activity) FloatingActionButton fab;
|
||||||
|
|
||||||
private LinearLayout textTypeLinearLayout;
|
|
||||||
private LinearLayout linkTypeLinearLayout;
|
|
||||||
private LinearLayout imageTypeLinearLayout;
|
|
||||||
private LinearLayout videoTypeLinearLayout;
|
|
||||||
|
|
||||||
private BottomSheetDialog dialog;
|
private BottomSheetDialog dialog;
|
||||||
|
|
||||||
private TextView mNameTextView;
|
private TextView mNameTextView;
|
||||||
@ -102,10 +97,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
View dialogView = View.inflate(this, R.layout.post_type_bottom_sheet, null);
|
View dialogView = View.inflate(this, R.layout.post_type_bottom_sheet, null);
|
||||||
textTypeLinearLayout = dialogView.findViewById(R.id.text_type_linear_layout_post_type_bottom_sheet);
|
LinearLayout textTypeLinearLayout = dialogView.findViewById(R.id.text_type_linear_layout_post_type_bottom_sheet);
|
||||||
linkTypeLinearLayout = dialogView.findViewById(R.id.link_type_linear_layout_post_type_bottom_sheet);
|
LinearLayout linkTypeLinearLayout = dialogView.findViewById(R.id.link_type_linear_layout_post_type_bottom_sheet);
|
||||||
imageTypeLinearLayout = dialogView.findViewById(R.id.image_type_linear_layout_post_type_bottom_sheet);
|
LinearLayout imageTypeLinearLayout = dialogView.findViewById(R.id.image_type_linear_layout_post_type_bottom_sheet);
|
||||||
videoTypeLinearLayout = dialogView.findViewById(R.id.video_type_linear_layout_post_type_bottom_sheet);
|
LinearLayout videoTypeLinearLayout = dialogView.findViewById(R.id.video_type_linear_layout_post_type_bottom_sheet);
|
||||||
|
|
||||||
dialog = new BottomSheetDialog(this);
|
dialog = new BottomSheetDialog(this);
|
||||||
dialog.setContentView(dialogView);
|
dialog.setContentView(dialogView);
|
||||||
|
@ -35,6 +35,7 @@ import java.util.Locale;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import SubredditDatabase.SubredditRoomDatabase;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -46,13 +47,13 @@ import retrofit2.Retrofit;
|
|||||||
public class PostImageActivity extends AppCompatActivity {
|
public class PostImageActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_SUBREDDIT_ICON = "ESI";
|
|
||||||
|
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||||
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
||||||
private static final String IMAGE_URI_STATE = "IUS";
|
private static final String IMAGE_URI_STATE = "IUS";
|
||||||
|
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
private static final int PICK_IMAGE_REQUEST_CODE = 1;
|
||||||
@ -72,6 +73,7 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
private String subredditName;
|
private String subredditName;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
private Uri imageUri;
|
private Uri imageUri;
|
||||||
|
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
@ -114,6 +116,8 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
|
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
|
||||||
|
|
||||||
if(savedInstanceState.getString(IMAGE_URI_STATE) != null) {
|
if(savedInstanceState.getString(IMAGE_URI_STATE) != null) {
|
||||||
imageUri = Uri.parse(savedInstanceState.getString(IMAGE_URI_STATE));
|
imageUri = Uri.parse(savedInstanceState.getString(IMAGE_URI_STATE));
|
||||||
loadImage();
|
loadImage();
|
||||||
@ -121,24 +125,16 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if(subredditName != null) {
|
if(subredditName != null) {
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
if(!loadSubredditIconSuccessful) {
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(iconUrl != null && !iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
iconUrl = getIntent().getExtras().getString(EXTRA_SUBREDDIT_ICON);
|
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@ -182,6 +178,29 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
mGlide.load(imageUri).into(imageView);
|
mGlide.load(imageUri).into(imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displaySubredditIcon() {
|
||||||
|
if(iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
mGlide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
} else {
|
||||||
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSubredditIcon() {
|
||||||
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
|
subredditName, iconImageUrl -> {
|
||||||
|
iconUrl = iconImageUrl;
|
||||||
|
displaySubredditIcon();
|
||||||
|
loadSubredditIconSuccessful = true;
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.post_image_activity, menu);
|
getMenuInflater().inflate(R.menu.post_image_activity, menu);
|
||||||
@ -306,6 +325,7 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
if(imageUri != null) {
|
if(imageUri != null) {
|
||||||
outState.putString(IMAGE_URI_STATE, imageUri.toString());
|
outState.putString(IMAGE_URI_STATE, imageUri.toString());
|
||||||
}
|
}
|
||||||
|
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -320,17 +340,7 @@ public class PostImageActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
if(!iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if(requestCode == PICK_IMAGE_REQUEST_CODE) {
|
} else if(requestCode == PICK_IMAGE_REQUEST_CODE) {
|
||||||
if(resultCode == RESULT_OK) {
|
if(resultCode == RESULT_OK) {
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Locale;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import SubredditDatabase.SubredditRoomDatabase;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -35,12 +36,12 @@ import retrofit2.Retrofit;
|
|||||||
public class PostLinkActivity extends AppCompatActivity {
|
public class PostLinkActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_SUBREDDIT_ICON = "ESI";
|
|
||||||
|
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||||
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
||||||
|
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ public class PostLinkActivity extends AppCompatActivity {
|
|||||||
private String subredditName;
|
private String subredditName;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
|
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@ -88,26 +90,20 @@ public class PostLinkActivity extends AppCompatActivity {
|
|||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
|
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
|
||||||
|
|
||||||
if(subredditName != null) {
|
if(subredditName != null) {
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
if(!loadSubredditIconSuccessful) {
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(iconUrl != null && !iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
iconUrl = getIntent().getExtras().getString(EXTRA_SUBREDDIT_ICON);
|
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@ -126,6 +122,29 @@ public class PostLinkActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displaySubredditIcon() {
|
||||||
|
if(iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
mGlide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
} else {
|
||||||
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSubredditIcon() {
|
||||||
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
|
subredditName, iconImageUrl -> {
|
||||||
|
iconUrl = iconImageUrl;
|
||||||
|
displaySubredditIcon();
|
||||||
|
loadSubredditIconSuccessful = true;
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.post_link_activity, menu);
|
getMenuInflater().inflate(R.menu.post_link_activity, menu);
|
||||||
@ -192,6 +211,7 @@ public class PostLinkActivity extends AppCompatActivity {
|
|||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
|
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
|
||||||
|
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -206,17 +226,7 @@ public class PostLinkActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
if(!iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Locale;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import SubredditDatabase.SubredditRoomDatabase;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -35,12 +36,12 @@ import retrofit2.Retrofit;
|
|||||||
public class PostTextActivity extends AppCompatActivity {
|
public class PostTextActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_SUBREDDIT_ICON = "ESI";
|
|
||||||
|
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||||
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
||||||
|
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
|
|
||||||
@ -55,6 +56,7 @@ public class PostTextActivity extends AppCompatActivity {
|
|||||||
private String subredditName;
|
private String subredditName;
|
||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
|
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@ -88,26 +90,21 @@ public class PostTextActivity extends AppCompatActivity {
|
|||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
|
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
|
||||||
|
|
||||||
if(subredditName != null) {
|
if(subredditName != null) {
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
if(!loadSubredditIconSuccessful) {
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(iconUrl != null && !iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
|
loadSubredditIconSuccessful = false;
|
||||||
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
iconUrl = getIntent().getExtras().getString(EXTRA_SUBREDDIT_ICON);
|
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@ -126,6 +123,29 @@ public class PostTextActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displaySubredditIcon() {
|
||||||
|
if(iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
mGlide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
} else {
|
||||||
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSubredditIcon() {
|
||||||
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
|
subredditName, iconImageUrl -> {
|
||||||
|
iconUrl = iconImageUrl;
|
||||||
|
displaySubredditIcon();
|
||||||
|
loadSubredditIconSuccessful = true;
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.post_text_activity, menu);
|
getMenuInflater().inflate(R.menu.post_text_activity, menu);
|
||||||
@ -192,6 +212,7 @@ public class PostTextActivity extends AppCompatActivity {
|
|||||||
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
outState.putString(SUBREDDIT_ICON_STATE, iconUrl);
|
||||||
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
outState.putBoolean(SUBREDDIT_SELECTED_STATE, subredditSelected);
|
||||||
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
|
outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
|
||||||
|
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -206,17 +227,7 @@ public class PostTextActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
if(!iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import java.util.Locale;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import SubredditDatabase.SubredditRoomDatabase;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
||||||
@ -47,13 +48,13 @@ import retrofit2.Retrofit;
|
|||||||
public class PostVideoActivity extends AppCompatActivity {
|
public class PostVideoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
static final String EXTRA_SUBREDDIT_NAME = "ESN";
|
||||||
static final String EXTRA_SUBREDDIT_ICON = "ESI";
|
|
||||||
|
|
||||||
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
private static final String SUBREDDIT_NAME_STATE = "SNS";
|
||||||
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
private static final String SUBREDDIT_ICON_STATE = "SIS";
|
||||||
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
private static final String SUBREDDIT_SELECTED_STATE = "SSS";
|
||||||
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
private static final String SUBREDDIT_IS_USER_STATE = "SIUS";
|
||||||
private static final String VIDEO_URI_STATE = "IUS";
|
private static final String VIDEO_URI_STATE = "IUS";
|
||||||
|
private static final String LOAD_SUBREDDIT_ICON_STATE = "LSIS";
|
||||||
|
|
||||||
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
|
||||||
private static final int PICK_VIDEO_REQUEST_CODE = 1;
|
private static final int PICK_VIDEO_REQUEST_CODE = 1;
|
||||||
@ -74,6 +75,7 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
private boolean subredditSelected = false;
|
private boolean subredditSelected = false;
|
||||||
private boolean subredditIsUser;
|
private boolean subredditIsUser;
|
||||||
private Uri videoUri;
|
private Uri videoUri;
|
||||||
|
private boolean loadSubredditIconSuccessful = true;
|
||||||
|
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private Locale mLocale;
|
private Locale mLocale;
|
||||||
@ -119,6 +121,8 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
iconUrl = savedInstanceState.getString(SUBREDDIT_ICON_STATE);
|
||||||
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
subredditSelected = savedInstanceState.getBoolean(SUBREDDIT_SELECTED_STATE);
|
||||||
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
|
||||||
|
loadSubredditIconSuccessful = savedInstanceState.getBoolean(LOAD_SUBREDDIT_ICON_STATE);
|
||||||
|
|
||||||
if(savedInstanceState.getString(VIDEO_URI_STATE) != null) {
|
if(savedInstanceState.getString(VIDEO_URI_STATE) != null) {
|
||||||
videoUri = Uri.parse(savedInstanceState.getString(VIDEO_URI_STATE));
|
videoUri = Uri.parse(savedInstanceState.getString(VIDEO_URI_STATE));
|
||||||
loadImage();
|
loadImage();
|
||||||
@ -126,24 +130,16 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if(subredditName != null) {
|
if(subredditName != null) {
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
if(!loadSubredditIconSuccessful) {
|
||||||
|
loadSubredditIcon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(iconUrl != null && !iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
if(getIntent().hasExtra(EXTRA_SUBREDDIT_NAME)) {
|
||||||
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
subredditName = getIntent().getExtras().getString(EXTRA_SUBREDDIT_NAME);
|
||||||
iconUrl = getIntent().getExtras().getString(EXTRA_SUBREDDIT_ICON);
|
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
|
loadSubredditIcon();
|
||||||
} else {
|
} else {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
@ -187,6 +183,29 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
mGlide.asBitmap().load(videoUri).into(imageView);
|
mGlide.asBitmap().load(videoUri).into(imageView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displaySubredditIcon() {
|
||||||
|
if(iconUrl != null && !iconUrl.equals("")) {
|
||||||
|
mGlide.load(iconUrl)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
} else {
|
||||||
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
||||||
|
.into(iconGifImageView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSubredditIcon() {
|
||||||
|
new LoadSubredditIconAsyncTask(SubredditRoomDatabase.getDatabase(this).subredditDao(),
|
||||||
|
subredditName, iconImageUrl -> {
|
||||||
|
iconUrl = iconImageUrl;
|
||||||
|
displaySubredditIcon();
|
||||||
|
loadSubredditIconSuccessful = true;
|
||||||
|
}).execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
getMenuInflater().inflate(R.menu.post_image_activity, menu);
|
getMenuInflater().inflate(R.menu.post_image_activity, menu);
|
||||||
@ -287,6 +306,7 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
if(videoUri != null) {
|
if(videoUri != null) {
|
||||||
outState.putString(VIDEO_URI_STATE, videoUri.toString());
|
outState.putString(VIDEO_URI_STATE, videoUri.toString());
|
||||||
}
|
}
|
||||||
|
outState.putBoolean(LOAD_SUBREDDIT_ICON_STATE, loadSubredditIconSuccessful);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -301,17 +321,7 @@ public class PostVideoActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
subreditNameTextView.setTextColor(getResources().getColor(R.color.primaryTextColor));
|
||||||
subreditNameTextView.setText(subredditName);
|
subreditNameTextView.setText(subredditName);
|
||||||
if(!iconUrl.equals("")) {
|
displaySubredditIcon();
|
||||||
mGlide.load(iconUrl)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.error(mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
} else {
|
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
|
|
||||||
.into(iconGifImageView);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if(requestCode == PICK_VIDEO_REQUEST_CODE) {
|
} else if(requestCode == PICK_VIDEO_REQUEST_CODE) {
|
||||||
if(resultCode == RESULT_OK) {
|
if(resultCode == RESULT_OK) {
|
||||||
|
@ -8,6 +8,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -22,7 +23,9 @@ import com.bumptech.glide.RequestManager;
|
|||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||||
import com.google.android.material.chip.Chip;
|
import com.google.android.material.chip.Chip;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -57,6 +60,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
|
|||||||
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity) TextView nSubscribersTextView;
|
@BindView(R.id.subscriber_count_text_view_view_subreddit_detail_activity) TextView nSubscribersTextView;
|
||||||
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity) TextView nOnlineSubscribersTextView;
|
@BindView(R.id.online_subscriber_count_text_view_view_subreddit_detail_activity) TextView nOnlineSubscribersTextView;
|
||||||
@BindView(R.id.description_text_view_view_subreddit_detail_activity) TextView descriptionTextView;
|
@BindView(R.id.description_text_view_view_subreddit_detail_activity) TextView descriptionTextView;
|
||||||
|
@BindView(R.id.fab_view_subreddit_detail_activity) FloatingActionButton fab;
|
||||||
|
|
||||||
private boolean subscriptionReady = false;
|
private boolean subscriptionReady = false;
|
||||||
private boolean isInLazyMode = false;
|
private boolean isInLazyMode = false;
|
||||||
@ -65,6 +69,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
|
|||||||
private Fragment mFragment;
|
private Fragment mFragment;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
private AppBarLayout.LayoutParams params;
|
private AppBarLayout.LayoutParams params;
|
||||||
|
private BottomSheetDialog dialog;
|
||||||
|
|
||||||
private SubscribedSubredditDao subscribedSubredditDao;
|
private SubscribedSubredditDao subscribedSubredditDao;
|
||||||
private SubredditViewModel mSubredditViewModel;
|
private SubredditViewModel mSubredditViewModel;
|
||||||
@ -85,8 +90,18 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_view_subreddit_detail);
|
setContentView(R.layout.activity_view_subreddit_detail);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
View dialogView = View.inflate(this, R.layout.post_type_bottom_sheet, null);
|
||||||
|
LinearLayout textTypeLinearLayout = dialogView.findViewById(R.id.text_type_linear_layout_post_type_bottom_sheet);
|
||||||
|
LinearLayout linkTypeLinearLayout = dialogView.findViewById(R.id.link_type_linear_layout_post_type_bottom_sheet);
|
||||||
|
LinearLayout imageTypeLinearLayout = dialogView.findViewById(R.id.image_type_linear_layout_post_type_bottom_sheet);
|
||||||
|
LinearLayout videoTypeLinearLayout = dialogView.findViewById(R.id.video_type_linear_layout_post_type_bottom_sheet);
|
||||||
|
|
||||||
|
dialog = new BottomSheetDialog(this);
|
||||||
|
dialog.setContentView(dialogView);
|
||||||
|
|
||||||
((Infinity) getApplication()).getmAppComponent().inject(this);
|
((Infinity) getApplication()).getmAppComponent().inject(this);
|
||||||
|
|
||||||
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
params = (AppBarLayout.LayoutParams) collapsingToolbarLayout.getLayoutParams();
|
||||||
@ -261,6 +276,38 @@ public class ViewSubredditDetailActivity extends AppCompatActivity {
|
|||||||
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
isInLazyMode = savedInstanceState.getBoolean(IS_IN_LAZY_MODE_STATE);
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textTypeLinearLayout.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, PostTextActivity.class);
|
||||||
|
intent.putExtra(PostTextActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
linkTypeLinearLayout.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, PostLinkActivity.class);
|
||||||
|
intent.putExtra(PostLinkActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
imageTypeLinearLayout.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, PostImageActivity.class);
|
||||||
|
intent.putExtra(PostImageActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
videoTypeLinearLayout.setOnClickListener(view -> {
|
||||||
|
Intent intent = new Intent(this, PostVideoActivity.class);
|
||||||
|
intent.putExtra(PostVideoActivity.EXTRA_SUBREDDIT_NAME, subredditName);
|
||||||
|
startActivity(intent);
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
fab.setOnClickListener(view -> {
|
||||||
|
dialog.show();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,4 +119,12 @@
|
|||||||
|
|
||||||
<include layout="@layout/content_view_subreddit_detail" />
|
<include layout="@layout/content_view_subreddit_detail" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_view_subreddit_detail_activity"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
app:srcCompat="@drawable/baseline_add_white_24" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in New Issue
Block a user