コード例 #1
0
ファイル: MainActivity.java プロジェクト: mikebal/MyVinyls
  private void populateList(ArrayList<Records> recordList, boolean artistMode) {
    final MyDBHandler dbHandler = new MyDBHandler(getApplicationContext(), null, null, 1);
    recordDisplayList = (ListView) findViewById(R.id.listViewMainDisplay);

    if (!databaseTable.equals("lentout")) {
      customAdapter = new ListViewAdapterMain(this, recordList, null);
      customAdapter.artistView = artistMode;
      customAdapter.callingTable = databaseTable;
    } else {
      ArrayList<LentOut> lentOutList =
          dbHandler.getLentOut("SELECT * FROM lentout ORDER BY album_id");
      customAdapter = new ListViewAdapterMain(this, recordList, lentOutList);
      customAdapter.setIsOnLendOutScreen(true);
      customAdapter.callingTable = databaseTable;
    }

    recordDisplayList.setAdapter(customAdapter);
    recordDisplayList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            Records selectedRecord = customAdapter.getItem(position);
            String selectedBandName = selectedRecord.get_bandname();
            populateArrayList(
                "SELECT * FROM " + databaseTable + " WHERE bandname='" + selectedBandName + "';",
                false);
          }
        });
    customAdapter.notifyDataSetChanged();
    dbHandler.close();
  }
コード例 #2
0
 public void onDelete(View view) {
   dbHandler.deleteAll();
   int s = dbHandler.size();
   TextView size = (TextView) findViewById(R.id.pll_text);
   String s2 = String.valueOf(s);
   size.setText(s2);
 }
コード例 #3
0
  // SETTING DATA FOR MAIN ACTIVITY GRID
  private void setTemperatureAndDescriptions(String[] dates) {

    SimpleDateFormat sdf = new SimpleDateFormat("HH");
    Calendar c = Calendar.getInstance();
    int hour = Integer.parseInt(sdf.format(c.getTime()));
    if (hour < 3) {
      hour = 0;
    } else {
      hour = hour - (hour % 3);
    }

    if (hour < 10) {
      for (int i = 0; i <= 4; i++) {
        String date = dates[i] + ": 0" + hour + "h";
        temperatures[i] = weatherDatabase.getTemperatureValue(date);
        values[i] = weatherDatabase.getSymbolName(date);
      }
    }
    if (hour >= 10) {
      for (int i = 0; i <= 4; i++) {
        String date = dates[i] + ": " + hour + "h";
        temperatures[i] = weatherDatabase.getTemperatureValue(date);
        values[i] = weatherDatabase.getSymbolName(date);
      }
    }
  }
コード例 #4
0
ファイル: AddLentOut.java プロジェクト: mikebal/MyVinyls
  private void lendOutRecord(MyDBHandler dbHandler) {

    int currentID = 1;
    EditText name = (EditText) findViewById(R.id.editTextLendoutName);
    Button dateOut = (Button) findViewById(R.id.editTextLentoutDateOut);
    Button dateDue = (Button) findViewById(R.id.editTextLentoutDue);

    if (name == null || dateDue == null || dateOut == null) return;

    String nameStr = name.getText().toString();
    ArrayList<String> listOfIDs = dbHandler.dbReturnListStrings("SELECT * FROM lentout", "_id");
    if (listOfIDs != null && listOfIDs.size() != 0) currentID += findLargestString(listOfIDs);
    String currentIDStr = String.valueOf(currentID);
    String dateOutStr = dateOut.getText().toString();
    if (dateOutStr.equals("Today")) {
      dateOutStr = getDateFromDatePicker((DatePicker) findViewById(R.id.datePickerLentOut));
    }
    String dateDueStr = dateDue.getText().toString();
    if (dateDueStr.equals("Unset")) {
      dateDueStr = "12/12/2025";
    }
    dbHandler.runRawQueryNoResult(
        "insert into lentout (_id,album_id,lentout,dateout,dueback) values ("
            + currentIDStr
            + ","
            + recordID
            + ",'"
            + nameStr
            + "','"
            + dateOutStr
            + "','"
            + dateDueStr
            + "');");
    finish();
  }
