Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution for issue #28 #175

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
Expand Down Expand Up @@ -158,6 +160,7 @@ public class LauncherActivity extends Activity implements View.OnClickListener,
private Gestures detector;
private ShortcutUtils shortcutUtils;

private Thread thread;
private static final TextWatcher mTextWatcher= new TextWatcher() {

@Override
Expand All @@ -168,7 +171,7 @@ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
//do here search
mSearchTask.execute(charSequence);
mSearchTask.execute(charSequence);
}

@Override
Expand Down Expand Up @@ -544,6 +547,42 @@ public void onClick(View view) {

}
}
class MyThread implements Runnable{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Override
public void run(){
try {
while (!Thread.currentThread().isInterrupted()) {
Thread.sleep(59900);
Date date = new Date(System.currentTimeMillis());
int hour = date.getHours();
int minute = date.getMinutes();
if(hour==12&&minute==29){
backup();
}
}
}
catch(InterruptedException e){
}

}
}

private void backup(){
Intent intentBackupFiles;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
intentBackupFiles = new Intent(Intent.ACTION_CREATE_DOCUMENT);
} else {
intentBackupFiles = new Intent(Intent.ACTION_GET_CONTENT);
;
}
intentBackupFiles.addCategory(Intent.CATEGORY_OPENABLE);
intentBackupFiles.setType("*/*");
SimpleDateFormat df = new SimpleDateFormat("yyyy_MM_dd_HHSS", Locale.getDefault());
df.format(new Date());
String date = df.format(new Date());
intentBackupFiles.putExtra(Intent.EXTRA_TITLE, "Backup_LastLauncher_" + date);
this.startActivityForResult(intentBackupFiles, BACKUP_REQUEST);
}

@Override
protected void onResume() {
Expand All @@ -557,11 +596,16 @@ protected void onResume() {
sortApps(DbUtils.getSortsTypes());
}
}

@Override
protected void onStart(){
super.onStart();
thread = new Thread(new MyThread());
thread.start();
}
@Override
protected void onStop() {
super.onStop();

thread.interrupt();
if (dialogs != null) {
dialogs.dismiss();
dialogs = null;
Expand Down Expand Up @@ -1333,4 +1377,4 @@ protected Void doInBackground(final Integer... integers) {
return null;
}
}
}
}