Skip to content

Commit

Permalink
Major Commit - 0.2.7
Browse files Browse the repository at this point in the history
 - Schedule Activity Added
   - Lists full schedule (Day Wise)
   - Updated UI
 - Optimized App & Removed some older dependencies
 - Updated Home Fragment
 - Updated README.md
  • Loading branch information
Sher1234 committed Jun 27, 2018
1 parent 6913b2f commit 96e4d91
Show file tree
Hide file tree
Showing 30 changed files with 450 additions and 1,226 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ Horrible Subs uses number of open source projects to work properly:
- Notifications might get delayed by 30 minutes (Max).
* In App Search for listing available subs from Horrible Subs
* Views All as well as Current Shows
* Lists full weeks schedule day wise(According to User Time)

Mentioned features might not work in upcoming releases but will be fixed soon
* ~~Lists full weeks Schedule (According to User Time)~~
* ~~Show pages for previous show releases~~
* ~~Search in List~~

#### Release Updates
```
Schedule Activity - Listing Full Schedule Major Commit - June 27, 2018
Shows Activity - Listing all & current shows, Improved UI Major Commit - June 27, 2018
New Search Activity, Improved Home UI with SearchView, Optimized Data Models Major Commit - June 27, 2018
New Home Activity, Improved Notifications, Improved UI for Releases & Schedule Major Commit - June 27, 2018
Expand Down Expand Up @@ -64,7 +65,7 @@ Currently Listing Latest 60 Releases & Reimplemented some features
#### Download
| Type | Date | Version | Api | Download |
| ------ | ------ | ------ | ------ | ------ |
| Alpha 2 | ------ | ------ | ------ | ------ |
| Alpha 2 | June 27 2018 | 27 | v4 | [Click Here](https://github.com/Sher1234/HorribleSubs/releases/download/hs-0.2.7/app-debug.apk) |
| Alpha 1 | June 27 2018 | 25 | v4 | [Click Here](https://github.com/Sher1234/HorribleSubs/releases/download/hs-0.2.5/app-debug.apk) |
| **Latest Release** | **April 25, 2018** | **22** | **v3** | **[Click Here](https://github.com/Sher1234/HorribleSubs/releases/download/hs-0.2.2/app-debug.apk)** |
| Release 1 | April 24, 2018 | 21 | v3 | [Click Here](https://github.com/Sher1234/HorribleSubs/releases/download/hs-0.2.1/hs-21.apk) |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "info.horriblesubs.sher"
minSdkVersion 15
targetSdkVersion 28
versionCode 26
versionName "0.2.6"
versionCode 27
versionName "0.2.7"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
23 changes: 4 additions & 19 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<receiver
android:name=".old.receiver.Notification"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>

<service
android:name=".old.service.NotifyService"
tools:ignore="ExportedService">
Expand Down Expand Up @@ -90,13 +81,12 @@
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".old.activity.Schedule"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".old.activity.List"
android:name=".activity.Schedule"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".old.activity.Detail"
android:label="@string/app_name"
Expand All @@ -106,11 +96,6 @@
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".old.activity.Search"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />

<activity
android:name=".old.activity.Favourite"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import info.horriblesubs.sher.model.base.ReleaseItem;
import info.horriblesubs.sher.model.base.ScheduleItem;
import info.horriblesubs.sher.model.response.HomeResponse;
import info.horriblesubs.sher.old.util.DialogX;
import info.horriblesubs.sher.util.DialogX;
import info.horriblesubs.sher.util.FragmentNavigation;
import retrofit2.Call;
import retrofit2.Callback;
Expand Down
203 changes: 203 additions & 0 deletions app/src/main/java/info/horriblesubs/sher/activity/Schedule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
package info.horriblesubs.sher.activity;

import android.annotation.SuppressLint;
import android.app.SearchManager;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import org.jetbrains.annotations.NotNull;

import java.util.Calendar;

import info.horriblesubs.sher.Api;
import info.horriblesubs.sher.AppController;
import info.horriblesubs.sher.R;
import info.horriblesubs.sher.fragment.ScheduleFragment;
import info.horriblesubs.sher.model.response.ScheduleResponse;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

@SuppressLint("StaticFieldLeak")
public class Schedule extends AppCompatActivity implements SearchView.OnQueryTextListener {

private final String[] DAYS = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "To be Scheduled"};
private ScheduleTask task;
private View progressBar;
private ViewPager viewPager;
private SearchView searchView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_schedule);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
viewPager = findViewById(R.id.viewPager);
searchView = findViewById(R.id.searchView);
progressBar = findViewById(R.id.progressBar);
TabLayout tabLayout = findViewById(R.id.tabLayout);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
for (String s : DAYS)
tabLayout.addTab(tabLayout.newTab().setText(s));
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));
EditText editText = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
editText.setTextColor(getResources().getColor(R.color.colorText));
editText.setHintTextColor(getResources().getColor(R.color.colorAccent));
editText.setTextSize((float) 13.5);
searchView.setOnQueryTextListener(this);
task = new ScheduleTask();
task.execute();
}

@Override
protected void onResume() {
super.onResume();
if (searchView.getQuery() != null && !searchView.getQuery().toString().isEmpty())
searchView.setQuery(null, false);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.notifications).setVisible(false).setEnabled(false);
return super.onPrepareOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.refresh:
if (task != null)
task.cancel(true);
task = null;
task = new ScheduleTask();
task.execute();
return true;

default:
return super.onOptionsItemSelected(item);
}
}

private void onLoadData(@NotNull ScheduleResponse scheduleResponse) {
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), scheduleResponse));
viewPager.setCurrentItem(Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1);
}

@Override
public boolean onQueryTextSubmit(String s) {
if (s == null || s.isEmpty() || s.length() < 2)
return false;
Intent intent = new Intent(this, Search.class);
intent.putExtra(SearchManager.QUERY, s);
startActivity(intent);
return true;
}

@Override
public boolean onQueryTextChange(String s) {
return false;
}

class ScheduleTask extends AsyncTask<Void, Void, Boolean> {

private int i = 0;
private ScheduleResponse schedule;

@Override
protected void onPreExecute() {
super.onPreExecute();
progressBar.requestFocus();
progressBar.setVisibility(View.VISIBLE);
}

@Override
protected Boolean doInBackground(Void... voids) {
Retrofit retrofit = AppController.getRetrofit(Api.Link);
Api api = retrofit.create(Api.class);
Call<ScheduleResponse> call = api.getSchedule();
call.enqueue(new Callback<ScheduleResponse>() {
@Override
public void onResponse(@NonNull Call<ScheduleResponse> call,
@NonNull Response<ScheduleResponse> response) {
if (response.body() != null)
schedule = response.body();
i = 1;
}

@Override
public void onFailure(@NonNull Call<ScheduleResponse> call, @NonNull Throwable t) {
t.printStackTrace();
i = -1;
}
});
while (true) {
if (i != 0)
return true;
if (isCancelled()) {
i = -1;
schedule = null;
return true;
}
}
}

@Override
protected void onPostExecute(Boolean aBoolean) {
super.onPostExecute(aBoolean);
progressBar.setVisibility(View.GONE);
if (i == 1) {
if (schedule == null)
Toast.makeText(Schedule.this, "Invalid Subz...", Toast.LENGTH_SHORT).show();
else
onLoadData(schedule);
} else
Toast.makeText(Schedule.this, "Server Error...", Toast.LENGTH_SHORT).show();
}
}

class PagerAdapter extends FragmentPagerAdapter {

private final ScheduleResponse scheduleResponse;

PagerAdapter(FragmentManager fragmentManager, ScheduleResponse scheduleResponse) {
super(fragmentManager);
this.scheduleResponse = scheduleResponse;
}

@Override
public Fragment getItem(int position) {
return ScheduleFragment.newInstance(scheduleResponse, position);
}

@Override
public int getCount() {
return 8;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import info.horriblesubs.sher.model.base.Item;
import info.horriblesubs.sher.model.base.ReleaseItem;
import info.horriblesubs.sher.old.activity.Detail;
import info.horriblesubs.sher.old.util.DialogX;
import info.horriblesubs.sher.util.DialogX;

/**
* ReleaseRecycler
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package info.horriblesubs.sher.fragment;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.button.MaterialButton;
import android.support.transition.ChangeTransform;
import android.support.transition.TransitionInflater;
import android.support.v4.app.Fragment;
Expand All @@ -20,19 +22,21 @@
import java.util.List;

import info.horriblesubs.sher.R;
import info.horriblesubs.sher.activity.Schedule;
import info.horriblesubs.sher.adapter.ReleaseRecycler;
import info.horriblesubs.sher.adapter.ScheduleRecycler;
import info.horriblesubs.sher.model.base.ScheduleItem;
import info.horriblesubs.sher.model.response.HomeResponse;

public class HomeFragment2 extends Fragment {
public class HomeFragment2 extends Fragment implements View.OnClickListener {

private static final String ARG_RESPONSE = "RESPONSE-HOME";
private static final String ARG_NUMBER = "RESPONSE-NUMBER";

private int type;
private HomeResponse homeResponse;
private RecyclerView recyclerView;
private MaterialButton button;
private TextView textView;

public static HomeFragment2 newInstance(HomeResponse homeResponse, int i) {
Expand All @@ -50,6 +54,9 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
View rootView = inflater.inflate(R.layout.fragment_home_2, container, false);
recyclerView = rootView.findViewById(R.id.recyclerView);
textView = rootView.findViewById(R.id.textView);
button = rootView.findViewById(R.id.button);
button.setOnClickListener(this);
button.setEnabled(false);
return rootView;
}

Expand Down Expand Up @@ -96,9 +103,21 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
break;

case 2:
button.setEnabled(true);
button.setVisibility(View.VISIBLE);
textView.setText(R.string.today_s_schedule);
recyclerView.setAdapter(new ScheduleRecycler(getContext(), getTodaySchedule()));
break;
}
}

@Override
public void onClick(View view) {
if (view.getId() == R.id.button) {
assert getFragmentManager() != null;
getFragmentManager().popBackStack();
assert getActivity() != null;
getActivity().startActivity(new Intent(getActivity(), Schedule.class));
}
}
}
Loading

0 comments on commit 96e4d91

Please sign in to comment.