diff --git a/app/build.gradle b/app/build.gradle index 05e1d905..dca03e46 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 19 targetSdkVersion 25 - versionCode 3 - versionName "1.1.0" + versionCode 4 + versionName "1.1.1" archivesBaseName = "mTHMMY-v$versionName" } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 8d844e67..2343f78d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -102,7 +102,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), layoutManager.getOrientation()); recyclerView.addItemDecoration(dividerItemDecoration); - downloadsAdapter = new DownloadsAdapter(getApplicationContext(), parsedDownloads); + downloadsAdapter = new DownloadsAdapter(this, parsedDownloads); recyclerView.setAdapter(downloadsAdapter); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java index 02c687df..a46dfeea 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java @@ -13,11 +13,15 @@ import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; +import java.net.MalformedURLException; +import java.net.URL; import java.util.ArrayList; import java.util.Objects; import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.model.Download; +import gr.thmmy.mthmmy.model.ThmmyFile; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; @@ -124,7 +128,17 @@ class DownloadsAdapter extends RecyclerView.Adapter { downloadViewHolder.title.setText(tmp); } } else { - //TODO implement download on click + downloadViewHolder.downloadRow.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + try { + ((BaseActivity) context).launchDownloadService(new ThmmyFile( + new URL(download.getUrl()), null, null)); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { downloadViewHolder.upperLinear.setBackgroundColor(context.getResources().getColor(R.color.background, null)); @@ -170,8 +184,8 @@ class DownloadsAdapter extends RecyclerView.Adapter { informationExpandable = (LinearLayout) download.findViewById(R.id.child_board_expandable); title = (TextView) download.findViewById(R.id.download_title); subTitle = (TextView) download.findViewById(R.id.download_sub_title); - extraInfo = (TextView) download.findViewById(R.id.download_extra_info); - uploaderDate = (TextView) download.findViewById(R.id.download_uploader_date); + uploaderDate = (TextView) download.findViewById(R.id.download_extra_info); + extraInfo = (TextView) download.findViewById(R.id.download_uploader_date); informationExpandableBtn = (ImageButton) download.findViewById(R.id.download_information_button); } }