diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-07-12 03:31:28 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-07-12 03:31:28 +0000 |
commit | fcc34b45d4aeae95bd16c9d70f0a2db5109951f0 (patch) | |
tree | d8708a4ede38d34d4ae70b9860aa6fb1e18262a1 /app/src/main/java | |
parent | 68d3a7b09f42aef6c3ec1874af3c9dee4c3eef8c (diff) | |
download | infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.gz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.bz2 infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.lz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.xz infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.tar.zst infinity-for-reddit-fcc34b45d4aeae95bd16c9d70f0a2db5109951f0.zip |
Use a modal bottom sheet to display post selection instead of an alert dialog. Fixed some icons.
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index bdcfece5..f452cb66 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -15,7 +15,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.view.GravityCompat; @@ -28,6 +27,7 @@ import com.bumptech.glide.request.RequestOptions; import com.ferfalk.simplesearchview.SimpleSearchView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.CollapsingToolbarLayout; +import com.google.android.material.bottomsheet.BottomSheetDialog; import com.google.android.material.floatingactionbutton.FloatingActionButton; import javax.inject.Inject; @@ -57,6 +57,13 @@ public class MainActivity extends AppCompatActivity { @BindView(R.id.settings_linear_layout_main_activity) LinearLayout settingsLinearLayout; @BindView(R.id.fab_main_activity) FloatingActionButton fab; + private LinearLayout textTypeLinearLayout; + private LinearLayout linkTypeLinearLayout; + private LinearLayout imageTypeLinearLayout; + private LinearLayout videoTypeLinearLayout; + + private BottomSheetDialog dialog; + private TextView mNameTextView; private TextView mKarmaTextView; private GifImageView mProfileImageView; @@ -95,6 +102,15 @@ public class MainActivity extends AppCompatActivity { ButterKnife.bind(this); + 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); + 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); + 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); Toolbar toolbar = findViewById(R.id.toolbar); @@ -221,27 +237,27 @@ public class MainActivity extends AppCompatActivity { }); } - fab.setOnClickListener(view -> { - new AlertDialog.Builder(this).setTitle(R.string.dialog_post_type) - .setItems(R.array.dialog_post_types_array, (dialog, which) -> { - Intent intent; - switch (which) { - case 0: - intent = new Intent(this, PostTextActivity.class); - break; - case 1: - intent = new Intent(this, PostLinkActivity.class); - break; - case 2: - Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); - return; - default: - Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); - return; - } + textTypeLinearLayout.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, PostTextActivity.class); + startActivity(intent); + dialog.dismiss(); + }); + linkTypeLinearLayout.setOnClickListener(view -> { + Intent intent = new Intent(MainActivity.this, PostLinkActivity.class); + startActivity(intent); + dialog.dismiss(); + }); + imageTypeLinearLayout.setOnClickListener(view -> { + Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }); + videoTypeLinearLayout.setOnClickListener(view -> { + Toast.makeText(this, "Not implemented yet", Toast.LENGTH_SHORT).show(); + dialog.dismiss(); + }); - startActivity(intent); - }).show(); + fab.setOnClickListener(view -> { + dialog.show(); }); } |