コード例 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_results);

    ouncesText = (TextView) findViewById(R.id.ounceTextView);
    cupsText = (TextView) findViewById(R.id.cupTextView);
    setAlarmBtn = (Button) findViewById(R.id.setAlarmButton);
    viewHistoryBtn = (Button) findViewById(R.id.viewHistoryButton);
    Bundle waterData = getIntent().getExtras();

    if (waterData == null) {
      return;
    } else {
      ouncesTotal = Integer.toString(waterData.getInt("ounces"));
      cupsTotal = Integer.toString(waterData.getInt("cups"));
      ouncesText.setText(ouncesTotal);
      cupsText.setText(cupsTotal);

      MyDBHandler myDBHandler = new MyDBHandler(this, null, null, 1);
      WaterTotals total = new WaterTotals(ouncesTotal, cupsTotal);
      myDBHandler.addTotal(total);
      //            WaterTotals newRecord = myDBHandler.getLatestRecord();
      //            Log.d(String.valueOf(newRecord), "New Record From Database");
    }
  }
コード例 #6
0
ファイル: EditConfig.java プロジェクト: SunilPLSR/ProMark2
  public void onButton(View view) {
    MyDBHandler dbHandler;
    dbHandler = new MyDBHandler(this, null, null, 1);
    String bt = e1.getText().toString();
    String at = e2.getText().toString();
    String text = t.getText().toString();

    dbHandler.input(bt, text, at, pack);
  }
コード例 #7
0
 public void onUndo(View view) {
   if (c1.isChecked()) dbHandler.deleteCoche(matU, diaU, mesU, anyU, horaU, minU);
   else if (c2.isChecked())
     dbHandler.addCoche(
         new Coche(
             matricula.getText().toString(), diaU, mesU, anyU, horaU, minU, -1, -1, -1, -1, -1));
   int s = dbHandler.size();
   String s2 = String.valueOf(s);
   TextView size = (TextView) findViewById(R.id.pll_text);
   size.setText(s2);
 }
コード例 #8
0
ファイル: MainActivity.java プロジェクト: mikebal/MyVinyls
 private void populateArrayList(String dbCall, boolean artistMode) {
   MyDBHandler dbHandler = new MyDBHandler(getApplicationContext(), null, null, 1);
   ArrayList<Records> recordList;
   if (dbCall.equals("GENRES")) {
     recordList = dbHandler.getGenres(databaseTable);
     populateGenreList(recordList);
   } else {
     recordList = dbHandler.databaseToList(dbCall, databaseTable);
     populateList(recordList, artistMode);
   }
   dbHandler.close();
 }
コード例 #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_coches);

    MyDBHandler dbHandler;
    dbHandler = new MyDBHandler(this, null, null, 1);
    SQLiteDatabase db = dbHandler.getWritableDatabase();
    Cursor cursor = dbHandler.listarCoche();

    ListView lvlitems = (ListView) findViewById(R.id.lvlitems);
    lvlitems.setTextFilterEnabled(true);
    final TodoCursorAdapter todoAdapter = new TodoCursorAdapter(this, cursor);
    lvlitems.setAdapter(todoAdapter);
  }
コード例 #10
0
ファイル: AddLentOut.java プロジェクト: mikebal/MyVinyls
  private void manageDuplicate(final MyDBHandler dbHandler) {
    String result =
        dbHandler.runRawQueryIfExists(
            "SELECT * FROM lentout WHERE album_id='" + recordID + "'", "album_id");
    if (!result.equals("-1")) {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);

      builder.setTitle("Duplicate Lent Out");
      builder.setMessage("This record is show as already out, would you like override?");

      builder.setPositiveButton(
          "YES",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              dbHandler.runRawQueryNoResult(
                  "DELETE FROM " + "lentout WHERE album_id=\"" + recordID + "\";");
              dialog.dismiss();
              lendOutRecord(dbHandler);
            }
          });

      builder.setNegativeButton(
          "NO",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              // Do nothing
              dialog.dismiss();
            }
          });

      AlertDialog alert = builder.create();
      alert.show();
    } else lendOutRecord(dbHandler);
  }
コード例 #11
0
  // sets up database on first open
  // or initialize stone positions based on database data
  private void initializeStones() {
    if (dbHandler.isEmpty()) {
      Log.d("V", "filling up table");
      FrameLayout b0 = (FrameLayout) findViewById(R.id.b0);
      FrameLayout t1 = (FrameLayout) findViewById(R.id.t1);
      FrameLayout t2 = (FrameLayout) findViewById(R.id.t2);
      FrameLayout t3 = (FrameLayout) findViewById(R.id.t3);
      FrameLayout b4 = (FrameLayout) findViewById(R.id.b4);
      FrameLayout b5 = (FrameLayout) findViewById(R.id.b5);
      FrameLayout t6 = (FrameLayout) findViewById(R.id.t6);
      FrameLayout t7 = (FrameLayout) findViewById(R.id.t7);
      FrameLayout t8 = (FrameLayout) findViewById(R.id.t8);
      FrameLayout b9 = (FrameLayout) findViewById(R.id.b9);
      FrameLayout b10 = (FrameLayout) findViewById(R.id.b10);
      FrameLayout t11 = (FrameLayout) findViewById(R.id.t11);
      FrameLayout t12 = (FrameLayout) findViewById(R.id.t12);
      FrameLayout t13 = (FrameLayout) findViewById(R.id.t13);
      FrameLayout b14 = (FrameLayout) findViewById(R.id.b14);
      dbHandler.addStone("" + b0.getId());
      dbHandler.addStone("" + t1.getId());
      dbHandler.addStone("" + t2.getId());
      dbHandler.addStone("" + t3.getId());
      dbHandler.addStone("" + b4.getId());
      dbHandler.addStone("" + b5.getId());
      dbHandler.addStone("" + t6.getId());
      dbHandler.addStone("" + t7.getId());
      dbHandler.addStone("" + t8.getId());
      dbHandler.addStone("" + b9.getId());
      dbHandler.addStone("" + b10.getId());
      dbHandler.addStone("" + t11.getId());
      dbHandler.addStone("" + t12.getId());
      dbHandler.addStone("" + t13.getId());
      dbHandler.addStone("" + b14.getId());
    }

    for (int i = 1; i <= numofstones; i++) {
      String ispot = dbHandler.getSpot(i);
      int spotid = Integer.parseInt(ispot);
      FrameLayout spot = (FrameLayout) findViewById(spotid);
      ImageView currentStone = allStones[i - 1];
      FrameLayout parent = (FrameLayout) currentStone.getParent();
      parent.removeView(currentStone);
      spot.addView(currentStone);
      currentStone.setVisibility(View.VISIBLE);
    }
  }
コード例 #12
0
 void printDataBase() {
   try {
     Log.i(Tag, "printDataBase from main");
     String s = m_dbHandler.databaseToString();
     m_list.setText(s);
   } catch (Exception err) {
     Log.i(Tag, err.getMessage());
   }
 }
コード例 #13
0
  @Nullable
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.hod_display_contact_details, container, false);

    usn_hod_details = (TextView) view.findViewById(R.id.usn_hod_details);
    res_hod_contact_details = (TextView) view.findViewById(R.id.res_hod_contact_details);

    Student student = new Student();
    Department department = new Department();
    MyDBHandler db = new MyDBHandler(getActivity(), null, null, 1);

    usn_hod_details.setText(student.getUsn().toString() + " DETAILS");
    String res1 = db.hodGetContact(department, student);
    res_hod_contact_details.setText(res1);
    return view;
  }
コード例 #14
0
 public void deleteFromDatabase(View view) {
   try {
     String productName = m_input.getText().toString();
     m_dbHandler.deleteProduct(productName);
     printDataBase();
   } catch (Exception err) {
     Log.i(Tag, err.getMessage());
   }
 }
コード例 #15
0
 public void AddNewProduct(View view) {
   try {
     String productName = m_input.getText().toString();
     Products p = new Products(productName, 10);
     m_dbHandler.addProduct(p);
     printDataBase();
   } catch (Exception err) {
     Log.i(Tag, err.getMessage());
   }
 }
