@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.second);
    setTitle("Second Activity");

    Intent inIntent = getIntent();
    String calc = inIntent.getStringExtra("calc");
    final double first = inIntent.getDoubleExtra("first", 0);
    final double second = inIntent.getDoubleExtra("second", 0);
    final double result;
    Button ret = (Button) findViewById(R.id.ret);

    if (calc.equals("plus")) result = Double.parseDouble(String.format("%.3f", first + second));
    else if (calc.equals("minus"))
      result = Double.parseDouble(String.format("%.3f", first - second));
    else if (calc.equals("multiply"))
      result = Double.parseDouble(String.format("%.3f", first * second));
    else if (calc.equals("divider"))
      result = Double.parseDouble(String.format("%.3f", first / second));
    else result = 0;

    ret.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent outIntent = new Intent(getApplicationContext(), MainActivity.class);
            outIntent.putExtra("result", result);
            setResult(RESULT_OK, outIntent);
            finish();
          }
        });
  }
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.meat_toppings);
   Intent i = getIntent();
   size = i.getStringExtra("size");
   numVeggieToppings = i.getIntExtra("numVeggieToppings", 0);
   setMeatToppingsView();
   setNextButton();
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow().setStatusBarColor(getResources().getColor(R.color.holo_blue_bright));
    }
    listmain = new ArrayList<ConRecItem>();
    tm = (EditText) findViewById(R.id.setext);
    final RecycleItemClickListener itemClickListener =
        new RecycleItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            switch (position) {
              default:
                Intent intent = new Intent(searchActivity.this, conActivity.class);
                Data data = new Data();
                File fl = new File("/storage/sdcard0/M++/data/slist.txt");
                String spos = data.getData(fl, position + 1);
                int pos = Integer.valueOf(spos);
                intent.putExtra("pos", pos);
                startActivity(intent);
                break;
            }
          }
        };
    int displayWidth = 0;
    int displayHeight = 0;
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    displayWidth = displayMetrics.widthPixels;
    displayHeight = displayMetrics.heightPixels;
    final int rpos = displayWidth / 320;
    listmain = new ArrayList<ConRecItem>();
    ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(
        new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(adapter);
    tm.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {
            // TODO: Implement this method
          }

          @Override
          public void onTextChanged(CharSequence p1, int p2, int p3, int p4) {
            // TODO: Implement this method
          }

          @Override
          public void afterTextChanged(Editable edit) {

            // TODO
            listmain = new ArrayList<ConRecItem>();
            System.out.println("okokok");
            File fs = new File("/storage/sdcard0/M++/data/fs_con.txt");
            File fl = new File("/storage/sdcard0/M++/data/slist.txt");
            String text = tm.getText().toString();
            if (fs.exists()) {
              listmain = new ArrayList<ConRecItem>();
              if (fl.exists()) {
                fl.delete();
              }

              try {
                fl.createNewFile();

                String reg = ".*" + text + ".*";

                FileReader fr = new FileReader(fs);

                BufferedReader br = new BufferedReader(fr);

                String temp = null;
                String s = "";

                while ((temp = br.readLine()) != null) {
                  s += temp + "\n";
                }

                String[] ss = s.split("\n");
                for (int i = 0; i <= ss.length; i++) {
                  try {
                    if (ss[10 * i].matches(reg)) {
                      ConRecItem p = new ConRecItem(ss[10 * i + 1], ss[10 * i]);
                      listmain.add(p);
                      String spos = String.valueOf(i);
                      Data data = new Data();
                      data.writeData(fl, spos + "\n", false);
                    }
                  } catch (ArrayIndexOutOfBoundsException e) {
                  }
                }
                ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener);
                RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
                recyclerView.setLayoutManager(
                    new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL));
                recyclerView.setAdapter(adapter);

              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          };
        });
  }
Beispiel #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    final String ID = intent.getStringExtra("ID");
    final String name = intent.getStringExtra("Name");
    final ActionBar actionBar = getSupportActionBar();

    setContentView(R.layout.individual_colour_change_layout);

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    ColH = settings.getInt("houCol" + ID, getResources().getColor(R.color.clokH));
    ColM = settings.getInt("minCol" + ID, getResources().getColor(R.color.clokM));
    ColS = settings.getInt("secCol" + ID, getResources().getColor(R.color.clokS));
    String currentTitle = name + ": " + getString(R.string.chsColour);
    if (actionBar != null) {
      actionBar.setTitle(currentTitle);
      actionBar.setDisplayUseLogoEnabled(false);
    }

    draw();

    Button reset = (Button) findViewById(R.id.reset);
    reset.setOnClickListener(
        v -> {
          Editor editor = settings.edit();
          ColH = IndividualColourChange.this.getResources().getColor(R.color.clokH);
          ColM = IndividualColourChange.this.getResources().getColor(R.color.clokM);
          ColS = IndividualColourChange.this.getResources().getColor(R.color.clokS);
          editor.putInt("houCol" + ID, ColH);
          editor.putInt("minCol" + ID, ColM);
          editor.putInt("secCol" + ID, ColS);
          editor.apply();
          IndividualColourChange.this.draw();
        });

    ImageView colPickH = (ImageView) findViewById(R.id.colorHou);
    colPickH.setClickable(true);
    colPickH.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColH = color;
                    Editor editor = settings.edit();
                    editor.putInt("houCol" + ID, ColH);
                    editor.apply();
                    draw();
                  },
                  ColH);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.hHandCol));
          dlg.show();
        });

    ImageView colPickM = (ImageView) findViewById(R.id.colorMin);
    colPickM.setClickable(true);
    colPickM.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColM = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColM);
                    editor.apply();
                    draw();
                  },
                  ColM);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.mHandCol));
          dlg.show();
        });

    ImageView colPickS = (ImageView) findViewById(R.id.colorSec);
    colPickS.setClickable(true);
    colPickS.setOnClickListener(
        v -> {
          ColorSelectorDialog dlg =
              new ColorSelectorDialog(
                  context,
                  color -> {
                    ColS = color;
                    Editor editor = settings.edit();
                    editor.putInt("minCol" + ID, ColS);
                    editor.apply();
                    draw();
                  },
                  ColS);
          dlg.setTitle(IndividualColourChange.this.getString(R.string.sHandCol));
          dlg.show();
        });
  }