nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.25k stars 1.76k forks source link

Intents are not type safe #5866

Open tobiasKaminsky opened 4 years ago

tobiasKaminsky commented 4 years ago

As we had this recently: https://github.com/nextcloud/android/pull/5857

To prevent this, my idea is to have a static "launch" function in ever needed activity, that handles creating the intent correctly. In this case it could be:

public static function launch/createIntent(File file, Account account) {
Intent i = new Intent(fileActivity, ConflictsResolveActivity.class);
i.putExtra(ConflictsResolveActivity.EXTRA_FILE, file);
i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, account);

return i;
}

What do you think? @ezaquarii @AndyScherzinger

ezaquarii commented 4 years ago

@tobiasKaminsky Yes, this is analogous to Fragment.newInstance() approach and works well.

AndyScherzinger commented 4 years ago

Yes, sound good to me too 👍