Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package codelabs.ambarrukmo.activity;
- import android.content.Intent;
- import android.support.design.widget.AppBarLayout;
- import android.support.design.widget.BottomSheetDialog;
- import android.support.design.widget.BottomSheetDialogFragment;
- import android.support.v4.widget.NestedScrollView;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.support.v7.widget.LinearLayoutManager;
- import android.view.View;
- import android.view.WindowManager;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.TextView;
- import com.google.gson.Gson;
- import com.squareup.picasso.Picasso;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- import butterknife.OnClick;
- import codelabs.ambarrukmo.R;
- import codelabs.ambarrukmo.fragment.BarcodeMenuFragment;
- import codelabs.ambarrukmo.fragment.QrCodeVoucherFragment;
- import codelabs.ambarrukmo.model.CategoryListPromo;
- import codelabs.ambarrukmo.model.GetPromoList;
- import codelabs.ambarrukmo.utils.RecentUtils;
- public class PromoCategoryDetailActivity extends BaseActivity implements View.OnClickListener {
- @BindView(R.id.iv_back)
- ImageView ivBack;
- @BindView(R.id.img_promo)
- ImageView imgPromo;
- @BindView(R.id.appbar)
- AppBarLayout appbar;
- @BindView(R.id.tv_promotitle)
- TextView tvPromoTitle;
- @BindView(R.id.nested_scroll)
- NestedScrollView nestedScroll;
- @BindView(R.id.tv_highlights1)
- TextView tvHighlights;
- @BindView(R.id.tv_notice2)
- TextView tvNotice;
- @BindView(R.id.btn_check_now)
- Button btnCheckNow;
- @BindView(R.id.btn_view_promo)
- TextView btnViewPromo;
- @BindView(R.id.viewMoreHighlight)
- Button viewMoreHighlight;
- @BindView(R.id.viewMoreNotice)
- Button viewMoreNotice;
- CategoryListPromo.DATABean.Promotions getPromoList;
- LinearLayoutManager layoutManager;
- private int mMaxScrollSize;
- private boolean mIsElementHidden;
- private static final int PERCENTAGE_TO_SHOW_ELEMENT = 40;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_promo_detail_category);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //for transparant status bar
- ButterKnife.bind(this);
- initVariables();
- initListeners();
- callFunctions();
- }
- private void initVariables(){
- getPromoList = new Gson().fromJson(getIntent().getStringExtra("promo"),CategoryListPromo.DATABean.Promotions.class);
- }
- private void initListeners(){
- btnCheckNow.setOnClickListener(this);
- btnViewPromo.setOnClickListener(this);
- viewMoreHighlight.setOnClickListener(this);
- viewMoreNotice.setOnClickListener(this);
- }
- private void callFunctions(){
- setData();
- }
- public void showBottomSheetDialog() {
- BottomSheetDialogFragment bottomSheetDialogFragment = new QrCodeVoucherFragment();
- bottomSheetDialogFragment.show(getSupportFragmentManager(),bottomSheetDialogFragment.getTag());
- }
- private void setData() {
- Picasso.get()
- .load(getPromoList.getPromo_image())
- .placeholder(R.drawable.img_step2)
- .error(R.drawable.img_step2)
- .into(imgPromo);
- tvPromoTitle.setText(getPromoList.getPromo_title());
- tvHighlights.setText(RecentUtils.fromHtml(getPromoList.getHighlight_txt()));
- tvNotice.setText(RecentUtils.fromHtml(getPromoList.getNotice_txt()));
- }
- public void viewPromoDetail() {
- Intent intent = new Intent(PromoCategoryDetailActivity.this, ViewPromoDetailActivity.class);
- // intent.putExtra("promoimage", getPromoList.getPromo_image());
- // intent.putExtra("promo",getPromoList.getPromo_title());
- // intent.putExtra("promotitle", getPromoList.get());
- startActivity(intent);
- }
- @Override
- public void onClick(View view) {
- if (view == btnCheckNow) {
- View sheetView= getLayoutInflater().inflate(R.layout.confirm_voucher_bottomdialog, null);
- BottomSheetDialog dialog = new BottomSheetDialog(this);
- dialog.setContentView(sheetView);
- dialog.show();
- Button buttoncancel = (Button)
- sheetView.findViewById(R.id.btn_cancel);
- Button buttonConf = (Button)
- sheetView.findViewById(R.id.btn_confirm);
- buttoncancel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
- buttonConf.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showBottomSheetDialog();
- }
- });
- }
- else if (view == btnViewPromo) {
- viewPromoDetail();
- }
- else if (view == viewMoreHighlight) {
- if (viewMoreHighlight.getText().toString().equals("View more")) {
- tvHighlights.setMaxLines(Integer.MAX_VALUE);
- viewMoreHighlight.setText("View less");
- } else {
- tvHighlights.setMaxLines(5);
- viewMoreHighlight.setText("View more");
- }
- } else if (view == viewMoreNotice) {
- if (viewMoreNotice.getText().toString().equals("View more")) {
- tvNotice.setMaxLines(Integer.MAX_VALUE);
- viewMoreNotice.setText("View less");
- } else {
- tvNotice.setMaxLines(5);
- viewMoreNotice.setText("View more");
- }
- }
- }
- @OnClick(R.id.iv_back)
- void closeactivity(){
- finish();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement