mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-12 00:48:29 -04:00
Possible fix for #19
This commit is contained in:
parent
6c3c3cea25
commit
cc1c75e2c9
@ -1,69 +0,0 @@
|
|||||||
package org.kiwix.kiwixmobile;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
|
|
||||||
@SuppressLint("ValidFragment")
|
|
||||||
public class BookmarkDialogFragment extends DialogFragment {
|
|
||||||
|
|
||||||
private BookmarkDialogListener listen;
|
|
||||||
|
|
||||||
private String[] contents;
|
|
||||||
|
|
||||||
private boolean isBookmarked;
|
|
||||||
|
|
||||||
public BookmarkDialogFragment(String[] contents, boolean isBookmarked) {
|
|
||||||
this.contents = contents;
|
|
||||||
this.isBookmarked = isBookmarked;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
AlertDialog.Builder build = new AlertDialog.Builder(getActivity());
|
|
||||||
//build.setTitle(R.string.menu_bookmarks);
|
|
||||||
String buttonText;
|
|
||||||
if (isBookmarked) {
|
|
||||||
buttonText = getResources().getString(R.string.remove_bookmark);
|
|
||||||
} else {
|
|
||||||
buttonText = getResources().getString(R.string.add_bookmark);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contents.length != 0) {
|
|
||||||
build.setItems(contents, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int choice) {
|
|
||||||
listen.onListItemSelect(contents[choice]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
build.setNeutralButton(buttonText, new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int choice) {
|
|
||||||
listen.onBookmarkButtonPressed();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return build.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity a) {
|
|
||||||
super.onAttach(a);
|
|
||||||
try {
|
|
||||||
listen = (BookmarkDialogListener) a;
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
throw new ClassCastException(a.toString()
|
|
||||||
+ " must implement BookmarkDialogListener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface BookmarkDialogListener {
|
|
||||||
|
|
||||||
public void onListItemSelect(String choice);
|
|
||||||
|
|
||||||
public void onBookmarkButtonPressed();
|
|
||||||
}
|
|
||||||
}
|
|
@ -50,22 +50,26 @@ public class HTMLUtils {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (element.equals("H1")) {
|
if (element.equals("H1")) {
|
||||||
mRightListView.removeHeaderView(headerView);
|
if (mRightListView.getHeaderViewsCount() == 0) {
|
||||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mRightListView.removeHeaderView(headerView);
|
||||||
View view = inflater.inflate(R.layout.section_list, null);
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
headerView = (TextView) view.findViewById(R.id.textTab);
|
View view = inflater.inflate(R.layout.section_list, null);
|
||||||
headerView.setText(sectionTitle);
|
headerView = (TextView) view.findViewById(R.id.textTab);
|
||||||
headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0);
|
headerView.setText(sectionTitle);
|
||||||
headerView.setBackgroundColor(Color.LTGRAY);
|
headerView.setPadding((int) (26 * context.getResources().getDisplayMetrics().density), 0, 0, 0);
|
||||||
headerView.setTypeface(Typeface.DEFAULT_BOLD);
|
headerView.setBackgroundColor(Color.LTGRAY);
|
||||||
headerView.setOnClickListener(new View.OnClickListener() {
|
headerView.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
@Override
|
headerView.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
@Override
|
||||||
context.getCurrentWebView().setScrollY(0);
|
public void onClick(View v) {
|
||||||
context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
|
context.getCurrentWebView().setScrollY(0);
|
||||||
}
|
context.mRightDrawerLayout.closeDrawer(Gravity.RIGHT);
|
||||||
});
|
}
|
||||||
mRightListView.addHeaderView(headerView);
|
});
|
||||||
|
mRightListView.addHeaderView(headerView);
|
||||||
|
} else {
|
||||||
|
headerView.setText(sectionTitle);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
textViews.add(i, new TextView(context));
|
textViews.add(i, new TextView(context));
|
||||||
sectionProperties.add(i, new KiwixMobileActivity.SectionProperties());
|
sectionProperties.add(i, new KiwixMobileActivity.SectionProperties());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user