コード例 #16
0
 private void populateList() {
   // get the items from the database
   String[] items = dbHandler.dbToString();
   // make sure it is not empty
   if (items.length == 0) {
     // if it is empty display this message
     items = new String[] {"No items in inventory"};
   }
   // add all of the items to the inventory list
   inventory.addAll(Arrays.asList(items));
 }
コード例 #17
0
ファイル: EditConfig.java プロジェクト: SunilPLSR/ProMark2
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_config);

    Bundle data = getIntent().getExtras();
    if (data == null) {
      return;
    }
    String name = data.getString("name");
    pack = data.getString("package");
    t = (TextView) findViewById(R.id.textView);
    e1 = (EditText) findViewById(R.id.editText);
    e2 = (EditText) findViewById(R.id.editText2);

    t.setText(name);
    MyDBHandler dbHandler;
    dbHandler = new MyDBHandler(this, null, null, 1);
    e1.setText(dbHandler.get_bt(pack));
    e2.setText(dbHandler.get_at(pack));
  }
コード例 #18
0
 // handle clicks for list items
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   // make sure it is not empty
   if (!inventory.get(position).equals("No items in inventory") && !held) {
     // get the clicked item
     String item = inventory.get(position);
     // get the amount and name of the item
     int amount = Integer.valueOf(item.split("     --     ")[1]);
     String name = inventory.get(position).split("     --     ")[0];
     // clear the inventory list
     inventory.clear();
     // subtract 1 from the amount and update the database
     dbHandler.updateItem(name, amount - 1);
     // fill the list view
     populateList();
     adapter.notifyDataSetChanged();
   }
 }
コード例 #19
0
  /**
   * This function will update the item that the seller has selected with the new attributes, if the
   * info given was valid.
   */
  public void updateInventory() {
    if ((nameET.getText().toString().equals(""))
        || (descriptionET.getText().toString().equals(""))
        || (quantityET.getText().toString().equals(""))
        || (invoicePriceET.getText().toString().equals(""))
        || (sellPriceET.getText().toString().equals(""))) {
      Toast.makeText(
              getApplicationContext(),
              "Please Fill all Fields before submitting.",
              Toast.LENGTH_SHORT)
          .show();
    } else {
      try {
        name = nameET.getText().toString();
        description = descriptionET.getText().toString();
        quantity = Integer.parseInt(quantityET.getText().toString());
        invoicePrice = Double.parseDouble(invoicePriceET.getText().toString());
        sellPrice = Double.parseDouble(sellPriceET.getText().toString());
        if ((invoicePrice < 0) || (sellPrice < 0)) {
          throw new NumberFormatException();
        }
        invoicePrice = round(invoicePrice, 2);
        sellPrice = round(sellPrice, 2);

        Product p = new Product(name, invoicePrice, sellPrice, quantity, description, seller);
        p.setId(id);

        db.updateSellersProduct(p.getId(), p);

        Intent k = new Intent(SellerChangeAttributes.this, SellerMainPage.class);
        startActivity(k);
      } catch (NumberFormatException e) {
        Toast.makeText(
                getApplicationContext(),
                "Make sure price fields are non negative decimal values",
                Toast.LENGTH_SHORT)
            .show();
      } catch (IllegalArgumentException e) {
        Toast.makeText(getApplicationContext(), "Please Fill all Fields.", Toast.LENGTH_SHORT)
            .show();
      }
    }
  }
