예제 #1
0
 @Override
 public void handleMessage(Message msg) {
   if (msg.what == 0) loadTable();
   else if (msg.what == 1) {
     TableLayout table = (TableLayout) findViewById(R.id.table);
     table.removeAllViews();
     TextView t = new TextView(current.getContext());
     t.setText(current.getContext().getString(R.string.balanceempty));
     t.setTextColor(Color.GRAY);
     t.setPadding(15, 25, 0, 0);
     table.addView(t);
   }
   super.handleMessage(msg);
 }
예제 #2
0
 @Implementation
 public Window getWindow() {
   if (window == null) {
     window = new TestWindow(realDialog.getContext());
   }
   return window;
 }
예제 #3
0
  public void showOptionAlert(final int row) {

    final CharSequence[] items = {
      current.getContext().getString(R.string.leadSendChall),
      current.getContext().getString(R.string.leadViewProfile),
      current.getContext().getString(R.string.leadAddFriend)
    };
    AlertDialog.Builder builder = new AlertDialog.Builder(current.getContext());
    builder.setTitle(current.getContext().getString(R.string.vgoodchoosedialog));
    builder.setItems(
        items,
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int item) {
            if (item == 0) {
              try {
                ChallengeCreate cc =
                    new ChallengeCreate(
                        current.getContext(), ChallengeCreate.SHOW_ENTRY, null, usersExts.get(row));
                cc.codeID = codeID;
                cc.show();
              } catch (Exception e) {
                e.printStackTrace();
              }
            } else if (item == 1) {
              try {
                UserProfile userProfile = new UserProfile(getContext(), usersExts.get(row));
                userProfile.show();
              } catch (Exception e) {
                e.printStackTrace();
              }
            } else if (item == 2) {
              try {
                Friends f = new Friends(current.getContext(), current, 0, 0);
                f.friendshipThread(usersExts.get(row), "invite");
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          }
        });
    AlertDialog alert = builder.create();
    alert.show();
  }
 @Override
 public void onClick(View v) {
   // Perform action on clicks
   RadioButton rb = (RadioButton) v;
   rb.setChecked(true);
   splashMenu.setRobotType(rb.getId());
   Toast.makeText(
           mDialog.getContext(), mSelectionMessage + " " + rb.getText(), Toast.LENGTH_SHORT)
       .show();
   mDialog.dismiss();
 }
 /**
  * 关闭dialog中打开的键盘
  *
  * @param dialog
  */
 public static void closeKeyboard(Dialog dialog) {
   if (dialog == null) {
     return;
   }
   View view = dialog.getWindow().peekDecorView();
   if (view != null) {
     InputMethodManager inputMethodManager =
         (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
     inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
   }
 }
예제 #6
0
  public void loadTable() {
    TableLayout table = (TableLayout) findViewById(R.id.table);
    // table.setColumnStretchable(1, true);
    table.removeAllViews();

    final ArrayList<View> rowList = new ArrayList<View>();

    for (int i = 0; i < balance.size(); i++) {
      // final LoaderImageView image = new LoaderImageView(getContext(), getUsersmallimg());
      final LoaderImageView image =
          new LoaderImageView(
              getContext(),
              balance.get(i).getApp().getImageUrl(),
              (int) (ratio * 60),
              (int) (ratio * 60));

      TableRow row =
          createRow(
              image,
              balance.get(i).getApp().getName(),
              balance.get(i).getCreationdate(),
              balance.get(i).getValue(),
              balance.get(i).getReason(),
              getContext());
      row.setId(i);
      rowList.add(row);
      View spacer = createSpacer(getContext(), 1, 1);
      spacer.setId(-100);
      rowList.add(spacer);
      View spacer2 = createSpacer(getContext(), 2, 1);
      spacer2.setId(-100);
      rowList.add(spacer2);
      BeButton b = new BeButton(current.getContext());
      if (i % 2 == 0)
        row.setBackgroundDrawable(
            b.setPressedBackg(
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.LIGHT_GRAY_GRADIENT),
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT),
                new BDrawableGradient(
                    0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT)));
      else
        row.setBackgroundDrawable(
            b.setPressedBackg(
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.GRAY_GRADIENT),
                new BDrawableGradient(0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT),
                new BDrawableGradient(
                    0, (int) (ratio * 70), BDrawableGradient.HIGH_GRAY_GRADIENT)));
    }

    for (View row : rowList) {
      table.addView(row);
    }
  }
예제 #7
0
  public void addDrink(View v) {

    // set up dialog
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_consumptie);
    dialog.setTitle("");
    dialog.setCancelable(true);
    // there are a lot of settings, for dialog, check them all out!

    int kosten = 0;
    switch (v.getId()) {
      case R.id.OnePaultje:
        kosten = 1;
        break;
      case R.id.TwoPaultje:
        kosten = 2;
        break;
      case R.id.ThreePaultje:
        kosten = 3;
        break;
    }
    GridLayout grid = (GridLayout) dialog.findViewById(R.id.gridLayout);
    for (Consumptie c : consumpties) {
      if (c.getKosten() == kosten) {
        Button b = new Button(dialog.getContext());
        b.setText(c.getNaam());
        b.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                dialog.cancel();
                Button but = (Button) v;
                addToList(but.getText().toString());
              }
            });
        grid.addView(b);
      }
    }
    dialog.show();
  }
