我想要做的是,从按钮边缘到屏幕上的某一点画一条线......
我正在使用一个对话框片段...我尝试的所有函数总是返回0点...
我试过以下:
@Override
protected Dialog createDialog(Bundle savedInstanceState, FragmentActivity activity)
{
Dialog d = builder.create();
View v = LayoutInflater.from(activity).inflate(R.layout.dialog, null);
builder.setView(v);
// custom view by my which draws simple lines between points...
LineDrawView ldv = new LineDrawView(getActivity());
ldv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
((RelativeLayout)v).addView(ldv);
Dialog d = builder.create();
button = ((Button) v.findViewById(R.id.button));
int[] pos = new int[2];
button.getLocationInWindow(pos);
// tried following ways, all always return p(0, 0)
// button.getLocationInWindow(pos);
// Debugger.d("x: " + pos[0] + ", y: " + pos[1], "POS");
// button.getLocationOnScreen(pos); …Run Code Online (Sandbox Code Playgroud) 在我的主批处理文件中,我包含另一个批处理文件并想要调用其中定义的函数,代码如下所示:
@echo off
call define_wait.bat
if "%1"=="WAIT" (
call :WAIT_AND_PRINT 5
echo.
)
REM rest...
Run Code Online (Sandbox Code Playgroud)
我的define_wait.bat如下所示:
:WAIT_AND_PRINT
set /a time=%1
for /l %%x in (1, 1, %time%) do (
ping -n 1 -w 1000 1.0.0.0 > null
echo|set /p=.
)
goto :EOF
:WAIT
set /a time="%1 * 1000"
ping -n 1 -w %time% 1.0.0.0 > null
goto :EOF
Run Code Online (Sandbox Code Playgroud)
问题是,如果我在另一个批处理文件中定义等待函数,它不起作用,调用call :WAIT_AND_PRINT 5不会正确传递参数(错误:缺少操作数)...如果我从Define_wait.bat int 我的主批处理中复制代码文件,一切正常...
我该如何正确地做到这一点?
我想要以下行为:
observableMain应该缓冲所有项目,直到observableResumed发出一个值.然后observableMain应该发出所有缓冲和所有功能值...
我在做什么activity's onCreate:
PublishSubject<T> subject = ...; // I create a subject to emit items to and to subscribe to
// 1) I create a main observable from my subject
final Observable<T> observableMain = subject
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
// 2) I use a custom base class in which I can register listeners
// for the onResume event and which I can query the isResumed state!
// I call the object the pauseResumeProvider!
// …Run Code Online (Sandbox Code Playgroud) 通常我用
Observable observable = someObservable.replay().refCount();
Run Code Online (Sandbox Code Playgroud)
创建一个只能执行一次的可观察对象。如果我observable多次订阅,则效果很好:
observable.observeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(...);
observable.observeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(...);
Run Code Online (Sandbox Code Playgroud)
将observable只执行一次-完美的,就像我想它。如果我现在执行以下操作:
Observable obs1 = observable.map(...); // call some operators
Observable obs2 = observable.map(...); // call some operators
obs1.observeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(...);
obs2.observeOn(Schedulers.io())
.subscribeOn(AndroidSchedulers.mainThread())
.subscribe(...);
Run Code Online (Sandbox Code Playgroud)
然后observable执行两次。我如何确保不会发生这种情况?
问题:
我在一个单独的类中保存了一些数据......有时它会发生,这个单例返回我从中导出的空数据,它被销毁了......
我的想法/想法:
实际上,我认为,只要应用程序存在,单例就会存在,只要应用程序记住其他任何东西,例如片段状态,我的单例也会存在它的最后数据.这不对吗?
具体问题:
我的情况如下:我从我的主片段转到子片段并在我的单身中保存一个选定的对象...我停止使用我的应用程序并在一段时间后回来.我的应用程序记住它的状态并重新创建片段,我的片段想从我的单例中获取所选对象并获得null.
我想,只要应用程序存在就应该存在一个单例,因此不需要保存...每当应用程序结束时,无论如何都不会恢复任何内容,我的应用程序将不会记住任何内容,所以无论如何都没关系.这是一个错误的假设吗?
我需要回答这个问题,因为如果我确定,上述想法是正确的,我至少知道,我必须在其他地方寻找问题......
我有一个习惯RelativeLayout,我甚至已经设定setLayoutTransition(null);.我将此自定义视图添加到WindowManager中((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).updateViewLayout(this, layoutParams);
我在自定义视图中更改视图并更改了LayoutParamsfor WindowManager和之后的调用updateViewLayout...
我认为,LayoutParams对于WindowManager动画的变化,但我不确定...
如何禁用所有动画?
我需要列出用户驱动器云中的所有图像。
我使用 https://www.googleapis.com/drive/v2/files和正确的过滤器来查询所有图像。我需要将应用程序中的结果分组到文件夹中。我知道一个文件可以有多个父文件,这很好。
我想避免使用第一次调用中的父 ID通过https://developers.google.com/drive/v2/reference/files/get进行调用(对于每个单个文件一个调用)来获取文件文件夹。
是否有一种网络友好的方式来获取文件夹中包含的所有文件?
编辑
一种简单的解决方案是在一个查询中获取具有 id 的所有文件夹,并在此结果中查找文件夹名称。也许这有可能吗?
成像,您要检查是否存在“ /folder/subfolder/subsubfolder/test/test.txt”文件,请执行以下操作:
DocumentFile sdCard = ...; // i have already retrieved the sd card root with the users help via SAF
String path = "<SD CARD>/folder/subfolder/subsubfolder/test/test.txt";
List<String> pathParts = Arrays.asList(path.split("/"));
DocumentFile doc = sdCard;
// go through all folders, starting at sd card, to check, if the desired file exists
for (int i = 1; i < pathParts.size(); i++)
{
DocumentFile nextDoc = doc.findFile(pathParts.get(i));
if (nextDoc != null)
doc = nextDoc;
else
{
doc = null;
break;
}
}
if …Run Code Online (Sandbox Code Playgroud) 我想使用图标包中的图标。我知道如何找到已安装的图标包。但是我不知道如何从图标包中加载图标。
查找图标包 - WORKS
这就是我找到图标包的方式:
private static ArrayList<String> getInstalledIconPacks(String filter)
{
ArrayList<String> packs = new ArrayList<>();
List<ResolveInfo> infos = MainApp.get().getPackageManager().queryIntentActivities(new Intent(filter), PackageManager.GET_META_DATA);
if (infos != null)
{
for (int i = 0; i < infos.size(); i++)
{
ActivityInfo activity = infos.get(i).activityInfo;
String packageName = activity.packageName;
if (packageName != null)
packs.add(packageName);
}
}
return packs;
}
Run Code Online (Sandbox Code Playgroud)
现在用户可以选择一个图标包。然后我尝试从图标包中加载一个图标,如下所示:
从图标包加载应用程序图标 - 不起作用
public static Drawable getIconPackIcon(String packageName)
{
L.d(AppUtil.class, "PackageName: " + packageName);
String componentName = MainApp.get().getPackageManager().getLaunchIntentForPackage(packageName).getComponent().toString();
L.d(AppUtil.class, "componentName: " + componentName);
try …Run Code Online (Sandbox Code Playgroud) 是否有一个函数、技巧、技巧来进行查询,只从整数字段设置了特殊位的表中检索值?
android ×9
rx-java ×2
view ×2
animation ×1
batch-file ×1
cmd ×1
documentfile ×1
drawable ×1
drawing ×1
icons ×1
lifecycle ×1
observable ×1
resources ×1
singleton ×1
sqlite ×1