mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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;
|
||||
|
||||
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[]{
|
||||
R.layout.welcome_wikipedia,
|
||||
R.layout.welcome_do_upload,
|
||||
|
|
@ -24,16 +17,34 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
|||
R.layout.welcome_image_details,
|
||||
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) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets total number of layouts
|
||||
* @return Number of layouts
|
||||
*/
|
||||
@Override
|
||||
public int getCount() {
|
||||
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
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return (view == object);
|
||||
|
|
@ -52,16 +63,32 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
|||
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
|
||||
public void destroyItem(ViewGroup container, int position, Object obj) {
|
||||
container.removeView((View) obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used create on clicked callback(s).
|
||||
*/
|
||||
public interface Callback {
|
||||
void onYesClicked();
|
||||
}
|
||||
|
||||
class ViewHolder {
|
||||
ViewHolder(View view) {
|
||||
ButterKnife.bind(this, view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers on click callback on button click
|
||||
*/
|
||||
@OnClick(R.id.welcomeYesButton)
|
||||
void onClicked() {
|
||||
if (callback != null) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,14 @@ public class LogBuilder {
|
|||
private final String schema;
|
||||
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) {
|
||||
this.prefs = prefs;
|
||||
this.data = new JSONObject();
|
||||
|
|
@ -30,6 +38,12 @@ public class LogBuilder {
|
|||
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) {
|
||||
try {
|
||||
data.put(key, value);
|
||||
|
|
@ -39,6 +53,10 @@ public class LogBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes JSON object to URL
|
||||
* @return URL to JSON object
|
||||
*/
|
||||
URL toUrl() {
|
||||
JSONObject fullData = new JSONObject();
|
||||
try {
|
||||
|
|
@ -66,6 +84,9 @@ public class LogBuilder {
|
|||
logTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in false
|
||||
*/
|
||||
public void log() {
|
||||
log(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,20 @@ class LogTask extends AsyncTask<LogBuilder, Void, Boolean> {
|
|||
|
||||
private final MediaWikiApi mwApi;
|
||||
|
||||
/**
|
||||
* Main constructor of LogTask
|
||||
*
|
||||
* @param mwApi Media wiki API instance
|
||||
*/
|
||||
public LogTask(MediaWikiApi mwApi) {
|
||||
this.mwApi = mwApi;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs events in background
|
||||
* @param logBuilders LogBuilder instance
|
||||
* @return Background success state ( TRUE or FALSE )
|
||||
*/
|
||||
@Override
|
||||
protected Boolean doInBackground(LogBuilder... logBuilders) {
|
||||
return mwApi.logEvents(logBuilders);
|
||||
|
|
|
|||
|
|
@ -4,15 +4,29 @@ public class MediaResult {
|
|||
private final String wikiSource;
|
||||
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) {
|
||||
this.wikiSource = wikiSource;
|
||||
this.parseTreeXmlSource = parseTreeXmlSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets wiki source
|
||||
* @return Wiki source
|
||||
*/
|
||||
public String getWikiSource() {
|
||||
return wikiSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets tree parsed in XML
|
||||
* @return XML parsed tree
|
||||
*/
|
||||
public String getParseTreeXmlSource() {
|
||||
return parseTreeXmlSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,24 @@ public class UploadResult {
|
|||
private String imageUrl;
|
||||
private String canonicalFilename;
|
||||
|
||||
/**
|
||||
* Minimal constructor
|
||||
*
|
||||
* @param resultStatus Upload result status
|
||||
* @param errorCode Upload error code
|
||||
*/
|
||||
UploadResult(String resultStatus, String errorCode) {
|
||||
this.resultStatus = resultStatus;
|
||||
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) {
|
||||
this.resultStatus = resultStatus;
|
||||
this.dateUploaded = dateUploaded;
|
||||
|
|
@ -21,22 +34,42 @@ public class UploadResult {
|
|||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets uploaded date
|
||||
* @return Upload date
|
||||
*/
|
||||
public Date getDateUploaded() {
|
||||
return dateUploaded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets image url
|
||||
* @return Uploaded image url
|
||||
*/
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets canonical file name
|
||||
* @return Uploaded file name
|
||||
*/
|
||||
public String getCanonicalFilename() {
|
||||
return canonicalFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets upload error code
|
||||
* @return Error code
|
||||
*/
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets upload result status
|
||||
* @return Upload result status
|
||||
*/
|
||||
public String getResultStatus() {
|
||||
return resultStatus;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue