gcc 4.4.3 c89
我有一些函数初始化一些硬件并返回true或false.如果为false,那么我必须以相反的顺序取消初始化.
但是,我的代码对所有if语句看起来都很不整洁.
例如,每个函数都可以返回true或false.这是一个样本.正如您所看到的,代码看起来非常不整洁.我只是在寻找有关如何清理它以使其更易于管理且可能更糟糕的任何建议?
非常感谢任何建议,
if(init_A() == TRUE) {
if(init_B() == TRUE) {
if(init_C() == TRUE) {
if(init_D() == TRUE) {
if(init_E() == TRUE) {
/* ALL STARTED OK */
}
else {
uninit_A();
uninit_B();
uninit_C();
uninit_D();
}
}
else {
uninit_A();
uninit_B();
uninit_C();
}
}
else {
uninit_A();
uninit_B();
}
}
else {
/* Failed to initialize B */
uninit_B();
}
}
else {
/* Failed to start */
}
Run Code Online (Sandbox Code Playgroud) Android Studio 1.5
Device Samsung 4.4.2
Run Code Online (Sandbox Code Playgroud)
我正在尝试将从ArrayList加载的项目动画化为recyclerview.我在单击下拉箭头时,项目应在展开时设置动画(减速),并在折叠时设置动画.但是,目前只显示列表项.
调用setAnimation的代码
@Override
public void onBindChildViewHolder(ChatChildViewHolder childViewHolder, int position, Object childListItem) {
ChatChildTitles chatChildTitles = (ChatChildTitles)childListItem;
childViewHolder.tvChildTitle.setText(chatChildTitles.getTitle());
setAnimation(childViewHolder.cvChildRooms, position);
}
Run Code Online (Sandbox Code Playgroud)
用于设置动画的代码
private void setAnimation(CardView viewToAnimate, int position) {
Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.fade_in);
animation.setInterpolator(mContext, android.R.anim.decelerate_interpolator);
viewToAnimate.startAnimation(animation);
}
Run Code Online (Sandbox Code Playgroud)
这是一些截图:
在崩溃的状态
这是我正在使用的布局,它代表将在recyclerView中显示的行:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
android:id="@+id/cvChildRooms"
xmlns:card="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card:cardBackgroundColor="@color/child_header_lighter_grey"
card:contentPadding="4dp"
card:cardPreventCornerOverlap="true">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical|start"
android:src="@drawable/photorace"/>
<TextView
android:id="@+id/tvChildTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center"
android:text="Coffee Latte Room"
android:fontFamily="sans-serif-light"
android:textSize="16sp"
android:textColor="@android:color/black"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
我有一个应该启动动画的功能.
private void …Run Code Online (Sandbox Code Playgroud) 这是在主函数内部声明函数原型的好方法吗?
我正在看一个C教程,我认为已经过时了.但是,他们在main中声明了函数原型.我通常在主要之前宣布在外面.
#include <stdio.h>
int main ()
{
char myname [30];
int theage;
int getage ();
printf ("\nEnter your name:");
gets (myname);
theage = getage ();
printf("\n AGE = %d and NAME = %s", theage, myname);
return 0;
}
int getage ()
{
int myage; /* local to only getage() */
printf ("\nEnter your age: ");
scanf ("%d",&myage);
return (myage);
}
Run Code Online (Sandbox Code Playgroud) C#2008 SP1
我正在编写一个我想给一些客户提供的应用程序.
使用的最佳解决方案是什么,以便在跟踪期(1个月)之后应用程序将不再起作用.
我想如果他们有兴趣购买软件,我会给他们许可证密钥或其他东西,以解锁应用程序.
因为我自己工作,所以预算非常有限.那么有没有免费的第三方产品呢?
我正在Linux(GCC 4.4.2)和Windows VS C++ Express Edition 2008下编译
我目前正在Windows XP Pro 32位下编译,并已将其添加到我的源代码中.
#if defined( WIN32 )
/* Do windows stuff here */
#endif
Run Code Online (Sandbox Code Playgroud)
但是,if语句中的代码被禁用(变灰).但是,如果我执行以下操作:
#if defined( _MSC_VER )
/* Do windows stuff here */
#endif
Run Code Online (Sandbox Code Playgroud)
if语句代码已启用.
我只是想知道,我应该使用什么.我见过很多程序员都使用WIN32.但是,似乎对我不起作用.我应该使用_MSC_VER吗?
非常感谢任何建议,
android studio 2.0 beta5
Run Code Online (Sandbox Code Playgroud)
我注意到,当我在工具栏中包含一个布局时,该布局的左边缘永远不会与工具栏的父级的左边缘对齐,即使我已将两者都设置为match_parent.
这是我的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:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp">
</LinearLayout>
</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)
这是正在发生的事情的屏幕截图.
从上图中可以看出,LinearLayout与父级不匹配.我也曾尝试FrameLayout和RelativeLayout并具有相同的结果.
我不确定这是android studio的错误还是左侧的这个空间是为某些东西保留的.
即使我在真实设备上运行应用程序,它也与父设备不匹配.
非常感谢任何建议
在我的机器人中gradle.properties我有以下内容:
android.enableAapt2=false
Run Code Online (Sandbox Code Playgroud)
我gradle.properties位于~/.gradle/gradle.properties我的本地机器中.
我想知道如何添加android.enableAapt=false到我的yml文件.
我试图在全局下添加它但是没有工作没有错误但是robolectric如果你使用的话需要设置它gradle:3.0.0-beta3.
language: android
jdk: oraclejdk8
env:
global:
- ANDROID_TARGET=android-25
- ANDROID_ABI=armeabi-v7a
- android.enableAapt2=false
android:
components:
- tools
- platform-tools
- build-tools-25.0.3
- android-25
- extra-android-m2repository
- sys-img-${ANDROID_ABI}-${ANDROID_TARGET}
licenses:
- android-sdk-license-.+
- '.+'
script:
- ./gradlew --daemon build jacocoTestReport --info
after_success:
- bash <(curl -s https://codecov.io/bash)
Run Code Online (Sandbox Code Playgroud)
以下是travis-ci上的配置文件
{
"language": "android",
"jdk": "oraclejdk8",
"android": {
"components": [
"tools",
"platform-tools",
"build-tools-25.0.3",
"android-25",
"extra-android-m2repository",
"sys-img-${ANDROID_ABI}-${ANDROID_TARGET}"
]
},
"licenses": …Run Code Online (Sandbox Code Playgroud) continuous-integration android aapt continuous-delivery travis-ci
Android Studio 3.2 Canary 2
Build #AI-173.4591728, built on February 8, 2018
JRE: 1.8.0_152-release-1024-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.14.18-300.fc27.x86_64
Run Code Online (Sandbox Code Playgroud)
我有以下活动,我想单元测试片段已经附加的情况,并应返回非null.并且应该落入其他条件:
这是我的活动:
public class BillingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.billing_container);
if(getSupportFragmentManager().findFragmentByTag(BillingView.TAG) == null) {
final FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(
R.id.billing_view_container,
BillingView.newInstance(),
BillingView.TAG);
fragmentTransaction.commit();
}
else {
Timber.d("Fragment already attached");
}
}
}
Run Code Online (Sandbox Code Playgroud)
测试类是这样的:我可以编写测试来附加一个片段,但是我想在片段已经附加时测试条件并且应该返回非null.
class BillingActivityTest: BaseRobolectricTestRunner() {
private lateinit var billingActivity: BillingActivity
@Before
fun setup() {
billingActivity = …Run Code Online (Sandbox Code Playgroud) VS 2005 SP3
我曾多次与进度条合作过.
但是,我需要一个垂直的.但是,我找不到任何会旋转它的属性.
进度条是否始终处于水平位置且无法更改.
非常感谢,
我正在维护别人的代码.代码在Linux平台上使用GCC 4.4.3用C语言编写.但是,代码跳了很多,很难找到调用所有函数的位置.
在Visual Studio中,有一个名为"调用层次结构"的功能,它将显示调用和调用函数的位置.Emacs(23.1.1)有这样的功能吗?
android ×4
c ×3
c# ×2
aapt ×1
emacs ×1
junit ×1
kotlin ×1
progress-bar ×1
robolectric ×1
travis-ci ×1
trialware ×1
unit-testing ×1