コード例 #20
0
        public boolean onDrag(View v, DragEvent event) {
          int dragEvent = event.getAction();

          switch (dragEvent) {
            case DragEvent.ACTION_DRAG_STARTED:
              View draggedView = (View) event.getLocalState();
              draggedView.setVisibility(View.INVISIBLE);
              break;
            case DragEvent.ACTION_DRAG_ENTERED:
              Log.i("Drag Event", "Entered");
              break;
            case DragEvent.ACTION_DRAG_EXITED:
              Log.i("Drag Event", "Exited");
              break;
            case DragEvent.ACTION_DROP:
              Log.i("Drag Event", "Dropped");
              ImageView view = (ImageView) event.getLocalState();
              ViewGroup owner = (ViewGroup) view.getParent();
              FrameLayout container = (FrameLayout) v;
              if ((container.getChildCount() > 0)) {
                Log.d("V", "Already stone in spot");
                view.setVisibility(view.VISIBLE);
              } else {
                owner.removeView(view);
                Stone thisstone = (Stone) view.getTag();
                int id = thisstone.get_id();
                int spot = container.getId();
                dbHandler.update(id, spot);
                container.addView(view);
                view.setVisibility(View.VISIBLE);
                Log.d("V", "drop success");
              }
              break;
            case DragEvent.ACTION_DRAG_ENDED:
              ImageView oldview = (ImageView) event.getLocalState();
              oldview.setVisibility(oldview.VISIBLE);
              break;
            default:
              break;
          }
          return true;
        }
コード例 #21
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sqllite);

    try {
      m_input = (EditText) findViewById(R.id.editText);
      m_list = (TextView) findViewById(R.id.textView6);

      m_db = openOrCreateDatabase("ProductsDB", Context.MODE_PRIVATE, null);
      m_dbHandler = new MyDBHandler(m_db);
      m_dbHandler.CreateTable("products");

      // m_dbHandler = new MyDBHandler1(this, "dbproducts1" , null , 1);
    } catch (Exception err) {
      Log.i(Tag, err.getMessage());
    }

    try {
      printDataBase();
    } catch (Exception err) {
      Log.i(Tag, err.getMessage());
    }
  }
コード例 #22
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   Log.i(Tag, "onDestroy");
   m_dbHandler.CloseDB();
 }
コード例 #23
0
  public void agregar_clicked(View view) {
    int s = dbHandler.size();
    if (dia.getText().toString().isEmpty()
        || mes.getText().toString().isEmpty()
        || any.getText().toString().isEmpty()
        || hora.getText().toString().isEmpty()
        || minut.getText().toString().isEmpty()) {
      Toast toast =
          Toast.makeText(getApplicationContext(), " Falten omplir camps", Toast.LENGTH_SHORT);
      toast.show();
    } else {
      int sdia = Integer.parseInt(dia.getText().toString());
      int smes = Integer.parseInt(mes.getText().toString());
      int sany = Integer.parseInt(any.getText().toString());
      int shora = Integer.parseInt(hora.getText().toString());
      int sminut = Integer.parseInt(minut.getText().toString());

      if (s >= 15 && c1.isChecked()) {
        Toast toast =
            Toast.makeText(getApplicationContext(), "EL PARKING ESTÀ PLE", Toast.LENGTH_LONG);
        toast.show();
      } else if (sdia <= 0
          || sdia > 31
          || smes <= 0
          || smes > 12
          || sany < 2016
          || shora < 0
          || shora >= 24
          || sminut < 0
          || sminut > 59) {
        errorInput();
      } else if (matricula.getText().toString().length() < 7
          || matricula.getText().toString().length() > 7) {
        errorInput();
      } else {
        if (c1.isChecked()) {
          Coche coche =
              new Coche(
                  matricula.getText().toString(),
                  sdia,
                  smes,
                  sany,
                  shora,
                  sminut,
                  -1,
                  -1,
                  -1,
                  -1,
                  -1);
          dbHandler.addCoche(coche);
          matU = (matricula.getText().toString());
          diaU = sdia;
          mesU = smes;
          anyU = sany;
          horaU = shora;
          minU = sminut;

          TextView size = (TextView) findViewById(R.id.pll_text);
          s = dbHandler.size();
          String s2 = String.valueOf(s);
          size.setText(s2);

          limpiarcampos();

          Toast toast =
              Toast.makeText(getApplicationContext(), "Afegit correctament!", Toast.LENGTH_SHORT);
          toast.show();
        } else if (c2.isChecked()) {

          Cursor cursor = dbHandler.cocheByMat(matricula.getText().toString());
          if (null != cursor && cursor.moveToFirst()) {
            int edia = Integer.parseInt(cursor.getString(cursor.getColumnIndex("dia")));
            int emes = Integer.parseInt(cursor.getString(cursor.getColumnIndex("mes")));
            int eany = Integer.parseInt(cursor.getString(cursor.getColumnIndex("any")));
            int ehora = Integer.parseInt(cursor.getString(cursor.getColumnIndex("hora")));
            int eminut = Integer.parseInt(cursor.getString(cursor.getColumnIndex("minut")));
            if (edia <= sdia
                && emes <= smes
                && eany <= sany
                && ehora <= shora
                && eminut <= sminut) {
              String mat = cursor.getString(cursor.getColumnIndex("matricula"));
              Coche coche =
                  new Coche(mat, edia, emes, eany, ehora, eminut, sdia, smes, sany, shora, sminut);
              dbHandler.borrarCoche(mat);
              dbHandler.addCoche(coche);
              TextView size = (TextView) findViewById(R.id.pll_text);
              s = dbHandler.size();
              String s2 = String.valueOf(s);
              size.setText(s2);
              double pt =
                  preuTiquet(edia, emes, eany, ehora, eminut, sdia, smes, sany, shora, sminut);
              TextView imp = (TextView) findViewById(R.id.importt_text);
              imp.setText(Double.toString(pt));

              Toast toast =
                  Toast.makeText(getApplicationContext(), "Ha sortit", Toast.LENGTH_SHORT);
              toast.show();

              matU = (matricula.getText().toString());
              diaU = sdia;
              mesU = smes;
              anyU = sany;
              horaU = shora;
              minU = sminut;

            } else {
              Toast toast =
                  Toast.makeText(
                      getApplicationContext(),
                      "El dia de sortida ha de ser posterior al d'entrada",
                      Toast.LENGTH_SHORT);
              toast.show();
            }
          } else {
            Toast toast =
                Toast.makeText(
                    getApplicationContext(),
                    "No està el cotxe aquest al parking",
                    Toast.LENGTH_SHORT);
            toast.show();
          }
        }
      }
    }
  }
