mirror of https://github.com/ThmmyNoLife/mTHMMY
Apostolos Fanakis
8 years ago
16 changed files with 776 additions and 106 deletions
@ -0,0 +1,274 @@ |
|||
package gr.thmmy.mthmmy.activities.downloads; |
|||
|
|||
import android.net.Uri; |
|||
import android.os.AsyncTask; |
|||
import android.os.Bundle; |
|||
import android.support.design.widget.FloatingActionButton; |
|||
import android.support.v7.widget.DividerItemDecoration; |
|||
import android.support.v7.widget.LinearLayoutManager; |
|||
import android.support.v7.widget.RecyclerView; |
|||
import android.support.v7.widget.Toolbar; |
|||
import android.view.View; |
|||
import android.widget.ProgressBar; |
|||
import android.widget.Toast; |
|||
|
|||
import org.jsoup.Jsoup; |
|||
import org.jsoup.nodes.Document; |
|||
import org.jsoup.nodes.Element; |
|||
import org.jsoup.select.Elements; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Objects; |
|||
|
|||
import javax.net.ssl.SSLHandshakeException; |
|||
|
|||
import gr.thmmy.mthmmy.R; |
|||
import gr.thmmy.mthmmy.base.BaseActivity; |
|||
import gr.thmmy.mthmmy.model.Download; |
|||
import gr.thmmy.mthmmy.model.LinkTarget; |
|||
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
|||
import mthmmy.utils.Report; |
|||
import okhttp3.Request; |
|||
import okhttp3.Response; |
|||
|
|||
public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener { |
|||
/** |
|||
* Debug Tag for logging debug output to LogCat |
|||
*/ |
|||
@SuppressWarnings("unused") |
|||
private static final String TAG = "DownloadsActivity"; |
|||
/** |
|||
* The key to use when putting download's url String to {@link DownloadsActivity}'s Bundle. |
|||
*/ |
|||
public static final String BUNDLE_DOWNLOADS_URL = "DOWNLOADS_URL"; |
|||
/** |
|||
* The key to use when putting download's title String to {@link DownloadsActivity}'s Bundle. |
|||
*/ |
|||
public static final String BUNDLE_DOWNLOADS_TITLE = "DOWNLOADS_TITLE"; |
|||
private static final String downloadsIndexUrl = "https://www.thmmy.gr/smf/index.php?action=tpmod;dl;"; |
|||
private String downloadsUrl; |
|||
String downloadsTitle; |
|||
private ArrayList<Download> parsedDownloads = new ArrayList<>(); |
|||
|
|||
private MaterialProgressBar progressBar; |
|||
private RecyclerView recyclerView; |
|||
private DownloadsAdapter downloadsAdapter; |
|||
private FloatingActionButton uploadFAB; |
|||
|
|||
private ParseDownloadPageTask parseDownloadPageTask; |
|||
private int numberOfPages = -1; |
|||
private int pagesLoaded = 0; |
|||
private boolean isLoadingMore; |
|||
private static final int visibleThreshold = 5; |
|||
private int lastVisibleItem, totalItemCount; |
|||
|
|||
@Override |
|||
protected void onCreate(Bundle savedInstanceState) { |
|||
super.onCreate(savedInstanceState); |
|||
setContentView(R.layout.activity_downloads); |
|||
|
|||
Bundle extras = getIntent().getExtras(); |
|||
downloadsTitle = extras.getString(BUNDLE_DOWNLOADS_TITLE); |
|||
if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) |
|||
downloadsTitle = "Downloads"; |
|||
downloadsUrl = extras.getString(BUNDLE_DOWNLOADS_URL); |
|||
if (downloadsUrl != null && !Objects.equals(downloadsUrl, "")) { |
|||
LinkTarget.Target target = LinkTarget.resolveLinkTarget(Uri.parse(downloadsUrl)); |
|||
if (!target.is(LinkTarget.Target.DOWNLOADS)) { |
|||
Report.e(TAG, "Bundle came with a non board url!\nUrl:\n" + downloadsUrl); |
|||
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show(); |
|||
finish(); |
|||
} |
|||
} else downloadsUrl = downloadsIndexUrl; |
|||
|
|||
toolbar = (Toolbar) findViewById(R.id.toolbar); |
|||
toolbar.setTitle(downloadsTitle); |
|||
/*setSupportActionBar(toolbar); |
|||
if (getSupportActionBar() != null) { |
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|||
getSupportActionBar().setDisplayShowHomeEnabled(true); |
|||
}*/ |
|||
|
|||
createDrawer(); |
|||
|
|||
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); |
|||
|
|||
recyclerView = (RecyclerView) findViewById(R.id.downloads_recycler_view); |
|||
recyclerView.setHasFixedSize(true); |
|||
final LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); |
|||
recyclerView.setLayoutManager(layoutManager); |
|||
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), |
|||
layoutManager.getOrientation()); |
|||
recyclerView.addItemDecoration(dividerItemDecoration); |
|||
downloadsAdapter = new DownloadsAdapter(getApplicationContext(), parsedDownloads); |
|||
recyclerView.setAdapter(downloadsAdapter); |
|||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { |
|||
@Override |
|||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { |
|||
super.onScrolled(recyclerView, dx, dy); |
|||
totalItemCount = layoutManager.getItemCount(); |
|||
lastVisibleItem = layoutManager.findLastVisibleItemPosition(); |
|||
|
|||
if (!isLoadingMore && totalItemCount <= (lastVisibleItem + visibleThreshold)) { |
|||
isLoadingMore = true; |
|||
onLoadMore(); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
uploadFAB = (FloatingActionButton) findViewById(R.id.download_fab); |
|||
uploadFAB.setEnabled(false); |
|||
|
|||
parseDownloadPageTask = new ParseDownloadPageTask(); |
|||
parseDownloadPageTask.execute(downloadsUrl); |
|||
} |
|||
|
|||
@Override |
|||
public void onLoadMore() { |
|||
if (pagesLoaded < numberOfPages) { |
|||
parsedDownloads.add(null); |
|||
downloadsAdapter.notifyItemInserted(parsedDownloads.size()); |
|||
|
|||
//Load data
|
|||
parseDownloadPageTask = new ParseDownloadPageTask(); |
|||
if (downloadsUrl.contains("tpstart")) |
|||
parseDownloadPageTask.execute(downloadsUrl.substring(0 |
|||
, downloadsUrl.lastIndexOf(";tpstart=")) + ";tpstart=" + pagesLoaded * 10); |
|||
else parseDownloadPageTask.execute(downloadsUrl + ";tpstart=" + pagesLoaded * 10); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void onBackPressed() { |
|||
if (drawer.isDrawerOpen()) { |
|||
drawer.closeDrawer(); |
|||
return; |
|||
} |
|||
super.onBackPressed(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onResume() { |
|||
drawer.setSelection(-1); |
|||
super.onResume(); |
|||
} |
|||
|
|||
@Override |
|||
protected void onDestroy() { |
|||
super.onDestroy(); |
|||
recyclerView.setAdapter(null); |
|||
if (parseDownloadPageTask != null && parseDownloadPageTask.getStatus() != AsyncTask.Status.RUNNING) |
|||
parseDownloadPageTask.cancel(true); |
|||
} |
|||
|
|||
/** |
|||
* An {@link AsyncTask} that handles asynchronous fetching of a downloads page and parsing it's |
|||
* data. {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link RecyclerView#swapAdapter} |
|||
* to build graphics. |
|||
* <p> |
|||
* <p>Calling TopicTask's {@link AsyncTask#execute execute} method needs to have profile's url |
|||
* as String parameter!</p> |
|||
*/ |
|||
class ParseDownloadPageTask extends AsyncTask<String, Void, Void> { |
|||
/** |
|||
* Debug Tag for logging debug output to LogCat |
|||
*/ |
|||
private static final String TAG = "ParseDownloadPageTask"; //Separate tag for AsyncTask
|
|||
private String thisPageUrl; |
|||
|
|||
@Override |
|||
protected void onPreExecute() { |
|||
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); |
|||
if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(false); |
|||
} |
|||
|
|||
@Override |
|||
protected Void doInBackground(String... downloadsUrl) { |
|||
thisPageUrl = downloadsUrl[0]; |
|||
Request request = new Request.Builder() |
|||
.url(downloadsUrl[0]) |
|||
.build(); |
|||
try { |
|||
Response response = BaseActivity.getClient().newCall(request).execute(); |
|||
parseDownloads(Jsoup.parse(response.body().string())); |
|||
} catch (SSLHandshakeException e) { |
|||
Report.w(TAG, "Certificate problem (please switch to unsafe connection)."); |
|||
} catch (Exception e) { |
|||
Report.e("TAG", "ERROR", e); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
protected void onPostExecute(Void voids) { |
|||
if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) |
|||
toolbar.setTitle(downloadsTitle); |
|||
|
|||
++pagesLoaded; |
|||
if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); |
|||
progressBar.setVisibility(ProgressBar.INVISIBLE); |
|||
downloadsAdapter.notifyDataSetChanged(); |
|||
isLoadingMore = false; |
|||
} |
|||
|
|||
private void parseDownloads(Document downloadPage) { |
|||
if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) |
|||
downloadsTitle = downloadPage.select("div.nav>b>a.nav").last().text(); |
|||
|
|||
//Removes loading item
|
|||
if (isLoadingMore) { |
|||
if (parsedDownloads.size() > 0) parsedDownloads.remove(parsedDownloads.size() - 1); |
|||
} |
|||
|
|||
Download.DownloadItemType type; |
|||
if (LinkTarget.resolveLinkTarget(Uri.parse(thisPageUrl)).is(LinkTarget. |
|||
Target.DOWNLOADS_CATEGORY)) type = Download.DownloadItemType.DOWNLOADS_CATEGORY; |
|||
else type = Download.DownloadItemType.DOWNLOADS_FILE; |
|||
|
|||
Elements pages = downloadPage.select("a.navPages"); |
|||
if (pages != null) { |
|||
for (Element page : pages) { |
|||
int pageNumber = Integer.parseInt(page.text()); |
|||
if (pageNumber > numberOfPages) numberOfPages = pageNumber; |
|||
} |
|||
} else numberOfPages = 1; |
|||
|
|||
Elements rows = downloadPage.select("table.tborder>tbody>tr"); |
|||
if (type == Download.DownloadItemType.DOWNLOADS_CATEGORY) { |
|||
Elements navigationLinks = downloadPage.select("div.nav>b"); |
|||
for (Element row : rows) { |
|||
if (row.select("td").size() == 1) continue; |
|||
|
|||
String url = row.select("b>a").first().attr("href"), |
|||
title = row.select("b>a").first().text(), |
|||
subtitle = row.select("div.smalltext:not(:has(a))").text(); |
|||
if (!row.select("td").last().hasClass("windowbg2")) { |
|||
if (navigationLinks.size() < 4) { |
|||
|
|||
parsedDownloads.add(new Download(type, url, title, subtitle, null, |
|||
true, null)); |
|||
} else { |
|||
String stats = row.text(); |
|||
stats = stats.replace(title, "").replace(subtitle, "").trim(); |
|||
parsedDownloads.add(new Download(type, url, title, subtitle, stats, |
|||
false, null)); |
|||
} |
|||
} else { |
|||
String stats = row.text(); |
|||
stats = stats.replace(title, "").replace(subtitle, "").trim(); |
|||
parsedDownloads.add(new Download(type, url, title, subtitle, stats, |
|||
false, null)); |
|||
} |
|||
} |
|||
} else { |
|||
parsedDownloads.add(new Download(type, |
|||
rows.select("b>a").first().attr("href"), |
|||
rows.select("b>a").first().text(), |
|||
rows.select("div.smalltext:not(:has(a))").text(), |
|||
rows.select("span:not(:has(a))").first().text(), |
|||
false, |
|||
rows.select("span:has(a)").first().html())); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,181 @@ |
|||
package gr.thmmy.mthmmy.activities.downloads; |
|||
|
|||
import android.content.Context; |
|||
import android.content.Intent; |
|||
import android.graphics.Typeface; |
|||
import android.os.Bundle; |
|||
import android.support.v7.widget.RecyclerView; |
|||
import android.view.LayoutInflater; |
|||
import android.view.View; |
|||
import android.view.ViewGroup; |
|||
import android.widget.ImageButton; |
|||
import android.widget.LinearLayout; |
|||
import android.widget.TextView; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Objects; |
|||
|
|||
import gr.thmmy.mthmmy.R; |
|||
import gr.thmmy.mthmmy.model.Download; |
|||
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; |
|||
|
|||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; |
|||
import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_TITLE; |
|||
import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL; |
|||
|
|||
class DownloadsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { |
|||
/** |
|||
* Debug Tag for logging debug output to LogCat |
|||
*/ |
|||
@SuppressWarnings("unused") |
|||
private static final String TAG = "DownloadsAdapter"; |
|||
private final int VIEW_TYPE_DOWNLOAD = 0; |
|||
private final int VIEW_TYPE_LOADING = 1; |
|||
|
|||
private final Context context; |
|||
private ArrayList<Download> parsedDownloads = new ArrayList<>(); |
|||
private final ArrayList<Boolean> downloadExpandableVisibility = new ArrayList<>(); |
|||
|
|||
DownloadsAdapter(Context context, ArrayList<Download> parsedDownloads) { |
|||
this.context = context; |
|||
this.parsedDownloads = parsedDownloads; |
|||
} |
|||
|
|||
interface OnLoadMoreListener { |
|||
void onLoadMore(); |
|||
} |
|||
|
|||
@Override |
|||
public int getItemViewType(int position) { |
|||
return (parsedDownloads.get(position) == null) ? VIEW_TYPE_LOADING : VIEW_TYPE_DOWNLOAD; |
|||
} |
|||
|
|||
@Override |
|||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
|||
if (viewType == VIEW_TYPE_DOWNLOAD) { |
|||
View download = LayoutInflater.from(parent.getContext()). |
|||
inflate(R.layout.activity_downloads_row, parent, false); |
|||
return new DownloadViewHolder(download); |
|||
} else if (viewType == VIEW_TYPE_LOADING) { |
|||
View loading = LayoutInflater.from(parent.getContext()). |
|||
inflate(R.layout.recycler_loading_item, parent, false); |
|||
return new LoadingViewHolder(loading); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Override |
|||
public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) { |
|||
if (holder instanceof DownloadViewHolder) { |
|||
final Download download = parsedDownloads.get(position); |
|||
final DownloadViewHolder downloadViewHolder = (DownloadViewHolder) holder; |
|||
|
|||
if (downloadExpandableVisibility.size() != parsedDownloads.size()) { |
|||
for (int i = downloadExpandableVisibility.size(); i < parsedDownloads.size(); ++i) |
|||
downloadExpandableVisibility.add(false); |
|||
} |
|||
|
|||
if (download.getType() == Download.DownloadItemType.DOWNLOADS_CATEGORY) { |
|||
downloadViewHolder.downloadRow.setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View view) { |
|||
Intent intent = new Intent(context, DownloadsActivity.class); |
|||
Bundle extras = new Bundle(); |
|||
extras.putString(BUNDLE_DOWNLOADS_URL, download.getUrl()); |
|||
extras.putString(BUNDLE_DOWNLOADS_TITLE, download.getTitle()); |
|||
intent.putExtras(extras); |
|||
intent.setFlags(FLAG_ACTIVITY_NEW_TASK); |
|||
context.startActivity(intent); |
|||
} |
|||
}); |
|||
|
|||
if (downloadExpandableVisibility.get(downloadViewHolder.getAdapterPosition())) { |
|||
downloadViewHolder.informationExpandable.setVisibility(View.VISIBLE); |
|||
downloadViewHolder.informationExpandableBtn.setImageResource(R.drawable.ic_arrow_drop_up); |
|||
} else { |
|||
downloadViewHolder.informationExpandable.setVisibility(View.GONE); |
|||
downloadViewHolder.informationExpandableBtn.setImageResource(R.drawable.ic_arrow_drop_down); |
|||
} |
|||
downloadViewHolder.informationExpandableBtn.setOnClickListener(new View.OnClickListener() { |
|||
@Override |
|||
public void onClick(View view) { |
|||
final boolean visible = downloadExpandableVisibility.get(downloadViewHolder. |
|||
getAdapterPosition()); |
|||
if (visible) { |
|||
downloadViewHolder.informationExpandable.setVisibility(View.GONE); |
|||
downloadViewHolder.informationExpandableBtn.setImageResource(R.drawable.ic_arrow_drop_down); |
|||
} else { |
|||
downloadViewHolder.informationExpandable.setVisibility(View.VISIBLE); |
|||
downloadViewHolder.informationExpandableBtn.setImageResource(R.drawable.ic_arrow_drop_up); |
|||
} |
|||
downloadExpandableVisibility.set(downloadViewHolder.getAdapterPosition(), !visible); |
|||
} |
|||
}); |
|||
downloadViewHolder.title.setTypeface(Typeface.createFromAsset(context.getAssets() |
|||
, "fonts/fontawesome-webfont.ttf")); |
|||
if (download.hasSubCategory()) { |
|||
String tmp = context.getResources().getString(R.string.fa_folder) + " " |
|||
+ download.getTitle(); |
|||
downloadViewHolder.title.setText(tmp); |
|||
} else { |
|||
String tmp = context.getResources().getString(R.string.fa_file) + " " |
|||
+ download.getTitle(); |
|||
downloadViewHolder.title.setText(tmp); |
|||
} |
|||
} else { |
|||
//TODO implement download on click
|
|||
|
|||
downloadViewHolder.upperLinear.setBackgroundColor(context.getResources().getColor(R.color.background)); |
|||
downloadViewHolder.informationExpandable.setVisibility(View.VISIBLE); |
|||
downloadViewHolder.informationExpandableBtn.setVisibility(View.GONE); |
|||
downloadViewHolder.informationExpandableBtn.setEnabled(false); |
|||
downloadViewHolder.title.setText(download.getTitle()); |
|||
} |
|||
|
|||
downloadViewHolder.subTitle.setText(download.getSubTitle()); |
|||
String tmp = download.getExtraInfo(); |
|||
if (tmp != null && !Objects.equals(tmp, "")) |
|||
downloadViewHolder.extraInfo.setText(tmp); |
|||
else downloadViewHolder.extraInfo.setVisibility(View.GONE); |
|||
tmp = download.getStatNumbers(); |
|||
if (tmp != null && !Objects.equals(tmp, "")) |
|||
downloadViewHolder.uploaderDate.setText(tmp); |
|||
else downloadViewHolder.uploaderDate.setVisibility(View.GONE); |
|||
} else if (holder instanceof LoadingViewHolder) { |
|||
LoadingViewHolder loadingViewHolder = (LoadingViewHolder) holder; |
|||
loadingViewHolder.progressBar.setIndeterminate(true); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public int getItemCount() { |
|||
return parsedDownloads.size(); |
|||
} |
|||
|
|||
private static class DownloadViewHolder extends RecyclerView.ViewHolder { |
|||
final LinearLayout upperLinear, downloadRow, informationExpandable; |
|||
final TextView title, subTitle, extraInfo, uploaderDate; |
|||
final ImageButton informationExpandableBtn; |
|||
|
|||
DownloadViewHolder(View download) { |
|||
super(download); |
|||
upperLinear = (LinearLayout) download.findViewById(R.id.upper_linear); |
|||
downloadRow = (LinearLayout) download.findViewById(R.id.download_row); |
|||
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); |
|||
informationExpandableBtn = (ImageButton) download.findViewById(R.id.download_information_button); |
|||
} |
|||
} |
|||
|
|||
private static class LoadingViewHolder extends RecyclerView.ViewHolder { |
|||
final MaterialProgressBar progressBar; |
|||
|
|||
LoadingViewHolder(View itemView) { |
|||
super(itemView); |
|||
progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,58 @@ |
|||
package gr.thmmy.mthmmy.model; |
|||
|
|||
public class Download { |
|||
public enum DownloadItemType {DOWNLOADS_CATEGORY, DOWNLOADS_FILE} |
|||
|
|||
private final String url, title, subTitle, statNumbers, extraInfo; |
|||
private final boolean hasSubCategory; |
|||
private final DownloadItemType type; |
|||
|
|||
public Download() { |
|||
type = null; |
|||
url = null; |
|||
title = null; |
|||
subTitle = null; |
|||
statNumbers = null; |
|||
hasSubCategory = false; |
|||
extraInfo = null; |
|||
} |
|||
|
|||
public Download(DownloadItemType type, String url, String title, String subTitle, |
|||
String statNumbers, boolean hasSubCategory, String extraInfo) { |
|||
this.type = type; |
|||
this.url = url; |
|||
this.title = title; |
|||
this.subTitle = subTitle; |
|||
this.statNumbers = statNumbers; |
|||
this.hasSubCategory = hasSubCategory; |
|||
this.extraInfo = extraInfo; |
|||
} |
|||
|
|||
public DownloadItemType getType() { |
|||
return type; |
|||
} |
|||
|
|||
public String getUrl() { |
|||
return url; |
|||
} |
|||
|
|||
public String getTitle() { |
|||
return title; |
|||
} |
|||
|
|||
public String getSubTitle() { |
|||
return subTitle; |
|||
} |
|||
|
|||
public String getStatNumbers() { |
|||
return statNumbers; |
|||
} |
|||
|
|||
public String getExtraInfo() { |
|||
return extraInfo; |
|||
} |
|||
|
|||
public boolean hasSubCategory() { |
|||
return hasSubCategory; |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|||
<vector |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:width="24dp" |
|||
android:height="24dp" |
|||
android:viewportHeight="24.0" |
|||
android:viewportWidth="24.0"> |
|||
<path |
|||
android:fillColor="#FFFFFF" |
|||
android:pathData="M9,16h6v-6h4l-7,-7 -7,7h4zM5,18h14v2L5,20z"/> |
|||
</vector> |
@ -0,0 +1,62 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<android.support.design.widget.CoordinatorLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
xmlns:app="http://schemas.android.com/apk/res-auto" |
|||
xmlns:tools="http://schemas.android.com/tools" |
|||
android:id="@+id/main_content" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:fitsSystemWindows="true" |
|||
tools:context=".activities.downloads.DownloadsActivity"> |
|||
|
|||
<android.support.design.widget.AppBarLayout |
|||
android:id="@+id/appbar" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:paddingTop="@dimen/appbar_padding_top" |
|||
android:theme="@style/ToolbarTheme"> |
|||
|
|||
<android.support.v7.widget.Toolbar |
|||
android:id="@+id/toolbar" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="?attr/actionBarSize" |
|||
android:background="?attr/colorPrimary" |
|||
app:popupTheme="@style/ToolbarTheme"> |
|||
</android.support.v7.widget.Toolbar> |
|||
</android.support.design.widget.AppBarLayout> |
|||
|
|||
<android.support.v7.widget.RecyclerView |
|||
android:id="@+id/downloads_recycler_view" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="match_parent" |
|||
android:layout_gravity="top|start" |
|||
android:layout_marginTop="64dp" |
|||
android:background="@color/background" |
|||
android:scrollbars="none" |
|||
tools:context="gr.thmmy.mthmmy.activities.downloads.DownloadsActivity"> |
|||
</android.support.v7.widget.RecyclerView> |
|||
|
|||
<me.zhanghai.android.materialprogressbar.MaterialProgressBar |
|||
android:id="@+id/progressBar" |
|||
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="@dimen/progress_bar_height" |
|||
android:indeterminate="true" |
|||
android:visibility="invisible" |
|||
app:layout_anchor="@id/appbar" |
|||
app:layout_anchorGravity="bottom|center" |
|||
app:mpb_indeterminateTint="@color/accent" |
|||
app:mpb_progressStyle="horizontal"/> |
|||
|
|||
<android.support.design.widget.FloatingActionButton |
|||
android:id="@+id/download_fab" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:layout_gravity="bottom|end" |
|||
android:layout_marginBottom="@dimen/fab_margins" |
|||
android:layout_marginEnd="@dimen/fab_margins" |
|||
app:layout_behavior="gr.thmmy.mthmmy.utils.ScrollAwareFABBehavior" |
|||
app:srcCompat="@drawable/ic_file_upload"/> |
|||
</android.support.design.widget.CoordinatorLayout> |
|||
|
|||
|
@ -0,0 +1,65 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<LinearLayout |
|||
xmlns:android="http://schemas.android.com/apk/res/android" |
|||
android:id="@+id/upper_linear" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:background="@color/card_background" |
|||
android:orientation="vertical" |
|||
android:paddingEnd="16dp" |
|||
android:paddingStart="16dp"> |
|||
|
|||
<LinearLayout |
|||
android:id="@+id/download_row" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginBottom="5dp" |
|||
android:layout_marginTop="5dp" |
|||
android:orientation="horizontal"> |
|||
|
|||
<TextView |
|||
android:id="@+id/download_title" |
|||
android:layout_width="0dp" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginBottom="2dp" |
|||
android:layout_marginTop="2dp" |
|||
android:layout_weight="1" |
|||
android:textColor="@color/accent" |
|||
android:textSize="18sp"/> |
|||
|
|||
<ImageButton |
|||
android:id="@+id/download_information_button" |
|||
android:layout_width="wrap_content" |
|||
android:layout_height="wrap_content" |
|||
android:background="@color/card_background" |
|||
android:contentDescription="@string/child_board_button" |
|||
android:src="@drawable/ic_arrow_drop_down"/> |
|||
</LinearLayout> |
|||
|
|||
<LinearLayout |
|||
android:id="@+id/child_board_expandable" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:layout_marginBottom="5dp" |
|||
android:orientation="vertical" |
|||
android:visibility="gone"> |
|||
|
|||
<TextView |
|||
android:id="@+id/download_sub_title" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:textColor="@color/secondary_text"/> |
|||
|
|||
<TextView |
|||
android:id="@+id/download_extra_info" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:textColor="@color/secondary_text"/> |
|||
|
|||
<TextView |
|||
android:id="@+id/download_uploader_date" |
|||
android:layout_width="match_parent" |
|||
android:layout_height="wrap_content" |
|||
android:textColor="@color/secondary_text"/> |
|||
</LinearLayout> |
|||
</LinearLayout> |
Loading…
Reference in new issue