@Before
 public void setup() {
   // Ensure we are not logged in
   final MainApplication application = MainApplication.instance();
   environment = application.getInjector().getInstance(EdxEnvironment.class);
   environment.getLoginPrefs().clear();
   environment.getSegment().resetIdentifyUser();
 }
Exemplo n.º 2
0
 @Override
 public String getDisplayName() {
   if (TextUtils.isEmpty(name)) {
     return MainApplication.instance().getString(R.string.untitled_block);
   }
   return name;
 }
  /** component can be null. @IComponent component should be ICourse */
  public void setData(CourseComponent component) {
    if (component != null && !component.isContainer()) return; //
    this.rootComponent = component;
    this.numOfTotalUnits = 0;
    mData.clear();
    if (rootComponent != null) {
      PrefManager.UserPrefManager userPrefManager =
          new PrefManager.UserPrefManager(MainApplication.instance());
      currentVideoMode = userPrefManager.isUserPrefVideoModel();
      List<IBlock> children = rootComponent.getChildren();
      this.numOfTotalUnits = children.size();
      for (IBlock block : children) {
        CourseComponent comp = (CourseComponent) block;
        if (currentVideoMode && comp.getBlockCount().videoCount == 0) continue;

        if (comp.isContainer()) {
          SectionRow header = new SectionRow(SectionRow.SECTION, comp);
          mData.add(header);
          for (IBlock childBlock : comp.getChildren()) {
            CourseComponent child = (CourseComponent) childBlock;
            if (currentVideoMode && child.getBlockCount().videoCount == 0) continue;
            SectionRow row = new SectionRow(SectionRow.ITEM, false, child);
            mData.add(row);
          }
        } else {
          SectionRow row = new SectionRow(SectionRow.ITEM, true, comp);
          mData.add(row);
        }
      }
    }
    notifyDataSetChanged();
  }
 /** @return <code>true</code> if we rebuild the list due to the change of mode preference */
 public boolean checkModeChange() {
   PrefManager.UserPrefManager userPrefManager =
       new PrefManager.UserPrefManager(MainApplication.instance());
   boolean modeInConfiguration = userPrefManager.isUserPrefVideoModel();
   if (modeInConfiguration != currentVideoMode) {
     setData(rootComponent);
     return true;
   } else {
     return false;
   }
 }