Possible fix for #19

This commit is contained in:
mhutti1 2016-04-09 21:45:47 +01:00
parent 6c3c3cea25
commit cc1c75e2c9
2 changed files with 20 additions and 85 deletions

View File

@ -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();
}
}

View File

@ -50,22 +50,26 @@ public class HTMLUtils {
@Override
public void run() {
if (element.equals("H1")) {
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);
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);
}
} else {
textViews.add(i, new TextView(context));
sectionProperties.add(i, new KiwixMobileActivity.SectionProperties());