@Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    url = getIntent().getStringExtra("url");
    title = url;
    type = getIntent().getStringExtra("type");
    isFromVideoActivity = getIntent().getBooleanExtra(VideoActivity.FROM_VIDEO_ACTIVITY, false);
    AppUtils.switchLanguage(getApplicationContext());
    this.setContentView(R.layout.player_on_line_video);
    this.initWebView();
    this.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
    progressView = (ImageView) findViewById(R.id.progress);
    progressDrawable = AppUtils.getVideoLoadProgress(this);
    progressView.setImageDrawable(progressDrawable);
    progressLayout = findViewById(R.id.progress_layout);
    btnBack = (ImageButton) findViewById(R.id.titlebar_layout);
    btnBack.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    if (Build.VERSION.SDK_INT < 19) mHandler.post(runnable);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
      getWindow()
          .getDecorView()
          .setSystemUiVisibility(
              View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
  }
예제 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AppUtils.switchLanguage(getApplicationContext());
    exitWithUserOption = false;
    EventBus.getDefault().register(this);
    initSlidingMenu();
    setContentView(R.layout.activity_main);
    Trace.e(tag, getString(R.string.lang));
    fMgr = getSupportFragmentManager();
    imageLoader = BaseApplication.getImageLoader(this);
    options =
        new DisplayImageOptions.Builder()
            .bitmapConfig(Bitmap.Config.RGB_565)
            .showStubImage(R.drawable.tab_center_normal)
            .showImageForEmptyUri(R.drawable.tab_center_normal)
            .showImageOnFail(R.drawable.tab_center_normal)
            .cacheInMemory(true)
            .cacheOnDisc(true)
            .build();
    if (AppUtils.isLogin(this)) majorTeamGsonModel = AppSharePreferences.getMajorTeam(this);
    mTitleView = (TitleView) findViewById(R.id.titlebar_layout);
    mTitleView.initTitleBar(null, 0, 0);
    mTitleView.setRightMenuButton();
    mTitleView.setTitleViewListener(mTitleViewListener);
    dealBottomButtonsClickEvent();
    initFragment(savedInstanceState);
    if (majorTeamGsonModel != null && !TextUtils.isEmpty(majorTeamGsonModel.avatar)) {
      File file = DiskCacheUtils.findInCache(majorTeamGsonModel.avatar, imageLoader.getDiskCache());
      if (file == null || !file.exists()) {
        imageLoader.displayImage(majorTeamGsonModel.avatar, majorImageView, options);
      } else {
        majorImageView.setImageBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()));
      }
    } else {
      if (AppSharePreferences.getFollowFlag(getApplicationContext())) {
        majorImageView.setImageResource(R.drawable.tab_center_notset_normal);
      } else {
        majorImageView.setImageResource(R.drawable.tab_center_normal);
      }
    }

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);

    AppService.startCheckVersion(this, false);
    mDownloadReceiver = new DownloadCompleteReceiver();
    registerReceiver(mDownloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    FeedbackAgent agent = new FeedbackAgent(this);
    agent.sync();

    /*
     * if
     * (AppSharePreferences.getDefault().getBoolean("MAIN_TOURNAMENT_GUIDE",
     * true)) { startActivity(new Intent(MainActivity.this,
     * GuideActivity.class)); }
     */

  }
예제 #3
0
 @Override
 public void onReceive(Context context, Intent intent) {
   if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
     long downId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
     List<Long> ids = AppSharePreferences.getDownloadIds(context);
     if (ids == null || !ids.contains(downId)) return;
     AppSharePreferences.deleteDownloadId(context, downId);
     DownloadManager manager =
         (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
     Cursor c = manager.query(new DownloadManager.Query().setFilterById(downId));
     if (c == null || !c.moveToFirst()) return;
     String url = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
     if (TextUtils.isEmpty(url)) {
       AppUtils.showToast(context, getResources().getString(R.string.download_fail) + "!");
       return;
     }
     Uri uri = Uri.parse(url);
     c.close();
     Intent i = new Intent();
     i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     i.setAction("android.intent.action.VIEW");
     i.addCategory("android.intent.category.DEFAULT");
     i.setType("application/vnd.android.package-archive");
     i.setData(uri);
     i.setDataAndType(uri, "application/vnd.android.package-archive");
     startActivity(i);
   }
 }
예제 #4
0
 @Override
 public void onActivityResult(int requestCode, int resultCode, Intent data) {
   if (resultCode == 30) {
     // 接受数据
     int resu = getActivity().getIntent().getIntExtra("111", 0);
     AppUtils.showToast(getActivity(), resu + "");
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
예제 #5
0
 @Override
 public void run() {
   Trace.d(tag, "refreshRunnable");
   mHandler.removeCallbacks(refreshRunnable);
   if (AppUtils.networkAvailable(getActivity())) {
     requestNewFeedRefresh();
   } else {
     mHandler.postDelayed(refreshRunnable, mRefreshRate);
   }
 }
예제 #6
0
 @Override
 public void onBackPressed() {
   if (System.currentTimeMillis() - exitTime > 1500) {
     AppUtils.showToast(getApplicationContext(), getString(R.string.exit_message));
     exitTime = System.currentTimeMillis();
     return;
   }
   exitWithUserOption = true;
   finish();
 }
예제 #7
0
 @Override
 public void onResume() {
   super.onResume();
   if (jumpSetting) {
     if (AppUtils.isLogin(getActivity()) && !AppSharePreferences.getFollowFlag(getActivity())) {
       Intent intent = new Intent(getActivity(), SubscriptionAddActivity.class);
       intent.putExtra(EXTRA_SUBSCRIPTION_SETTING, true);
       startActivity(intent);
     }
     jumpSetting = false;
   }
   if (AppSharePreferences.getFollowFlag(getActivity())) startRefreshNews();
 }
예제 #8
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == LanguageChangeActivity.LANGUAGE_CHANGE_REQUEST_CODE
       && resultCode == LanguageChangeActivity.LANGUAGE_CHANGE_RESULT_CODE) {
     AppSharePreferences.getDefault(getApplicationContext()).edit().remove("MENU_LAST_MODIFY");
     AppSharePreferences.deleteSplashLastModify(getApplicationContext());
     DatabaseHelper.deleteMenuCache(getApplicationContext());
     AppUtils.initMenuFromCache(getApplicationContext());
     AppSharePreferences.saveGroupExtendIds(this, null);
     if (Build.VERSION.SDK_INT >= 11) recreate();
     else {
       Intent intent = new Intent(this, BaseSplashActivity.class);
       startActivity(intent);
       finish();
     }
   }
 }
  @SuppressLint({"JavascriptInterface", "SetJavaScriptEnabled"})
  private void initWebView() {
    mWebContent = (WebView) findViewById(R.id.news_detail_content);
    customViewContainer = (FrameLayout) findViewById(R.id.customViewContainer);
    mWebViewClient = new CustomWebViewClient();
    mWebContent.setWebViewClient(mWebViewClient);

    mWebChromeClient = new MyWebChromeClient();
    mWebContent.addJavascriptInterface(new JavascriptCallBack(), "Android");
    mWebContent.setWebChromeClient(mWebChromeClient);
    WebSettings settings = mWebContent.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setAppCachePath(AppUtils.getWebCachePath(this));
    settings.setAllowFileAccess(true);
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    mWebContent.loadUrl(url);
  }
예제 #10
0
 private void requestNewFeedRefresh() {
   StringRequest req =
       new StringRequest(
           Urls.SERVER_PATH + "/feed/unread_num?offset=" + offset,
           new Response.Listener<String>() {
             @Override
             public void onResponse(String response) {
               if (!TextUtils.isEmpty(response)) {
                 try {
                   JSONObject json = new JSONObject(response);
                   int count = json.getInt("unread_num");
                   String msg = json.getString("message");
                   if (count > 0 && !TextUtils.isEmpty(msg)) {
                     showRefreshNewsCount(msg, true);
                     stopRefreshNews();
                     return;
                   }
                 } catch (Exception e) {
                   e.printStackTrace();
                 }
                 startRefreshNews();
               }
             }
           },
           new Response.ErrorListener() {
             @Override
             public void onErrorResponse(VolleyError error) {
               Trace.d(TAG, error.getMessage());
               startRefreshNews();
             }
           });
   if (TextUtils.isEmpty(REFRESH_TAG)) REFRESH_TAG = getUniqueRequestTag();
   req.setHeaders(AppUtils.getOAuthMap(getActivity()));
   req.addHeader("lang", getString(R.string.lang));
   req.setShouldCache(false);
   ApplicationController.getInstance().addToRequestQueue(req, REFRESH_TAG);
 }
예제 #11
0
  /** @param type 0 refresh 1 more */
  private void request(String url, final int type) {
    if (type == 0) {
      stopRefreshNews();
      showRefreshNewsCount(null, false);
      refreshing = true;
      mHandler.removeCallbacks(stopRefreshRunnable);
    }
    if (adapter.getItemCount() == 0) {
      mEmptyView.show(true);
      mEmptyView.onLoading();
    }
    mEmptyView.setOnClickListener(null);
    GsonRequest<FeedDatasGsonModel> req =
        new GsonRequest<FeedDatasGsonModel>(
            url,
            FeedDatasGsonModel.class,
            AppUtils.getOAuthMap(getActivity()),
            new Response.Listener<FeedDatasGsonModel>() {
              @Override
              public void onResponse(FeedDatasGsonModel response) {
                if (response != null) {
                  nextUrl = response.next;
                  if (response.data != null && !response.data.isEmpty()) {
                    if (type == 0) {
                      data.clear();
                    }
                    data.addAll(response.data);
                  }
                }

                if (!TextUtils.isEmpty(nextUrl)) {
                  adapter.setLoadMoreEnable(true);
                  adapter.setLoadMoreState(0);
                } else {
                  adapter.setLoadMoreEnable(true);
                  adapter.setLoadMoreState(XListViewFooter.STATE_NOTDATA);
                }

                adapter.notifyDataSetChanged();
                if (type == 0) {
                  offset = response != null ? response.offset : null;
                  if (!TextUtils.isEmpty(offset)) {
                    try {
                      offset = URLEncoder.encode(offset, "UTF-8");
                    } catch (UnsupportedEncodingException e) {
                      e.printStackTrace();
                    }
                    startRefreshNews();
                  }
                  mRefresh.clearAnimation();
                  refreshing = false;
                  swipeRefreshLayout.setRefreshing(false);
                } else isLoading = false;
                if (adapter.getItemCount() <= 0) {
                  mEmptyView.show(true);
                  mEmptyView.onFailed(getString(R.string.no_data));
                } else if (mEmptyView.isShowing()) mEmptyView.show(false);
              }
            },
            new Response.ErrorListener() {
              @Override
              public void onErrorResponse(VolleyError error) {
                if (mRefresh != null) mRefresh.clearAnimation();
                if (type == 0) {
                  if (!TextUtils.isEmpty(offset)) {
                    startRefreshNews();
                  }
                  if (data.isEmpty()) {
                    mEmptyView.show(true);
                    ErrorEntity entity = AppUtils.getErrorEntity(error);
                    mEmptyView.onFailed(
                        entity != null && !TextUtils.isEmpty(entity.getMessage())
                            ? entity.getMessage()
                            : getString(R.string.chat_load_failed));
                    mEmptyView.setOnClickListener(mRefreshNewsListener);
                  }
                  refreshing = false;
                  swipeRefreshLayout.setRefreshing(false);
                } else {
                  adapter.setLoadMoreEnable(true);
                  adapter.setLoadMoreState(0);
                  adapter.notifyDataSetChanged();
                  isLoading = false;
                }
              }
            });
    req.setShouldCache(false);
    addRequest(req);
  }