我正在开发一个Android应用程序,我最近从Eclipse迁移到Android Studio和Gradle.
在我的预测中,我创建了5个UI Libs,并将它们作为模块添加到我的项目中,我创建的库被推送到我的github帐户(公开).
在eclipse中为标记为lib的项目添加外部依赖项时,当您更新外部项目的代码然后清理构建时,您的项目会获得这些更新,但在Gradle中我注意到它创建了物理副本,完全独立于其源,我的问题是如何只更改外部库并更新我的项目.
这是从我的gradle的配置剪切:
dependencies {
// Libraries
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:5.0.89'
.
.
.
compile 'com.squareup.picasso:picasso:2.4.0'
// Projects
compile project(':com.shehabic.helpicon')
.
.
}
Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的"问题",或者可能是一个"功能",我只是不知道,只要在我的RecyclerView中加载NativeAdExpress,如果只有部分NativeAd可见,它会强制RecyclerView滚动直到原生广告变得完全可见,这种行为导致列表在我滚动时继续跳跃.
我的布局主要是:
具有Tabs和ViewPager的Activity> AppBar> Pager中的每个页面都包含PullToRefresh,里面有一个RecyclerView,RecyclerView有两种类型的项目(Article和NativeAdExpress).
更新:我猜测为什么会发生这种情况主要是因为原生广告在webview中表达渲染,并且这个webview获得焦点然后这会导致RecyclerView滚动到它,但这只是一个猜测
更新2:显然这是支持库中的一个问题.24.0.0,这太过于up2date的成本:(
Heres是我的完整XML /布局
<?xml version="1.0" encoding="utf-8"?>
<my.package.custom.views.CustomDrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:openDrawer="end">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
style="@style/AlertDialog.AppCompat.Light"
fontPath="fonts/fonts/DroidKufi-Regular.ttf"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
app:elevation="5px"
app:headerLayout="@layout/nav_header"
app:itemIconTint="@color/colorPrimary"
app:itemTextColor="@color/contentColor"
app:actionLayout="@layout/nav_item_layout"
app:menu="@menu/drawer_menu"
app:theme="@style/NavDrawerStyle"
tools:openDrawer="end"
/>
</my.package.custom.views.CustomDrawerLayout>
Run Code Online (Sandbox Code Playgroud)
其中"app_bar_main.xml"如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.activities.ArticlesListActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="52dp"
android:background="?attr/colorPrimary"
android:gravity="end"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingEnd="14dp"
android:paddingStart="14dp">
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/ivCustomDrawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true" …Run Code Online (Sandbox Code Playgroud) 我想知道如何在插件中调试 Flutter iOS 代码?我可以打开每次创建插件时生成的示例应用程序,但我将插件代码视为二进制框架,因此我无法调试它。
对于 android,这相当简单,我只需在 AS 中打开 android 文件夹,插件 + 示例就在那里,我只需添加运行配置并立即开始调试。
但我真的希望为 iOS 找到类似的方法。
我正在使用一个名为AppWarp(http://appwarp.shephertz.com)的多人游戏客户端,您可以在其中添加事件监听器,以便在事件发生时回调,让我们假设我们将讨论连接侦听器,其中你需要实现这个接口:
public interface ConnectionRequestListener {
void onConnectDone(ConnectEvent var1);
void onDisconnectDone(ConnectEvent var1);
void onInitUDPDone(byte var1);
}
Run Code Online (Sandbox Code Playgroud)
我的目标是主要创建此客户端的Reactive版本,以便在我的应用程序内部使用,而不是直接使用客户端本身(我也将在以后依赖于接口,而不是像示例中那样依赖于WarpClient本身,但是这不重要,请在最后阅读我的问题).
所以我做的如下:
1)我引入了一个新事件,名为RxConnectionEvent(主要对Connection相关事件进行分组),如下所示:
public class RxConnectionEvent {
// This is the original connection event from the source client
private final ConnectEvent connectEvent;
// this is to identify if it was Connection / Disconnection
private final int eventType;
public RxConnectionEvent(ConnectEvent connectEvent, int eventType) {
this.connectEvent = connectEvent;
this.eventType = eventType;
}
public ConnectEvent getConnectEvent() {
return connectEvent;
}
public int getEventType() {
return eventType; …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个库,该库使 QA 或开发人员能够在他们的应用程序中调试网络流量,我们目前使用 OKHttp,我知道如何创建拦截器并将所有请求数据分派到库。这样开发人员或 QA 可以查看此类数据(有效负载/URL/大小/响应代码/持续时间...等),但是我想创建一个更通用的解决方案来侦听 HTTP 流量甚至 TCP 流量,然后从那里获取数据,但是我找不到起点,我知道这是可能的,因为 Firebase Performance 正在这样做,但我仍然找不到 API 或无论如何都无法监听此类流量。
我希望来自 Google Firebase 性能团队的人员分享一些有关他们如何做到这一点的信息(如果这不是商业秘密的话):)
我遇到了这个解决方案: https: //github.com/cyruliu/Sensitive_API_Monitor/blob/master/app/src/main/java/com/android/reverse/apimonitor/NetWorkHook.java 但是,反射看起来有点糟糕,我希望找到更好的方法。
我最近将mac-os升级到了Mojave,我们将Android项目的gradle包装器升级到了
distributionUrl = https://services.gradle.org/distributions/gradle-4.6-all.zip
Java版本:
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
Run Code Online (Sandbox Code Playgroud)
我为gradle(gradle.properties)具有以下配置:
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2560M
Run Code Online (Sandbox Code Playgroud)
从命令行进行构建时,gradle会在此步骤停留至少4-5分钟。
15:26:04.001 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Apply plugin com.google.gms.google-services to project ':app'' started
15:26:04.072 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Apply plugin com.google.gms.google-services to project ':app''
15:26:04.073 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Apply script build.gradle to project ':app''
15:26:04.074 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 3.053 secs
15:26:04.076 [INFO] [org.gradle.api.Project] Parsing …Run Code Online (Sandbox Code Playgroud) 我有一个包含WebView的PopupWindow打开Facebook页面的应用程序,任何上下文菜单如:WebView中的文本字段上的自动完成,甚至是长按,应该显示用户复制/粘贴/剪切的选项立即崩溃应用程序跟随错误:
FATAL EXCEPTION: main
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@418cdab0 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:700)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:345)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149)
at android.view.Window$LocalWindowManager.addView(Window.java:554)
at android.widget.PopupWindow.invokePopup(PopupWindow.java:1013)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:856)
at android.widget.PopupWindow.showAtLocation(PopupWindow.java:820)
at android.webkit.WebViewClassic$PastePopupWindow.show(WebViewClassic.java:971)
at android.webkit.WebViewClassic.showPasteWindow(WebViewClassic.java:7037)
at android.webkit.WebViewClassic.access$10300(WebViewClassic.java:235)
at android.webkit.WebViewClassic$PrivateHandler.handleMessage(WebViewClassic.java:11376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)
注意:我对该问题的理解是,上下文菜单/窗口实际上显示在应用程序本身的范围内,而不是使用另一个PopWindow(由Core WebView类生成的自动)在WebView内部,此类错误地引用了上下文.
我的守则如下:
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/openpopup"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Open …Run Code Online (Sandbox Code Playgroud) 假设我有一个HTML页面如下:
<!-- This is the opening tag -->
<div class="content_text">
<div>Title</div>
<div>Author Name</div>
<div>Some complicated HTML elements correctly validated</div>
<b>Some more text</b>
<img ... />
<div> more and more text </div>
</div><!-- This is the correct closing tag -->
Run Code Online (Sandbox Code Playgroud)
如何获取div的开头class="content_text"和正确的结束标记之间的内容?
我尝试了正则表达式,但我找不到任何简单甚至难以实现的方法.
我试过XPath,但我仍然无法获得内容.相反,我得到了外部div中的文本.
我有一个实现AppCompat v7工具栏的应用程序,Lollipop上这个工具栏的高度是Androids <5.0的两倍大
更新:我现在将添加Kitkat和Lollipop的截图 工具栏xml如下:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:fitsSystemWindows="true"
android:gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
theme="@style/ThemeOverlay.AppCompat.ActionBar"
>
<LinearLayout
android:padding="0dp"
android:layout_margin="0dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right|center_vertical">
<TextView
android:id="@+id/action_bar_restaurant_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/restaurant_label_action_bar_margin_start"
android:layout_weight="1"
android:alpha="0"
android:ellipsize="end"
android:gravity="left"
android:singleLine="true"
android:textColor="@color/white"
android:textSize="@dimen/restaurant_label_action_bar_font_size" />
<ImageButton
android:id="@+id/shuffle_restaurant"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="7dp"
android:layout_weight="0"
android:background="@color/transparent"
android:scaleType="fitXY"
android:src="@drawable/shuffle_button" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
我的布局如下:
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<include layout="@layout/activity_content" />
</FrameLayout>
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="fill_parent"
android:layout_gravity="start"
android:background="@color/list_background"
android:choiceMode="singleChoice"
android:divider="@color/list_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/list_selector"
android:paddingTop="50dp" />
</android.support.v4.widget.DrawerLayout> …Run Code Online (Sandbox Code Playgroud) 如何在围绕其自身轴旋转路径中的对象时,如下图所示:

虽然这是我实际得到的:

这是我的代码:
AnimationSet as1 = new AnimationSet(true);
as1.setFillAfter(true);
float dist = 0.5f;
// The following is too slow just to inspect the animation
int duration = 5000; // 5 seconds
// Tried the following: RELATIVE_TO_SELF and RELATIVE_TO_PARENT but no difference
int ttype = Animation.RELATIVE_TO_SELF; // Type of translation
// Move to X: distance , Y: distance
TranslateAnimation ta1 = new TranslateAnimation( ttype,0,ttype,dist,ttype,0, ttype,dist);
ta1.setDuration(duration);
// Add Translation to the set
as1.addAnimation(ta1);
// Rotate around its center
int rtype = …Run Code Online (Sandbox Code Playgroud) android ×6
admob ×1
build.gradle ×1
domdocument ×1
flutter ×1
gradle ×1
ios ×1
java ×1
native-ads ×1
php ×1
regex ×1
rx-java ×1
xpath ×1