小编Vin*_*ing的帖子

使用方法引用在proguard之后使用NoSuchMethodError崩溃

compile&proguard之前的源代码:

public class IntentSession extends BaseIntentSession {
    @Override
    public void onResume() {
        super.onResume();
        mExecutor.exec(getIntent(), this::finish);
    }
}
Run Code Online (Sandbox Code Playgroud)

编译和编译后的反编译代码:(用CFR 0_118反编译)

public class a extends superA {

    public void e() {
        super.e();
        this.c.a(this.j(), b.a((a)this)); // the problematic code here
    }
}
Run Code Online (Sandbox Code Playgroud)

现在是编译&proguard之后的关键代码,b该类的反编译代码:

final class b implements c.a {
    private a a;

    b (a a1) {
        this.a = a1;
    }

    static /* synthetic */ b a(final a a) {
        return new b(a);
    }

    @LambdaForm.Hidden
    public void a() {
        this.a.finish();
    }
} …
Run Code Online (Sandbox Code Playgroud)

android gradle android-proguard

8
推荐指数
1
解决办法
1400
查看次数

Android RelativeLayout:当两个视图不在同一个容器中时,如何将视图放在另一个视图下面

我在LinearLayout中有一个TitleBar(#lotTopTitleBar),而LinearLayout将是屏幕的完整大小,现在,我想在下面的TitleBar中显示一个View(#lotFloatView)引用,但两个视图都不在同一级别的容器中,所以layout_below不起作用,如果有人知道,请帮我改变.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <LinearLayout android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical">

        <LinearLayout android:id="@+id/lotTopTitleBar"
                      android:layout_width="match_parent"
                      android:layout_height="50dp">
        </LinearLayout>

        <LinearLayout android:layout_width="match_parent"
                      android:layout_height="0dp"
                      android:layout_weight="1">
        </LinearLayout>

        <LinearLayout android:layout_width="match_parent"
                      android:layout_height="50dp">
        </LinearLayout>

    </LinearLayout>

    <LinearLayout android:id="@+id/lotFloatView"
                  android:layout_width="120dp"
                  android:layout_height="wrap_content"
                  android:layout_below="@id/lotTopTitleBar">
        <Button android:layout_width="match_parent"
                android:layout_height="60dp"
                android:background="@null" />
        <Button android:layout_width="match_parent"
                android:layout_height="60dp"
                android:background="@null" />
    </LinearLayout>

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

android relativelayout

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

如何从另一个页面控制viewPages页面

ViewPager每页都有3 listView页.我希望以listView一种方式设置动画,当用户水平滑动下一页时,listView应该根据下一页的宽度来显示项目.

即第一项应该完全推入,第二项应该是可见的一半,口渴应该是可见的一半,以此类推.

这种类型的动画已经在mi3 xiamo中用于联系人列表.

在此输入图像描述

在上图中,我向右滑动.注意"最近"列表项可见性.

如果有人可以帮助我做这个动画,那将是一个很大的帮助.请ListView根据页面更改分享一些关于动画的链接或提示ViewPager.

animation android android-listview android-fragments android-viewpager

7
推荐指数
1
解决办法
408
查看次数

如何保存并检查文件是否存在于作用域存储中?

到目前为止,我检查文件是否存在,如果不存在,则将其保存到 Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) 中的设备,但 Android 10 不支持它。

所以我尝试使用 mediastore API 来保存图像。

READ_STORAGE_PERMISSION -> 不允许

首先,我使用以下代码查询 contentresolver 以检查文件是否存在:

Uri collection = null;
collection = MediaStore.Images.Media.getContentUri(MediaStore.VOLUME_EXTERNAL);
String[] PROJECTION = new String[]{MediaStore.Images.Media.DISPLAY_NAME,
        MediaStore.MediaColumns.RELATIVE_PATH};
String QUERY = MediaStore.Files.FileColumns.RELATIVE_PATH + " like ? and " + 
MediaStore.Files.FileColumns.DISPLAY_NAME + " like ?";

ContentResolver mContentResolver = this.getContentResolver();
Cursor cursor = mContentResolver.query(collection, PROJECTION, QUERY , new String[]{"%" + dirName + "%", "%" + fname + "%"}, null);

if (cursor != null) {
    Log.d("upisdk", "cursor != null");
    if (cursor.getCount() > …
Run Code Online (Sandbox Code Playgroud)

android mediastore android-11

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

有没有办法在多个嵌套的RecyclerViews之间共享相同的LayoutManager

我正在开发一个显示游戏列表的应用程序,在每个游戏的itemView中,我还有一个要显示的视频列表.预览和结构如下.

在此输入图像描述

我部署了一个RecyclerView作为窗口根视图,然后对于视频,我使用了网格式的RecyclerView来显示,所以这里我们得到了一个嵌套的RecyclerView结构.

但是有麻烦,因为游戏之间的视频数量不一致,我不希望视频列表的RecyclerView能够滚动,所以最好的方法是使View的高度伸展动态取决于它有多少行.我听到一个令人失望的结论说,没有办法从互联网上实现这一目标.真的吗?任何替代方案可以这样做?

到目前为止关于这个问题,我不知道要解决它,所以我手动更改RecyclerView的高度作为临时解决方案.

videoGridRecyclerView.getLayoutParams().height = rowCount * 242;
Run Code Online (Sandbox Code Playgroud)

鉴于视频项目是完全相同的结构,如果这些RecyclerViews可以在屏幕上刷掉它后重新使用该视频的itemViews会很好,它将需要更好的性能提升.

然后我试着让一个特定的RecycledViewPool传播到每个嵌套的RecyclerViews.

public class MainActivity extends Activity {
    private RecyclerView.RecycledViewPool mViewPool;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // create the RecycledViewPool from first and re-use for each nested RecyclerViews.
        mViewPool = new RecyclerView.RecycledViewPool();
        ...
    }
}
Run Code Online (Sandbox Code Playgroud)

即使我完成了这项工作,我仍然注意到正在执行的onCreateViewHolder方法和膨胀计数器在我循环刷根RootlerView期间增加.

private static class VideoAdapter extends RecyclerView.Adapter<GridViewHolder> {
    private List<Video> mVideoList;

    private VideoAdapter(List<Video> videoList) {
        mVideoList = videoList;
    }

    // this method would always invoke during i swipe the RecyclerView.
    @Override
    public GridViewHolder …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-listview android-5.0-lollipop android-recyclerview

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