コード例 #24
0
 @Override
 protected void onStop() {
   super.onStop();
   Log.i(Tag, "OnStop");
   m_dbHandler.CloseDB();
 }
コード例 #25
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.in_out);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    /** DECLARACIÓ DE VARIABLES */
    matricula = (EditText) findViewById(R.id.mat_text);
    dia = (EditText) findViewById(R.id.dia_text);
    mes = (EditText) findViewById(R.id.mes_text);
    any = (EditText) findViewById(R.id.any_text);
    hora = (EditText) findViewById(R.id.hora_text);
    minut = (EditText) findViewById(R.id.minut_text);

    /** RECUPEREM LA BASE DE DADES * */
    dbHandler = new MyDBHandler(this, null, null, 1);
    int s = dbHandler.size();

    /** MIREM LES FILES QUE TE * */
    TextView size = (TextView) findViewById(R.id.pll_text);
    String s2 = String.valueOf(s);
    size.setText(s2);

    /** DISPLAY INTERFICIE * */
    c1 = (CheckBox) findViewById(R.id.c1);
    c2 = (CheckBox) findViewById(R.id.c2);
    final Button btn = (Button) findViewById(R.id.confirm);
    final TextView txtV = (TextView) findViewById(R.id.importt);
    final TextView txtE = (TextView) findViewById(R.id.importt_text);

    /** PREPARACIO DE PARAMETRES * */
    c1.setChecked(true); // Entrada checked

    txtE.setVisibility(View.GONE); // Import
    txtV.setVisibility(View.GONE); // Import a pagar

    /** ENTRADA CHECK BOX CHECKED * */
    c1.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) { // entrada
            c2.setChecked(false);
            c1.setChecked(b);
            btn.setText("Confirmar entrada");
            txtE.setVisibility(View.GONE); // Import
            txtV.setVisibility(View.GONE); // Import a pagar
          }
        });

    /** SALIDA CHECK BOX CHECKED * */
    c2.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() { // sortida
          @Override
          public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (c2.isChecked()) c2.setChecked(true);
            c1.setChecked(false);
            c2.setChecked(b);
            btn.setText("Confirmar sortida");
            txtE.setVisibility(View.VISIBLE); // Import
            txtV.setVisibility(View.VISIBLE); // Import a pagar
          }
        });
  }
