小编Rob*_*son的帖子

如果它包含特定元素,则隐藏推送通知

如果它有例如密钥,我将不会显示收到的推送通知,从通知顶部通知菜单我的通知update.现在,如果我收到此密钥的通知,则所有通知都在通知栏中.我不想为用户提供此通知.

我正在使用WakefulBroadcastReceiver下面的句柄通知:

public class PusherReceiver extends WakefulBroadcastReceiver {
    private boolean isAppOnForeground(Context context) {
        ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> appProcesses = activityManager.getRunningAppProcesses();
        if (appProcesses == null) 
            return false;

        final String packageName = context.getPackageName();
        for (ActivityManager.RunningAppProcessInfo appProcess : appProcesses) {
            if (appProcess.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND && appProcess.processName.equals(packageName)) {
                return true;
            }
        }

        return false;
    }

    public void onReceive(final Context context, Intent intent) {
        Log.i("SimpleWakefulReceiver", "Starting service @ " + SystemClock.elapsedRealtime());
        if (!isAppOnForeground((context))) {
            String pushNotificationBody = intent.getStringExtra("alert");

            try …
Run Code Online (Sandbox Code Playgroud)

java android react-native onesignal react-native-android

13
推荐指数
1
解决办法
567
查看次数

Javascript - 将 css 样式添加到具有类的元素

我只想在 JS 中添加一种 css 样式。我不想只为一件事包含 jQuery。

我的代码:

document.addEventListener('DOMContentLoaded', function() {
    if (navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) {
        var productAttr = document.getElementsByClassName('product-attributes');
        productAttr.style.top = "-90px";
    }
});
Run Code Online (Sandbox Code Playgroud)

来自控制台的错误是:

类型错误:'undefined' 不是一个对象(评估 'productAttr.style.top = "-90px"')

如果我想更改其他样式的不透明度或颜色,我会遇到同样的问题。

我怎样才能解决这个问题 ?

预先感谢您的帮助。

javascript

6
推荐指数
1
解决办法
2万
查看次数

Bootstrap轮播如何在xs大小的滑块上隐藏一个项目?

我怎样才能在xs-size上隐藏bootstrap-carousel中的一两个项目?

当我在carousel中将此类'hidden-xs'添加到此项目时,项目div看起来像:

<div class="item hidden-xs">
      <img src="imgTop2.jpg" alt="...">
</div>
Run Code Online (Sandbox Code Playgroud)

所有物品和旋转木马都消失了.

当我将'hidden-xs'类添加到此项的img元素时,存在同样的问题.

我该如何解决这个问题?我想在xs上只隐藏一两张幻灯片.其他人必须通过可见.

我的代码看起来像:

<div id="carousel-top" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="hidden carousel-indicators" style="display:none">
      <li data-target="#carousel-top" data-slide-to="0" class="active"></li>
      <li class="" data-target="#carousel-top" data-slide-to="1"></li>
      <li class="" data-target="#carousel-top" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">

      <div class="item active">
      <img src="imgTop.jpg" alt="...">
    </div>

    <div class="item">
      <img src="imgTop2.jpg" alt="...">
    </div>

    <div class="item">
      <img src="imgTop3.jpg" alt="...">
    </div>

    <div class="item">
      <img src="imgTop4.jpg" alt="...">
    </div>

    <div class="item">
      <img src="imgTop5.jpg" alt="...">
    </div>


    </div>

    <!-- Controls …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery twitter-bootstrap twitter-bootstrap-3

5
推荐指数
1
解决办法
9189
查看次数

在悬停时动画的箭头线

如何在悬停到箭头线条时将一个线条效果设置为动画效果

我尝试使用边框执行此操作,但此箭头和线条必须位于具有透明背景的图像上.

我在这张图片的顶部有一条线,我需要在该图像的底部悬停并使用箭头悬停:

悬停在中心的箭头线

这是我的代码:

* {
  box-sizing: border-box;
}
.bg {
  margin: 0 auto;
  background: url('http://i.imgur.com/RECDV24.jpg') center no-repeat;
  background-size: cover;
  width: 100vh;
  height: 100vh;
  position: relative;
  padding: 1em;
}
.line {
  height: 2px;
  position: absolute;
  top: 50%;
  left: 1em;
  right: 1em;
  background: #fff;
}
.bg:hover .line:after {
  height: 10px;
  width: 10px;
  position: absolute;
  content: '';
  background: transparent;
  border: 2px solid #fff;
  border-top-width: 0px;
  border-left-width: 0px;
  transform: rotate(45deg);
  bottom: -6px;
  left: calc(50% - 4px);
} …
Run Code Online (Sandbox Code Playgroud)

html css css3 css-animations css-shapes

5
推荐指数
1
解决办法
1087
查看次数

将活动类添加到wordpress循环的第一项

我在WordPress的类别上创建了滑块并发布了缩略图。

我试图将活动类添加到循环中的第一个项目,但循环在所有项目中显示该类。

我该如何解决?

这是我的循环:

<div class="carousel-inner" role="listbox">

    <?php
        $c = 0;
        $class = '';
        query_posts('category_name=slider&showposts=3');
        if ( have_posts() ) : while ( have_posts() ) : the_post();
            $c++;

            $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' );
            $url = $thumb['0'];

            if ( $c == 1 ) $class .= ' active';
                ?>
                 <div class="item <?php echo $class; ?>">
                     <img src="<?php echo $url; ?>" class="img-responsive" alt="...">
                     <div class="carousel-caption">
                          <h2><?php the_content() ?></h2>
                     </div>
                 </div>
                 <?php
        endwhile;endif;
        wp_reset_query();
    ?>

</div>
Run Code Online (Sandbox Code Playgroud)

http://pastebin.com/R5XA3ik9

php wordpress wordpress-theming

1
推荐指数
2
解决办法
7297
查看次数