Browse Source

Added download functionality to downloads activity

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
3eebae2e98
  1. 4
      app/build.gradle
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
  3. 20
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java

4
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"
}

2
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

20
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<RecyclerView.ViewHolder> {
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<RecyclerView.ViewHolder> {
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);
}
}

Loading…
Cancel
Save