Example #1
0
 @SuppressLint("NewApi")
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   Log.d("wang", "MyRoad onActivityResult");
   if (data != null) {
     String result = data.getExtras().getString("result");
     if (!result.isEmpty()) {
       if (result.equals("ok1")) {
         Log.d("wang", "result is ok1");
         int flag;
         flag = app.getAllCount();
         if (flag == 0) {
           news.setVisibility(View.GONE);
         } else {
           news.setBadgeCount(flag);
         }
       }
     }
   }
 }
Example #2
0
  @SuppressLint("NewApi")
  private void loginView() {
    setContentView(R.layout.account_info);
    TextView v_return = (TextView) findViewById(R.id.tv_return);
    v_return.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent();
            intent.putExtra("result", "ok1");
            setResult(RESULT_OK, intent);

            finish();
          }
        });
    TextView priva = (TextView) findViewById(R.id.tv_private);
    if (!app.getSign().isEmpty()) {
      priva.setText(app.getSign());
    }
    TextView account = (TextView) findViewById(R.id.tv_account);
    account.setText(app.getUser());
    TextView qq = (TextView) findViewById(R.id.tv_qq);
    qq.setText(app.getQQ());
    TextView email = (TextView) findViewById(R.id.tv_email);
    email.setText(app.getEmail());
    TextView roadTopic = (TextView) findViewById(R.id.road_topic);
    news = (BadgeView) findViewById(R.id.news);
    roadTopic.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View arg0) {
            Intent intent = new Intent();
            intent.setClass(ProfileActivity.this, MySafeRoadActivity.class);
            startActivityForResult(intent, 1);
          }
        });
    // news.setTargetView(roadTopic);
    // badgeView.setBadgeGravity(Gravity.CENTER | Gravity.RIGHT);
    // badgeView.setBadgeCount(Integer.valueOf(newsCount));
    if (!newsCount.equals("")) {
      news.setBadgeCount(Integer.valueOf(newsCount));
    }
  }
 private void setView() {
   recyclerView.setLayoutManager(manager);
   recyclerView.setAdapter(adapter);
   badgeView.setTargetView(shopping_car_tv);
   badgeView.setBadgeCount(3);
 }
