Example #1
0
 public void switchFragment(String mCategry) {
   drawer.closeDrawer();
   getFragmentManager()
       .beginTransaction()
       .replace(
           com.sspai.navigationdrawer.R.id.frame_container,
           (android.app.Fragment) HomeFragment.newInstance(mCategry))
       .commit();
 }
Example #2
0
 private void mitchDevice(String brandString) {
   for (String key : map.keySet()) {
     if (key.equals(brandString)) {
       getFragmentManager()
           .beginTransaction()
           .replace(
               com.sspai.navigationdrawer.R.id.frame_container,
               (android.app.Fragment) HomeFragment.newInstance(brandString))
           .commit();
     }
   }
 }
Example #3
0
  @Override
  public void init(Bundle savedInstanceState) {
    map = new HashMap<String, String>();
    map.put("google", "Nexus");
    map.put("samsung", "Samsung");
    map.put("htc", "HTC");
    map.put("Sony", "SONY");
    map.put("lge", "LG");
    map.put("Huawei", "华为");
    map.put("nubia", "中兴");
    map.put("Xiaomi", "小米");
    map.put("Meizu", "魅族");
    map.put("ONEPLUS", "一加");
    map.put("smartisan", "锤子");
    map.put("other", "其他");
    AppInfo app = AppInfo.get(this);
    app.inject(this);
    Dart.inject(this);

    container = appContainer.get(this, app);
    drawer = this;
    sp = getApplicationContext().getSharedPreferences("dfbrand", Context.MODE_PRIVATE);

    // set drawer menu width in dp
    this.setDrawerDPWidth(300);

    // create HeadItem 1 with menu
    // create menu
    com.sspai.navigationdrawer.menu.Menu menu1 = new com.sspai.navigationdrawer.menu.Menu();

    brand = sp.getString("brand", "Meizu");
    section1 =
        this.newSection(
            map.get("google"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.google_color)),
            HomeFragment.newInstance("google"),
            false);
    // set on click listener for section 31
    section1.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("google");
          }
        });
    Section section2 =
        this.newSection(
            map.get("samsung"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.samsung_color)),
            false);

    // set on click listener for section 2
    section2.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("samsung");
          }
        });
    Section section3 =
        this.newSection(
            map.get("htc"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.htc_color)),
            false);

    // set on click listener for section 2
    section3.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("htc");
          }
        });
    Section section4 =
        this.newSection(
            map.get("Sony"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.sony_color)),
            false);

    // set on click listener for section 2
    section4.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("Sony");
          }
        });
    Section section5 =
        this.newSection(
            map.get("lge"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.lge_color)),
            false);

    section5.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("lge");
          }
        });

    Section section6 =
        this.newSection(
            map.get("Huawei"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.huawei_color)),
            false);

    section6.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("Huawei");
          }
        });

    Section section7 =
        this.newSection(
            map.get("nubia"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.nubia_color)),
            false);
    section7.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("nubia");
          }
        });

    Section section8 =
        this.newSection(
            map.get("Xiaomi"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.xiaomi_color)),
            false);

    section8.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("Xiaomi");
          }
        });
    Section section9 =
        this.newSection(
            map.get("Meizu"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.meizu_color)),
            false);
    section9.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("Meizu");
          }
        });
    Section section10 =
        this.newSection(
            map.get("ONEPLUS"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.oneplue_color)),
            false);
    section10.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("ONEPLUS");
          }
        });
    Section section11 =
        this.newSection(
            map.get("smartisan"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.smartisan_color)),
            false);
    section11.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("smartisan");
          }
        });
    Section section12 =
        this.newSection(
            map.get("other"),
            TextDrawable.builder().buildRound("", getResources().getColor(R.color.other_color)),
            false);
    section12.setOnClickListener(
        new SectionListener() {
          @Override
          public void onClick(Section section) {
            unSelectOldSection(section);
            switchFragment("other");
          }
        });

    // add sections to the menu
    menu1.getSections().add(section1);
    menu1.getSections().add(section2);
    menu1.getSections().add(section3);
    menu1.getSections().add(section4);
    menu1.getSections().add(section5);
    menu1.getSections().add(section6);
    menu1.getSections().add(section7);
    menu1.getSections().add(section8);
    menu1.getSections().add(section9);
    menu1.getSections().add(section10);
    menu1.getSections().add(section11);
    menu1.getSections().add(section12);
    menu1.getSections().add(new Devisor());
    // create headItem1 and add menu1
    HeadItem headItem1 =
        new HeadItem(
            "少数派出品", "", null, this.getResources().getDrawable(R.drawable.menu_banner), menu1, 0);
    // add headItem1 to the drawer
    this.addHeadItem(headItem1);
    headItem1.setCloseDrawerOnChanged(true);
    // set this class as onchangedListener
    this.setOnChangedListener(this);
  }