Advertisement
Carelkat

MainActivity (BlackLabel)

Oct 12th, 2017
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.38 KB | None | 0 0
  1. package com.example.android.sab;
  2.  
  3. import android.app.Activity;
  4. import android.content.Context;
  5. import android.content.Intent;
  6. import android.media.Image;
  7. import android.net.Uri;
  8. import android.os.Parcelable;
  9. import android.support.annotation.NonNull;
  10. import android.support.design.widget.BottomNavigationView;
  11. import android.support.v4.app.NotificationCompat;
  12. import android.support.v4.content.ContextCompat;
  13. import android.support.v7.app.AppCompatActivity;
  14. import android.os.Bundle;
  15. import android.support.v7.widget.LinearLayoutManager;
  16. import android.support.v7.widget.RecyclerView;
  17. import android.util.Log;
  18. import android.view.Menu;
  19. import android.view.MenuItem;
  20.  
  21. import java.util.ArrayList;
  22.  
  23. import static android.R.id.message;
  24. import static android.os.Build.VERSION_CODES.M;
  25. import static com.example.android.sab.R.string.n;
  26.  
  27.  
  28. //import static com.example.android.sab.CastleLager.modelArrayList;
  29.  
  30. public class BlackLabel extends brands {
  31.  
  32.     private RecyclerView recyclerView;
  33.     //private String modelArrayList;
  34.     private Context ctx;
  35.     public static ArrayList<Model> modelArrayList;
  36.     private CustomAdapter customAdapter;
  37.  
  38.         //incomingData.setText(incomingName);;
  39.     //private Button btnnext;
  40.  
  41.     // supossing to have an image called ic_play inside my drawables.
  42.  
  43.     public String[] brandlist = new String[]{
  44.             "Black Label 340ml NRB (85023)",
  45.             "Brutal Fruit Litchi 275ml NRB (85736)",
  46.             "Castle Lager 500ml Cans (85023)",
  47.             "Black Label 440ml NRB (86798)",
  48.             "Black Label 330ml RB (85556)",
  49.             "Black Label 750ml RB (85021)",
  50.             "Black Label 340ml NRB 12 Pack (87009)",
  51.             "Black Label 500ml Cans 12 Pack (85022)"};
  52.  
  53.     public int[] pallet_size = {
  54.             84,
  55.             127,
  56.             81,
  57.             80,
  58.             120,
  59.             70,
  60.             132,
  61.             90};
  62.  
  63.     public int[] myimage = {
  64.             R.drawable.black_label,
  65.             R.drawable.brutal_fruit,
  66.             R.drawable.castle_lager,
  67.             R.drawable.flying_fish,
  68.             R.drawable.castle_lite,
  69.             R.drawable.hansa,
  70.             R.drawable.lion_lager,
  71.             R.drawable.milk_stout};
  72.  
  73.     protected void onCreate(Bundle savedInstanceState) {
  74.         super.onCreate(savedInstanceState);
  75.         setContentView(R.layout.order_by_brand);
  76.         setTitle("Black Label");
  77.  
  78.         recyclerView = (RecyclerView) findViewById(R.id.recycler);
  79.  
  80.         modelArrayList = getModel();
  81.         customAdapter = new CustomAdapter(this);
  82.         recyclerView.setAdapter(customAdapter);
  83.         recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false));
  84.     }
  85.     private ArrayList<Model> getModel() {
  86.         final ArrayList<Model> list = new ArrayList<>();
  87.         for (int i = 0; i < 8; i++) {
  88.  
  89.             final Model model = new Model();
  90.             model.setNumber(0);
  91.             model.setNumber2(0);
  92.             model.setImage(myimage[i]);
  93.             model.setBrand(brandlist[i]);
  94.             model.setPallet_size(pallet_size[i]);
  95.             list.add(model);
  96.  
  97.         BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottomNavView_Bar);
  98.         BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
  99.         Menu menu = bottomNavigationView.getMenu();
  100.         MenuItem menuItem = menu.getItem(0);
  101.         menuItem.setChecked(true);
  102.  
  103.              class Model {
  104.  
  105.                  public String brand;
  106.                  private int number2;
  107.  
  108.                  public int getNumber2() {
  109.                      return number2;
  110.                  }
  111.                  public String getBrand() {
  112.                      return brand;
  113.                  }
  114.              }
  115.         bottomNavigationView.setOnNavigationItemSelectedListener(
  116.  
  117.                 new BottomNavigationView.OnNavigationItemSelectedListener() {
  118.                     @Override
  119.                     public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  120.                         switch (item.getItemId()) {
  121.                             case R.id.ic_home:
  122.                                 Intent intent1 = new Intent(BlackLabel.this, MainActivity.class);
  123.                                 startActivity(intent1);
  124.                                 break;
  125.  
  126.                             case R.id.ic_clear:
  127.                                 Intent intent2 = new Intent(BlackLabel.this, BlackLabel.class);
  128.                                 startActivity(intent2);
  129.                                 break;
  130.  
  131.                             case R.id.ic_email:
  132.                                 String extradata = model.getBrand() + model.getNumber2();
  133.                                 Intent intent = new Intent(Intent.ACTION_SENDTO);
  134.                                 intent.setData(Uri.parse("mailto:someone@somewhere.co.za"));
  135.                                 intent.putExtra(Intent.EXTRA_SUBJECT, "Please place order for....");
  136.                                 intent.putExtra(Intent.EXTRA_TEXT, extradata);
  137.                                 if (intent.resolveActivity(getPackageManager()) != null) {
  138.                                     startActivity(intent);
  139.                                 }
  140.                         }
  141.                         return false;
  142.                     }
  143.  
  144.                 });
  145.     }
  146.    return list;
  147. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement