mirror of
https://github.com/playmusicexporter/playmusicexporter
synced 2024-10-31 22:54:56 +00:00
Added a refresh button to bin the previous database, copy the new one, and reload it into the UI. Saves having to kill the app and re-open to see the latest changes. Should address "Issue #8 Reload Play Music Files"
This commit is contained in:
parent
c33c463327
commit
9247ed0829
5 changed files with 62 additions and 1 deletions
|
@ -35,6 +35,7 @@ import android.support.v4.widget.DrawerLayout;
|
|||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -43,6 +44,8 @@ import android.widget.EditText;
|
|||
|
||||
import de.arcus.framework.logger.Logger;
|
||||
import de.arcus.framework.crashhandler.CrashHandler;
|
||||
import de.arcus.playmusiclib.exceptions.CouldNotOpenDatabaseException;
|
||||
import de.arcus.playmusiclib.exceptions.NoSuperUserException;
|
||||
import re.jcg.playmusicexporter.R;
|
||||
import re.jcg.playmusicexporter.fragments.MusicTrackListFragment;
|
||||
import re.jcg.playmusicexporter.fragments.MusicContainerListFragment;
|
||||
|
@ -325,8 +328,32 @@ public class MusicContainerListActivity extends AppCompatActivity
|
|||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.music_track_list, menu);
|
||||
|
||||
MenuItem itemRefreshLibrary = menu. findItem(R.id.action_refresh);
|
||||
itemRefreshLibrary.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item)
|
||||
{
|
||||
try
|
||||
{
|
||||
mPlayMusicManager.realoadDatabase();
|
||||
}
|
||||
catch (NoSuperUserException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (CouldNotOpenDatabaseException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
mPlayMusicManager = null;
|
||||
loadPlayMusicExporter();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
// Finds the search item and create the search view
|
||||
MenuItem itemSearch = menu.findItem(R.id.action_search);
|
||||
MenuItem itemSearch = menu. findItem(R.id.action_search);
|
||||
mSearchView = (SearchView)MenuItemCompat.getActionView(itemSearch);
|
||||
|
||||
if (mSearchView != null) {
|
||||
|
|
25
playmusicexporter/src/main/res/drawable/ic_menu_refresh.xml
Normal file
25
playmusicexporter/src/main/res/drawable/ic_menu_refresh.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!--
|
||||
Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:pathData="M17.6,6.4C16.2,4.9 14.2,4 12,4c-4.4,0 -8,3.6 -8,8s3.6,8 8,8c3.7,0 6.8,-2.6 7.7,-6l-2.1,0c-0.8,2.3 -3,4 -5.6,4c-3.3,0 -6,-2.7 -6,-6s2.7,-6 6,-6c1.7,0 3.1,0.7 4.2,1.8L13,11l7,0L20,4L17.6,6.4z"
|
||||
android:fillColor="@color/white"/>
|
||||
</vector>
|
|
@ -29,4 +29,10 @@
|
|||
app:showAsAction="always"
|
||||
app:actionViewClass="android.support.v7.widget.SearchView"
|
||||
/>
|
||||
|
||||
|
||||
<item android:id="@+id/action_refresh"
|
||||
android:title="@string/action_refesh"
|
||||
android:icon="@drawable/ic_menu_refresh"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
|
@ -44,4 +44,6 @@
|
|||
<color name="button_navigation_drawer_active">#11000000</color>
|
||||
<color name="button_navigation_drawer_text">#88000000</color>
|
||||
<color name="button_navigation_drawer_text_active">#ef6c00</color>
|
||||
<color name="white">#ffffffff</color>
|
||||
<color name="black">#ff000000</color>
|
||||
</resources>
|
|
@ -146,4 +146,5 @@
|
|||
<string name="file_handling_category">File Handling</string>
|
||||
<string name="overwrite_summary">Always overwrite the exported file, even if it already exists.</string>
|
||||
<string name="overwrite_title">Overwrite Existing Files</string>
|
||||
<string name="action_refesh">Refresh</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue