mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Another attempt at #19
This commit is contained in:
parent
cc1c75e2c9
commit
19be3942e6
17
res/layout/content_header.xml
Normal file
17
res/layout/content_header.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
android:id="@+id/contentHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_toLeftOf="@+id/deleteButton"
|
||||
android:ellipsize="end"
|
||||
android:fontFamily="sans-serif-light"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"/>
|
@ -214,6 +214,8 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
||||
|
||||
private int tempVisitCount;
|
||||
|
||||
public static TextView headerView;
|
||||
|
||||
@Override
|
||||
public void onActionModeStarted(ActionMode mode) {
|
||||
if (mActionMode == null) {
|
||||
@ -333,6 +335,24 @@ public class KiwixMobileActivity extends AppCompatActivity {
|
||||
mRightDrawerList = (ListView) findViewById(R.id.right_drawer_list);
|
||||
mRightDrawerList.setDivider(null);
|
||||
mRightDrawerList.setDividerHeight(0);
|
||||
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.content_header, null);
|
||||
headerView = (TextView) view.findViewById(R.id.contentHeader);
|
||||
headerView.setText(R.string.no_section_info);
|
||||
headerView.setPadding((int) (26 * getResources().getDisplayMetrics().density), 0, 0, 0);
|
||||
headerView.setBackgroundColor(Color.LTGRAY);
|
||||
headerView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
headerView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getCurrentWebView().setScrollY(0);
|
||||
mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
|
||||
}
|
||||
});
|
||||
mRightDrawerList.addHeaderView(headerView);
|
||||
|
||||
mRightDrawerList.setAdapter(mRightArrayAdapter);
|
||||
TextView tView = (TextView) findViewById(R.id.empty);
|
||||
mRightDrawerList.setEmptyView(tView);
|
||||
|
@ -1,20 +1,16 @@
|
||||
package org.kiwix.kiwixmobile.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.HeaderViewListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import java.util.List;
|
||||
import org.kiwix.kiwixmobile.KiwixMobileActivity;
|
||||
import org.kiwix.kiwixmobile.R;
|
||||
|
||||
public class HTMLUtils {
|
||||
|
||||
@ -23,14 +19,11 @@ public class HTMLUtils {
|
||||
private ArrayAdapter arrayAdapter;
|
||||
private KiwixMobileActivity context;
|
||||
private Handler mHandler;
|
||||
private ListView mRightListView;
|
||||
private TextView headerView;
|
||||
|
||||
public HTMLUtils(List<KiwixMobileActivity.SectionProperties> sectionProperties, List<TextView> textViews, ListView listView, KiwixMobileActivity context, Handler handler) {
|
||||
this.sectionProperties = sectionProperties;
|
||||
this.textViews = textViews;
|
||||
this.mRightListView = listView;
|
||||
this.arrayAdapter = (ArrayAdapter) listView.getAdapter();
|
||||
this.arrayAdapter = ((ArrayAdapter)((HeaderViewListAdapter)listView.getAdapter()).getWrappedAdapter());
|
||||
this.context = context;
|
||||
this.mHandler = handler;
|
||||
}
|
||||
@ -50,26 +43,7 @@ public class HTMLUtils {
|
||||
@Override
|
||||
public void run() {
|
||||
if (element.equals("H1")) {
|
||||
if (mRightListView.getHeaderViewsCount() == 0) {
|
||||
mRightListView.removeHeaderView(headerView);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.section_list, null);
|
||||
headerView = (TextView) view.findViewById(R.id.textTab);
|
||||
headerView.setText(sectionTitle);
|
||||
headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0);
|
||||
headerView.setBackgroundColor(Color.LTGRAY);
|
||||
headerView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
headerView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
context.getCurrentWebView().setScrollY(0);
|
||||
context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
|
||||
}
|
||||
});
|
||||
mRightListView.addHeaderView(headerView);
|
||||
} else {
|
||||
headerView.setText(sectionTitle);
|
||||
}
|
||||
KiwixMobileActivity.headerView.setText(sectionTitle);
|
||||
} else {
|
||||
textViews.add(i, new TextView(context));
|
||||
sectionProperties.add(i, new KiwixMobileActivity.SectionProperties());
|
||||
|
Loading…
x
Reference in New Issue
Block a user