|
|
@ -20,6 +20,7 @@ package org.floens.chan.ui.activity; |
|
|
|
import android.app.ActionBar; |
|
|
|
import android.app.ActionBar; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.FragmentTransaction; |
|
|
|
import android.app.FragmentTransaction; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.content.res.Configuration; |
|
|
@ -28,12 +29,17 @@ import android.os.Bundle; |
|
|
|
import android.support.v4.app.ActionBarDrawerToggle; |
|
|
|
import android.support.v4.app.ActionBarDrawerToggle; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.util.DisplayMetrics; |
|
|
|
import android.util.DisplayMetrics; |
|
|
|
|
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
|
import android.view.MenuItem; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.view.ViewGroup.LayoutParams; |
|
|
|
import android.view.ViewGroup.LayoutParams; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
import android.widget.AdapterView; |
|
|
|
|
|
|
|
import android.widget.BaseAdapter; |
|
|
|
import android.widget.FrameLayout; |
|
|
|
import android.widget.FrameLayout; |
|
|
|
|
|
|
|
import android.widget.Spinner; |
|
|
|
|
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
|
|
|
|
import org.floens.chan.ChanApplication; |
|
|
|
import org.floens.chan.ChanApplication; |
|
|
|
import org.floens.chan.R; |
|
|
|
import org.floens.chan.R; |
|
|
@ -43,23 +49,26 @@ import org.floens.chan.core.model.Pin; |
|
|
|
import org.floens.chan.core.model.Post; |
|
|
|
import org.floens.chan.core.model.Post; |
|
|
|
import org.floens.chan.service.WatchService; |
|
|
|
import org.floens.chan.service.WatchService; |
|
|
|
import org.floens.chan.ui.fragment.ThreadFragment; |
|
|
|
import org.floens.chan.ui.fragment.ThreadFragment; |
|
|
|
|
|
|
|
import org.floens.chan.utils.Logger; |
|
|
|
import org.floens.chan.utils.Utils; |
|
|
|
import org.floens.chan.utils.Utils; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
public class BoardActivity extends BaseActivity implements ActionBar.OnNavigationListener { |
|
|
|
public class BoardActivity extends BaseActivity implements AdapterView.OnItemSelectedListener { |
|
|
|
|
|
|
|
private static final String TAG = "BoardActivity"; |
|
|
|
|
|
|
|
|
|
|
|
private Loadable boardLoadable; |
|
|
|
private Loadable boardLoadable; |
|
|
|
private Loadable threadLoadable; |
|
|
|
private Loadable threadLoadable; |
|
|
|
private ThreadFragment boardFragment; |
|
|
|
private ThreadFragment boardFragment; |
|
|
|
private ThreadFragment threadFragment; |
|
|
|
private ThreadFragment threadFragment; |
|
|
|
|
|
|
|
|
|
|
|
private boolean actionBarSetToListNavigation; |
|
|
|
private boolean ignoreNextOnItemSelected = false; |
|
|
|
|
|
|
|
private Spinner boardSpinner; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
protected void onCreate(Bundle savedInstanceState) { |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
super.onCreate(savedInstanceState); |
|
|
|
|
|
|
|
|
|
|
|
actionBarSetToListNavigation = false; |
|
|
|
|
|
|
|
boardLoadable = new Loadable(); |
|
|
|
boardLoadable = new Loadable(); |
|
|
|
threadLoadable = new Loadable(); |
|
|
|
threadLoadable = new Loadable(); |
|
|
|
|
|
|
|
|
|
|
@ -72,10 +81,13 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
ft.commitAllowingStateLoss(); |
|
|
|
ft.commitAllowingStateLoss(); |
|
|
|
|
|
|
|
|
|
|
|
final ActionBar actionBar = getActionBar(); |
|
|
|
final ActionBar actionBar = getActionBar(); |
|
|
|
actionBar.setListNavigationCallbacks( |
|
|
|
|
|
|
|
new ArrayAdapter<>(actionBar.getThemedContext(), R.layout.board_select_spinner, |
|
|
|
boardSpinner = new Spinner(actionBar.getThemedContext()); |
|
|
|
android.R.id.text1, ChanApplication.getBoardManager().getSavedKeys()), this |
|
|
|
boardSpinner.setAdapter(new BoardSpinnerAdapter(this)); |
|
|
|
); |
|
|
|
boardSpinner.setOnItemSelectedListener(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actionBar.setCustomView(boardSpinner); |
|
|
|
|
|
|
|
actionBar.setDisplayShowCustomEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
updatePaneState(); |
|
|
|
updatePaneState(); |
|
|
|
updateActionBarState(); |
|
|
|
updateActionBarState(); |
|
|
@ -118,6 +130,8 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ignoreNextOnItemSelected = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -158,6 +172,12 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
super.initDrawer(); |
|
|
|
super.initDrawer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void onPostCreate(Bundle savedInstanceState) { |
|
|
|
|
|
|
|
super.onPostCreate(savedInstanceState); |
|
|
|
|
|
|
|
pinDrawerListener.syncState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
super.onCreateOptionsMenu(menu); |
|
|
|
super.onCreateOptionsMenu(menu); |
|
|
@ -174,6 +194,47 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
updatePaneState(); |
|
|
|
updatePaneState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onBackPressed() { |
|
|
|
|
|
|
|
if (threadPane.isOpen()) { |
|
|
|
|
|
|
|
super.onBackPressed(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
threadPane.openPane(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void openPin(Pin pin) { |
|
|
|
|
|
|
|
startLoadingThread(pin.loadable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pinDrawer.closeDrawer(pinDrawerView); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onOPClicked(Post post) { |
|
|
|
|
|
|
|
startLoadingThread(new Loadable(post.board, post.no, post.subject)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void updatePin(Pin pin) { |
|
|
|
|
|
|
|
super.updatePin(pin); |
|
|
|
|
|
|
|
updateActionBarState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onNothingSelected(final AdapterView<?> parent) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onPanelClosed(View view) { |
|
|
|
|
|
|
|
updateActionBarState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onPanelOpened(View view) { |
|
|
|
|
|
|
|
updateActionBarState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void updatePaneState() { |
|
|
|
private void updatePaneState() { |
|
|
|
DisplayMetrics metrics = new DisplayMetrics(); |
|
|
|
DisplayMetrics metrics = new DisplayMetrics(); |
|
|
|
getWindowManager().getDefaultDisplay().getMetrics(metrics); |
|
|
|
getWindowManager().getDefaultDisplay().getMetrics(metrics); |
|
|
@ -210,39 +271,6 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
right.requestLayout(); |
|
|
|
right.requestLayout(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void openPin(Pin pin) { |
|
|
|
|
|
|
|
startLoadingThread(pin.loadable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pinDrawer.closeDrawer(pinDrawerView); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onOPClicked(Post post) { |
|
|
|
|
|
|
|
startLoadingThread(new Loadable(post.board, post.no, post.subject)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void onPostCreate(Bundle savedInstanceState) { |
|
|
|
|
|
|
|
super.onPostCreate(savedInstanceState); |
|
|
|
|
|
|
|
pinDrawerListener.syncState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onBackPressed() { |
|
|
|
|
|
|
|
if (threadPane.isOpen()) { |
|
|
|
|
|
|
|
super.onBackPressed(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
threadPane.openPane(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void updatePin(Pin pin) { |
|
|
|
|
|
|
|
super.updatePin(pin); |
|
|
|
|
|
|
|
updateActionBarState(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateActionBarState() { |
|
|
|
private void updateActionBarState() { |
|
|
|
// Force the actionbar state after the ThreadPane layout,
|
|
|
|
// Force the actionbar state after the ThreadPane layout,
|
|
|
|
// otherwise the ThreadPane incorrectly reports that it's not slidable.
|
|
|
|
// otherwise the ThreadPane incorrectly reports that it's not slidable.
|
|
|
@ -259,14 +287,13 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
|
|
|
|
|
|
|
|
if (threadPane.isSlideable()) { |
|
|
|
if (threadPane.isSlideable()) { |
|
|
|
if (threadPane.isOpen()) { |
|
|
|
if (threadPane.isOpen()) { |
|
|
|
int index = getBoardIndexNavigator(boardLoadable.board); |
|
|
|
int index = getSpinnerIndex(boardLoadable.board); |
|
|
|
|
|
|
|
|
|
|
|
if (index >= 0) { |
|
|
|
if (index >= 0) { |
|
|
|
// actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
|
|
|
actionBar.setDisplayShowCustomEnabled(true); |
|
|
|
setActionBarListMode(); |
|
|
|
|
|
|
|
actionBar.setTitle(""); |
|
|
|
actionBar.setTitle(""); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); |
|
|
|
actionBar.setDisplayShowCustomEnabled(false); |
|
|
|
String niceTitle = ChanApplication.getBoardManager().getBoardKey(boardLoadable.board); |
|
|
|
String niceTitle = ChanApplication.getBoardManager().getBoardKey(boardLoadable.board); |
|
|
|
if (niceTitle == null) { |
|
|
|
if (niceTitle == null) { |
|
|
|
actionBar.setTitle("/" + boardLoadable.board + "/"); |
|
|
|
actionBar.setTitle("/" + boardLoadable.board + "/"); |
|
|
@ -275,44 +302,35 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
actionBar.setHomeButtonEnabled(true); |
|
|
|
|
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(true); |
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
if (boardLoadable.isBoardMode()) |
|
|
|
if (boardLoadable.isBoardMode()) |
|
|
|
setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board)); |
|
|
|
setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); |
|
|
|
actionBar.setDisplayShowCustomEnabled(false); |
|
|
|
actionBar.setTitle(threadLoadable.title); |
|
|
|
actionBar.setTitle(threadLoadable.title); |
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(false); |
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(false); |
|
|
|
|
|
|
|
|
|
|
|
if (threadLoadable.isThreadMode()) |
|
|
|
if (threadLoadable.isThreadMode()) |
|
|
|
setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no)); |
|
|
|
setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
setActionBarListMode(); |
|
|
|
actionBar.setDisplayShowCustomEnabled(true); |
|
|
|
// actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
|
|
|
|
|
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(true); |
|
|
|
pinDrawerListener.setDrawerIndicatorEnabled(true); |
|
|
|
actionBar.setTitle(threadLoadable.title); |
|
|
|
actionBar.setTitle(threadLoadable.title); |
|
|
|
|
|
|
|
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true); |
|
|
|
if (threadLoadable.isThreadMode()) { |
|
|
|
|
|
|
|
|
|
|
|
if (threadLoadable.isThreadMode()) |
|
|
|
|
|
|
|
setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no)); |
|
|
|
setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
actionBar.setHomeButtonEnabled(true); |
|
|
|
|
|
|
|
actionBar.setDisplayHomeAsUpEnabled(true); |
|
|
|
actionBar.setDisplayShowTitleEnabled(true); |
|
|
|
actionBar.setDisplayShowTitleEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
invalidateOptionsMenu(); |
|
|
|
invalidateOptionsMenu(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setActionBarListMode() { |
|
|
|
|
|
|
|
ActionBar actionBar = getActionBar(); |
|
|
|
|
|
|
|
if (actionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_LIST) |
|
|
|
|
|
|
|
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) { |
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) { |
|
|
|
boolean open = threadPane.isOpen(); |
|
|
|
boolean open = threadPane.isOpen(); |
|
|
@ -398,51 +416,40 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onPanelClosed(View view) { |
|
|
|
public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { |
|
|
|
updateActionBarState(); |
|
|
|
if (ignoreNextOnItemSelected) { |
|
|
|
} |
|
|
|
Logger.d(TAG, "Ignoring onItemSelected"); |
|
|
|
|
|
|
|
ignoreNextOnItemSelected = false; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
List<String> savedValues = ChanApplication.getBoardManager().getSavedValues(); |
|
|
|
public void onPanelOpened(View view) { |
|
|
|
if (position >= 0 && position < savedValues.size()) { |
|
|
|
updateActionBarState(); |
|
|
|
Loadable board = new Loadable(savedValues.get(position)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// onItemSelected is called after the view initializes,
|
|
|
|
|
|
|
|
// ignore if it's the same board
|
|
|
|
|
|
|
|
if (boardLoadable.equals(board)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startLoadingBoard(board); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the navigator to appropriately and calls startLoadingBoard |
|
|
|
* Sets the spinner to the appropriate position and calls startLoadingBoard |
|
|
|
* |
|
|
|
* |
|
|
|
* @param board |
|
|
|
* @param board |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void loadBoard(String board) { |
|
|
|
private void loadBoard(String board) { |
|
|
|
boardLoadable = new Loadable(board); |
|
|
|
boardLoadable = new Loadable(board); |
|
|
|
|
|
|
|
|
|
|
|
int index = getBoardIndexNavigator(boardLoadable.board); |
|
|
|
int index = getSpinnerIndex(boardLoadable.board); |
|
|
|
if (index >= 0) { |
|
|
|
if (index >= 0 && boardSpinner.getSelectedItemPosition() != index) { |
|
|
|
ActionBar actionBar = getActionBar(); |
|
|
|
boardSpinner.setSelection(index); |
|
|
|
setActionBarListMode(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (actionBar.getSelectedNavigationIndex() != index) { |
|
|
|
|
|
|
|
actionBar.setSelectedNavigationItem(index); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
startLoadingBoard(boardLoadable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
startLoadingBoard(boardLoadable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean onNavigationItemSelected(int position, long id) { |
|
|
|
|
|
|
|
if (!actionBarSetToListNavigation) { |
|
|
|
|
|
|
|
actionBarSetToListNavigation = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
List<String> savedValues = ChanApplication.getBoardManager().getSavedValues(); |
|
|
|
|
|
|
|
if (position >= 0 && position < savedValues.size()) { |
|
|
|
|
|
|
|
boardLoadable = new Loadable(savedValues.get(position)); |
|
|
|
|
|
|
|
startLoadingBoard(boardLoadable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
startLoadingBoard(boardLoadable); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void startLoadingBoard(Loadable loadable) { |
|
|
|
private void startLoadingBoard(Loadable loadable) { |
|
|
@ -489,14 +496,14 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
* @param startUri |
|
|
|
* @param startUri |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void handleIntentURI(Uri startUri) { |
|
|
|
private void handleIntentURI(Uri startUri) { |
|
|
|
|
|
|
|
Logger.d(TAG, "Opening " + startUri.getPath()); |
|
|
|
|
|
|
|
|
|
|
|
List<String> parts = startUri.getPathSegments(); |
|
|
|
List<String> parts = startUri.getPathSegments(); |
|
|
|
|
|
|
|
|
|
|
|
if (parts.size() == 1) { |
|
|
|
if (parts.size() == 1) { |
|
|
|
// Board mode
|
|
|
|
// Board mode
|
|
|
|
String rawBoard = parts.get(0); |
|
|
|
String rawBoard = parts.get(0); |
|
|
|
if (ChanApplication.getBoardManager().getBoardExists(rawBoard)) { |
|
|
|
if (ChanApplication.getBoardManager().getBoardExists(rawBoard)) { |
|
|
|
// To clear the flag
|
|
|
|
|
|
|
|
loadBoard(rawBoard); |
|
|
|
|
|
|
|
loadBoard(rawBoard); |
|
|
|
loadBoard(rawBoard); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
handleIntentURIFallback(startUri.toString()); |
|
|
|
handleIntentURIFallback(startUri.toString()); |
|
|
@ -515,7 +522,6 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
startLoadingThread(new Loadable(rawBoard, no)); |
|
|
|
startLoadingThread(new Loadable(rawBoard, no)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
handleIntentURIFallback(startUri.toString()); |
|
|
|
handleIntentURIFallback(startUri.toString()); |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showUrlOpenPicker(startUri.toString()); |
|
|
|
showUrlOpenPicker(startUri.toString()); |
|
|
@ -537,7 +543,7 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
}).setCancelable(false).create().show(); |
|
|
|
}).setCancelable(false).create().show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int getBoardIndexNavigator(String boardValue) { |
|
|
|
private int getSpinnerIndex(String boardValue) { |
|
|
|
List<String> list = ChanApplication.getBoardManager().getSavedValues(); |
|
|
|
List<String> list = ChanApplication.getBoardManager().getSavedValues(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
if (list.get(i).equals(boardValue)) { |
|
|
|
if (list.get(i).equals(boardValue)) { |
|
|
@ -547,4 +553,38 @@ public class BoardActivity extends BaseActivity implements ActionBar.OnNavigatio |
|
|
|
|
|
|
|
|
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private class BoardSpinnerAdapter extends BaseAdapter { |
|
|
|
|
|
|
|
private Context context; |
|
|
|
|
|
|
|
private List<String> keys; |
|
|
|
|
|
|
|
private List<String> values; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BoardSpinnerAdapter(Context context) { |
|
|
|
|
|
|
|
this.context = context; |
|
|
|
|
|
|
|
keys = ChanApplication.getBoardManager().getSavedKeys(); |
|
|
|
|
|
|
|
values = ChanApplication.getBoardManager().getSavedValues(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public int getCount() { |
|
|
|
|
|
|
|
return keys.size(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public Object getItem(final int position) { |
|
|
|
|
|
|
|
return keys.get(position); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public long getItemId(final int position) { |
|
|
|
|
|
|
|
return position; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public View getView(final int position, final View convertView, final ViewGroup parent) { |
|
|
|
|
|
|
|
TextView view = (TextView) LayoutInflater.from(context).inflate(R.layout.board_select_spinner, null); |
|
|
|
|
|
|
|
view.setText(keys.get(position)); |
|
|
|
|
|
|
|
return view; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|