Exemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity());
    backgroundManager.attach(getActivity().getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager);

    mDefaultBackground = getResources().getDrawable(R.drawable.amphitheatre);

    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);

    Video video = (Video) getActivity().getIntent().getSerializableExtra(Constants.VIDEO);

    if (video.isMovie()) {
      new DetailRowBuilderTask(getActivity(), this).execute(video);
    } else {
      List<Video> videos =
          Select.from(Video.class)
              .where(Condition.prop("name").eq(video.getName()), Condition.prop("is_movie").eq(0))
              .list();

      Map<String, List<Video>> groups =
          new TreeMap<String, List<Video>>(Collections.reverseOrder());

      for (Video vid : videos) {
        // if an Episode item exists then categorize it
        // otherwise, add it to the uncategorized list
        if (vid.getTvShow() != null && vid.getTvShow().getEpisode() != null) {
          int seasonNumber = vid.getTvShow().getEpisode().getSeasonNumber();
          String key = String.format(getString(R.string.season_number), seasonNumber);

          if (groups.containsKey(key)) {
            List<Video> subVideos = groups.get(key);
            subVideos.add(vid);
          } else {
            List<Video> list = new ArrayList<Video>();
            list.add(vid);
            groups.put(key, list);
          }
        } else {
          String key = getString(R.string.uncategorized);

          if (groups.containsKey(key)) {
            groups.get(key).add(vid);
          } else {
            List<Video> list = new ArrayList<Video>();
            list.add(vid);
            groups.put(key, list);
          }
        }
      }

      new DetailRowBuilderTask(getActivity(), groups, this).execute(video);
    }

    setOnItemClickedListener(getDefaultItemClickedListener());
    updateBackground(video.getBackgroundImageUrl());
  }
Exemplo n.º 2
0
  @Test(expected = NoSuchFieldException.class)
  public void testSetFieldValueFromCursor() throws NoSuchFieldException {
    final TestRecord record = new TestRecord().setName("bla bla");
    Long id = record.save();
    record.setId(id);

    Cursor cursor = Select.from(TestRecord.class).getCursor();

    TestRecord testRecord = new TestRecord();
    Field field = TestRecord.class.getField("name");

    ReflectionUtil.setFieldValueFromCursor(cursor, field, testRecord);
  }
  public void injectAccountsDataUI(RequestsCallback callback, boolean force) {
    List<Account> accounts =
        Select.from(Account.class)
            .where(Condition.prop("bankcode").eq(this.getHandler().BANK_CODE))
            .list();

    long currentTime = System.currentTimeMillis();
    long accountLastUpdate = 0;

    if (accounts.size() != 0) accountLastUpdate = accounts.get(0).milli;

    if ((currentTime - accountLastUpdate) > Utility.REFRESH_TIME || force) {
      this.getHandler().fetchAccountsNewData(callback);

    } else {
      callback.doOnComplete(new RequestResult(ACCOUNTS_IN_DB, this.getHandler().BANK_NAME));
    }
  }
Exemplo n.º 4
0
 public boolean isNew() {
   long count = Select.from(Members.class).where(Condition.prop("id").eq(id)).count();
   return count == 0;
 }
Exemplo n.º 5
0
 public boolean isNew() {
   long count =
       Select.from(MifosGroup.class).where(Condition.prop("group_id").eq(groupId)).count();
   return count == 0;
 }
