Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 686368d

Browse files
authored
Small fixes and test (#189)
* fix support for loadLayoutDescription * small format and remove notnull * remove log * checks for constraintSet gone, nested ML performance, fast transition with scroll
1 parent c0974e2 commit 686368d

19 files changed

+1917
-9
lines changed

constraintlayout/.idea/codeStyles/Project.xml

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/MotionLayoutVerification/app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@
2424
android:configChanges="orientation|screenSize"/>
2525
<activity android:name=".RotationAngular"
2626
android:configChanges="orientation|screenSize"/>
27-
<activity android:name=".CustomSwipeClick" />
27+
<activity android:name=".CustomSwipeClick" />
28+
<activity android:name=".RotationToolbar"
29+
android:label="To Run Disable Animation"
30+
android:configChanges="orientation|screenSize"/>
31+
<activity android:name=".RotationRotateToToolbar"
32+
android:label="To Run Disable Animation"
33+
android:configChanges="orientation|screenSize"/>
34+
<activity android:name=".ConstraintSetVerify"
35+
android:label="Test ConstraintSet on ConstraintLayout"
36+
/>
37+
<activity android:name=".CheckCallbackActivity" />
38+
2839
</application>
2940

3041
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.support.constraint.app;
18+
19+
import android.content.Context;
20+
import android.os.Bundle;
21+
import android.util.Log;
22+
import android.view.ViewGroup;
23+
import android.widget.TextView;
24+
25+
import androidx.annotation.Nullable;
26+
import androidx.appcompat.app.AppCompatActivity;
27+
import androidx.constraintlayout.motion.widget.Debug;
28+
import androidx.constraintlayout.motion.widget.MotionLayout;
29+
import androidx.constraintlayout.motion.widget.TransitionAdapter;
30+
import androidx.recyclerview.widget.LinearLayoutManager;
31+
import androidx.recyclerview.widget.RecyclerView;
32+
33+
// used with verification_042.xml
34+
public class CheckCallbackActivity extends AppCompatActivity {
35+
private static final String TAG = "CustomSwipeClick";
36+
String layout_name;
37+
MotionLayout mMotionLayout;
38+
39+
@Override
40+
protected void onCreate(@Nullable Bundle savedInstanceState) {
41+
super.onCreate(savedInstanceState);
42+
Bundle extra = getIntent().getExtras();
43+
String prelayout = extra.getString(Utils.KEY);
44+
setTitle(layout_name = prelayout);
45+
Context ctx = getApplicationContext();
46+
int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
47+
setContentView(id);
48+
mMotionLayout = Utils.findMotionLayout(this);
49+
50+
populateRecyclerView();
51+
52+
TextView text = findViewById(R.id.text);
53+
if (text != null) {
54+
mMotionLayout.setTransitionListener(new TransitionAdapter() {
55+
@Override
56+
public void onTransitionCompleted(MotionLayout motionLayout, int currentId) {
57+
text.setText((currentId == R.id.expanded) ? "cb down" : "cb up");
58+
Log.v(TAG, Debug.getLoc() + " "+Debug.getName(getApplicationContext(),currentId));
59+
}
60+
61+
});
62+
}
63+
}
64+
// ================================= Recycler support ====================================
65+
private void populateRecyclerView() {
66+
RecyclerView rview = Utils.findView(this, RecyclerView.class);
67+
if (rview == null) {
68+
return;
69+
}
70+
71+
rview.setLayoutManager(new LinearLayoutManager(this));
72+
rview.setAdapter(new MyAdapter());
73+
}
74+
75+
static class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
76+
private String[] mDataset = new String[300];
77+
{
78+
for (int i = 0; i < mDataset.length; i++) {
79+
mDataset[i] = "hello world 1234567890 ".substring(0,12+(i%10));
80+
}
81+
}
82+
83+
@Override
84+
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
85+
TextView tv = new TextView(parent.getContext());
86+
tv.setPadding(10, 10, 10, 5);
87+
tv.setTextSize(30);
88+
RecyclerView.ViewHolder vh = new RecyclerView.ViewHolder(tv){};
89+
return vh;
90+
}
91+
92+
@Override
93+
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
94+
((TextView)holder.itemView).setText(mDataset[position]);
95+
}
96+
97+
@Override
98+
public int getItemCount() {
99+
return mDataset.length;
100+
}
101+
}
102+
103+
104+
105+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (C) 2021 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.support.constraint.app;
18+
19+
import android.content.Context;
20+
import android.os.Bundle;
21+
import android.view.View;
22+
23+
import androidx.annotation.Nullable;
24+
import androidx.appcompat.app.ActionBar;
25+
import androidx.appcompat.app.AppCompatActivity;
26+
import androidx.constraintlayout.widget.ConstraintLayout;
27+
import androidx.constraintlayout.widget.ConstraintSet;
28+
29+
public class ConstraintSetVerify extends AppCompatActivity {
30+
private static final String TAG = "ConstraintSetVerify";
31+
String layout_name;
32+
ConstraintLayout mConstraintLayout;
33+
34+
@Override
35+
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
36+
super.onCreate(savedInstanceState);
37+
Bundle extra = getIntent().getExtras();
38+
String prelayout = extra.getString(Utils.KEY);
39+
layout_name = prelayout;
40+
Context ctx = getApplicationContext();
41+
int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
42+
ActionBar bar = getSupportActionBar();
43+
if (bar != null) {
44+
bar.hide();
45+
}
46+
setContentView(id);
47+
mConstraintLayout = Utils.findConstraintLayout(this);
48+
findViewById(R.id.showContent).setOnClickListener( (v)->showContent(v));
49+
findViewById(R.id.showSplash).setOnClickListener( (v)->showSplash(v));
50+
}
51+
public void showSplash(View v) {
52+
ConstraintSet set = new ConstraintSet();
53+
set.clone(mConstraintLayout);
54+
set.setVerticalBias(R.id.logo, 0.5f);
55+
set.setVisibility(R.id.splashScreen, View.VISIBLE);
56+
set.setVisibility(R.id.contentGroup, View.GONE);
57+
set.applyTo(mConstraintLayout);
58+
}
59+
public void showContent(View v) {
60+
61+
ConstraintSet set = new ConstraintSet();
62+
set.clone(mConstraintLayout);
63+
set.setVerticalBias(R.id.logo, 0.3f);
64+
set.setVisibility(R.id.splashScreen, View.GONE);
65+
set.setVisibility(R.id.contentGroup, View.VISIBLE);
66+
set.applyTo(mConstraintLayout);
67+
68+
}
69+
70+
}

0 commit comments

Comments
 (0)