NextActivity onCreate()被跳过

时间:2018-07-13 19:22:01

标签: java android android-fragments

我正在创建一个社交应用,用户可以上传图像,然后在随后的下一个屏幕上写标题。我的问题是用户创建标题的活动被完全跳过,并转到个人资料页面。图像进入了Firebase存储,但我无法写标题。

07-10 15:23:21.150 30970-31309/tabian.com.hash E/ImageLoader: UIL doesn't support scheme(protocol) by default [com.google.android.gms.tasks.zzu@f488c6e]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
java.lang.UnsupportedOperationException: UIL doesn't support scheme(protocol) by default [com.google.android.gms.tasks.zzu@f488c6e]. You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))
at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStreamFromOtherSource(BaseImageDownloader.java:280)
at com.nostra13.universalimageloader.core.download.BaseImageDownloader.getStream(BaseImageDownloader.java:99)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.downloadImage(LoadAndDisplayImageTask.java:291)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryCacheImageOnDisk(LoadAndDisplayImageTask.java:274)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.tryLoadBitmap(LoadAndDisplayImageTask.java:230)
at com.nostra13.universalimageloader.core.LoadAndDisplayImageTask.run(LoadAndDisplayImageTask.java:136)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)

GalleryFragment.Java

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_gallery, container, false);
galleryImage = view.findViewById(R.id.galleryImageView);
gridView = view.findViewById(R.id.gridView);
directorySpinner = view.findViewById(R.id.spinnerDirectory);
mProgressBar = view.findViewById(R.id.progressBar);
mProgressBar.setVisibility(View.GONE);
directories = new ArrayList<>();
Log.d(TAG, "onCreateView: Started.");

ImageView shareClose = view.findViewById(R.id.ivCloseShare);
shareClose.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.d(TAG, "onClick: Closing the gallery screen.");
        Objects.requireNonNull(GalleryFragment.this.getActivity());
    }
});

    TextView nextScreen = view.findViewById(R.id.tvNext);
    nextScreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "onClick: Navigating to the final share screen.");

            if (isTaskRoot()) {
                Intent intent = new Intent(GalleryFragment.this.getActivity(), NextActivity.class);
                intent.putExtra(getString(R.string.selected_image), mSelectedImage);
                GalleryFragment.this.startActivity(intent);
            } else {
                Intent intent = new Intent(GalleryFragment.this.getActivity(), AccountSettingsActivity.class);
                intent.putExtra(getString(R.string.selected_image), mSelectedImage);
                intent.putExtra(getString(R.string.return_to_fragment), getString(R.string.edit_profile_fragment));
                GalleryFragment.this.startActivity(intent);
                Objects.requireNonNull(GalleryFragment.this.getActivity());
            }
        }
    });
    init();

    return view;

}

NextActivity.Java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_next);
    mFirebaseMethods = new FirebaseMethods(NextActivity.this);
    mCaption = (EditText) findViewById(R.id.caption) ;

    setupFirebaseAuth();

    ImageView backArrow = (ImageView) findViewById(R.id.ivBackArrow);
    backArrow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "onClick: Closing the activity");
            finish();
        }
    });

    TextView share = (TextView) findViewById(R.id.tvShare);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.d(TAG, "onClick: Navigating to the final share screen.");
            //upload the image to firebase
            Toast.makeText(NextActivity.this, "Attempting to upload new photo", Toast.LENGTH_SHORT).show();
            String caption = mCaption.getText().toString();

            if(intent.hasExtra(getString(R.string.selected_image))){
                imgUrl = intent.getStringExtra(getString(R.string.selected_image));
                mFirebaseMethods.uploadNewPhoto(getString(R.string.new_photo), caption, imageCount, imgUrl,null);
            }
            else if(intent.hasExtra(getString(R.string.selected_bitmap))){
                bitmap = (Bitmap) intent.getParcelableExtra(getString(R.string.selected_bitmap));
                mFirebaseMethods.uploadNewPhoto(getString(R.string.new_photo), caption, imageCount, null,bitmap);
            }

        }
    });

    setImage();
}

ProfileActivity.Java:

public class ProfileActivity extends AppCompatActivity implements
    ProfileFragment.OnGridImageSelectedListener ,
    ViewPostFragment.OnCommentThreadSelectedListener,
    ViewProfileFragment.OnGridImageSelectedListener{

private static final String TAG = "ProfileActivity";

@Override
public void onCommentThreadSelectedListener(Photo photo) {
    Log.d(TAG, "onCommentThreadSelectedListener:  selected a comment thread");

    ViewCommentsFragment fragment = new ViewCommentsFragment();
    Bundle args = new Bundle();
    args.putParcelable(getString(R.string.photo), photo);
    fragment.setArguments(args);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment);
    transaction.addToBackStack(getString(R.string.view_comments_fragment));
    transaction.commit();
}

@Override
public void onGridImageSelected(Photo photo, int activityNumber) {
    Log.d(TAG, "onGridImageSelected: selected an image gridview: " + photo.toString());

    ViewPostFragment fragment = new ViewPostFragment();
    Bundle args = new Bundle();
    args.putParcelable(getString(R.string.photo), photo);
    args.putInt(getString(R.string.activity_number), activityNumber);

    fragment.setArguments(args);

    FragmentTransaction transaction  = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.container, fragment);
    transaction.addToBackStack(getString(R.string.view_post_fragment));
    transaction.commit();

}


private static final int ACTIVITY_NUM = 4;
private static final int NUM_GRID_COLUMNS = 3;

private Context mContext = ProfileActivity.this;

private ProgressBar mProgressBar;
private ImageView profilePhoto;


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_profile);
    Log.d(TAG, "onCreate: started.");

    init();


}

0 个答案:

没有答案