diff --git a/.gitignore b/.gitignore
index 9c4de58..09fb1e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,51 @@
-.gradle
-/local.properties
-/.idea/workspace.xml
-/.idea/libraries
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# generated files
+bin/
+gen/
+
+# ignore Gradle files
+.gradle/
+build/
+
+# local configuration file (sdk path, etc)
+local.properties
+
+# Proguard folder generated by Eclipse
+proguard/
+
+# Ant
+build.xml
+
+# Maven
+target/
+pom.xml.*
+release.properties
+
+# Eclipse
+.classpath
+.project
+.externalToolBuilders/
+
+# IntelliJ
+*.iml
+*.ipr
+*.iws
+.idea/
+out/
+
+# Mac
.DS_Store
-/build
-/captures
+
+# Crashlytics
+crashlytics.properties
+crashlytics-build.properties
+com_crashlytics_export_strings.xml
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..85ee276
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index fc72a92..9ad087b 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 22
- buildToolsVersion "23.0.0 rc2"
+ buildToolsVersion "22.0.1"
defaultConfig {
applicationId "cz.kinst.jakub.statefulviewsample"
@@ -22,4 +22,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
+ compile project(':library')
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index eb21bf2..0e8a52f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,21 +1,21 @@
+ package="cz.kinst.jakub.statefulviewsample">
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/app/src/main/java/cz/kinst/jakub/statefulviewsample/MainActivity.java b/app/src/main/java/cz/kinst/jakub/statefulviewsample/MainActivity.java
index dc4f591..a871420 100644
--- a/app/src/main/java/cz/kinst/jakub/statefulviewsample/MainActivity.java
+++ b/app/src/main/java/cz/kinst/jakub/statefulviewsample/MainActivity.java
@@ -2,10 +2,10 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
-import android.view.Menu;
-import android.view.MenuItem;
import android.view.View;
+import com.strv.StatefulView;
+
public class MainActivity extends AppCompatActivity
{
@@ -13,16 +13,6 @@ public class MainActivity extends AppCompatActivity
StatefulView mStatefulView;
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mStatefulView = (StatefulView) findViewById(R.id.stateful);
- mStatefulView.showProgress();
- }
-
-
public void showContent(View view)
{
mStatefulView.showContent();
@@ -48,28 +38,12 @@ public void showEmpty(View view)
@Override
- public boolean onCreateOptionsMenu(Menu menu)
+ protected void onCreate(Bundle savedInstanceState)
{
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_main, menu);
- return true;
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ mStatefulView = (StatefulView) findViewById(R.id.stateful);
+ mStatefulView.showProgress();
}
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
-
- //noinspection SimplifiableIfStatement
- if(id == R.id.action_settings)
- {
- return true;
- }
-
- return super.onOptionsItemSelected(item);
- }
}
diff --git a/app/src/main/java/cz/kinst/jakub/statefulviewsample/ViewState.java b/app/src/main/java/cz/kinst/jakub/statefulviewsample/ViewState.java
deleted file mode 100644
index d83b66b..0000000
--- a/app/src/main/java/cz/kinst/jakub/statefulviewsample/ViewState.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package cz.kinst.jakub.statefulviewsample;
-
-
-public enum ViewState
-{
- CONTENT, PROGRESS, OFFLINE, EMPTY
-}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index d98d547..35e2424 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,12 +1,10 @@
-
+ android:layout_weight="1"
+ app:offlineLayout="@layout/custom_placeholder_offline"
+ app:stateTextAppearance="@style/TextAppearance.AppCompat.Body1">
-
+
diff --git a/app/src/main/res/layout/custom_placeholder_offline.xml b/app/src/main/res/layout/custom_placeholder_offline.xml
new file mode 100644
index 0000000..6b3e528
--- /dev/null
+++ b/app/src/main/res/layout/custom_placeholder_offline.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/view/CountdownTextView.java b/app/src/main/res/layout/view/CountdownTextView.java
deleted file mode 100644
index 6e862b6..0000000
--- a/app/src/main/res/layout/view/CountdownTextView.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.os.CountDownTimer;
-import android.support.annotation.StringRes;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-import com.stereocast.R;
-
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * Created by jakubkinst on 20/07/15.
- */
-public class CountdownTextView extends TextView
-{
- private CountDownTimer mCountDownTimer;
- private OnCountdownFinishedListener mListener;
-
-
- public interface OnCountdownFinishedListener
- {
- void onCountdownFinished();
- }
-
-
- public CountdownTextView(Context context)
- {
- super(context);
- init();
- }
-
-
- public CountdownTextView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- init();
- }
-
-
- public CountdownTextView(Context context, AttributeSet attrs, int defStyleAttr)
- {
- super(context, attrs, defStyleAttr);
- init();
- }
-
-
- public void setOnCountdownFinishedListener(OnCountdownFinishedListener listener)
- {
- mListener = listener;
- }
-
-
- public void startCountdown(Date targetDate)
- {
- cancelTimer();
- mCountDownTimer = new CountDownTimer(targetDate.getTime() - new Date().getTime(), 1000)
- {
- public void onTick(long millisUntilFinished)
- {
- long hours = TimeUnit.MILLISECONDS.toHours(millisUntilFinished);
- long minutes = TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished)
- - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished));
- long seconds = TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished)
- - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished));
-
- if(hours > 1)
- setText(String.format(getString(R.string.fragment_show_available_remaining_hours), hours, minutes, seconds));
- else if(hours == 1)
- setText(String.format(getString(R.string.fragment_show_available_remaining_hour), hours, minutes, seconds));
- else if(minutes >= 1)
- setText(String.format(getString(R.string.fragment_show_available_remaining_minutes), minutes, seconds));
- else
- setText(String.format(getString(R.string.fragment_show_available_remaining_seconds), seconds));
-
- }
-
-
- public void onFinish()
- {
- if(mListener != null)
- mListener.onCountdownFinished();
- }
- }.start();
- }
-
-
- public void cancelTimer()
- {
- if(mCountDownTimer != null)
- mCountDownTimer.cancel();
- }
-
-
- @Override
- protected void onDetachedFromWindow()
- {
- cancelTimer();
- super.onDetachedFromWindow();
- }
-
-
- private void init()
- {
-
- }
-
-
- private String getString(@StringRes int resourceId)
- {
- return getContext().getString(resourceId);
- }
-}
diff --git a/app/src/main/res/layout/view/EmailSuggestionAutoCompleteTextView.java b/app/src/main/res/layout/view/EmailSuggestionAutoCompleteTextView.java
deleted file mode 100644
index 94fe460..0000000
--- a/app/src/main/res/layout/view/EmailSuggestionAutoCompleteTextView.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-
-import com.stereocast.utility.UserUtility;
-
-
-public class EmailSuggestionAutoCompleteTextView extends AutoCompleteTextView
-{
-
- private int mThreshold;
-
-
- public EmailSuggestionAutoCompleteTextView(Context context)
- {
- super(context);
- }
-
-
- public EmailSuggestionAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle)
- {
- super(context, attrs, defStyle);
- }
-
-
- public EmailSuggestionAutoCompleteTextView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- ArrayAdapter adapter = new ArrayAdapter<>(context, android.R.layout.simple_dropdown_item_1line, UserUtility.getDeviceEmailAccounts());
- setAdapter(adapter);
- }
-
-
- @Override
- public void setThreshold(int threshold)
- {
- if(threshold < 0)
- {
- threshold = 0;
- }
- mThreshold = threshold;
- }
-
-
- @Override
- public boolean enoughToFilter()
- {
- return getText().length() >= mThreshold;
- }
-
-
- @Override
- public int getThreshold()
- {
- return mThreshold;
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/view/EventHeaderItemView.java b/app/src/main/res/layout/view/EventHeaderItemView.java
deleted file mode 100644
index 527b932..0000000
--- a/app/src/main/res/layout/view/EventHeaderItemView.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.bumptech.glide.Glide;
-import com.stereocast.R;
-import com.stereocast.StereocastApplication;
-import com.stereocast.entity.Event;
-import com.stereocast.entity.Track;
-import com.stereocast.listener.PurchaseConnector;
-
-import java.util.Date;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-
-
-/**
- * Created by tomasgarba on 07/24/15.
- */
-public class EventHeaderItemView extends FrameLayout
-{
- private final PurchaseConnector mPurchaseConnector;
- @Bind(R.id.include_tracklist_header_title)
- TextView mTitle;
- @Bind(R.id.include_tracklist_header_subtitle)
- TextView mSubtitle;
- @Bind(R.id.include_tracklist_header_cover)
- ImageView mImageView;
- @Bind(R.id.include_tracklist_header_primary_button)
- Button mBuyCurrentButton;
- @Bind(R.id.include_event_tracklist_buy_all_bar_buy_all_button)
- TextView mBuyAllButton;
- @Bind(R.id.include_event_tracklist_buy_all_bar_all_purchased)
- TextView mAllPurchasedText;
- private Event mEvent;
- private String mTrackPrice = "";
- private String mEventPrice = "";
-
-
- public EventHeaderItemView(Context context, PurchaseConnector purchaseConnector,
- Event event, String trackPrice,
- String eventPrice)
- {
- super(context);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
-
- LayoutInflater.from(getContext()).inflate(R.layout.include_tracklist_header, this);
- ButterKnife.bind(this, this);
- mPurchaseConnector = purchaseConnector;
- mEvent = event;
- mTrackPrice = trackPrice;
- mEventPrice = eventPrice;
- }
-
-
- public void bind(Event event, String trackPrice, String eventPrice)
- {
- mEvent = event;
- mTrackPrice = trackPrice;
- mEventPrice = eventPrice;
-
- if(mEvent != null)
- {
- Track mCurrentTrack = mEvent.getCurrentlyPlayingTrack();
-
- if(mCurrentTrack != null)
- {
- Glide.with(StereocastApplication.getContext())
- .load(mEvent.getCoverUrl())
- .placeholder(R.drawable.image_cover_placeholder)
- .error(R.drawable.image_cover_placeholder)
- .into(mImageView);
- mTitle.setText(mCurrentTrack.getTitle());
- mSubtitle.setText(mCurrentTrack.getSubtitle());
-
- if(mPurchaseConnector.isTrackPurchased(mCurrentTrack))
- {
- mBuyCurrentButton.setText(R.string.title_purchased);
- mBuyCurrentButton.setEnabled(false);
- }
- else
- {
- mBuyCurrentButton.setEnabled(true);
- mBuyCurrentButton.setText(String.format(StereocastApplication.getContext().getString(R.string.fragment_event_i_want_this_one), mTrackPrice));
- }
- }
-
- if(mPurchaseConnector.isEventPurchased(mEvent))
- {
- mBuyAllButton.setVisibility(View.GONE);
- mAllPurchasedText.setText(R.string.title_purchased);
- mAllPurchasedText.setVisibility(View.VISIBLE);
- }
- else
- {
- mBuyAllButton.setVisibility(View.VISIBLE);
- mBuyAllButton.setText(String.format(StereocastApplication.getContext().getString(R.string.track_state_buy_all), mEventPrice));
- mAllPurchasedText.setVisibility(View.GONE);
- }
-
- // decide if header should be displayed
- Date now = new Date();
- if(mEvent.getFinishedAt() != null && mEvent.getFinishedAt().before(now) && mEvent.getPurchaseWindowEnd().after(now))
- {
- this.setVisibility(View.GONE);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0));
- }
- else
- {
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- this.setVisibility(View.VISIBLE);
- }
- }
- else
- {
- // hide header when event is null, showing in Library or Download fragment
- this.setVisibility(View.GONE);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0));
- }
- }
-
-
- @OnClick(R.id.include_tracklist_header_primary_button)
- void buyCurrentTrack()
- {
- if(mEvent != null)
- {
- Track currentTrack = mEvent.getCurrentlyPlayingTrack();
- mPurchaseConnector.purchaseTrack(currentTrack);
- }
- }
-
-
- @OnClick(R.id.include_event_tracklist_buy_all_bar_buy_all_button)
- void onPurchaseEventClicked()
- {
- if(mEvent != null)
- {
- mPurchaseConnector.purchaseEvent(mEvent);
- }
- }
-}
diff --git a/app/src/main/res/layout/view/EventTrackItemView.java b/app/src/main/res/layout/view/EventTrackItemView.java
deleted file mode 100644
index 8bc934b..0000000
--- a/app/src/main/res/layout/view/EventTrackItemView.java
+++ /dev/null
@@ -1,257 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.ProgressBar;
-import android.widget.TextView;
-
-import com.filippudak.ProgressPieView.ProgressPieView;
-import com.stereocast.BusProvider;
-import com.stereocast.R;
-import com.stereocast.entity.Track;
-import com.stereocast.event.download.TrackDownloadCancelEvent;
-import com.stereocast.event.download.TrackDownloadErrorEvent;
-import com.stereocast.event.download.TrackDownloadEvent;
-import com.stereocast.listener.PurchaseConnector;
-import com.stereocast.utility.NavigationHandler;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-
-
-/**
- * Created by jakubkinst on 14/07/15.
- */
-public class EventTrackItemView extends LinearLayout implements View.OnClickListener, View.OnLongClickListener
-{
- private final PurchaseConnector mPurchaseConnector;
- private final NavigationHandler mNavigationHandler;
- @Bind(R.id.view_track_item_title)
- TextView mTitle;
- @Bind(R.id.view_track_item_subtitle)
- TextView mSubtitle;
- @Bind(R.id.view_track_item_download_percent)
- ProgressPieView mDownloadProgress;
- @Bind(R.id.view_track_item_download_button)
- TintableImageView mDownloadButton;
- @Bind(R.id.view_track_item_download_complete)
- TextView mDownloadCompleteText;
- @Bind(R.id.view_track_item_buy)
- TextView mBuyText;
- @Bind(R.id.view_track_item_waiting)
- TextView mWaitingText;
- @Bind(R.id.view_track_item_loading)
- ProgressBar mLoadingProgress;
-
- private Track mTrack;
- private State mState = State.READY_TO_DOWNLOAD;
-
-
- private enum State
- {
- NOT_PUBLISHED, PUBLISHED, WAITING, READY_TO_DOWNLOAD, DOWNLOADING, DOWNLOADED, LOADING
- }
-
-
- public EventTrackItemView(Context context, PurchaseConnector purchaseConnector, NavigationHandler navigationHandler)
- {
- super(context);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- LayoutInflater.from(getContext()).inflate(R.layout.view_event_track_item, this);
- ButterKnife.bind(this, this);
- setOnClickListener(this);
- setOnLongClickListener(this);
- mPurchaseConnector = purchaseConnector;
- mNavigationHandler = navigationHandler;
- }
-
-
- public void onEventMainThread(final TrackDownloadErrorEvent event)
- {
- if(mTrack != null && mTrack.getId().equals(event.getTrackId()))
- resolveState();
- }
-
-
- public void onEventMainThread(final TrackDownloadCancelEvent event)
- {
- if(mTrack != null && mTrack.getId().equals(event.getTrackId()))
- resolveState();
- }
-
-
- public void onEventMainThread(final TrackDownloadEvent event)
- {
- if(mTrack != null && mTrack.getId() != null && mTrack.getId().equals(event.getTrackId()))
- {
- mDownloadProgress.setProgress(event.getPercentDownloaded());
- setState(event.isFinished() ? State.DOWNLOADED : State.DOWNLOADING);
- }
- }
-
-
- public void bind(final Track track)
- {
- mTrack = track;
- mTitle.setText(mTrack.getTitle());
- mSubtitle.setText(mTrack.getSubtitle());
- mBuyText.setText(String.format(getContext().getString(R.string.track_state_buy), mTrack.getPrice()));
- resolveState();
- }
-
-
- @Override
- public void onClick(View v)
- {
- if(getState() == State.READY_TO_DOWNLOAD)
- {
- setState(State.LOADING);
- mTrack.download();
- }
- else if(getState() == State.DOWNLOADING)
- {
- mTrack.cancelDownload();
- resolveState();
- }
- else if(getState() == State.PUBLISHED)
- {
- mPurchaseConnector.purchaseTrack(mTrack);
- resolveState();
- }
- else if(getState() == State.DOWNLOADED)
- {
- mNavigationHandler.showLibraryEvent(mTrack.getPinnedEvent().getId(), true);
- }
- else if(getState() == State.WAITING)
- {
- mNavigationHandler.showSnackBarMessage(getContext().getString(R.string.event_waiting_message));
- }
- }
-
-
- @Override
- public boolean onLongClick(View v)
- {
- if(getState() == State.DOWNLOADED)
- {
- mTrack.getDownloadedFile().delete();
- resolveState();
- return true;
- }
- return false;
- }
-
-
- public State getState()
- {
- return mState;
- }
-
-
- public void setState(State state)
- {
- mState = state;
- if(state == State.NOT_PUBLISHED)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadCompleteText.setVisibility(GONE);
- mDownloadProgress.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.PUBLISHED)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadCompleteText.setVisibility(GONE);
- mDownloadProgress.setVisibility(GONE);
- mBuyText.setVisibility(VISIBLE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.WAITING)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadProgress.setVisibility(GONE);
- mDownloadCompleteText.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(VISIBLE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.READY_TO_DOWNLOAD)
- {
- mDownloadButton.setVisibility(VISIBLE);
- mDownloadProgress.setVisibility(VISIBLE);
- mDownloadProgress.setProgress(0);
- mDownloadProgress.setText("");
- mDownloadCompleteText.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.DOWNLOADED)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadCompleteText.setVisibility(VISIBLE);
- mDownloadProgress.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.DOWNLOADING)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadProgress.setVisibility(VISIBLE);
- mDownloadProgress.setText("");
- mDownloadCompleteText.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(GONE);
- }
- else if(state == State.LOADING)
- {
- mDownloadButton.setVisibility(GONE);
- mDownloadCompleteText.setVisibility(GONE);
- mDownloadProgress.setVisibility(GONE);
- mBuyText.setVisibility(GONE);
- mWaitingText.setVisibility(GONE);
- mLoadingProgress.setVisibility(VISIBLE);
- }
- }
-
-
- @Override
- protected void onAttachedToWindow()
- {
- super.onAttachedToWindow();
- BusProvider.get().register(this);
- }
-
-
- @Override
- protected void onDetachedFromWindow()
- {
- BusProvider.get().unregister(this);
- super.onDetachedFromWindow();
- }
-
-
- private void resolveState()
- {
- if(!mTrack.isPublished())
- setState(State.NOT_PUBLISHED);
- else if(mPurchaseConnector.isTrackBeingPurchased(mTrack))
- setState(State.LOADING);
- else if(!mPurchaseConnector.isTrackPurchased(mTrack))
- setState(State.PUBLISHED);
- else if(!mTrack.isReadyToDownload())
- setState(State.WAITING);
- else if(!mTrack.isDownloaded())
- setState(State.READY_TO_DOWNLOAD);
- else
- setState(State.DOWNLOADED);
- }
-}
diff --git a/app/src/main/res/layout/view/LibraryTrackHeaderItemView.java b/app/src/main/res/layout/view/LibraryTrackHeaderItemView.java
deleted file mode 100644
index 54acab9..0000000
--- a/app/src/main/res/layout/view/LibraryTrackHeaderItemView.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.bumptech.glide.Glide;
-import com.stereocast.R;
-import com.stereocast.StereocastApplication;
-import com.stereocast.activity.PlayerActivity;
-import com.stereocast.entity.Event;
-import com.stereocast.entity.Track;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-
-
-/**
- * Created by tomasgarba on 08/03/15.
- */
-public class LibraryTrackHeaderItemView extends FrameLayout
-{
- @Bind(R.id.include_tracklist_header_title)
- TextView mEventTitle;
- @Bind(R.id.include_tracklist_header_subtitle)
- TextView mEventSubtitle;
- @Bind(R.id.include_tracklist_header_cover)
- ImageView mShowImage;
- @Bind(R.id.include_tracklist_header_primary_button)
- Button mPlayAllButton;
-
- private Track mTrack;
- private Event mEvent;
-
-
- public LibraryTrackHeaderItemView(Context context)
- {
- super(context);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- LayoutInflater.from(getContext()).inflate(R.layout.include_tracklist_header, this);
- ButterKnife.bind(this, this);
- }
-
-
- public void bind(Event event)
- {
- mEvent = event;
-
- mPlayAllButton.setText(R.string.button_play_now);
-
- if(mEvent != null)
- {
- mPlayAllButton.setOnClickListener(v -> v.getContext().startActivity(PlayerActivity.newIntent(v.getContext(), mEvent.getPlayableTracks(), 0)));
- mEventTitle.setText(mEvent.getTitle());
- mEventSubtitle.setText(mEvent.getSubtitle());
- Glide.with(StereocastApplication.getContext())
- .load(mEvent.getCoverUrl())
- .placeholder(R.drawable.image_cover_placeholder)
- .error(R.drawable.image_cover_placeholder)
- .into(mShowImage);
- }
- }
-}
diff --git a/app/src/main/res/layout/view/LibraryTrackItemView.java b/app/src/main/res/layout/view/LibraryTrackItemView.java
deleted file mode 100644
index b97ab0f..0000000
--- a/app/src/main/res/layout/view/LibraryTrackItemView.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.stereocast.R;
-import com.stereocast.entity.Track;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-
-
-/**
- * Created by jakubkinst on 14/07/15.
- */
-public class LibraryTrackItemView extends LinearLayout implements View.OnClickListener
-{
- @Bind(R.id.view_track_item_title)
- TextView mTitle;
- @Bind(R.id.view_track_item_subtitle)
- TextView mSubtitle;
- @Bind(R.id.view_track_item_position)
- TextView mPositionText;
- private Track mTrack;
-
-
- public LibraryTrackItemView(Context context)
- {
- super(context);
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- LayoutInflater.from(getContext()).inflate(R.layout.view_library_track_item, this);
- ButterKnife.bind(this, this);
- setOnClickListener(this);
- }
-
-
- public void bind(final Track track, final int position)
- {
- mTrack = track;
-
- mTitle.setText(mTrack.getTitle());
- mSubtitle.setText(mTrack.getSubtitle());
- mPositionText.setText((position + 1) + "");
- }
-
-
- @Override
- public void onClick(View v)
- {
-
- }
-}
diff --git a/app/src/main/res/layout/view/LinearDividerItemDecoration.java b/app/src/main/res/layout/view/LinearDividerItemDecoration.java
deleted file mode 100644
index 76bf7fa..0000000
--- a/app/src/main/res/layout/view/LinearDividerItemDecoration.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.graphics.drawable.Drawable;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.util.AttributeSet;
-import android.view.View;
-
-
-// code taken from: https://gist.github.com/lapastillaroja/858caf1a82791b6c1a36
-public class LinearDividerItemDecoration extends RecyclerView.ItemDecoration
-{
- private Drawable mDivider;
- private boolean mShowFirstDivider = false;
- private boolean mShowLastDivider = false;
-
-
- public LinearDividerItemDecoration(Context context, AttributeSet attrs)
- {
- final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.listDivider});
- mDivider = a.getDrawable(0);
- a.recycle();
- }
-
-
- public LinearDividerItemDecoration(Context context, AttributeSet attrs, boolean showFirstDivider, boolean showLastDivider)
- {
- this(context, attrs);
- mShowFirstDivider = showFirstDivider;
- mShowLastDivider = showLastDivider;
- }
-
-
- public LinearDividerItemDecoration(Drawable divider)
- {
- mDivider = divider;
- }
-
-
- public LinearDividerItemDecoration(Drawable divider, boolean showFirstDivider, boolean showLastDivider)
- {
- this(divider);
- mShowFirstDivider = showFirstDivider;
- mShowLastDivider = showLastDivider;
- }
-
-
- @Override
- public void getItemOffsets(Rect outRect, View view, RecyclerView recyclerView, RecyclerView.State state)
- {
- super.getItemOffsets(outRect, view, recyclerView, state);
-
- if(mDivider == null)
- {
- return;
- }
-
- if(recyclerView.getChildPosition(view) < 1)
- {
- return;
- }
-
- if(getOrientation(recyclerView) == LinearLayoutManager.VERTICAL)
- {
- outRect.top = mDivider.getIntrinsicHeight();
- }
- else
- {
- outRect.left = mDivider.getIntrinsicWidth();
- }
- }
-
-
- @Override
- public void onDrawOver(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state)
- {
- if(mDivider == null)
- {
- super.onDrawOver(canvas, recyclerView, state);
- return;
- }
-
- // initialization
- int left = 0, right = 0, top = 0, bottom = 0, size;
- int orientation = getOrientation(recyclerView);
- int childCount = recyclerView.getChildCount();
-
- if(orientation == LinearLayoutManager.VERTICAL)
- {
- size = mDivider.getIntrinsicHeight();
- left = recyclerView.getPaddingLeft();
- right = recyclerView.getWidth() - recyclerView.getPaddingRight();
- }
- else
- {
- size = mDivider.getIntrinsicWidth();
- top = recyclerView.getPaddingTop();
- bottom = recyclerView.getHeight() - recyclerView.getPaddingBottom();
- }
-
- for(int i = mShowFirstDivider ? 0 : 1; i < childCount; i++)
- {
- View child = recyclerView.getChildAt(i);
- RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
-
- if(orientation == LinearLayoutManager.VERTICAL)
- {
- top = child.getTop() - params.topMargin - size;
- bottom = top + size;
- }
- else
- {
- left = child.getLeft() - params.leftMargin - size;
- right = left + size;
- }
-
- mDivider.setBounds(left, top, right, bottom);
- mDivider.draw(canvas);
- }
-
- // show last divider
- if(mShowLastDivider && childCount > 0)
- {
- View child = recyclerView.getChildAt(childCount - 1);
- RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
-
- if(orientation == LinearLayoutManager.VERTICAL)
- {
- top = child.getBottom() + params.bottomMargin;
- bottom = top + size;
- }
- else
- {
- left = child.getRight() + params.rightMargin;
- right = left + size;
- }
-
- mDivider.setBounds(left, top, right, bottom);
- mDivider.draw(canvas);
- }
- }
-
-
- private int getOrientation(RecyclerView recyclerView)
- {
- if(recyclerView.getLayoutManager() instanceof LinearLayoutManager)
- {
- LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
- return linearLayoutManager.getOrientation();
- }
- else
- {
- throw new IllegalStateException(this.getClass().getSimpleName() + " can only be used with a " + LinearLayoutManager.class.getSimpleName());
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/view/PurchasePopupView.java b/app/src/main/res/layout/view/PurchasePopupView.java
deleted file mode 100644
index cc10148..0000000
--- a/app/src/main/res/layout/view/PurchasePopupView.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.LinearLayout;
-
-import com.stereocast.R;
-import com.stereocast.entity.Event;
-import com.stereocast.listener.PurchaseConnector;
-
-import java.util.Date;
-
-import butterknife.Bind;
-import butterknife.ButterKnife;
-import butterknife.OnClick;
-
-
-/**
- * Created by jakubkinst on 14/07/15.
- */
-public class PurchasePopupView extends LinearLayout implements CountdownTextView.OnCountdownFinishedListener
-{
- @Bind(R.id.view_purchase_popup_title)
- CountdownTextView mCountdown;
- @Bind(R.id.view_purchase_popup_button_primary)
- Button mButtonPrimary;
- @Bind(R.id.view_purchase_popup_button_secondary)
- Button mButtonSecondary;
- private Event mEvent;
- private PurchaseConnector mPurchaseConnector;
-
-
- public PurchasePopupView(Context context)
- {
- super(context);
- init();
- }
-
-
- public PurchasePopupView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- init();
- }
-
-
- public void setEvent(Event event, PurchaseConnector purchaseConnector)
- {
- mEvent = event;
- long target = event.getPurchaseWindowEnd().getTime();
- mCountdown.startCountdown(new Date(target));
- mPurchaseConnector = purchaseConnector;
- if(purchaseConnector.isEventPurchased(event))
- setVisibility(GONE);
- else
- {
- setVisibility(VISIBLE);
- mButtonPrimary.setText(String.format(getContext().getString(R.string.track_state_buy_all), purchaseConnector.getEventPrice()));
- }
-
- }
-
-
- @Override
- public void onCountdownFinished()
- {
- dismiss();
- }
-
-
- @OnClick(R.id.view_purchase_popup_button_primary)
- void buyEntireShow()
- {
- mPurchaseConnector.purchaseEvent(mEvent);
- }
-
-
- @OnClick(R.id.view_purchase_popup_button_secondary)
- void dismiss()
- {
- setVisibility(GONE);
- }
-
-
- private void init()
- {
- setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
- LayoutInflater.from(getContext()).inflate(R.layout.view_purchase_popup, this);
- ButterKnife.bind(this, this);
- mCountdown.setOnCountdownFinishedListener(this);
- }
-}
diff --git a/app/src/main/res/layout/view/SelectorLinearLayout.java b/app/src/main/res/layout/view/SelectorLinearLayout.java
deleted file mode 100644
index e999b0d..0000000
--- a/app/src/main/res/layout/view/SelectorLinearLayout.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package layout.view;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-
-
-/**
- * Created by Leos on 16. 7. 2015.
- */
-public class SelectorLinearLayout extends LinearLayout
-{
- private static final int[] ATTR_LIST_SELECTOR = {android.R.attr.listSelector};
-
- private final Drawable mSelector;
-
-
- public SelectorLinearLayout(Context context)
- {
- this(context, null);
- }
-
-
- public SelectorLinearLayout(Context context, AttributeSet attrs)
- {
- this(context, attrs, 0);
- }
-
-
- public SelectorLinearLayout(Context context, AttributeSet attrs, int defStyleAttr)
- {
- super(context, attrs, defStyleAttr);
-
- TypedArray a = context.obtainStyledAttributes(attrs, ATTR_LIST_SELECTOR, 0, 0);
- mSelector = a.getDrawable(0);
- a.recycle();
-
- if(mSelector != null)
- {
- setWillNotDraw(false);
- mSelector.setCallback(this);
- }
- }
-
-
- @Override
- public void jumpDrawablesToCurrentState()
- {
- super.jumpDrawablesToCurrentState();
-
- final Drawable d = mSelector;
- if(d != null)
- {
- d.jumpToCurrentState();
- }
- }
-
-
- @Override
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public void drawableHotspotChanged(float x, float y)
- {
- if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
- {
- return;
- }
-
- super.drawableHotspotChanged(x, y);
-
- final Drawable d = mSelector;
- if(d != null)
- {
- d.setHotspot(x, y);
- }
- }
-
-
- @Override
- public void draw(Canvas canvas)
- {
- super.draw(canvas);
-
- final Drawable d = mSelector;
- if(d != null)
- {
- d.setBounds(0, 0, getWidth(), getHeight());
- d.draw(canvas);
- }
- }
-
-
- @Override
- protected void drawableStateChanged()
- {
- super.drawableStateChanged();
-
- final Drawable d = mSelector;
- if(d != null && d.isStateful())
- {
- d.setState(getDrawableState());
- }
- }
-
-
- @Override
- protected boolean verifyDrawable(Drawable who)
- {
- return who == mSelector || super.verifyDrawable(who);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/view/SquareImageView.java b/app/src/main/res/layout/view/SquareImageView.java
deleted file mode 100644
index 70af0eb..0000000
--- a/app/src/main/res/layout/view/SquareImageView.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-
-/**
- * Created by jakubkinst on 30/07/15.
- */
-public class SquareImageView extends ImageView
-{
- public SquareImageView(Context context)
- {
- super(context);
- }
-
-
- public SquareImageView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- }
-
-
- public SquareImageView(Context context, AttributeSet attrs, int defStyleAttr)
- {
- super(context, attrs, defStyleAttr);
- }
-
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
- {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-
- int height = getMeasuredHeight();
- setMeasuredDimension(height, height);
- }
-}
diff --git a/app/src/main/res/layout/view/StatefulView.java b/app/src/main/res/layout/view/StatefulView.java
deleted file mode 100644
index 62a302f..0000000
--- a/app/src/main/res/layout/view/StatefulView.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import com.stereocast.R;
-
-
-/**
- * Created by jakubkinst on 05/08/15.
- */
-public class StatefulView extends FrameLayout
-{
- private ViewState mViewState = null;
- private View mContainerContent;
- private FrameLayout mContainerProgress, mContainerOffline, mContainerEmpty;
- private boolean mViewAlreadyTransformed = false;
-
-
- public StatefulView(Context context)
- {
- super(context);
- initialize();
- }
-
-
- public StatefulView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- initialize();
- }
-
-
- public StatefulView(Context context, AttributeSet attrs, int defStyleAttr)
- {
- super(context, attrs, defStyleAttr);
- initialize();
- }
-
-
- public void setEmptyText(CharSequence emptyText)
- {
- ((TextView) findViewById(R.id.placeholder_empty_text)).setText(emptyText);
- }
-
-
- public void setOfflineText(CharSequence offlineText)
- {
- ((TextView) findViewById(R.id.placeholder_offline_text)).setText(offlineText);
- }
-
-
- public void showContent()
- {
- setViewState(ViewState.CONTENT);
- }
-
-
- public void showProgress()
- {
- setViewState(ViewState.PROGRESS);
- }
-
-
- public void showOffline()
- {
- setViewState(ViewState.OFFLINE);
- }
-
-
- public void showEmpty()
- {
- setViewState(ViewState.EMPTY);
- }
-
-
- public ViewState getViewState()
- {
- return mViewState;
- }
-
-
- public void setViewState(ViewState viewState)
- {
- mViewState = viewState;
- if(mViewAlreadyTransformed)
- {
- if(mContainerContent != null)
- mContainerContent.setVisibility(viewState == ViewState.CONTENT ? View.VISIBLE : View.GONE);
- if(mContainerProgress != null)
- mContainerProgress.setVisibility(viewState == ViewState.PROGRESS ? View.VISIBLE : View.GONE);
- if(mContainerOffline != null)
- mContainerOffline.setVisibility(viewState == ViewState.OFFLINE ? View.VISIBLE : View.GONE);
- if(mContainerEmpty != null)
- mContainerEmpty.setVisibility(viewState == ViewState.EMPTY ? View.VISIBLE : View.GONE);
- }
- }
-
-
- private void initialize()
- {
- addView(LayoutInflater.from(getContext()).inflate(R.layout.view_stateful, this, false));
- mContainerProgress = (FrameLayout) findViewById(R.id.container_progress);
- mContainerOffline = (FrameLayout) findViewById(R.id.container_offline);
- mContainerEmpty = (FrameLayout) findViewById(R.id.container_empty);
- }
-
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right, int bottom)
- {
-
- if(!mViewAlreadyTransformed)
- {
- mContainerContent = getChildAt(1);
- mViewAlreadyTransformed = true;
- }
- setViewState(mViewState);
- super.onLayout(changed, left, top, right, bottom);
- }
-}
diff --git a/app/src/main/res/layout/view/ThemedSnackbar.java b/app/src/main/res/layout/view/ThemedSnackbar.java
deleted file mode 100644
index 0cfa460..0000000
--- a/app/src/main/res/layout/view/ThemedSnackbar.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package layout.view;
-
-import android.support.design.widget.Snackbar;
-import android.view.View;
-
-import com.stereocast.R;
-
-
-/**
- * Created by jakubkinst on 25/06/15.
- */
-public class ThemedSnackbar
-{
- public static Snackbar make(View view, CharSequence text, int duration)
- {
- if(view == null)
- return null;
- Snackbar snackbar = Snackbar.make(view, text, duration);
- snackbar.getView().setBackgroundColor(view.getResources().getColor(R.color.snackbar_bg));
- return snackbar;
- }
-
-
- public static Snackbar make(View view, int resId, @Snackbar.Duration int duration)
- {
- return make(view, view.getResources().getText(resId), duration);
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/view/TintableImageView.java b/app/src/main/res/layout/view/TintableImageView.java
deleted file mode 100644
index e10a602..0000000
--- a/app/src/main/res/layout/view/TintableImageView.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package layout.view;
-
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import android.graphics.PorterDuff;
-import android.support.annotation.ColorInt;
-import android.support.annotation.ColorRes;
-import android.util.AttributeSet;
-import android.widget.ImageView;
-
-import com.stereocast.R;
-
-
-public class TintableImageView extends ImageView
-{
-
-
- public TintableImageView(Context context)
- {
- super(context);
- }
-
-
- public TintableImageView(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- init(context, attrs, 0);
- }
-
-
- public TintableImageView(Context context, AttributeSet attrs, int defStyle)
- {
- super(context, attrs, defStyle);
- init(context, attrs, defStyle);
- }
-
-
- public void setTintColor(@ColorInt int color)
- {
- super.setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
-
-
- public void setTintColorResource(@ColorRes int colorResource)
- {
- super.setColorFilter(getContext().getResources().getColor(colorResource), PorterDuff.Mode.SRC_IN);
- }
-
-
- private void init(Context context, AttributeSet attrs, int defStyle)
- {
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TintableImageView, defStyle, 0);
- int tintColor = a.getColor(R.styleable.TintableImageView_tint, Color.BLACK);
- a.recycle();
- setTintColor(tintColor);
- }
-
-
-}
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index 8b40ee7..0000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816..0000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 48b8832..0db11dd 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -1,9 +1,4 @@
+
-
- 16dp
- 16dp
-
16dp
- 32dp
- 72dp
-
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index abb36af..787e72e 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -2,7 +2,8 @@
+
diff --git a/build.gradle b/build.gradle
index d2ee2a3..10b21c4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.2.3'
+ classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/library/.gitignore b/library/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/library/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/library/build.gradle b/library/build.gradle
new file mode 100644
index 0000000..9595203
--- /dev/null
+++ b/library/build.gradle
@@ -0,0 +1,23 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion 22
+ buildToolsVersion "22.0.1"
+
+ defaultConfig {
+ minSdkVersion 15
+ targetSdkVersion 22
+ versionCode 1
+ versionName "1.0"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ compile fileTree(dir: 'libs', include: ['*.jar'])
+}
diff --git a/app/app.iml b/library/library.iml
similarity index 87%
rename from app/app.iml
rename to library/library.iml
index 8e9b2d5..d615027 100644
--- a/app/app.iml
+++ b/library/library.iml
@@ -1,9 +1,9 @@
-
+
-
+
@@ -23,6 +23,7 @@
+
@@ -36,13 +37,13 @@
-
+
-
+
@@ -71,8 +72,6 @@
-
-
@@ -90,8 +89,5 @@
-
-
-
\ No newline at end of file
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
new file mode 100644
index 0000000..45ecb69
--- /dev/null
+++ b/library/proguard-rules.pro
@@ -0,0 +1,17 @@
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in /Users/jakubkinst/Library/Android/sdk/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the proguardFiles
+# directive in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/library/src/androidTest/java/com/example/statefulview/ApplicationTest.java b/library/src/androidTest/java/com/example/statefulview/ApplicationTest.java
new file mode 100644
index 0000000..f274cbf
--- /dev/null
+++ b/library/src/androidTest/java/com/example/statefulview/ApplicationTest.java
@@ -0,0 +1,16 @@
+package com.example.statefulview;
+
+import android.app.Application;
+import android.test.ApplicationTestCase;
+
+
+/**
+ * Testing Fundamentals
+ */
+public class ApplicationTest extends ApplicationTestCase
+{
+ public ApplicationTest()
+ {
+ super(Application.class);
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..732944c
--- /dev/null
+++ b/library/src/main/AndroidManifest.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/java/cz/kinst/jakub/statefulviewsample/StatefulView.java b/library/src/main/java/com/strv/StatefulView.java
similarity index 66%
rename from app/src/main/java/cz/kinst/jakub/statefulviewsample/StatefulView.java
rename to library/src/main/java/com/strv/StatefulView.java
index cbb0276..2053c44 100644
--- a/app/src/main/java/cz/kinst/jakub/statefulviewsample/StatefulView.java
+++ b/library/src/main/java/com/strv/StatefulView.java
@@ -1,6 +1,7 @@
-package cz.kinst.jakub.statefulviewsample;
+package com.strv;
import android.content.Context;
+import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
@@ -13,6 +14,8 @@
*/
public class StatefulView extends FrameLayout
{
+ private final int mTextAppearance;
+ private View mOfflineView, mEmptyView, mProgressView;
private ViewState mViewState = null;
private View mContent;
private FrameLayout mContainerProgress, mContainerOffline, mContainerEmpty;
@@ -20,19 +23,25 @@ public class StatefulView extends FrameLayout
public StatefulView(Context context)
{
- super(context);
+ this(context, null);
}
public StatefulView(Context context, AttributeSet attrs)
{
- super(context, attrs);
+ this(context, attrs, 0);
}
public StatefulView(Context context, AttributeSet attrs, int defStyleAttr)
{
super(context, attrs, defStyleAttr);
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StatefulView);
+ mTextAppearance = a.getResourceId(R.styleable.StatefulView_stateTextAppearance, R.style.TextAppearanceStateDefault);
+ mOfflineView = LayoutInflater.from(context).inflate(a.getResourceId(R.styleable.StatefulView_offlineLayout, R.layout.default_placeholder_offline), null);
+ mEmptyView = LayoutInflater.from(context).inflate(a.getResourceId(R.styleable.StatefulView_emptyLayout, R.layout.default_placeholder_empty), null);
+ mProgressView = LayoutInflater.from(context).inflate(a.getResourceId(R.styleable.StatefulView_progressLayout, R.layout.default_placeholder_progress), null);
+
}
@@ -92,11 +101,6 @@ public void setViewState(ViewState viewState)
}
- private void initialize()
- {
- }
-
-
@Override
protected void onFinishInflate()
{
@@ -104,8 +108,14 @@ protected void onFinishInflate()
mContent = getChildAt(0);
addView(LayoutInflater.from(getContext()).inflate(R.layout.view_stateful, this, false));
mContainerProgress = (FrameLayout) findViewById(R.id.container_progress);
+ mContainerProgress.addView(mProgressView);
mContainerOffline = (FrameLayout) findViewById(R.id.container_offline);
+ mContainerOffline.addView(mOfflineView);
mContainerEmpty = (FrameLayout) findViewById(R.id.container_empty);
+ mContainerEmpty.addView(mEmptyView);
+
+ ((TextView) findViewById(R.id.placeholder_empty_text)).setTextAppearance(getContext(), mTextAppearance);
+ ((TextView) findViewById(R.id.placeholder_empty_text)).setTextAppearance(getContext(), mTextAppearance);
}
@@ -116,4 +126,9 @@ protected void onAttachedToWindow()
super.onAttachedToWindow();
initialize();
}
+
+
+ private void initialize()
+ {
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/layout/view/ViewState.java b/library/src/main/java/com/strv/ViewState.java
similarity index 75%
rename from app/src/main/res/layout/view/ViewState.java
rename to library/src/main/java/com/strv/ViewState.java
index 47c2d39..e1c9543 100644
--- a/app/src/main/res/layout/view/ViewState.java
+++ b/library/src/main/java/com/strv/ViewState.java
@@ -1,4 +1,4 @@
-package layout.view;
+package com.strv;
public enum ViewState
diff --git a/app/src/main/res/layout/placeholder_empty.xml b/library/src/main/res/layout/default_placeholder_empty.xml
similarity index 91%
rename from app/src/main/res/layout/placeholder_empty.xml
rename to library/src/main/res/layout/default_placeholder_empty.xml
index 8c3dafb..3994398 100644
--- a/app/src/main/res/layout/placeholder_empty.xml
+++ b/library/src/main/res/layout/default_placeholder_empty.xml
@@ -17,7 +17,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
- android:text="@string/placeholder_empty"/>
+ android:text="@string/default_placeholder_empty"/>
diff --git a/app/src/main/res/layout/placeholder_offline.xml b/library/src/main/res/layout/default_placeholder_offline.xml
similarity index 91%
rename from app/src/main/res/layout/placeholder_offline.xml
rename to library/src/main/res/layout/default_placeholder_offline.xml
index 382e6a3..0b86be7 100644
--- a/app/src/main/res/layout/placeholder_offline.xml
+++ b/library/src/main/res/layout/default_placeholder_offline.xml
@@ -17,7 +17,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
- android:text="@string/placeholder_offline"/>
+ android:text="@string/default_placeholder_offline"/>
diff --git a/app/src/main/res/layout/placeholder_progress.xml b/library/src/main/res/layout/default_placeholder_progress.xml
similarity index 100%
rename from app/src/main/res/layout/placeholder_progress.xml
rename to library/src/main/res/layout/default_placeholder_progress.xml
diff --git a/app/src/main/res/layout/view_stateful.xml b/library/src/main/res/layout/view_stateful.xml
similarity index 83%
rename from app/src/main/res/layout/view_stateful.xml
rename to library/src/main/res/layout/view_stateful.xml
index 7515b7c..3d0b3e6 100644
--- a/app/src/main/res/layout/view_stateful.xml
+++ b/library/src/main/res/layout/view_stateful.xml
@@ -10,7 +10,6 @@
android:layout_height="match_parent"
android:visibility="gone">
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..18debe0
--- /dev/null
+++ b/library/src/main/res/values/attrs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..48b8832
--- /dev/null
+++ b/library/src/main/res/values/dimens.xml
@@ -0,0 +1,9 @@
+
+
+ 16dp
+ 16dp
+
+ 16dp
+ 32dp
+ 72dp
+
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
new file mode 100644
index 0000000..66cc314
--- /dev/null
+++ b/library/src/main/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+ No data
+ No network
+
diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml
new file mode 100644
index 0000000..790fa08
--- /dev/null
+++ b/library/src/main/res/values/styles.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/settings.gradle b/settings.gradle
index e7b4def..3306997 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app'
+include ':app', ':library'