예제 #1
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == 1) {

      GetData gd = new GetData(this);
      gd.execute();
    }
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.onglet2);
    swipeContainer = (SwipeRefreshLayout) findViewById(R.id.swipeContainer);
    swipeContainer.setRefreshing(true);
    ta = this;
    spinner = (ListView) findViewById(R.id.spinner);

    // Setup refresh listener which triggers new data loading
    swipeContainer.setOnRefreshListener(
        new SwipeRefreshLayout.OnRefreshListener() {
          @Override
          public void onRefresh() {
            // Your code to refresh the list here.
            // Make sure you call swipeContainer.setRefreshing(false)
            // once the network request has completed successfully.
            // fetchTimelineAsync(0);
            GetData dataGetter = new GetData(ta);
            dataGetter.execute();

            swipeContainer.setRefreshing(false);
          }
        });

    GetData dataGetter = new GetData(this);
    dataGetter.execute();

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

            Global.evenement_id = "" + (vvvv.get(position).toString());
            Intent i = new Intent(ta, detailEvenementAmis.class);
            startActivityForResult(i, 1);
            /*ArrayList temp = maliste.get(position);
            Log.d("invite :", "" + temp.get(0));
            Participe("" + temp.get(0));*/

          }
        });
    swipeContainer.setRefreshing(false);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);
    il = ImageLoader.getInstance();
    dio =
        new DisplayImageOptions.Builder()
            .showStubImage(R.drawable.testimg)
            .showImageForEmptyUri(R.drawable.testimg)
            .cacheInMemory()
            .cacheOnDisc()
            .displayer(new RoundedBitmapDisplayer(20))
            .build();
    fragData = gd.getData();

    image = (ImageView) rootView.findViewById(R.id.image);

    brand_name = (TextView) rootView.findViewById(R.id.brand_name);
    product_name = (TextView) rootView.findViewById(R.id.product_name);
    price = (TextView) rootView.findViewById(R.id.price);
    percentoff = (TextView) rootView.findViewById(R.id.percentoff);
    url = (TextView) rootView.findViewById(R.id.url);
    schedule_button = (Button) rootView.findViewById(R.id.schedule_button);

    String imagePath;
    imagePath = fragData.get("thumbnailImageUrl");
    il.displayImage(imagePath, image, dio);
    String mbrand_name = fragData.get("brandName");
    brand_name.setText(mbrand_name);
    String mproduct_name = fragData.get("productName");
    product_name.setText(mproduct_name);

    String mprice = fragData.get("price");
    price.setText(mprice);
    String mpercentoff = fragData.get("percentOff");
    percentoff.setText(mpercentoff);
    String murl = fragData.get("productUrl");
    url.setText(murl);

    if (!checkSharedPreferences()) {
      if (itemIds == null) {
        itemIds = new ArrayList<String>();
      }
      schedule_button.setVisibility(View.VISIBLE);
      schedule_button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              itemIds.add(productId);

              StringBuilder sb = new StringBuilder();
              for (String s : itemIds) {
                sb.append(s).append(",");
              }
              SharedPreferences.Editor editor = pref.edit();
              editor.putString("user_items", sb.toString());
              editor.commit();
              AlarmScheduleReciever.scheduleAlarms(getActivity());
              schedule_button.setVisibility(View.GONE);
              Toast.makeText(getActivity(), "Schedule alarm", Toast.LENGTH_SHORT).show();
            }
          });
    } else schedule_button.setVisibility(View.GONE);
    return rootView;
  }
