use of com.kiminonawa.mydiary.shared.FileManager in project MyDiary by erttyy8821.
the class SettingActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
//For set status bar
ChinaPhoneHelper.setStatusBar(this, true);
themeManager = ThemeManager.getInstance();
//Create fileManager for get temp folder
tempFileManager = new FileManager(this, FileManager.TEMP_DIR);
tempFileManager.clearDir();
SP_setting_theme = (Spinner) findViewById(R.id.SP_setting_theme);
IV_setting_profile_bg = (ImageView) findViewById(R.id.IV_setting_profile_bg);
IV_setting_theme_main_color = (ImageView) findViewById(R.id.IV_setting_theme_main_color);
IV_setting_theme_dark_color = (ImageView) findViewById(R.id.IV_setting_theme_dark_color);
But_setting_theme_default_bg = (Button) findViewById(R.id.But_setting_theme_default_bg);
But_setting_theme_default = (Button) findViewById(R.id.But_setting_theme_default);
But_setting_theme_apply = (Button) findViewById(R.id.But_setting_theme_apply);
But_setting_theme_apply.setOnClickListener(this);
SP_setting_language = (Spinner) findViewById(R.id.SP_setting_language);
But_setting_fix_photo_17_dir = (Button) findViewById(R.id.But_setting_fix_photo_17_dir);
But_setting_fix_photo_17_dir.setOnClickListener(this);
initSpinner();
initTheme(themeManager.getCurrentTheme());
initLanguage();
}
use of com.kiminonawa.mydiary.shared.FileManager in project MyDiary by erttyy8821.
the class MainActivity method updateTopicBg.
private void updateTopicBg(int position, int topicBgStatus, String newTopicBgFileName) {
switch(topicBgStatus) {
case TopicDetailDialogFragment.TOPIC_BG_ADD_PHOTO:
File outputFile = themeManager.getTopicBgSavePathFile(this, mainTopicAdapter.getList().get(position).getId(), mainTopicAdapter.getList().get(position).getType());
//Copy file into topic dir
try {
if (outputFile.exists()) {
outputFile.delete();
}
FileUtils.moveFile(new File(new FileManager(this, FileManager.TEMP_DIR).getDirAbsolutePath() + "/" + newTopicBgFileName), outputFile);
//Enter the topic
mainTopicAdapter.gotoTopic(mainTopicAdapter.getList().get(position).getType(), position);
} catch (IOException e) {
Toast.makeText(this, getString(R.string.topic_topic_bg_fail), Toast.LENGTH_LONG).show();
e.printStackTrace();
}
break;
case TopicDetailDialogFragment.TOPIC_BG_REVERT_DEFAULT:
File topicBgFile = themeManager.getTopicBgSavePathFile(this, mainTopicAdapter.getList().get(position).getId(), mainTopicAdapter.getList().get(position).getType());
//Just delete the file , the topic's activity will check file for changing the bg
if (topicBgFile.exists()) {
topicBgFile.delete();
}
break;
}
}
use of com.kiminonawa.mydiary.shared.FileManager in project MyDiary by erttyy8821.
the class MainActivity method onTopicDelete.
@Override
public void onTopicDelete(final int position) {
DBManager dbManager = new DBManager(MainActivity.this);
dbManager.opeDB();
switch(mainTopicAdapter.getList().get(position).getType()) {
case ITopic.TYPE_CONTACTS:
dbManager.delAllContactsInTopic(mainTopicAdapter.getList().get(position).getId());
break;
case ITopic.TYPE_MEMO:
dbManager.delAllMemoInTopic(mainTopicAdapter.getList().get(position).getId());
dbManager.deleteAllCurrentMemoOrder(mainTopicAdapter.getList().get(position).getId());
break;
case ITopic.TYPE_DIARY:
//Because FOREIGN key is not work in this version,
//so delete diary item first , then delete diary
Cursor diaryCursor = dbManager.selectDiaryList(mainTopicAdapter.getList().get(position).getId());
for (int i = 0; i < diaryCursor.getCount(); i++) {
dbManager.delAllDiaryItemByDiaryId(diaryCursor.getLong(0));
diaryCursor.moveToNext();
}
diaryCursor.close();
dbManager.delAllDiaryInTopic(mainTopicAdapter.getList().get(position).getId());
break;
}
//Delete the dir if it exist.
try {
FileUtils.deleteDirectory(new FileManager(MainActivity.this, mainTopicAdapter.getList().get(position).getType(), mainTopicAdapter.getList().get(position).getId()).getDir());
} catch (IOException e) {
//Do nothing if delete fail
e.printStackTrace();
}
dbManager.delTopic(mainTopicAdapter.getList().get(position).getId());
//Don't delete the topic order, it will be refreshed next moving time.
dbManager.closeDB();
//Search for remove the topiclist
for (int i = 0; i < topicList.size(); i++) {
if (topicList.get(i).getId() == mainTopicAdapter.getList().get(position).getId()) {
topicList.remove(i);
break;
}
}
//remove the filter list
mainTopicAdapter.getList().remove(position);
//Notify recycle view
mainTopicAdapter.notifyItemRemoved(position);
mainTopicAdapter.notifyItemRangeChanged(position, mainTopicAdapter.getItemCount());
//Clear the filter
EDT_main_topic_search.setText("");
}
use of com.kiminonawa.mydiary.shared.FileManager in project MyDiary by erttyy8821.
the class DiaryViewerDialogFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
callback = (DiaryViewerCallback) getTargetFragment();
diaryId = getArguments().getLong("diaryId", -1L);
if (diaryId != -1) {
if (isEditMode) {
diaryViewerHandler = new DiaryViewerHandler(this);
diaryFileManager = new FileManager(getActivity(), FileManager.DIARY_EDIT_CACHE_DIR);
diaryFileManager.clearDir();
PB_diary_item_content_hint.setVisibility(View.VISIBLE);
mTask = new CopyDiaryToEditCacheTask(getActivity(), diaryFileManager, this);
//Make ths ProgressBar show 0.7s+.
loadDiaryHandler = new Handler();
initHandlerOrTaskIsRunning = true;
loadDiaryHandler.postDelayed(new Runnable() {
@Override
public void run() {
//Copy the file into editCash
mTask.execute(((DiaryActivity) getActivity()).getTopicId(), diaryId);
}
}, 700);
} else {
diaryFileManager = new FileManager(getActivity(), ((DiaryActivity) getActivity()).getTopicId(), diaryId);
initData();
}
}
}
use of com.kiminonawa.mydiary.shared.FileManager in project MyDiary by erttyy8821.
the class DiaryFragment method onCreate.
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
calendar = Calendar.getInstance();
timeTools = TimeTools.getInstance(getActivity().getApplicationContext());
noLocation = getString(R.string.diary_no_location);
//The file is not editable
tempFileManager = new FileManager(getActivity(), FileManager.TEMP_DIR);
}
Aggregations