mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #160 from misaochan/media-detail-fragment
PR for 'Desc/License/Cats empty'
This commit is contained in:
commit
f6e699fe42
5 changed files with 44 additions and 23 deletions
|
|
@ -102,7 +102,7 @@ public class CategoryContentProvider extends ContentProvider {
|
|||
|
||||
@Override
|
||||
public int bulkInsert(Uri uri, ContentValues[] values) {
|
||||
Log.d("Commons", "Hello, bulk insert!");
|
||||
Log.d("Commons", "Hello, bulk insert! (CategoryContentProvider)");
|
||||
int uriType = uriMatcher.match(uri);
|
||||
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
|
||||
sqlDB.beginTransaction();
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ public class ContributionsContentProvider extends ContentProvider{
|
|||
|
||||
@Override
|
||||
public int bulkInsert(Uri uri, ContentValues[] values) {
|
||||
Log.d("Commons", "Hello, bulk insert!");
|
||||
Log.d("Commons", "Hello, bulk insert! (ContributionsContentProvider)");
|
||||
int uriType = uriMatcher.match(uri);
|
||||
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
|
||||
sqlDB.beginTransaction();
|
||||
|
|
|
|||
|
|
@ -185,17 +185,17 @@ public class MediaDetailFragment extends Fragment {
|
|||
private void displayMediaDetails(final Media media) {
|
||||
String actualUrl = (media.getLocalUri() != null && !TextUtils.isEmpty(media.getLocalUri().toString())) ? media.getLocalUri().toString() : media.getThumbnailUrl(640);
|
||||
if(actualUrl.startsWith("http")) {
|
||||
Log.d("Volley", "Actual URL starts with http and is: " + actualUrl);
|
||||
|
||||
ImageLoader loader = ((CommonsApplication)getActivity().getApplicationContext()).getImageLoader();
|
||||
MediaWikiImageView mwImage = (MediaWikiImageView)image;
|
||||
mwImage.setLoadingView(loadingProgress); //FIXME: Set this as an attribute
|
||||
mwImage.setMedia(media, loader);
|
||||
|
||||
Log.d("Volley", actualUrl);
|
||||
// FIXME: For transparent images
|
||||
|
||||
// Load image metadata: desc, license, categories
|
||||
// FIXME: keep the spinner going while we load data
|
||||
// FIXME: cache this data
|
||||
// Load image metadata: desc, license, categories
|
||||
detailFetchTask = new AsyncTask<Void, Void, Boolean>() {
|
||||
private MediaDataExtractor extractor;
|
||||
|
||||
|
|
@ -243,6 +243,8 @@ public class MediaDetailFragment extends Fragment {
|
|||
};
|
||||
Utils.executeAsyncTask(detailFetchTask);
|
||||
} else {
|
||||
//FIXME: This branch does not display desc, categories, and license
|
||||
Log.d("Volley", "Actual URL does not start with http and is: " + actualUrl);
|
||||
com.nostra13.universalimageloader.core.ImageLoader.getInstance().displayImage(actualUrl, image, displayOptions, new ImageLoadingListener() {
|
||||
public void onLoadingStarted(String s, View view) {
|
||||
loadingProgress.setVisibility(View.VISIBLE);
|
||||
|
|
@ -260,10 +262,26 @@ public class MediaDetailFragment extends Fragment {
|
|||
if(bitmap.hasAlpha()) {
|
||||
image.setBackgroundResource(android.R.color.white);
|
||||
}
|
||||
|
||||
// Set text of desc, license, and categories
|
||||
// FIXME: This reveals the desc, license, and categories fields, but displays the wrong desc and categories
|
||||
desc.setText(prettyDescription(media));
|
||||
license.setText(prettyLicense(media));
|
||||
|
||||
categoryNames.removeAll(categoryNames);
|
||||
categoryNames.addAll(media.getCategories());
|
||||
|
||||
categoriesLoaded = true;
|
||||
categoriesPresent = (categoryNames.size() > 0);
|
||||
if (!categoriesPresent) {
|
||||
// Stick in a filler element.
|
||||
categoryNames.add(getString(R.string.detail_panel_cats_none));
|
||||
}
|
||||
rebuildCatList();
|
||||
}
|
||||
|
||||
public void onLoadingCancelled(String s, View view) {
|
||||
throw new RuntimeException("Image loading cancelled. But why?");
|
||||
Log.e("Volley", "Image loading cancelled. But why?");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,15 +36,13 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
|||
private Boolean editable;
|
||||
private CommonsApplication app;
|
||||
|
||||
public void onPageScrolled(int i, float v, int i2) {
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
public MediaDetailPagerFragment() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public void onPageSelected(int i) {
|
||||
}
|
||||
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public MediaDetailPagerFragment(Boolean editable) {
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
public interface MediaDetailProvider {
|
||||
|
|
@ -54,6 +52,8 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
|||
public void registerDataSetObserver(DataSetObserver observer);
|
||||
public void unregisterDataSetObserver(DataSetObserver observer);
|
||||
}
|
||||
|
||||
//FragmentStatePagerAdapter allows user to swipe across collection of images (no. of images undetermined)
|
||||
private class MediaDetailAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
public MediaDetailAdapter(FragmentManager fm) {
|
||||
|
|
@ -79,15 +79,6 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
|||
}
|
||||
}
|
||||
|
||||
public MediaDetailPagerFragment() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public MediaDetailPagerFragment(Boolean editable) {
|
||||
this.editable = editable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_media_detail_pager, container, false);
|
||||
|
|
@ -187,6 +178,7 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
|||
Uri imageUri = Uri.parse(imageUrl);
|
||||
|
||||
DownloadManager.Request req = new DownloadManager.Request(imageUri);
|
||||
//These are not the image title and description fields, they are download descs for notifications
|
||||
req.setDescription(getString(R.string.app_name));
|
||||
req.setTitle(m.getDisplayTitle());
|
||||
req.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
|
|
@ -284,4 +276,15 @@ public class MediaDetailPagerFragment extends Fragment implements ViewPager.OnPa
|
|||
public void showImage(int i) {
|
||||
pager.setCurrentItem(i);
|
||||
}
|
||||
|
||||
public void onPageScrolled(int i, float v, int i2) {
|
||||
getActivity().supportInvalidateOptionsMenu();
|
||||
}
|
||||
|
||||
public void onPageSelected(int i) {
|
||||
}
|
||||
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ public class ModificationsContentProvider extends ContentProvider{
|
|||
|
||||
@Override
|
||||
public int bulkInsert(Uri uri, ContentValues[] values) {
|
||||
Log.d("Commons", "Hello, bulk insert!");
|
||||
Log.d("Commons", "Hello, bulk insert! (ModificationsContentProvider)");
|
||||
int uriType = uriMatcher.match(uri);
|
||||
SQLiteDatabase sqlDB = dbOpenHelper.getWritableDatabase();
|
||||
sqlDB.beginTransaction();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue