Java 片段之间的静态位图变量访问

Java 片段之间的静态位图变量访问,java,android,debugging,android-asynctask,android-cardview,Java,Android,Debugging,Android Asynctask,Android Cardview,cardwiew中的ImageView未从LRUCache加载。我肯定出了什么问题,但经过几天的调试后还是无法解决。如果代码可以完整地呈现在这里就好了,但这里是最相关的代码片段 设置 RecyclerViews'CardViews中的TextView绑定完美,但同一CardViews中的ImageViews没有绑定。我确信图像存在于缓存中,因为根据程序,长时间单击(空白)ImageViews确实会在另一个WebView中显示图像。Fragment1在AsyncTask中加载,以及Fragmen

cardwiew
中的
ImageView
未从
LRUCache
加载。我肯定出了什么问题,但经过几天的调试后还是无法解决。如果代码可以完整地呈现在这里就好了,但这里是最相关的代码片段

设置

RecyclerView
s'
CardView
s中的
TextView
绑定完美,但同一
CardView
s中的
ImageView
s没有绑定。我确信图像存在于缓存中,因为根据程序,长时间单击(空白)
ImageView
s确实会在另一个
WebView
中显示图像。
Fragment1
AsyncTask
中加载,以及
Fragment
1和2在
AsyncTask
完成后加载

cardwiew
Layout

<FrameLayout
android:id="@+id/flDContainer"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout
    android:id="@+id/rlDetFront"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <android.support.v7.widget.CardView
        android:id="@+id/cvDet"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardCornerRadius="10dp"
        card_view:cardElevation="12dp"
        card_view:contentPadding="2dp">

                   <TextView
                        android:id="@+id/tvDsDistance"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:textSize="16sp"/>

                    <TextView
                        android:id="@+id/tvDsDistanceUnit"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textSize="10sp"/>

            <RelativeLayout
                android:id="@+id/rlMediaLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/headerLayout">

                <ImageView
                    android:id="@+id/DetMedia"
                    android:layout_width="310dp"
                    android:layout_height="200dp"
                    android:layout_centerHorizontal="true"
                    android:layout_weight="1"
                    android:adjustViewBounds="true"
                    android:maxHeight="200dp"
                    android:maxWidth="310dp"
                    android:src="@drawable/cake_12"/>

            </RelativeLayout>
        </android.support.v7.widget.CardView>
    :
    :
    :
    :
RecyclerView
适配器的
onBindViewHolder

@Override
public void onBindViewHolder(MyCardHolder myCardHolder, final int position)
{
    MyView my = this.mysView.get(position);

    String logoFilename = my.getMyerLogo();
    String address = my.getAddress();
    String city = my.getCity();
    String state = my.getState();
    String country = my.getCountry();
    String zip = my.getZip();
        :
        :
        :
    myCardHolder.shopSL.setText(my.getSubLocality());
    myCardHolder.myEndDate.setText(UIHelper.makeDisplayDate(Long.parseLong(myEnds), false));
        :
        :
        :
    Bitmap tempBitmap;
    tempBitmap = fragment1.logoMemCache.get(logoFilename);
    myCardHolder.shopLogo.setImageBitmap(tempBitmap);
    tempBitmap = fragment1.myetMemCache.get(myFilename);
    myCardHolder.myet.setImageBitmap(tempBitmap);

    myCardHolder.tvAddress.setText(fullAddress);
    myCardHolder.tvPhones.setText(phones);
        :
        :
        :
}
ViewHolder

public class MyCardHolder extends RecyclerView.ViewHolder
{
private final String LOG_TAG = "POJO MyCardHolder";

RelativeLayout llMyCardFront;
RelativeLayout myTakenCounterLayout;
RelativeLayout myDateLayout;
TextView tvDistance;
TextView tvAddress;
TextView tvPhones;
TextView distanceUnit;
ImageView det;
TextView myTop;
TextView myBot;
ImageView shopLogo;
TextView shopName;
    :
    :
    :
// FAB toolbar
FloatingActionButton fabDirections, fabCallMobile, fabCallLandline, fabWebsite;

public MyCardHolder(View myItemView)
{
    super(myItemView);
    RelativeLayout myUserStatusLayout;

    llMyCardFront = (RelativeLayout) myItemView.findViewById(R.id.rlMyetFront);
    tvDistance = (TextView) myItemView.findViewById(R.id.tvMysDistance);
    claimButton = (Button) myItemView.findViewById(R.id.btMyClaim);
    distanceUnit = (TextView) myItemView.findViewById(R.id.tvMysDistanceUnit);
    det = (ImageView) myItemView.findViewById(R.id.DetMedia);
    myTop = (TextView) myItemView.findViewById(R.id.primaryTitle);
    myBot = (TextView) myItemView.findViewById(R.id.subTitle);
    shopLogo = (ImageView) myItemView.findViewById(R.id.shopLogo);
    shopName = (TextView) myItemView.findViewById(R.id.shopName);
                    :
                    :
                    :
                    :
    fabDirections = (FloatingActionButton) myItemView.findViewById(R.id.fabDirections);
                    :
                    :
                    :
}
}
class MyTapListener implements View.OnClickListener
{
final String LOG_TAG = "MyTapListener";

@Override
public void onClick(View myItemView)
{
    CardView cardFront = (CardView) myItemView.findViewById(R.id.cvMyet);
    CardView cardBack = (CardView) myItemView.findViewById(R.id.cvMyetBack);

    RelativeLayout llMyetBack = (RelativeLayout) myItemView.findViewById(R.id.rlMyetBack);
    RelativeLayout llMyetFront = (RelativeLayout) myItemView.findViewById(R.id.rlMyetFront);

    /* Some layout animations here when the user clicks on a CardView */
                    :
                    :
                    :
}
}
class FABToolbarListener implements View.OnClickListener
{

    /* FAB listener */
                    :
                    :
                    :
} // of class FABToolbarListener
class MyMediaListener implements View.OnLongClickListener
{
@Override
public boolean onLongClick(View clickedPic)
{
    int id = clickedPic.getId();
    Context context = clickedPic.getContext();
    String filename = (String) clickedPic.getTag(id);
    String shopName = (String) clickedPic.getTag(R.id.action_show_website);
    showOriginalImage(context, picFilename, shopName);
    return false;
}

private void showOriginalImage(Context context, String filename, String shopName)
{
    Intent fullMyetIntent = new Intent(context, ZoomerActivity.class);
    fullDIntent.putExtra(MyContract.D_PREFIX, filename);
    fullDIntent.putExtra(MyContract.D_PICKED, shopName);
    context.startActivity(fullDIntent);
} // of showOriginalImage() }
cardwiew
输出

public class MyCardHolder extends RecyclerView.ViewHolder
{
private final String LOG_TAG = "POJO MyCardHolder";

RelativeLayout llMyCardFront;
RelativeLayout myTakenCounterLayout;
RelativeLayout myDateLayout;
TextView tvDistance;
TextView tvAddress;
TextView tvPhones;
TextView distanceUnit;
ImageView det;
TextView myTop;
TextView myBot;
ImageView shopLogo;
TextView shopName;
    :
    :
    :
// FAB toolbar
FloatingActionButton fabDirections, fabCallMobile, fabCallLandline, fabWebsite;

public MyCardHolder(View myItemView)
{
    super(myItemView);
    RelativeLayout myUserStatusLayout;

    llMyCardFront = (RelativeLayout) myItemView.findViewById(R.id.rlMyetFront);
    tvDistance = (TextView) myItemView.findViewById(R.id.tvMysDistance);
    claimButton = (Button) myItemView.findViewById(R.id.btMyClaim);
    distanceUnit = (TextView) myItemView.findViewById(R.id.tvMysDistanceUnit);
    det = (ImageView) myItemView.findViewById(R.id.DetMedia);
    myTop = (TextView) myItemView.findViewById(R.id.primaryTitle);
    myBot = (TextView) myItemView.findViewById(R.id.subTitle);
    shopLogo = (ImageView) myItemView.findViewById(R.id.shopLogo);
    shopName = (TextView) myItemView.findViewById(R.id.shopName);
                    :
                    :
                    :
                    :
    fabDirections = (FloatingActionButton) myItemView.findViewById(R.id.fabDirections);
                    :
                    :
                    :
}
}
class MyTapListener implements View.OnClickListener
{
final String LOG_TAG = "MyTapListener";

@Override
public void onClick(View myItemView)
{
    CardView cardFront = (CardView) myItemView.findViewById(R.id.cvMyet);
    CardView cardBack = (CardView) myItemView.findViewById(R.id.cvMyetBack);

    RelativeLayout llMyetBack = (RelativeLayout) myItemView.findViewById(R.id.rlMyetBack);
    RelativeLayout llMyetFront = (RelativeLayout) myItemView.findViewById(R.id.rlMyetFront);

    /* Some layout animations here when the user clicks on a CardView */
                    :
                    :
                    :
}
}
class FABToolbarListener implements View.OnClickListener
{

    /* FAB listener */
                    :
                    :
                    :
} // of class FABToolbarListener
class MyMediaListener implements View.OnLongClickListener
{
@Override
public boolean onLongClick(View clickedPic)
{
    int id = clickedPic.getId();
    Context context = clickedPic.getContext();
    String filename = (String) clickedPic.getTag(id);
    String shopName = (String) clickedPic.getTag(R.id.action_show_website);
    showOriginalImage(context, picFilename, shopName);
    return false;
}

private void showOriginalImage(Context context, String filename, String shopName)
{
    Intent fullMyetIntent = new Intent(context, ZoomerActivity.class);
    fullDIntent.putExtra(MyContract.D_PREFIX, filename);
    fullDIntent.putExtra(MyContract.D_PICKED, shopName);
    context.startActivity(fullDIntent);
} // of showOriginalImage() }

是否有任何
cardwiew
-
ImageView
-
LRUCache
关系、怪癖或专家技巧我在这里遗漏了

请让我知道你还需要检查哪些代码


非常感谢

您的视图持有者代码在哪里?谢谢您的查看,@AllayKhalil!请查看更新后的问题-添加了
ViewHolder
片段。最后,我不得不自己做食谱。以下是对我有效的方法:-使适配器类位于
片段的内部
-在
AsyncTask