mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
added JavaDoc comments
This commit is contained in:
parent
4ef996f2c0
commit
28264e93ce
5 changed files with 112 additions and 7 deletions
|
|
@ -10,13 +10,6 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class WelcomePagerAdapter extends PagerAdapter {
|
public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
private static final int PAGE_FINAL = 4;
|
|
||||||
private Callback callback;
|
|
||||||
|
|
||||||
public interface Callback {
|
|
||||||
void onYesClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
static final int[] PAGE_LAYOUTS = new int[]{
|
static final int[] PAGE_LAYOUTS = new int[]{
|
||||||
R.layout.welcome_wikipedia,
|
R.layout.welcome_wikipedia,
|
||||||
R.layout.welcome_do_upload,
|
R.layout.welcome_do_upload,
|
||||||
|
|
@ -24,16 +17,34 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
R.layout.welcome_image_details,
|
R.layout.welcome_image_details,
|
||||||
R.layout.welcome_final
|
R.layout.welcome_final
|
||||||
};
|
};
|
||||||
|
private static final int PAGE_FINAL = 4;
|
||||||
|
private Callback callback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes callback to provided one
|
||||||
|
*
|
||||||
|
* @param callback New callback
|
||||||
|
* it can be null.
|
||||||
|
*/
|
||||||
public void setCallback(@Nullable Callback callback) {
|
public void setCallback(@Nullable Callback callback) {
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets total number of layouts
|
||||||
|
* @return Number of layouts
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return PAGE_LAYOUTS.length;
|
return PAGE_LAYOUTS.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares given view with provided object
|
||||||
|
* @param view Adapter view
|
||||||
|
* @param object Adapter object
|
||||||
|
* @return Equality between view and object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isViewFromObject(View view, Object object) {
|
public boolean isViewFromObject(View view, Object object) {
|
||||||
return (view == object);
|
return (view == object);
|
||||||
|
|
@ -52,16 +63,32 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a way to remove an item from container
|
||||||
|
* @param container Adapter view group container
|
||||||
|
* @param position Index of item
|
||||||
|
* @param obj Adapter object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void destroyItem(ViewGroup container, int position, Object obj) {
|
public void destroyItem(ViewGroup container, int position, Object obj) {
|
||||||
container.removeView((View) obj);
|
container.removeView((View) obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface used create on clicked callback(s).
|
||||||
|
*/
|
||||||
|
public interface Callback {
|
||||||
|
void onYesClicked();
|
||||||
|
}
|
||||||
|
|
||||||
class ViewHolder {
|
class ViewHolder {
|
||||||
ViewHolder(View view) {
|
ViewHolder(View view) {
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers on click callback on button click
|
||||||
|
*/
|
||||||
@OnClick(R.id.welcomeYesButton)
|
@OnClick(R.id.welcomeYesButton)
|
||||||
void onClicked() {
|
void onClicked() {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,14 @@ public class LogBuilder {
|
||||||
private final String schema;
|
private final String schema;
|
||||||
private final SharedPreferences prefs;
|
private final SharedPreferences prefs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main constructor of LogBuilder
|
||||||
|
*
|
||||||
|
* @param schema Log schema
|
||||||
|
* @param revision Log revision
|
||||||
|
* @param mwApi Wiki media API instance
|
||||||
|
* @param prefs Instance of SharedPreferences
|
||||||
|
*/
|
||||||
LogBuilder(String schema, long revision, MediaWikiApi mwApi, SharedPreferences prefs) {
|
LogBuilder(String schema, long revision, MediaWikiApi mwApi, SharedPreferences prefs) {
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
this.data = new JSONObject();
|
this.data = new JSONObject();
|
||||||
|
|
@ -30,6 +38,12 @@ public class LogBuilder {
|
||||||
this.mwApi = mwApi;
|
this.mwApi = mwApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds data to preferences
|
||||||
|
* @param key Log key
|
||||||
|
* @param value Log object value
|
||||||
|
* @return LogBuilder
|
||||||
|
*/
|
||||||
public LogBuilder param(String key, Object value) {
|
public LogBuilder param(String key, Object value) {
|
||||||
try {
|
try {
|
||||||
data.put(key, value);
|
data.put(key, value);
|
||||||
|
|
@ -39,6 +53,10 @@ public class LogBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes JSON object to URL
|
||||||
|
* @return URL to JSON object
|
||||||
|
*/
|
||||||
URL toUrl() {
|
URL toUrl() {
|
||||||
JSONObject fullData = new JSONObject();
|
JSONObject fullData = new JSONObject();
|
||||||
try {
|
try {
|
||||||
|
|
@ -66,6 +84,9 @@ public class LogBuilder {
|
||||||
logTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this);
|
logTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs in false
|
||||||
|
*/
|
||||||
public void log() {
|
public void log() {
|
||||||
log(false);
|
log(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,20 @@ class LogTask extends AsyncTask<LogBuilder, Void, Boolean> {
|
||||||
|
|
||||||
private final MediaWikiApi mwApi;
|
private final MediaWikiApi mwApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main constructor of LogTask
|
||||||
|
*
|
||||||
|
* @param mwApi Media wiki API instance
|
||||||
|
*/
|
||||||
public LogTask(MediaWikiApi mwApi) {
|
public LogTask(MediaWikiApi mwApi) {
|
||||||
this.mwApi = mwApi;
|
this.mwApi = mwApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs events in background
|
||||||
|
* @param logBuilders LogBuilder instance
|
||||||
|
* @return Background success state ( TRUE or FALSE )
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(LogBuilder... logBuilders) {
|
protected Boolean doInBackground(LogBuilder... logBuilders) {
|
||||||
return mwApi.logEvents(logBuilders);
|
return mwApi.logEvents(logBuilders);
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,29 @@ public class MediaResult {
|
||||||
private final String wikiSource;
|
private final String wikiSource;
|
||||||
private final String parseTreeXmlSource;
|
private final String parseTreeXmlSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full-fledged constructor of MediaResult
|
||||||
|
*
|
||||||
|
* @param wikiSource Media wiki source
|
||||||
|
* @param parseTreeXmlSource Media tree parsed in XML
|
||||||
|
*/
|
||||||
MediaResult(String wikiSource, String parseTreeXmlSource) {
|
MediaResult(String wikiSource, String parseTreeXmlSource) {
|
||||||
this.wikiSource = wikiSource;
|
this.wikiSource = wikiSource;
|
||||||
this.parseTreeXmlSource = parseTreeXmlSource;
|
this.parseTreeXmlSource = parseTreeXmlSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets wiki source
|
||||||
|
* @return Wiki source
|
||||||
|
*/
|
||||||
public String getWikiSource() {
|
public String getWikiSource() {
|
||||||
return wikiSource;
|
return wikiSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets tree parsed in XML
|
||||||
|
* @return XML parsed tree
|
||||||
|
*/
|
||||||
public String getParseTreeXmlSource() {
|
public String getParseTreeXmlSource() {
|
||||||
return parseTreeXmlSource;
|
return parseTreeXmlSource;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,24 @@ public class UploadResult {
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
private String canonicalFilename;
|
private String canonicalFilename;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimal constructor
|
||||||
|
*
|
||||||
|
* @param resultStatus Upload result status
|
||||||
|
* @param errorCode Upload error code
|
||||||
|
*/
|
||||||
UploadResult(String resultStatus, String errorCode) {
|
UploadResult(String resultStatus, String errorCode) {
|
||||||
this.resultStatus = resultStatus;
|
this.resultStatus = resultStatus;
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full-fledged constructor
|
||||||
|
* @param resultStatus Upload result status
|
||||||
|
* @param dateUploaded Uploaded date
|
||||||
|
* @param canonicalFilename Uploaded file name
|
||||||
|
* @param imageUrl Uploaded image file name
|
||||||
|
*/
|
||||||
UploadResult(String resultStatus, Date dateUploaded, String canonicalFilename, String imageUrl) {
|
UploadResult(String resultStatus, Date dateUploaded, String canonicalFilename, String imageUrl) {
|
||||||
this.resultStatus = resultStatus;
|
this.resultStatus = resultStatus;
|
||||||
this.dateUploaded = dateUploaded;
|
this.dateUploaded = dateUploaded;
|
||||||
|
|
@ -21,22 +34,42 @@ public class UploadResult {
|
||||||
this.imageUrl = imageUrl;
|
this.imageUrl = imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets uploaded date
|
||||||
|
* @return Upload date
|
||||||
|
*/
|
||||||
public Date getDateUploaded() {
|
public Date getDateUploaded() {
|
||||||
return dateUploaded;
|
return dateUploaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets image url
|
||||||
|
* @return Uploaded image url
|
||||||
|
*/
|
||||||
public String getImageUrl() {
|
public String getImageUrl() {
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets canonical file name
|
||||||
|
* @return Uploaded file name
|
||||||
|
*/
|
||||||
public String getCanonicalFilename() {
|
public String getCanonicalFilename() {
|
||||||
return canonicalFilename;
|
return canonicalFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets upload error code
|
||||||
|
* @return Error code
|
||||||
|
*/
|
||||||
public String getErrorCode() {
|
public String getErrorCode() {
|
||||||
return errorCode;
|
return errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets upload result status
|
||||||
|
* @return Upload result status
|
||||||
|
*/
|
||||||
public String getResultStatus() {
|
public String getResultStatus() {
|
||||||
return resultStatus;
|
return resultStatus;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue