mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix fragments
This commit is contained in:
parent
6fa26af61c
commit
7dde464d9d
5 changed files with 55 additions and 46 deletions
|
|
@ -28,6 +28,7 @@ import fr.free.nrw.commons.auth.AuthenticatedActivity;
|
|||
import fr.free.nrw.commons.mwapi.MediaResult;
|
||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
|
|
@ -106,6 +107,7 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
return "Booga!";
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe();
|
||||
return true;
|
||||
}
|
||||
|
|
@ -113,6 +115,8 @@ public class ReviewActivity extends AuthenticatedActivity {
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* References ReviewPagerAdapter to null before the activity is destroyed
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -21,22 +21,23 @@ import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
|||
public class ReviewCategoryMissuseFragment extends CommonsDaggerSupportFragment {
|
||||
int position;
|
||||
String fileName;
|
||||
private View textView;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
static ReviewCategoryMissuseFragment init(int val, String fileName) {
|
||||
ReviewCategoryMissuseFragment fragment = new ReviewCategoryMissuseFragment();
|
||||
// Supply val input as an argument.
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("val", val);
|
||||
args.putString("fileName", fileName);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
|
||||
if (simpleDraweeView!=null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -44,10 +45,10 @@ public class ReviewCategoryMissuseFragment extends CommonsDaggerSupportFragment
|
|||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
false);
|
||||
View textView = layoutView.findViewById(R.id.testingText);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
|
||||
if (fileName!= null) {
|
||||
SimpleDraweeView simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,22 +20,23 @@ import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
|||
public class ReviewLicenceViolationFragment extends CommonsDaggerSupportFragment {
|
||||
int position;
|
||||
String fileName;
|
||||
private View textView;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
static ReviewLicenceViolationFragment init(int val, String fileName) {
|
||||
ReviewLicenceViolationFragment fragment = new ReviewLicenceViolationFragment();
|
||||
// Supply val input as an argument.
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("val", val);
|
||||
args.putString("fileName", fileName);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
|
||||
if (simpleDraweeView!=null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -44,10 +45,10 @@ public class ReviewLicenceViolationFragment extends CommonsDaggerSupportFragment
|
|||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
false);
|
||||
View textView = layoutView.findViewById(R.id.testingText);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
if (fileName!= null) {
|
||||
SimpleDraweeView simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,30 +19,25 @@ import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
|||
|
||||
public class ReviewOutOfContextFragment extends CommonsDaggerSupportFragment {
|
||||
|
||||
int position;
|
||||
String fileName;
|
||||
private int position;
|
||||
private String fileName;
|
||||
private View textView;
|
||||
private SimpleDraweeView simpleDraweeView;
|
||||
|
||||
static ReviewOutOfContextFragment init(int val, String fileName) {
|
||||
ReviewOutOfContextFragment fragment = new ReviewOutOfContextFragment();
|
||||
// Supply val input as an argument.
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("val", val);
|
||||
args.putString("fileName", fileName);
|
||||
fragment.setArguments(args);
|
||||
if (fileName != null) {
|
||||
//updateFragment(val, file);
|
||||
public void update(int position, String fileName) {
|
||||
this.position = position;
|
||||
this.fileName = fileName;
|
||||
|
||||
if (simpleDraweeView!=null) {
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
fileName = getArguments() != null ? getArguments().getString("fileName") : "";
|
||||
|
||||
//position = getArguments() != null ? getArguments().getInt("val") : 1;
|
||||
//fileName = getArguments() != null ? getArguments().getString("fileName") : " ";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -50,10 +45,10 @@ public class ReviewOutOfContextFragment extends CommonsDaggerSupportFragment {
|
|||
Bundle savedInstanceState) {
|
||||
View layoutView = inflater.inflate(R.layout.review_out_of_context, container,
|
||||
false);
|
||||
View textView = layoutView.findViewById(R.id.testingText);
|
||||
textView = layoutView.findViewById(R.id.testingText);
|
||||
|
||||
simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
if (fileName!= null) {
|
||||
SimpleDraweeView simpleDraweeView = layoutView.findViewById(R.id.imageView);
|
||||
simpleDraweeView.setImageURI(Utils.makeThumbBaseUrl(fileName));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,15 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
|||
public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
||||
private int currentPosition;
|
||||
ReviewOutOfContextFragment reviewOutOfContextFragment;
|
||||
ReviewLicenceViolationFragment reviewLicenceViolationFragment;
|
||||
ReviewCategoryMissuseFragment reviewCategoryMissuseFragment;
|
||||
|
||||
|
||||
public ReviewPagerAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
reviewOutOfContextFragment = new ReviewOutOfContextFragment();
|
||||
reviewLicenceViolationFragment = new ReviewLicenceViolationFragment();
|
||||
reviewCategoryMissuseFragment = new ReviewCategoryMissuseFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -28,13 +33,16 @@ public class ReviewPagerAdapter extends FragmentStatePagerAdapter {
|
|||
switch (position) {
|
||||
case 0: // Fragment # 0 - This will show image
|
||||
currentPosition = 0;
|
||||
return ReviewOutOfContextFragment.init(position, ReviewController.fileName);
|
||||
reviewOutOfContextFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewOutOfContextFragment;
|
||||
case 1: // Fragment # 1 - This will show image
|
||||
currentPosition = 1;
|
||||
return ReviewLicenceViolationFragment.init(position, ReviewController.fileName);
|
||||
reviewLicenceViolationFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewLicenceViolationFragment;
|
||||
default:// Fragment # 2-9 - Will show list
|
||||
currentPosition = 2;
|
||||
return ReviewCategoryMissuseFragment.init(position, ReviewController.fileName);
|
||||
reviewCategoryMissuseFragment.update(currentPosition, ReviewController.fileName);
|
||||
return reviewCategoryMissuseFragment;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue