Fixed revert

This commit is contained in:
Somethingweirdhere 2018-06-28 15:10:21 +02:00 committed by Christian Schabesberger
parent 7bedacf5ad
commit 01abc244b1
2 changed files with 26 additions and 39 deletions

View File

@ -10,6 +10,7 @@ import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
@ -46,6 +47,7 @@ import org.schabi.newpipe.util.ThemeHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.schabi.newpipe.util.NavigationHelper.MAIN_FRAGMENT_TAG;
@ -206,32 +208,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte
String save = prefs.getString("saveUsedTabs", "1\n2\n4\n");
String tabsArray[] = save.trim().split("\n");
KioskList kl = null;
try {
StreamingService service = NewPipe.getService(currentServiceId);
kl = service.getKioskList();
} catch (Exception e) {
ErrorActivity.reportError(activity, e,
activity.getClass(),
null,
ErrorActivity.ErrorInfo.make(UserAction.UI_ERROR,
"none", "", R.string.app_ui_crash));
}
for(String tabInformation:tabsArray) {
if(tabInformation.equals(TAB_NUMBER_KIOSK)) {
if (kl != null) {
for(String ks : kl.getAvailableKiosks()) {
tabs.add(tabInformation+"\t"+ks);
}
}
} else {
tabs.add(tabInformation);
for(String tabNumber:tabsArray) { {
tabs.add(tabNumber);
}
}
Collections.addAll(tabs, tabsArray);
}
/*//////////////////////////////////////////////////////////////////////////

View File

@ -128,11 +128,7 @@ public class ChoseTabsFragment extends Fragment {
private void addTab(int position) {
if(position!=6) {
selectedTabs.add(String.valueOf(position));
selectedTabsAdapter.notifyDataSetChanged();
saveChanges();
} else {
if(position==6) {
SelectChannelFragment selectChannelFragment = new SelectChannelFragment();
selectChannelFragment.setOnSelectedLisener((String url, String name, int service) -> {
selectedTabs.add(position+"\t"+url+"\t"+name+"\t"+service);
@ -140,6 +136,18 @@ public class ChoseTabsFragment extends Fragment {
saveChanges();
});
selectChannelFragment.show(getFragmentManager(), "select_channel");
} else if(position==1) {
SelectKioskFragment selectKioskFragment = new SelectKioskFragment();
selectKioskFragment.setOnSelectedLisener((String kioskId, int service_id) -> {
selectedTabs.add(position+"\t"+kioskId+"\t"+service_id);
selectedTabsAdapter.notifyDataSetChanged();
saveChanges();
});
selectKioskFragment.show(getFragmentManager(), "select_kiosk");
} else {
selectedTabs.add(String.valueOf(position));
selectedTabsAdapter.notifyDataSetChanged();
saveChanges();
}
}
@ -168,7 +176,7 @@ public class ChoseTabsFragment extends Fragment {
@Override
public void onBindViewHolder(@NonNull ChoseTabsFragment.SelectedTabsAdapter.TabViewHolder holder, int position) {
holder.bind(position, holder);
holder.bind(position);
}
@Override
@ -192,12 +200,8 @@ public class ChoseTabsFragment extends Fragment {
view = itemView;
}
void bind(int position, ChoseTabsFragment.SelectedTabsAdapter.TabViewHolder holder) {
void bind(int position) {
handle.setImageResource(ThemeHelper.getIconByAttr(R.attr.drag_handle, getContext()));
handle.setOnTouchListener(getOnTouchListener(holder));
view.setOnLongClickListener(getOnLongClickListener(holder));
if(selectedTabs.get(position).startsWith("6\t")) {
String channelInfo[] = selectedTabs.get(position).split("\t");
@ -205,6 +209,12 @@ public class ChoseTabsFragment extends Fragment {
if (channelInfo.length == 4) channelName = channelInfo[2];
String textToSet = availableTabs[6] + ": " + channelName;
text.setText(textToSet);
} else if(selectedTabs.get(position).startsWith("1\t")) {
String kioskInfo[] = selectedTabs.get(position).split("\t");
String kioskName = "";
if (kioskInfo.length == 3) kioskName = kioskInfo[1];
String textToSet = availableTabs[1] + ": " + kioskName;
text.setText(textToSet);
} else {
text.setText(availableTabs[Integer.parseInt(selectedTabs.get(position))]);
}