Example #4
0
  private void initview() {
    // 底部滑条
    mTabLine = (ImageView) findViewById(R.id.bottom_tabline);
    // 底部布局
    bottom_mainPage = (LinearLayout) findViewById(R.id.bottom_mainpage_lin_layout);
    bottom_secondPage = (LinearLayout) findViewById(R.id.bottom_secondPage_lin_layout);
    bottom_thirdPage = (LinearLayout) findViewById(R.id.bottom_thirdPage_lin_layout);
    bottom_lastPage = (LinearLayout) findViewById(R.id.bottom_lastPage_lin_layout);
    // 底部Image
    bottom_mainPage_imge = (ImageView) findViewById(R.id.bottom_mainpage_image);
    bottom_secondPage_imge = (ImageView) findViewById(R.id.bottom_secondPage_iamge);
    bottom_thirdPage_image = (ImageView) findViewById(R.id.bottom_thirdPage_iamge);
    bottom_lastPage_image = (ImageView) findViewById(R.id.bottom_lastPage_image);
    // 底部Text
    bottom_mainPage_text = (TextView) findViewById(R.id.bottom_mainpage_text);
    bottom_secondPage_text = (TextView) findViewById(R.id.bottom_secondPage_text);
    bottom_thirdPage_text = (TextView) findViewById(R.id.bottom_thirdPage_text);
    bottom_lastPage_text = (TextView) findViewById(R.id.bottom_lastPage_text);
    // view的获取
    viewPager = (ViewPager) findViewById(R.id.id_viewpager);
    // 用把各个Fragment放在list容器
    List<Fragment> list = new ArrayList<Fragment>();
    list.add(new MainPageFragment());
    list.add(new SecondPageFragment());
    list.add(new ThirdPageFragment());
    list.add(new LastPageFragment());
    // 适配
    viewPagerAapter = new ViewPagerAdapter(getSupportFragmentManager(), list);
    viewPager.setAdapter(viewPagerAapter);
    clearcolor();
    // 初始化第一页
    viewPager.setCurrentItem(0, true);
    bottom_mainPage_imge.setImageResource(R.drawable.home1);
    bottom_mainPage_text.setTextColor(Color.parseColor("#008000"));
    // 重其他界面跳过了是回到滑动的第几页
    Bundle bundle = MainActivity.this.getIntent().getExtras();
    int currentItem = bundle.getInt("CurrentItem");

    // 显示
    badgeView = new BadgeView(this);
    bottom_thirdPage.addView(badgeView);
    badgeView.setTargetView(bottom_thirdPage);

    if (currentItem == 1) {
      String city_name = bundle.getString("city_name");
      // Toast.makeText(this, "城市名"+city_name, 1000).show();
      viewPager.setCurrentItem(1, true);
      // 首页的滑块去颜色
      clearcolor();
      // 当前页上色
      bottom_secondPage_imge.setImageResource(R.drawable.nearby1);
      bottom_secondPage_text.setTextColor(Color.parseColor("#008000"));
    }
    if (currentItem == 2) {
      viewPager.setCurrentItem(2, true);
      // 首页的滑块去颜色
      clearcolor();
      // 当前页上色
      bottom_thirdPage_image.setImageResource(R.drawable.find1);
      bottom_thirdPage_text.setTextColor(Color.parseColor("#008000"));
    }
    if (currentItem == 3) {
      viewPager.setCurrentItem(3, true);
      // 首页的滑块去颜色
      clearcolor();
      // 当前页上色
      bottom_lastPage_image.setImageResource(R.drawable.me1);
      bottom_lastPage_text.setTextColor(Color.parseColor("#008000"));
    }
    // 监听滑动
    viewPager.setOnPageChangeListener(
        new OnPageChangeListener() {
          @Override
          public void onPageSelected(int position) {
            resetTextViewColor();
            resetImageViewSrc();
            switch (position) {
              case 0:
                bottom_mainPage_imge.setImageResource(R.drawable.home1);
                bottom_mainPage_text.setTextColor(Color.parseColor("#008000"));
                break;
              case 1:
                bottom_secondPage_imge.setImageResource(R.drawable.nearby1);
                bottom_secondPage_text.setTextColor(Color.parseColor("#008000"));
                break;
              case 2:
                bottom_thirdPage_image.setImageResource(R.drawable.find1);
                bottom_thirdPage_text.setTextColor(Color.parseColor("#008000"));
                break;
              case 3:
                bottom_lastPage_image.setImageResource(R.drawable.me1);
                bottom_lastPage_text.setTextColor(Color.parseColor("#008000"));
            }
          }

          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffPx) {
            /** 屏幕滑动时,tabLine的布局 */
            LinearLayout.LayoutParams lp =
                (android.widget.LinearLayout.LayoutParams) mTabLine.getLayoutParams();
            // mTabLine.setBackgroundColor(Color.parseColor("#145554"));
            lp.leftMargin = (int) ((position + positionOffset) * widthScreen1_4); // 控制滑动时,离左边的边距
            mTabLine.setLayoutParams(lp);
          }

          @Override
          public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

          }
          // 重置Image的颜色
          private void resetImageViewSrc() {
            bottom_mainPage_imge.setImageResource(R.drawable.home);
            bottom_secondPage_imge.setImageResource(R.drawable.nearby);
            bottom_thirdPage_image.setImageResource(R.drawable.find);
            bottom_lastPage_image.setImageResource(R.drawable.me);
          }
          // 重置text的颜色
          private void resetTextViewColor() {
            bottom_mainPage_text.setTextColor(Color.parseColor("#A6A6A6"));
            bottom_secondPage_text.setTextColor(Color.parseColor("#A6A6A6"));
            bottom_thirdPage_text.setTextColor(Color.parseColor("#A6A6A6"));
            bottom_lastPage_text.setTextColor(Color.parseColor("#A6A6A6"));
          }
        });
    // 底部布局的监听,自定义监听类
    BottomLayoutListener listener = new BottomLayoutListener();
    bottom_mainPage.setOnClickListener(listener);
    bottom_secondPage.setOnClickListener(listener);
    bottom_thirdPage.setOnClickListener(listener);
    bottom_lastPage.setOnClickListener(listener);
  }
Example #5
0
 @Override
 public void unReadMessageUpdate(int count) {
   if (count == 0 && badgeView.getBadgeCount() == 0) badgeView.setVisibility(View.GONE);
   badgeView.setVisibility(View.VISIBLE);
   badgeView.setBadgeCount(count);
 }