예제 #8
0
  public UserBalance(Context context) {
    super(context, R.style.ThemeBeintoo);
    current = this;

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.userbalance);

    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // GETTING DENSITY PIXELS RATIO
    ratio = (context.getApplicationContext().getResources().getDisplayMetrics().densityDpi / 160d);
    // SET UP LAYOUTS
    double pixels = ratio * 40;
    RelativeLayout beintooBar = (RelativeLayout) findViewById(R.id.beintoobarsmall);
    beintooBar.setBackgroundDrawable(
        new BDrawableGradient(0, (int) pixels, BDrawableGradient.BAR_GRADIENT));
    TextView titleBar = (TextView) findViewById(R.id.dialogTitle);
    titleBar.setText(current.getContext().getString(R.string.balance));

    startLoading();
  }
예제 #9
0
  /**
   * Shows a dialog with info about an event.
   *
   * @param id The id of the event
   */
  private void showDialog(int id) {

    // Create the dialog
    final Dialog dialog = new Dialog(getActivity());

    // Set window
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_around);

    // Date formatters
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
    SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd-", Locale.US);
    SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.US);

    // Set the custom dialog components - text, image and button
    TextView tvTitle = (TextView) dialog.findViewById(R.id.tv_dialog_around_title);
    TextView tvDescription = (TextView) dialog.findViewById(R.id.tv_dialog_around_description);
    TextView tvDate = (TextView) dialog.findViewById(R.id.tv_dialog_around_date);
    TextView tvTime = (TextView) dialog.findViewById(R.id.tv_dialog_around_time);
    TextView tvPlace = (TextView) dialog.findViewById(R.id.tv_dialog_around_place);
    TextView tvAddress = (TextView) dialog.findViewById(R.id.tv_dialog_around_address);
    Button btClose = (Button) dialog.findViewById(R.id.bt_around_close);

    // Get info about the event
    SQLiteDatabase db = getActivity().openOrCreateDatabase(GM.DB_NAME, Context.MODE_PRIVATE, null);
    Cursor cursor =
        db.rawQuery(
            "SELECT event.id, event.name, description, start, end, place.name, address, lat, lon FROM event, place WHERE place.id = event.place AND event.id = "
                + id
                + ";",
            null);
    if (cursor.getCount() > 0) {
      cursor.moveToNext();

      // Set title
      tvTitle.setText(cursor.getString(1));
      markerName = cursor.getString(1);

      // Set description
      tvDescription.setText(cursor.getString(2));

      // Set date
      try {
        Date day = dateFormat.parse(cursor.getString(3));
        Date date = new Date();

        // If the event is today, show "Today" instead of the date.
        if (dayFormat.format(day).equals(dayFormat.format(date))) {
          tvDate.setText(dialog.getContext().getString(R.string.today));
        } else {
          Calendar cal = Calendar.getInstance();
          cal.setTime(date);
          cal.add(Calendar.HOUR_OF_DAY, 24);

          // If the event is tomorrow, show "Tomorrow" instead of the date.
          if (dayFormat.format(cal.getTime()).equals(dayFormat.format(date))) {
            tvDate.setText(dialog.getContext().getString(R.string.tomorrow));
          }

          // Else, show the date
          else {
            SimpleDateFormat printFormat = new SimpleDateFormat("dd MMMM", Locale.US);
            tvDate.setText(printFormat.format(day));
          }
        }
      } catch (Exception ex) {
        Log.e("Error parsing around event date", ex.toString());
      }

      // Set time
      try {
        if (cursor.getString(4) == null)
          tvTime.setText(timeFormat.format(dateFormat.parse(cursor.getString(3))));
        else
          tvTime.setText(
              timeFormat.format(dateFormat.parse(cursor.getString(3)))
                  + " - "
                  + timeFormat.format(timeFormat.parse(cursor.getString(4))));
      } catch (ParseException ex) {
        Log.e("Error parsing around event time", ex.toString());
      }

      // Set place
      tvPlace.setText(cursor.getString(5));
      tvAddress.setText(cursor.getString(6));

      // Set up map
      location =
          new LatLng(
              Double.parseDouble(cursor.getString(7)), Double.parseDouble(cursor.getString(8)));
      mapView = (MapView) dialog.findViewById(R.id.mv_dialog_around_map);
      mapView.onCreate(bund);

      // Close db connection
      cursor.close();
      db.close();

      // Set close button
      btClose.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              dialog.dismiss();
            }
          });

      // Actions to take when the dialog is cancelled
      dialog.setOnCancelListener(
          new OnCancelListener() {
            @Override
            public void onCancel(DialogInterface dialog) {
              if (map != null) map.setMyLocationEnabled(false);
              if (mapView != null) {
                mapView.onResume();
                mapView.onDestroy();
              }
            }
          });

      // Show the dialog
      WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
      lp.dimAmount = 0.0f;
      dialog.show();

      // Start the map
      startMap();
      mapView.onResume();
      dialog.setOnShowListener(
          new OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
              // Gets to GoogleMap from the MapView and does initialization stuff
              startMap();
            }
          });
    }
  }
예제 #10
0
 public static AppCompatDelegate create(Dialog dialog, AppCompatCallback callback) {
   return create(dialog.getContext(), dialog.getWindow(), callback);
 }
예제 #11
0
파일: ai.java 프로젝트: sheytoon/Soroush
 public static ai m3462a(Dialog dialog, ah ahVar) {
   return m3463a(dialog.getContext(), dialog.getWindow(), ahVar);
 }
예제 #12
0
 @Implementation
 public LayoutInflater getLayoutInflater() {
   return LayoutInflater.from(realDialog.getContext());
 }