コード例 #26
0
  // SETTING DATA FOR DETAILED ACTIVITY GRID
  private void setDetailedTemperatureAndDescription(String date) {

    temperaturesClickedDate = weatherDatabase.getTemperatureValueClickedDate(date);
    valuesClickedDate = weatherDatabase.getSymbolNameClickedDate(date);
    Log.d("" + date, "date");
  }
コード例 #27
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_favorites);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setTitle("My Favorites");
    /** **************************************************** */
    db = new MyDBHandler(this, null, null, 1);
    favList = (ArrayList<Article>) db.favoritesToArray();
    arrayAdapter = new MyAdapter(getBaseContext(), R.layout.single_row, favList);
    listView = (ListView) findViewById(R.id.listView);
    listView.setAdapter(arrayAdapter);
    // LONG PRESS ITEM -> DELETE
    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            final Article currentArticle = (Article) parent.getItemAtPosition(position);
            AlertDialog.Builder builder = new AlertDialog.Builder(MyFavoritesActivity.this);
            builder.setTitle("Delete Favorite");
            builder.setMessage("Are you sure you want to delete this article from favorites?");
            builder.setPositiveButton(
                android.R.string.yes,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // continue with delete
                    db.unsetFavorite(currentArticle.getLinkRef());
                    favList = (ArrayList<Article>) db.favoritesToArray();
                    // recreate the adapter in order to refresh the list
                    MyAdapter tmpAdapter =
                        new MyAdapter(getBaseContext(), R.layout.single_row, favList);
                    tmpAdapter.notifyDataSetChanged();
                    listView.setAdapter(tmpAdapter);
                    arrayAdapter = tmpAdapter;
                  }
                });
            builder.setNegativeButton(
                android.R.string.no,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    // do nothing
                  }
                });
            builder.setIcon(android.R.drawable.stat_notify_error);
            AlertDialog alert = builder.create();
            alert.show();
            return false;
          }
        });

    // SHORT PRESS ITEM -> OPEN LINK
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final Article currentArticle = (Article) parent.getItemAtPosition(position);
            switch (currentArticle.getHeader()) {
              case "Gazzetta dello Sport":
                Intent iGazzetta = new Intent(getBaseContext(), GazzettaActivity.class);
                iGazzetta.putExtra("title", currentArticle.getTitle());
                iGazzetta.putExtra("article", currentArticle.getLinkRef());
                iGazzetta.putExtra("image", currentArticle.getImageRef());
                startActivity(iGazzetta);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case "Sport Mediaset":
                Intent iSportMediaset = new Intent(getBaseContext(), SportMediasetActivity.class);
                iSportMediaset.putExtra("title2", currentArticle.getTitle());
                iSportMediaset.putExtra("article2", currentArticle.getLinkRef());
                iSportMediaset.putExtra("image2", currentArticle.getImageRef());
                startActivity(iSportMediaset);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case "Tuttosport":
                Intent iTuttosport = new Intent(getBaseContext(), TuttosportActivity.class);
                iTuttosport.putExtra("title3", currentArticle.getTitle());
                iTuttosport.putExtra("article3", currentArticle.getLinkRef());
                iTuttosport.putExtra("image3", currentArticle.getImageRef());
                startActivity(iTuttosport);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
              case "Corriere dello Sport":
                Intent iCorriere = new Intent(getBaseContext(), CorriereActivity.class);
                iCorriere.putExtra("title4", currentArticle.getTitle());
                iCorriere.putExtra("article4", currentArticle.getLinkRef());
                iCorriere.putExtra("image4", currentArticle.getImageRef());
                startActivity(iCorriere);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            }
          }
        });
  }
コード例 #28
0
 @Override
 protected void onDestroy() {
   weatherDatabase.deleteTable();
   super.onDestroy();
 }
コード例 #29
0
 public void OnTruncate(View view) {
   m_dbHandler.TruncateTable();
   printDataBase();
 }