예제 #4
0
 public void RefreshListe(View view) {
   GetData gd = new GetData(this);
   gd.execute();
 }
  public static void main(String[] args) {

    ArrayList<BankAccount> bankAccounts = new ArrayList<>();
    ArrayList<BankAccount> closedBankAccounts = new ArrayList<>();

    boolean done = false;

    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
    Date date = new Date();

    while (!done) {
      int menu =
          GetData.getInt(
              "\tUnited Bank of Java\n"
                  + "\nPlease Choose From the Following"
                  + "\n1. Create New Account"
                  + "\n2. Update Existing Account"
                  + "\n3. Close an Account"
                  + "\n4. View Account Information"
                  + "\n5. Exit");

      switch (menu) {
        case 1: // Create bank account obj and store in database
          String first = JOptionPane.showInputDialog(null, "What is your first name?");
          String last = JOptionPane.showInputDialog(null, "What is your last name?");
          Name customerName = new Name(first, last);
          JOptionPane.showMessageDialog(null, "Customer name is " + customerName.getName());
          String street = JOptionPane.showInputDialog(null, "What's your street address?");
          String city = JOptionPane.showInputDialog(null, "What city do you live in?");
          String state = JOptionPane.showInputDialog(null, "What state do you live in?");
          String zip = JOptionPane.showInputDialog(null, "What is your ZIP code?");
          Address customerAddress = new Address(street, city, state, zip);
          JOptionPane.showMessageDialog(
              null, "Customer's address is: \n" + customerAddress.getAddress());
          String accountNum =
              JOptionPane.showInputDialog(null, "What do you want your account number to be?");
          Customer c = new Customer(customerName, customerAddress, accountNum);
          JOptionPane.showMessageDialog(
              null,
              "Welcome!\nHere's your info.\nName: "
                  + c.getName()
                  + "\nAddress: "
                  + c.getAddress()
                  + "\nAccount #: "
                  + c.getAccountNum());
          String balance = JOptionPane.showInputDialog(null, "What will be your initial balance?");
          double bal = Double.parseDouble(balance);
          BankAccount bankacc = new BankAccount(c, bal);
          JOptionPane.showMessageDialog(null, "Your balance is: \n" + bankacc.getBalance());
          bankAccounts.add(bankacc);
          System.out.print(bankAccounts.indexOf(bankacc) + " " + bankAccounts.size());

          break;

        case 2: // Update Account
          int money =
              GetData.getInt(
                  "What would you like to do?"
                      + "\n1. Make a deposit."
                      + "\n2. Make a withdrawal."
                      + "\n");

          switch (money) {
            case 1: // Make a deposit
              String accNum = JOptionPane.showInputDialog(null, "What is your account number?");
              if (BankAccount.findAccNum(bankAccounts, accNum)) {
                JOptionPane.showMessageDialog(null, "Account found!");
                int i = BankAccount.findIndex(bankAccounts, accNum);
                JOptionPane.showMessageDialog(
                    null, "Account balance is currently: $" + bankAccounts.get(i).getBalance());
                String x = JOptionPane.showInputDialog(null, "How much would you like to deposit?");
                double y = Double.parseDouble(x);
                bankAccounts.get(i).deposit(y);
                JOptionPane.showMessageDialog(
                    null, "Your new balance is: $" + bankAccounts.get(i).getBalance());
              } else {
                JOptionPane.showMessageDialog(null, "Account not in database.");
              }
              break;

            case 2: // Make a withdrawal
              String accNum1 = JOptionPane.showInputDialog(null, "What is your account number?");
              if (BankAccount.findAccNum(bankAccounts, accNum1)) {
                JOptionPane.showMessageDialog(null, "Account found!");
                int i = BankAccount.findIndex(bankAccounts, accNum1);
                JOptionPane.showMessageDialog(
                    null, "Account balance is currently: $" + bankAccounts.get(i).getBalance());
                String x =
                    JOptionPane.showInputDialog(null, "How much would you like to withdraw?");
                double y = Double.parseDouble(x);

                if (y < bankAccounts.get(i).getBalance()) {
                  bankAccounts.get(i).withdraw(y);
                  JOptionPane.showMessageDialog(
                      null, "Your new balance is: $" + bankAccounts.get(i).getBalance());
                } else {
                  JOptionPane.showMessageDialog(null, "Insufficient funds.");
                }
              } else {
                JOptionPane.showMessageDialog(null, "Account not in database.");
              }
              break;

            default:
              JOptionPane.showMessageDialog(null, "Invalid option.");
              break;
          }

          break;

        case 3: // close account
          String accNum = JOptionPane.showInputDialog(null, "What is the account number?");
          if (BankAccount.findAccNum(bankAccounts, accNum)) {
            JOptionPane.showMessageDialog(null, "Account found!");
            int i = BankAccount.findIndex(bankAccounts, accNum);
            BankAccount clone = bankAccounts.get(i);
            bankAccounts.get(i).deactivate();
            JOptionPane.showMessageDialog(
                null, "Account is located in the ArrayList at index: " + i);
            closedBankAccounts.add(clone);
            bankAccounts.remove(i);
          } else {
            JOptionPane.showMessageDialog(null, "Account not found!");
          }

          break;

        case 4: // view account info
          int view =
              GetData.getInt(
                  "What information would you like to view?"
                      + "\n1. Single Account"
                      + "\n2. All active accounts"
                      + "\n3. All inactive accounts"
                      + "\n");

          switch (view) {
            case 1: // view single account
              String accNum2 =
                  JOptionPane.showInputDialog(
                      null, "Please enter account number to view information on it.");

              if (BankAccount.findAccNum(bankAccounts, accNum2)) {
                JOptionPane.showMessageDialog(null, "Account found!");

                int i = BankAccount.findIndex(bankAccounts, accNum2);
                JOptionPane.showMessageDialog(
                    null,
                    "Name: "
                        + bankAccounts.get(i).getName()
                        + "\nAccount Number: "
                        + bankAccounts.get(i).getAccountNum()
                        + "\nBalance: $"
                        + bankAccounts.get(i).getBalance());
              } else {
                JOptionPane.showMessageDialog(null, "Account not in database.");
              }

              break;

            case 2: // view all account

              /*JTextArea textArea = new JTextArea("Date: " + dateFormat.format(date) +
                          BankAccount.printAllCustomers(bankAccounts));
                  JScrollPane scrollPane = new JScrollPane(textArea);
                  textArea.setLineWrap(true);
                  textArea.setWrapStyleWord(true);
                  scrollPane.setPreferredSize( new Dimension( 300, 400 ) );
                  JOptionPane.showMessageDialog(null, scrollPane, "Current Customers",
                         JOptionPane.YES_NO_OPTION);

              */
              break;

            case 3: // view all closed accounts
              break;

            default:
              JOptionPane.showMessageDialog(null, "Invalid Option.");
              break;
          } // end view
          break;

        case 5: // exit
          done = true;
          break;

        default:
          JOptionPane.showMessageDialog(null, "Account not found.");
          break;
      }
    }
  }
예제 #6
0
 private void loadData() {
   GetData data = new GetData();
   data.execute();
 }