Exemplo n.º 6
0
  /** Get the selected data and show it. */
  private void drawData() {
    // Get shopping list in the dates range
    Select selectSLInRange =
        Select.from(ShoppingList.class)
            .whereOr(
                Condition.prop("date").gt(minDate.getTime().getTime()),
                Condition.prop("date").eq(minDate.getTime().getTime()))
            .and(Condition.prop("date").lt(maxDate.getTime().getTime()));
    List<ShoppingList> shoppingLists = selectSLInRange.list();

    // Show number of shopping lists retrieved
    Toast.makeText(getActivity(), shoppingLists.size() + " shopping lists", Toast.LENGTH_SHORT)
        .show();

    // If there's one or more, draw the chart
    // Each year is painted in one color. All the shopping list of one month must be
    // merge to get the total spend money amount of that month
    if (shoppingLists.size() > 0) {
      String[] mMonths =
          new String[] {
            "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
          };
      Collections.sort(shoppingLists);
      Map<String, List<BarEntry>> entrysYear = new HashMap<>();
      List<String> labels = new ArrayList<>();
      // First item
      Date date = shoppingLists.get(0).getDate();
      Calendar cal = getInstance();
      cal.setTime(date);
      int year = cal.get(YEAR);
      int month = cal.get(MONTH);
      entrysYear.put(year + "", new ArrayList<BarEntry>());
      labels.add(mMonths[month % 12]);

      float totalPrice = 0;
      int newYear;
      int newMonth;
      for (int i = 0; i < shoppingLists.size(); i++) {
        Date d = shoppingLists.get(i).getDate();
        Calendar c = getInstance();
        c.setTime(d);
        newYear = c.get(YEAR);
        newMonth = c.get(MONTH);

        if (newMonth == month && newYear == year) {
          totalPrice += shoppingLists.get(i).getTotalPrice();
        } else {
          // If not same year -> add new one
          if (newYear != year) {
            entrysYear.put(newYear + "", new ArrayList<BarEntry>());
          }
          // If not same month -> save previous month
          BarEntry be = new BarEntry(totalPrice, labels.size() - 1);
          entrysYear.get(year + "").add(be);
          // Add new month
          labels.add(mMonths[newMonth % 12]);
          totalPrice = shoppingLists.get(i).getTotalPrice();
        }
        year = newYear;
        month = newMonth;
      }
      // Save last one
      BarEntry be = new BarEntry(totalPrice, labels.size() - 1);
      entrysYear.get(year + "").add(be);

      BarData data = new BarData(labels);
      int i = 0;
      for (String name : entrysYear.keySet()) {
        BarDataSet dataset = new BarDataSet(entrysYear.get(name), name);
        dataset.setColor(ColorTemplate.COLORFUL_COLORS[i % ColorTemplate.COLORFUL_COLORS.length]);
        dataset.setBarSpacePercent(35f);
        data.addDataSet(dataset);
        i++;
      }
      data.setValueTextSize(10f);
      chart1.setData(data);
      chart1.notifyDataSetChanged(); // let the chart know it's data changed
      chart1.invalidate(); // refresh
      chart1.animateXY(1000, 1000);
    }
  }
Exemplo n.º 7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
      LayoutInflater mInflater =
          (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      convertView = mInflater.inflate(R.layout.row_shop_cloth, null);
    }

    Location location = null;
    long locationId = shopCloths.get(position).getLocationId();
    if (locationId != 0) {
      location =
          Select.from(Location.class).where(Condition.prop("Location_Id").eq(locationId)).first();
    }

    UserSite userSite = null;
    String userName = shopCloths.get(position).getUser_Name();
    if (userName != null) {
      userSite = Select.from(UserSite.class).where(Condition.prop("UserName").eq(userName)).first();
    }

    TextView txtName = (TextView) convertView.findViewById(R.id.name);
    TextView txtCategory = (TextView) convertView.findViewById(R.id.category);
    TextView txtType = (TextView) convertView.findViewById(R.id.cloth_type);
    TextView txtDiscription = (TextView) convertView.findViewById(R.id.discription);
    TextView txtLocation = (TextView) convertView.findViewById(R.id.location);
    TextView txtPrice = (TextView) convertView.findViewById(R.id.price);
    TextView txtColor = (TextView) convertView.findViewById(R.id.color);
    TextView txtSize = (TextView) convertView.findViewById(R.id.size);
    TextView txtEmail = (TextView) convertView.findViewById(R.id.email);
    TextView txtPhoneNo = (TextView) convertView.findViewById(R.id.phone_no);

    txtName.setText(shopCloths.get(position).getItem_Name());
    if (shopCloths.get(position).getCatagory().equals("female_cloth"))
      txtCategory.setText(R.string.sp_female_cloth);
    else if (shopCloths.get(position).getCatagory().equals("Male_cloth"))
      txtCategory.setText(R.string.sp_male_cloth);
    else if (shopCloths.get(position).getCatagory().equals("Kids_cloth"))
      txtCategory.setText(R.string.sp_kids_cloth);
    else if (shopCloths.get(position).getCatagory().equals("cloth_designer"))
      txtCategory.setText(R.string.sp_cloth_designer);
    else txtCategory.setText(R.string.sp_all_category);

    if (shopCloths.get(position).getType().equals("modern")) txtType.setText(R.string.sp_modern);
    else if (shopCloths.get(position).getType().equals("traditional"))
      txtType.setText(R.string.sp_traditional);
    else txtType.setText(R.string.sp_all_cloth_type);
    txtDiscription.setText(shopCloths.get(position).getDiscription());
    if (location != null) {
      if (SplashScreen.localization == 1) txtLocation.setText(location.getLocationName_am());
      else txtLocation.setText(location.getLocationName());
    }
    txtPrice.setText(String.valueOf(shopCloths.get(position).getPrice()));
    txtColor.setText(shopCloths.get(position).getColor());
    txtSize.setText(shopCloths.get(position).getSize());
    if (userSite != null) {
      txtPhoneNo.setText(userSite.getPhone_Number());
      txtEmail.setText(userSite.getE_mail());
    }

    return convertView;
  }