mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Multiple History date format
This commit is contained in:
parent
6c07ca4649
commit
82a85cc8dc
@ -3,7 +3,7 @@ package org.kiwix.kiwixmobile.data.local.dao;
|
||||
import android.content.Context;
|
||||
import com.yahoo.squidb.data.SquidCursor;
|
||||
import com.yahoo.squidb.sql.Query;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -24,9 +24,8 @@ public class HistoryDao {
|
||||
}
|
||||
|
||||
public void saveHistory(History history) {
|
||||
DateFormat dateFormat =
|
||||
DateFormat.getDateInstance(DateFormat.MEDIUM, getCurrentLocale(context));
|
||||
String date = dateFormat.format(new Date(history.getTimeStamp()));
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("d MMM yyyy", getCurrentLocale(context));
|
||||
String date = sdf.format(new Date(history.getTimeStamp()));
|
||||
kiwixDatabase.deleteWhere(History.class, History.HISTORY_URL.eq(history.getHistoryUrl())
|
||||
.and(History.DATE.eq(date)).and(History.ZIM_ID.eq(history.getZimId())));
|
||||
kiwixDatabase.persist(new History()
|
||||
|
@ -3,6 +3,7 @@ package org.kiwix.kiwixmobile.history;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.Settings;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -13,6 +14,7 @@ import androidx.appcompat.view.ActionMode;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import butterknife.BindView;
|
||||
import java.io.File;
|
||||
@ -34,6 +36,7 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
||||
private final List<History> historyList = new ArrayList<>();
|
||||
private final List<History> fullHistory = new ArrayList<>();
|
||||
private final List<History> deleteList = new ArrayList<>();
|
||||
private static final String LIST_STATE_KEY = "recycler_list_state";
|
||||
|
||||
@BindView(R.id.toolbar)
|
||||
Toolbar toolbar;
|
||||
@ -43,6 +46,8 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
||||
RecyclerView recyclerView;
|
||||
private boolean refreshAdapter = true;
|
||||
private HistoryAdapter historyAdapter;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private Parcelable listState;
|
||||
private ActionMode actionMode;
|
||||
private final ActionMode.Callback actionModeCallback = new ActionMode.Callback() {
|
||||
@Override
|
||||
@ -111,15 +116,34 @@ public class HistoryActivity extends BaseActivity implements HistoryContract.Vie
|
||||
actionBar.setTitle(R.string.history);
|
||||
}
|
||||
|
||||
|
||||
historyAdapter = new HistoryAdapter(historyList, deleteList, this);
|
||||
recyclerView.setAdapter(historyAdapter);
|
||||
layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
presenter.loadHistory(sharedPreferenceUtil.getShowHistoryCurrentBook());
|
||||
if (listState != null) {
|
||||
layoutManager.onRestoreInstanceState(listState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle state) {
|
||||
super.onSaveInstanceState(state);
|
||||
listState = layoutManager.onSaveInstanceState();
|
||||
state.putParcelable(LIST_STATE_KEY, listState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Bundle state) {
|
||||
super.onRestoreInstanceState(state);
|
||||
if (state != null) {
|
||||
listState = state.getParcelable(LIST_STATE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user