|
|
|
|
@ -18,12 +18,14 @@ import androidx.viewpager.widget.ViewPager; |
|
|
|
|
import com.fongmi.android.tv.App; |
|
|
|
|
import com.fongmi.android.tv.api.ApiConfig; |
|
|
|
|
import com.fongmi.android.tv.bean.Class; |
|
|
|
|
import com.fongmi.android.tv.bean.History; |
|
|
|
|
import com.fongmi.android.tv.bean.Hot; |
|
|
|
|
import com.fongmi.android.tv.bean.Result; |
|
|
|
|
import com.fongmi.android.tv.bean.Site; |
|
|
|
|
import com.fongmi.android.tv.databinding.FragmentVodBinding; |
|
|
|
|
import com.fongmi.android.tv.event.CastEvent; |
|
|
|
|
import com.fongmi.android.tv.event.RefreshEvent; |
|
|
|
|
import com.fongmi.android.tv.event.SyncEvent; |
|
|
|
|
import com.fongmi.android.tv.impl.FilterCallback; |
|
|
|
|
import com.fongmi.android.tv.impl.SiteCallback; |
|
|
|
|
import com.fongmi.android.tv.model.SiteViewModel; |
|
|
|
|
@ -40,6 +42,7 @@ import com.fongmi.android.tv.ui.custom.dialog.FilterDialog; |
|
|
|
|
import com.fongmi.android.tv.ui.custom.dialog.LinkDialog; |
|
|
|
|
import com.fongmi.android.tv.ui.custom.dialog.ReceiveDialog; |
|
|
|
|
import com.fongmi.android.tv.ui.custom.dialog.SiteDialog; |
|
|
|
|
import com.fongmi.android.tv.utils.Notify; |
|
|
|
|
import com.fongmi.android.tv.utils.Prefers; |
|
|
|
|
import com.fongmi.android.tv.utils.Trans; |
|
|
|
|
import com.google.common.net.HttpHeaders; |
|
|
|
|
@ -232,6 +235,31 @@ public class VodFragment extends BaseFragment implements SiteCallback, FilterCal |
|
|
|
|
return mResult == null ? new Result() : mResult; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Callback getCallback() { |
|
|
|
|
return new Callback() { |
|
|
|
|
@Override |
|
|
|
|
public void success() { |
|
|
|
|
RefreshEvent.history(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Callback getCallback(SyncEvent event) { |
|
|
|
|
return new Callback() { |
|
|
|
|
@Override |
|
|
|
|
public void success() { |
|
|
|
|
RefreshEvent.config(); |
|
|
|
|
RefreshEvent.video(); |
|
|
|
|
onSyncEvent(event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void error(int resId) { |
|
|
|
|
Notify.show(resId); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
|
public void onRefreshEvent(RefreshEvent event) { |
|
|
|
|
switch (event.getType()) { |
|
|
|
|
@ -250,6 +278,15 @@ public class VodFragment extends BaseFragment implements SiteCallback, FilterCal |
|
|
|
|
ReceiveDialog.create().event(event).show(this); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN) |
|
|
|
|
public void onSyncEvent(SyncEvent event) { |
|
|
|
|
if (ApiConfig.get().getConfig().equals(event.getConfig())) { |
|
|
|
|
History.sync(event.getHistory(), getCallback()); |
|
|
|
|
} else { |
|
|
|
|
ApiConfig.get().clear().config(event.getConfig()).load(getCallback(event)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setSite(Site item) { |
|
|
|
|
ApiConfig.get().setHome(item); |
|
|
|
|
|